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

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

Issue 16335018: Add NaCl proxies for Pepper Video Source and Destination resources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Linux (create SIMPLE image data). Created 7 years, 6 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
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"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 int32_t VideoSourceResource::GetFrame( 59 int32_t VideoSourceResource::GetFrame(
60 PP_VideoFrame_Private* frame, 60 PP_VideoFrame_Private* frame,
61 scoped_refptr<TrackedCallback> callback) { 61 scoped_refptr<TrackedCallback> callback) {
62 if (!is_open_) 62 if (!is_open_)
63 return PP_ERROR_FAILED; 63 return PP_ERROR_FAILED;
64 64
65 if (TrackedCallback::IsPending(get_frame_callback_)) 65 if (TrackedCallback::IsPending(get_frame_callback_))
66 return PP_ERROR_INPROGRESS; 66 return PP_ERROR_INPROGRESS;
67 67
68 get_frame_callback_ = callback; 68 get_frame_callback_ = callback;
69
70 Call<PpapiPluginMsg_VideoSource_GetFrameReply>(RENDERER, 69 Call<PpapiPluginMsg_VideoSource_GetFrameReply>(RENDERER,
71 PpapiHostMsg_VideoSource_GetFrame(), 70 PpapiHostMsg_VideoSource_GetFrame(),
72 base::Bind(&VideoSourceResource::OnPluginMsgGetFrameComplete, this, 71 base::Bind(&VideoSourceResource::OnPluginMsgGetFrameComplete, this,
73 frame)); 72 frame));
74 return PP_OK_COMPLETIONPENDING; 73 return PP_OK_COMPLETIONPENDING;
75 } 74 }
76 75
77 void VideoSourceResource::Close() { 76 void VideoSourceResource::Close() {
78 Post(RENDERER, PpapiHostMsg_VideoSource_Close()); 77 Post(RENDERER, PpapiHostMsg_VideoSource_Close());
79 78
(...skipping 11 matching lines...) Expand all
91 is_open_ = true; 90 is_open_ = true;
92 open_callback_->Run(result); 91 open_callback_->Run(result);
93 } 92 }
94 } 93 }
95 94
96 void VideoSourceResource::OnPluginMsgGetFrameComplete( 95 void VideoSourceResource::OnPluginMsgGetFrameComplete(
97 PP_VideoFrame_Private* frame, 96 PP_VideoFrame_Private* frame,
98 const ResourceMessageReplyParams& reply_params, 97 const ResourceMessageReplyParams& reply_params,
99 const HostResource& image_data, 98 const HostResource& image_data,
100 const PP_ImageDataDesc& image_desc, 99 const PP_ImageDataDesc& image_desc,
101 int fd,
102 PP_TimeTicks timestamp) { 100 PP_TimeTicks timestamp) {
103 // The callback may have been aborted by Close(). 101 // The callback may have been aborted by Close().
104 if (TrackedCallback::IsPending(get_frame_callback_)) { 102 if (TrackedCallback::IsPending(get_frame_callback_)) {
105 int32_t result = reply_params.result(); 103 int32_t result = reply_params.result();
106 if (result == PP_OK && 104 if (result == PP_OK &&
107 PPB_ImageData_Shared::IsImageDataDescValid(image_desc)) { 105 PPB_ImageData_Shared::IsImageDataDescValid(image_desc)) {
108 frame->timestamp = timestamp; 106 frame->timestamp = timestamp;
109 107
110 #if defined(OS_ANDROID)
111 frame->image_data = 0;
112 #elif defined(TOOLKIT_GTK)
113 frame->image_data =
114 (new PlatformImageData(image_data, image_desc, fd))->GetReference();
115 #elif defined(OS_LINUX) || defined(OS_WIN) || defined(OS_MACOSX)
116 base::SharedMemoryHandle handle; 108 base::SharedMemoryHandle handle;
117 if (!reply_params.TakeSharedMemoryHandleAtIndex(0, &handle)) 109 if (!reply_params.TakeSharedMemoryHandleAtIndex(0, &handle))
118 frame->image_data = 0; 110 frame->image_data = 0;
119 frame->image_data = 111 frame->image_data =
120 (new PlatformImageData( 112 (new SimpleImageData(
121 image_data, image_desc, handle))->GetReference(); 113 image_data, image_desc, handle))->GetReference();
122 #else
123 #error Not implemented.
124 #endif
125 } 114 }
126 get_frame_callback_->Run(result); 115 get_frame_callback_->Run(result);
127 } 116 }
128 } 117 }
129 118
130 } // namespace proxy 119 } // namespace proxy
131 } // namespace ppapi 120 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698