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

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

Issue 15039009: Add PPAPI tests for VideoSource and VideoDestination resources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/video_source_resource.h ('k') | ppapi/tests/test_video_destination.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/proxy/video_source_resource.h" 5 #include "ppapi/proxy/video_source_resource.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "ipc/ipc_message.h" 8 #include "ipc/ipc_message.h"
9 #include "ppapi/c/pp_errors.h" 9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/c/private/pp_video_frame_private.h" 10 #include "ppapi/c/private/pp_video_frame_private.h"
11 #include "ppapi/proxy/ppapi_messages.h" 11 #include "ppapi/proxy/ppapi_messages.h"
12 #include "ppapi/proxy/ppb_image_data_proxy.h"
12 #include "ppapi/shared_impl/ppapi_globals.h" 13 #include "ppapi/shared_impl/ppapi_globals.h"
13 #include "ppapi/shared_impl/resource_tracker.h" 14 #include "ppapi/shared_impl/resource_tracker.h"
14 #include "ppapi/shared_impl/var.h" 15 #include "ppapi/shared_impl/var.h"
15 #include "ppapi/thunk/enter.h" 16 #include "ppapi/thunk/enter.h"
16 17
17 using ppapi::thunk::EnterResourceNoLock; 18 using ppapi::thunk::EnterResourceNoLock;
18 using ppapi::thunk::PPB_VideoSource_Private_API; 19 using ppapi::thunk::PPB_VideoSource_Private_API;
19 20
20 namespace ppapi { 21 namespace ppapi {
21 namespace proxy { 22 namespace proxy {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 void VideoSourceResource::Close() { 77 void VideoSourceResource::Close() {
77 Post(RENDERER, PpapiHostMsg_VideoSource_Close()); 78 Post(RENDERER, PpapiHostMsg_VideoSource_Close());
78 79
79 if (TrackedCallback::IsPending(open_callback_)) 80 if (TrackedCallback::IsPending(open_callback_))
80 open_callback_->PostAbort(); 81 open_callback_->PostAbort();
81 if (TrackedCallback::IsPending(get_frame_callback_)) 82 if (TrackedCallback::IsPending(get_frame_callback_))
82 get_frame_callback_->PostAbort(); 83 get_frame_callback_->PostAbort();
83 } 84 }
84 85
85 void VideoSourceResource::OnPluginMsgOpenComplete( 86 void VideoSourceResource::OnPluginMsgOpenComplete(
86 const ResourceMessageReplyParams& params) { 87 const ResourceMessageReplyParams& reply_params) {
87 if (TrackedCallback::IsPending(open_callback_)) { 88 if (TrackedCallback::IsPending(open_callback_)) {
88 int32_t result = params.result(); 89 int32_t result = reply_params.result();
89 if (result == PP_OK) 90 if (result == PP_OK)
90 is_open_ = true; 91 is_open_ = true;
91 open_callback_->Run(result); 92 open_callback_->Run(result);
92 } 93 }
93 } 94 }
94 95
95 void VideoSourceResource::OnPluginMsgGetFrameComplete( 96 void VideoSourceResource::OnPluginMsgGetFrameComplete(
96 PP_VideoFrame_Private* frame, 97 PP_VideoFrame_Private* frame,
97 const ResourceMessageReplyParams& params, 98 const ResourceMessageReplyParams& reply_params,
98 const HostResource& image_data, 99 const HostResource& image_data,
100 const PP_ImageDataDesc& image_desc,
101 int fd,
99 PP_TimeTicks timestamp) { 102 PP_TimeTicks timestamp) {
100 // The callback may have been aborted by Close(). 103 // The callback may have been aborted by Close().
101 if (TrackedCallback::IsPending(get_frame_callback_)) { 104 if (TrackedCallback::IsPending(get_frame_callback_)) {
102 int32_t result = params.result(); 105 int32_t result = reply_params.result();
103 if (result == PP_OK) { 106 if (result == PP_OK) {
104 frame->timestamp = timestamp; 107 frame->timestamp = timestamp;
105 frame->image_data = image_data.host_resource(); 108
109 #if defined(OS_ANDROID)
110 frame->image_data = 0;
111 #elif defined(OS_WIN) || defined(OS_MACOSX)
112 base::SharedMemoryHandle handle;
113 if (!reply_params.TakeSharedMemoryHandleAtIndex(0, &handle))
114 frame->image_data = 0;
115 frame->image_data =
116 (new ImageData(image_data, image_desc, handle))->GetReference();
117 #elif defined(OS_LINUX)
118 frame->image_data =
119 (new ImageData(image_data, image_desc, fd))->GetReference();
120 #else
121 #error Not implemented.
122 #endif
106 } 123 }
107 get_frame_callback_->Run(result); 124 get_frame_callback_->Run(result);
108 } 125 }
109 } 126 }
110 127
111 } // namespace proxy 128 } // namespace proxy
112 } // namespace ppapi 129 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/video_source_resource.h ('k') | ppapi/tests/test_video_destination.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698