OLD | NEW |
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 "content/renderer/pepper/pepper_video_source_host.h" | 5 #include "content/renderer/pepper/pepper_video_source_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/safe_numerics.h" | 8 #include "base/safe_numerics.h" |
9 #include "content/public/renderer/renderer_ppapi_host.h" | 9 #include "content/public/renderer/renderer_ppapi_host.h" |
10 #include "content/renderer/render_thread_impl.h" | 10 #include "content/renderer/render_thread_impl.h" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 192 |
193 // Convert a video timestamp (int64, in nanoseconds) to a time delta (int64, | 193 // Convert a video timestamp (int64, in nanoseconds) to a time delta (int64, |
194 // microseconds) and then to a PP_TimeTicks (a double, in seconds). All times | 194 // microseconds) and then to a PP_TimeTicks (a double, in seconds). All times |
195 // are relative to the Unix Epoch. | 195 // are relative to the Unix Epoch. |
196 base::TimeDelta time_delta = base::TimeDelta::FromMicroseconds( | 196 base::TimeDelta time_delta = base::TimeDelta::FromMicroseconds( |
197 frame->GetTimeStamp() / base::Time::kNanosecondsPerMicrosecond); | 197 frame->GetTimeStamp() / base::Time::kNanosecondsPerMicrosecond); |
198 PP_TimeTicks timestamp = time_delta.InSecondsF(); | 198 PP_TimeTicks timestamp = time_delta.InSecondsF(); |
199 | 199 |
200 reply_context_.params.set_result(PP_OK); | 200 reply_context_.params.set_result(PP_OK); |
201 | 201 |
202 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_ANDROID) | 202 #if defined(TOOLKIT_GTK) |
| 203 // For GTK, we pass the SysV shared memory key in the message. |
| 204 PpapiPluginMsg_VideoSource_GetFrameReply reply_msg(host_resource, |
| 205 image_desc, |
| 206 image_handle.fd, |
| 207 timestamp); |
| 208 #elif defined(OS_POSIX) || defined(OS_WIN) |
203 ppapi::proxy::SerializedHandle serialized_handle; | 209 ppapi::proxy::SerializedHandle serialized_handle; |
204 PpapiPluginMsg_VideoSource_GetFrameReply reply_msg(host_resource, | 210 PpapiPluginMsg_VideoSource_GetFrameReply reply_msg(host_resource, |
205 image_desc, | 211 image_desc, |
206 0, | 212 0, |
207 timestamp); | 213 timestamp); |
208 serialized_handle.set_shmem(image_handle, byte_count); | 214 serialized_handle.set_shmem(image_handle, byte_count); |
209 reply_context_.params.AppendHandle(serialized_handle); | 215 reply_context_.params.AppendHandle(serialized_handle); |
210 #elif defined(OS_LINUX) | |
211 // For Linux, we pass the SysV shared memory key in the message. | |
212 PpapiPluginMsg_VideoSource_GetFrameReply reply_msg(host_resource, | |
213 image_desc, | |
214 image_handle.fd, | |
215 timestamp); | |
216 #else | 216 #else |
217 // Not supported on other platforms. | 217 // Not supported on other platforms. |
218 // This is a stub reply_msg to not break the build. | 218 // This is a stub reply_msg to not break the build. |
219 PpapiPluginMsg_VideoSource_GetFrameReply reply_msg(host_resource, | 219 PpapiPluginMsg_VideoSource_GetFrameReply reply_msg(host_resource, |
220 image_desc, | 220 image_desc, |
221 0, | 221 0, |
222 timestamp); | 222 timestamp); |
223 NOTIMPLEMENTED(); | 223 NOTIMPLEMENTED(); |
224 SendGetFrameErrorReply(PP_ERROR_NOTSUPPORTED); | 224 SendGetFrameErrorReply(PP_ERROR_NOTSUPPORTED); |
225 return; | 225 return; |
(...skipping 18 matching lines...) Expand all Loading... |
244 | 244 |
245 void PepperVideoSourceHost::Close() { | 245 void PepperVideoSourceHost::Close() { |
246 if (source_handler_.get() && !stream_url_.empty()) | 246 if (source_handler_.get() && !stream_url_.empty()) |
247 source_handler_->Close(stream_url_, frame_receiver_.get()); | 247 source_handler_->Close(stream_url_, frame_receiver_.get()); |
248 | 248 |
249 source_handler_.reset(NULL); | 249 source_handler_.reset(NULL); |
250 stream_url_.clear(); | 250 stream_url_.clear(); |
251 } | 251 } |
252 | 252 |
253 } // namespace content | 253 } // namespace content |
OLD | NEW |