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

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

Issue 128683003: [PPAPI] Implement media stream video track API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@video_track_impl_cl
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 "base/logging.h"
8 #include "ppapi/proxy/ppapi_messages.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::SendEnqueueFrameMessageToHost(
29 int32_t index) {
30 DCHECK_GE(index, 0);
31 DCHECK_LT(index, frame_buffer()->number_of_frames());
32 Post(RENDERER, PpapiHostMsg_MediaStreamTrack_EnqueueFrame(index));
33 }
34
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_InitFrames, OnPluginMsgInitFrames)
41 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
42 PpapiPluginMsg_MediaStreamTrack_EnqueueFrame, OnPluginMsgEnqueueFrame)
43 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED(
44 PluginResource::OnReplyReceived(params, msg))
45 IPC_END_MESSAGE_MAP()
46 }
47
48 void MediaStreamTrackResourceBase::CloseInternal() {
49 if (!has_ended_) {
50 Post(RENDERER, PpapiHostMsg_MediaStreamTrack_Close());
51 has_ended_ = true;
52 }
53 }
54
55 void MediaStreamTrackResourceBase::OnPluginMsgInitFrames(
56 const ResourceMessageReplyParams& params,
57 int32_t number_of_frames,
58 int32_t frame_size) {
59 base::SharedMemoryHandle shm_handle = base::SharedMemory::NULLHandle();
60 params.TakeSharedMemoryHandleAtIndex(0, &shm_handle);
61 frame_buffer_.SetFrames(number_of_frames, frame_size,
62 scoped_ptr<base::SharedMemory>(new base::SharedMemory(shm_handle, true)),
63 false);
64 }
65
66 void MediaStreamTrackResourceBase::OnPluginMsgEnqueueFrame(
67 const ResourceMessageReplyParams& params,
68 int32_t index) {
69 frame_buffer_.EnqueueFrame(index);
70 }
71
72 } // namespace proxy
73 } // 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