OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |