| 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 "ppapi/proxy/media_stream_track_resource_base.h" | 5 #include "ppapi/proxy/media_stream_track_resource_base.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ppapi/proxy/ppapi_messages.h" | 8 #include "ppapi/proxy/ppapi_messages.h" |
| 9 | 9 |
| 10 namespace ppapi { | 10 namespace ppapi { |
| 11 namespace proxy { | 11 namespace proxy { |
| 12 | 12 |
| 13 MediaStreamTrackResourceBase::MediaStreamTrackResourceBase( | 13 MediaStreamTrackResourceBase::MediaStreamTrackResourceBase( |
| 14 Connection connection, | 14 Connection connection, |
| 15 PP_Instance instance, | 15 PP_Instance instance, |
| 16 int pending_renderer_id, | 16 int pending_renderer_id, |
| 17 const std::string& id) | 17 const std::string& id) |
| 18 : PluginResource(connection, instance), | 18 : PluginResource(connection, instance), |
| 19 frame_buffer_(this), | 19 buffer_manager_(this), |
| 20 id_(id), | 20 id_(id), |
| 21 has_ended_(false) { | 21 has_ended_(false) { |
| 22 AttachToPendingHost(RENDERER, pending_renderer_id); | 22 AttachToPendingHost(RENDERER, pending_renderer_id); |
| 23 } | 23 } |
| 24 | 24 |
| 25 MediaStreamTrackResourceBase::~MediaStreamTrackResourceBase() { | 25 MediaStreamTrackResourceBase::~MediaStreamTrackResourceBase() { |
| 26 } | 26 } |
| 27 | 27 |
| 28 void MediaStreamTrackResourceBase::SendEnqueueFrameMessageToHost( | 28 void MediaStreamTrackResourceBase::SendEnqueueBufferMessageToHost( |
| 29 int32_t index) { | 29 int32_t index) { |
| 30 DCHECK_GE(index, 0); | 30 DCHECK_GE(index, 0); |
| 31 DCHECK_LT(index, frame_buffer()->number_of_frames()); | 31 DCHECK_LT(index, buffer_manager()->number_of_buffers()); |
| 32 Post(RENDERER, PpapiHostMsg_MediaStreamTrack_EnqueueFrame(index)); | 32 Post(RENDERER, PpapiHostMsg_MediaStreamTrack_EnqueueBuffer(index)); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void MediaStreamTrackResourceBase::OnReplyReceived( | 35 void MediaStreamTrackResourceBase::OnReplyReceived( |
| 36 const ResourceMessageReplyParams& params, | 36 const ResourceMessageReplyParams& params, |
| 37 const IPC::Message& msg) { | 37 const IPC::Message& msg) { |
| 38 IPC_BEGIN_MESSAGE_MAP(MediaStreamTrackResourceBase, msg) | 38 IPC_BEGIN_MESSAGE_MAP(MediaStreamTrackResourceBase, msg) |
| 39 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL( | 39 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL( |
| 40 PpapiPluginMsg_MediaStreamTrack_InitFrames, OnPluginMsgInitFrames) | 40 PpapiPluginMsg_MediaStreamTrack_InitBuffers, OnPluginMsgInitBuffers) |
| 41 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL( | 41 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL( |
| 42 PpapiPluginMsg_MediaStreamTrack_EnqueueFrame, OnPluginMsgEnqueueFrame) | 42 PpapiPluginMsg_MediaStreamTrack_EnqueueBuffer, OnPluginMsgEnqueueBuffer) |
| 43 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED( | 43 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED( |
| 44 PluginResource::OnReplyReceived(params, msg)) | 44 PluginResource::OnReplyReceived(params, msg)) |
| 45 IPC_END_MESSAGE_MAP() | 45 IPC_END_MESSAGE_MAP() |
| 46 } | 46 } |
| 47 | 47 |
| 48 void MediaStreamTrackResourceBase::CloseInternal() { | 48 void MediaStreamTrackResourceBase::CloseInternal() { |
| 49 if (!has_ended_) { | 49 if (!has_ended_) { |
| 50 Post(RENDERER, PpapiHostMsg_MediaStreamTrack_Close()); | 50 Post(RENDERER, PpapiHostMsg_MediaStreamTrack_Close()); |
| 51 has_ended_ = true; | 51 has_ended_ = true; |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 void MediaStreamTrackResourceBase::OnPluginMsgInitFrames( | 55 void MediaStreamTrackResourceBase::OnPluginMsgInitBuffers( |
| 56 const ResourceMessageReplyParams& params, | 56 const ResourceMessageReplyParams& params, |
| 57 int32_t number_of_frames, | 57 int32_t number_of_buffers, |
| 58 int32_t frame_size) { | 58 int32_t buffer_size) { |
| 59 base::SharedMemoryHandle shm_handle = base::SharedMemory::NULLHandle(); | 59 base::SharedMemoryHandle shm_handle = base::SharedMemory::NULLHandle(); |
| 60 params.TakeSharedMemoryHandleAtIndex(0, &shm_handle); | 60 params.TakeSharedMemoryHandleAtIndex(0, &shm_handle); |
| 61 frame_buffer_.SetFrames(number_of_frames, frame_size, | 61 buffer_manager_.SetBuffers(number_of_buffers, buffer_size, |
| 62 scoped_ptr<base::SharedMemory>(new base::SharedMemory(shm_handle, true)), | 62 scoped_ptr<base::SharedMemory>(new base::SharedMemory(shm_handle, true)), |
| 63 false); | 63 false); |
| 64 } | 64 } |
| 65 | 65 |
| 66 void MediaStreamTrackResourceBase::OnPluginMsgEnqueueFrame( | 66 void MediaStreamTrackResourceBase::OnPluginMsgEnqueueBuffer( |
| 67 const ResourceMessageReplyParams& params, | 67 const ResourceMessageReplyParams& params, |
| 68 int32_t index) { | 68 int32_t index) { |
| 69 frame_buffer_.EnqueueFrame(index); | 69 buffer_manager_.EnqueueBuffer(index); |
| 70 } | 70 } |
| 71 | 71 |
| 72 } // namespace proxy | 72 } // namespace proxy |
| 73 } // namespace ppapi | 73 } // namespace ppapi |
| OLD | NEW |