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

Side by Side Diff: ppapi/proxy/media_stream_track_resource_base.cc

Issue 101463008: [NOT FOR REVIEW][PPAPI] Implement MediaStreamVideoTrack pepper API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Update Created 6 years, 11 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
(Empty)
1 // Copyright (c) 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.
4
5 #include "ppapi/proxy/media_stream_track_resource_base.h"
6
7 #include "ppapi/proxy/ppapi_messages.h"
8 #include "ppapi/shared_impl/var.h"
9
10 namespace ppapi {
11 namespace proxy {
12
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 frame_buffer_(this),
20 id_(id),
21 has_ended_(false) {
22 AttachToPendingHost(RENDERER, pending_renderer_id);
23 }
24
25 MediaStreamTrackResourceBase::~MediaStreamTrackResourceBase() {
26 }
27
28 void MediaStreamTrackResourceBase::HostEnqueueFrame(int32_t index) {
29 DCHECK_GE(index, 0);
30 DCHECK_LT(index, frame_buffer()->number_of_frames());
31 Post(RENDERER, PpapiHostMsg_MediaStreamTrack_EnqueueFrame(index));
32 }
33
34 void MediaStreamTrackResourceBase::OnReplyReceived(
35 const ResourceMessageReplyParams& params,
36 const IPC::Message& msg) {
37 IPC_BEGIN_MESSAGE_MAP(MediaStreamTrackResourceBase, msg)
38 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
39 PpapiPluginMsg_MediaStreamTrack_InitFrames, OnPluginMsgInitFrames)
40 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
41 PpapiPluginMsg_MediaStreamTrack_EnqueueFrame, OnPluginMsgEnqueueFrame)
42 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED(
43 PluginResource::OnReplyReceived(params, msg))
44 IPC_END_MESSAGE_MAP()
45 }
46
47 thunk::PPB_MediaStreamTrack_API*
48 MediaStreamTrackResourceBase::AsPPB_MediaStreamTrack_API() {
49 return this;
50 }
51
52 PP_Var MediaStreamTrackResourceBase::GetId() {
53 return StringVar::StringToPPVar(id_);
54 }
55
56 PP_Bool MediaStreamTrackResourceBase::HasEnded() {
57 return PP_FromBool(has_ended_);
58 }
59
60 void MediaStreamTrackResourceBase::Close() {
61 if (!has_ended_) {
62 Post(RENDERER, PpapiHostMsg_MediaStreamTrack_Close());
63 has_ended_ = true;
64 }
65 }
66
67 void MediaStreamTrackResourceBase::OnPluginMsgInitFrames(
68 const ResourceMessageReplyParams& params,
69 int32_t number_of_frames,
70 int32_t frame_size) {
71 base::SharedMemoryHandle shm_handle = base::SharedMemory::NULLHandle();
72 params.TakeSharedMemoryHandleAtIndex(0, &shm_handle);
73 frame_buffer_.SetFrames(number_of_frames, frame_size,
74 scoped_ptr<base::SharedMemory>(new base::SharedMemory(shm_handle, true)),
75 false);
76 }
77
78 void MediaStreamTrackResourceBase::OnPluginMsgEnqueueFrame(
79 const ResourceMessageReplyParams& params,
80 int32_t index) {
81 frame_buffer_.EnqueueFrame(index);
82 }
83
84 } // namespace proxy
85 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/media_stream_track_resource_base.h ('k') | ppapi/proxy/media_stream_video_track_resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698