Add mips support to install-debian.wheezy.sysroot.py
[chromium-blink-merge.git] / ppapi / proxy / media_stream_track_resource_base.cc
blob12ebdb7c4f97ebae83e6fd0e035e78ab21579a78
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"
10 namespace ppapi {
11 namespace proxy {
13 MediaStreamTrackResourceBase::MediaStreamTrackResourceBase(
14 Connection connection,
15 PP_Instance instance,
16 int pending_renderer_id,
17 const std::string& id)
18 : PluginResource(connection, instance),
19 buffer_manager_(this),
20 id_(id),
21 has_ended_(false) {
22 AttachToPendingHost(RENDERER, pending_renderer_id);
25 MediaStreamTrackResourceBase::MediaStreamTrackResourceBase(
26 Connection connection,
27 PP_Instance instance)
28 : PluginResource(connection, instance),
29 buffer_manager_(this),
30 has_ended_(false) {
33 MediaStreamTrackResourceBase::~MediaStreamTrackResourceBase() {
36 void MediaStreamTrackResourceBase::SendEnqueueBufferMessageToHost(
37 int32_t index) {
38 DCHECK_GE(index, 0);
39 DCHECK_LT(index, buffer_manager()->number_of_buffers());
40 Post(RENDERER, PpapiHostMsg_MediaStreamTrack_EnqueueBuffer(index));
43 void MediaStreamTrackResourceBase::OnReplyReceived(
44 const ResourceMessageReplyParams& params,
45 const IPC::Message& msg) {
46 PPAPI_BEGIN_MESSAGE_MAP(MediaStreamTrackResourceBase, msg)
47 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
48 PpapiPluginMsg_MediaStreamTrack_InitBuffers, OnPluginMsgInitBuffers)
49 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
50 PpapiPluginMsg_MediaStreamTrack_EnqueueBuffer, OnPluginMsgEnqueueBuffer)
51 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
52 PpapiPluginMsg_MediaStreamTrack_EnqueueBuffers,
53 OnPluginMsgEnqueueBuffers)
54 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED(
55 PluginResource::OnReplyReceived(params, msg))
56 PPAPI_END_MESSAGE_MAP()
59 void MediaStreamTrackResourceBase::CloseInternal() {
60 if (!has_ended_) {
61 Post(RENDERER, PpapiHostMsg_MediaStreamTrack_Close());
62 has_ended_ = true;
66 void MediaStreamTrackResourceBase::OnPluginMsgInitBuffers(
67 const ResourceMessageReplyParams& params,
68 int32_t number_of_buffers,
69 int32_t buffer_size,
70 bool readonly) {
71 base::SharedMemoryHandle shm_handle = base::SharedMemory::NULLHandle();
72 params.TakeSharedMemoryHandleAtIndex(0, &shm_handle);
73 buffer_manager_.SetBuffers(number_of_buffers, buffer_size,
74 scoped_ptr<base::SharedMemory>(new base::SharedMemory(shm_handle,
75 readonly)),
76 false);
79 void MediaStreamTrackResourceBase::OnPluginMsgEnqueueBuffer(
80 const ResourceMessageReplyParams& params,
81 int32_t index) {
82 buffer_manager_.EnqueueBuffer(index);
85 void MediaStreamTrackResourceBase::OnPluginMsgEnqueueBuffers(
86 const ResourceMessageReplyParams& params,
87 const std::vector<int32_t>& indices) {
88 for (size_t i = 0; i < indices.size(); ++i)
89 buffer_manager_.EnqueueBuffer(indices[i]);
92 } // namespace proxy
93 } // namespace ppapi