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

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: Fix review issues 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
9 namespace ppapi {
10 namespace proxy {
11
12 MediaStreamTrackResourceBase::MediaStreamTrackResourceBase(
13 Connection connection,
14 PP_Instance instance,
15 int pending_renderer_id,
16 const std::string& id)
17 : PluginResource(connection, instance),
18 frame_buffer_(this),
19 id_(id),
20 has_ended_(false) {
21 AttachToPendingHost(RENDERER, pending_renderer_id);
22 }
23
24 MediaStreamTrackResourceBase::~MediaStreamTrackResourceBase() {
25 }
26
27 void MediaStreamTrackResourceBase::SendEnqueueFrameMessageToHost(
28 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 void MediaStreamTrackResourceBase::CloseInternal() {
48 if (!has_ended_) {
49 Post(RENDERER, PpapiHostMsg_MediaStreamTrack_Close());
50 has_ended_ = true;
51 }
52 }
53
54 void MediaStreamTrackResourceBase::OnPluginMsgInitFrames(
55 const ResourceMessageReplyParams& params,
56 int32_t number_of_frames,
57 int32_t frame_size) {
58 base::SharedMemoryHandle shm_handle = base::SharedMemory::NULLHandle();
59 params.TakeSharedMemoryHandleAtIndex(0, &shm_handle);
60 frame_buffer_.SetFrames(number_of_frames, frame_size,
61 scoped_ptr<base::SharedMemory>(new base::SharedMemory(shm_handle, true)),
62 false);
63 }
64
65 void MediaStreamTrackResourceBase::OnPluginMsgEnqueueFrame(
66 const ResourceMessageReplyParams& params,
67 int32_t index) {
68 frame_buffer_.EnqueueFrame(index);
69 }
70
71 } // namespace proxy
72 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698