Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: content/renderer/pepper/pepper_media_stream_track_host_base.cc

Issue 140783004: [PPAPI] Pepper MediaStream API audio track implementation and example. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix review issues Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/pepper/pepper_media_stream_track_host_base.h" 5 #include "content/renderer/pepper/pepper_media_stream_track_host_base.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/public/renderer/render_thread.h" 8 #include "content/public/renderer/render_thread.h"
9 #include "content/public/renderer/renderer_ppapi_host.h" 9 #include "content/public/renderer/renderer_ppapi_host.h"
10 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.h"
(...skipping 21 matching lines...) Expand all
32 } 32 }
33 33
34 bool PepperMediaStreamTrackHostBase::InitFrames(int32_t number_of_frames, 34 bool PepperMediaStreamTrackHostBase::InitFrames(int32_t number_of_frames,
35 int32_t frame_size) { 35 int32_t frame_size) {
36 DCHECK_GT(number_of_frames, 0); 36 DCHECK_GT(number_of_frames, 0);
37 DCHECK_GT(frame_size, 37 DCHECK_GT(frame_size,
38 static_cast<int32_t>(sizeof(ppapi::MediaStreamFrame::Header))); 38 static_cast<int32_t>(sizeof(ppapi::MediaStreamFrame::Header)));
39 // Make each frame 4 byte aligned. 39 // Make each frame 4 byte aligned.
40 frame_size = (frame_size + 3) & ~0x3; 40 frame_size = (frame_size + 3) & ~0x3;
41 41
42 // TODO(penghuang): |HostAllocateSharedMemoryBuffer| uses sync IPC. We should
43 // avoid it.
42 int32_t size = number_of_frames * frame_size; 44 int32_t size = number_of_frames * frame_size;
43 content::RenderThread* render_thread = content::RenderThread::Get(); 45 content::RenderThread* render_thread = content::RenderThread::Get();
44 scoped_ptr<base::SharedMemory> shm( 46 scoped_ptr<base::SharedMemory> shm(
45 render_thread->HostAllocateSharedMemoryBuffer(size).Pass()); 47 render_thread->HostAllocateSharedMemoryBuffer(size).Pass());
46 if (!shm) 48 if (!shm)
47 return false; 49 return false;
48 50
49 base::SharedMemoryHandle shm_handle = shm->handle(); 51 base::SharedMemoryHandle shm_handle = shm->handle();
50 if (!frame_buffer_.SetFrames(number_of_frames, frame_size, shm.Pass(), true)) 52 if (!frame_buffer_.SetFrames(number_of_frames, frame_size, shm.Pass(), true))
51 return false; 53 return false;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 return PP_OK; 95 return PP_OK;
94 } 96 }
95 97
96 int32_t PepperMediaStreamTrackHostBase::OnHostMsgClose( 98 int32_t PepperMediaStreamTrackHostBase::OnHostMsgClose(
97 HostMessageContext* context) { 99 HostMessageContext* context) {
98 OnClose(); 100 OnClose();
99 return PP_OK; 101 return PP_OK;
100 } 102 }
101 103
102 } // namespace content 104 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698