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
3 // found in the LICENSE file.
5 #include "ppapi/proxy/media_stream_track_resource_base.h"
7 #include "base/logging.h"
8 #include "ppapi/proxy/ppapi_messages.h"
13 MediaStreamTrackResourceBase::MediaStreamTrackResourceBase(
14 Connection connection
,
16 int pending_renderer_id
,
17 const std::string
& id
)
18 : PluginResource(connection
, instance
),
19 buffer_manager_(this),
22 AttachToPendingHost(RENDERER
, pending_renderer_id
);
25 MediaStreamTrackResourceBase::~MediaStreamTrackResourceBase() {
28 void MediaStreamTrackResourceBase::SendEnqueueBufferMessageToHost(
31 DCHECK_LT(index
, buffer_manager()->number_of_buffers());
32 Post(RENDERER
, PpapiHostMsg_MediaStreamTrack_EnqueueBuffer(index
));
35 void MediaStreamTrackResourceBase::OnReplyReceived(
36 const ResourceMessageReplyParams
& params
,
37 const IPC::Message
& msg
) {
38 IPC_BEGIN_MESSAGE_MAP(MediaStreamTrackResourceBase
, msg
)
39 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
40 PpapiPluginMsg_MediaStreamTrack_InitBuffers
, OnPluginMsgInitBuffers
)
41 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
42 PpapiPluginMsg_MediaStreamTrack_EnqueueBuffer
, OnPluginMsgEnqueueBuffer
)
43 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED(
44 PluginResource::OnReplyReceived(params
, msg
))
48 void MediaStreamTrackResourceBase::CloseInternal() {
50 Post(RENDERER
, PpapiHostMsg_MediaStreamTrack_Close());
55 void MediaStreamTrackResourceBase::OnPluginMsgInitBuffers(
56 const ResourceMessageReplyParams
& params
,
57 int32_t number_of_buffers
,
58 int32_t buffer_size
) {
59 base::SharedMemoryHandle shm_handle
= base::SharedMemory::NULLHandle();
60 params
.TakeSharedMemoryHandleAtIndex(0, &shm_handle
);
61 buffer_manager_
.SetBuffers(number_of_buffers
, buffer_size
,
62 scoped_ptr
<base::SharedMemory
>(new base::SharedMemory(shm_handle
, true)),
66 void MediaStreamTrackResourceBase::OnPluginMsgEnqueueBuffer(
67 const ResourceMessageReplyParams
& params
,
69 buffer_manager_
.EnqueueBuffer(index
);