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

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 issue 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);
yzshen1 2014/01/10 21:05:17 wrong indent.
Peng 2014/01/10 22:46:58 Done.
22 }
23
24 MediaStreamTrackResourceBase::~MediaStreamTrackResourceBase() {
25 }
26
27 void MediaStreamTrackResourceBase::HostEnqueueFrame(int32_t index) {
28 DCHECK_GE(index, 0);
29 DCHECK_LT(index, frame_buffer()->number_of_frames());
30 Post(RENDERER, PpapiHostMsg_MediaStreamTrack_EnqueueFrame(index));
31 }
32
33 void MediaStreamTrackResourceBase::OnReplyReceived(
34 const ResourceMessageReplyParams& params,
35 const IPC::Message& msg) {
36 IPC_BEGIN_MESSAGE_MAP(MediaStreamTrackResourceBase, msg)
37 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
38 PpapiPluginMsg_MediaStreamTrack_InitFrames, OnPluginMsgInitFrames)
39 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
40 PpapiPluginMsg_MediaStreamTrack_EnqueueFrame, OnPluginMsgEnqueueFrame)
41 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED(
42 PluginResource::OnReplyReceived(params, msg))
43 IPC_END_MESSAGE_MAP()
44 }
45
46 void MediaStreamTrackResourceBase::CloseInternal() {
47 if (!has_ended_) {
48 Post(RENDERER, PpapiHostMsg_MediaStreamTrack_Close());
49 has_ended_ = true;
50 }
51 }
52
53 void MediaStreamTrackResourceBase::OnPluginMsgInitFrames(
54 const ResourceMessageReplyParams& params,
55 int32_t number_of_frames,
56 int32_t frame_size) {
57 base::SharedMemoryHandle shm_handle = base::SharedMemory::NULLHandle();
58 params.TakeSharedMemoryHandleAtIndex(0, &shm_handle);
59 frame_buffer_.SetFrames(number_of_frames, frame_size,
60 scoped_ptr<base::SharedMemory>(new base::SharedMemory(shm_handle, true)),
61 false);
62 }
63
64 void MediaStreamTrackResourceBase::OnPluginMsgEnqueueFrame(
65 const ResourceMessageReplyParams& params,
66 int32_t index) {
67 frame_buffer_.EnqueueFrame(index);
68 }
69
70 } // namespace proxy
71 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698