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 <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
11 #include "content/public/renderer/renderer_ppapi_host.h" | 11 #include "content/public/renderer/renderer_ppapi_host.h" |
12 #include "content/renderer/media/video_track_to_pepper_adapter.h" | 12 #include "content/renderer/media/video_track_to_pepper_adapter.h" |
13 #include "content/renderer/pepper/ppb_image_data_impl.h" | 13 #include "content/renderer/pepper/ppb_image_data_impl.h" |
14 #include "content/renderer/render_thread_impl.h" | 14 #include "content/renderer/render_thread_impl.h" |
| 15 #include "media/base/video_util.h" |
15 #include "ppapi/c/pp_errors.h" | 16 #include "ppapi/c/pp_errors.h" |
16 #include "ppapi/host/dispatch_host_message.h" | 17 #include "ppapi/host/dispatch_host_message.h" |
17 #include "ppapi/host/ppapi_host.h" | 18 #include "ppapi/host/ppapi_host.h" |
18 #include "ppapi/proxy/host_dispatcher.h" | 19 #include "ppapi/proxy/host_dispatcher.h" |
19 #include "ppapi/proxy/ppapi_messages.h" | 20 #include "ppapi/proxy/ppapi_messages.h" |
20 #include "ppapi/proxy/ppb_image_data_proxy.h" | 21 #include "ppapi/proxy/ppb_image_data_proxy.h" |
21 #include "ppapi/shared_impl/scoped_pp_resource.h" | 22 #include "ppapi/shared_impl/scoped_pp_resource.h" |
22 #include "ppapi/thunk/enter.h" | 23 #include "ppapi/thunk/enter.h" |
23 #include "ppapi/thunk/ppb_image_data_api.h" | 24 #include "ppapi/thunk/ppb_image_data_api.h" |
24 #include "third_party/libyuv/include/libyuv/convert.h" | 25 #include "third_party/libyuv/include/libyuv/convert.h" |
(...skipping 23 matching lines...) Expand all Loading... |
48 base::ThreadChecker thread_checker_; | 49 base::ThreadChecker thread_checker_; |
49 }; | 50 }; |
50 | 51 |
51 PepperVideoSourceHost::FrameReceiver::FrameReceiver( | 52 PepperVideoSourceHost::FrameReceiver::FrameReceiver( |
52 const base::WeakPtr<PepperVideoSourceHost>& host) | 53 const base::WeakPtr<PepperVideoSourceHost>& host) |
53 : host_(host) {} | 54 : host_(host) {} |
54 | 55 |
55 PepperVideoSourceHost::FrameReceiver::~FrameReceiver() {} | 56 PepperVideoSourceHost::FrameReceiver::~FrameReceiver() {} |
56 | 57 |
57 void PepperVideoSourceHost::FrameReceiver::GotFrame( | 58 void PepperVideoSourceHost::FrameReceiver::GotFrame( |
58 const scoped_refptr<media::VideoFrame>& frame) { | 59 const scoped_refptr<media::VideoFrame>& video_frame) { |
59 DCHECK(thread_checker_.CalledOnValidThread()); | 60 DCHECK(thread_checker_.CalledOnValidThread()); |
60 if (!host_) | 61 if (!host_) |
61 return; | 62 return; |
| 63 |
| 64 if (!(video_frame->format() == media::PIXEL_FORMAT_I420 || |
| 65 video_frame->format() == media::PIXEL_FORMAT_YV12A)) { |
| 66 NOTREACHED(); |
| 67 return; |
| 68 } |
| 69 scoped_refptr<media::VideoFrame> frame = video_frame; |
| 70 // Drop alpha channel since we do not support it yet. |
| 71 if (frame->format() == media::PIXEL_FORMAT_YV12A) |
| 72 frame = media::WrapAsI420VideoFrame(video_frame); |
| 73 |
62 // Hold a reference to the new frame and release the previous. | 74 // Hold a reference to the new frame and release the previous. |
63 host_->last_frame_ = frame; | 75 host_->last_frame_ = frame; |
64 if (host_->get_frame_pending_) | 76 if (host_->get_frame_pending_) |
65 host_->SendGetFrameReply(); | 77 host_->SendGetFrameReply(); |
66 } | 78 } |
67 | 79 |
68 PepperVideoSourceHost::PepperVideoSourceHost(RendererPpapiHost* host, | 80 PepperVideoSourceHost::PepperVideoSourceHost(RendererPpapiHost* host, |
69 PP_Instance instance, | 81 PP_Instance instance, |
70 PP_Resource resource) | 82 PP_Resource resource) |
71 : ResourceHost(host->GetPpapiHost(), instance, resource), | 83 : ResourceHost(host->GetPpapiHost(), instance, resource), |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 if (frame_source_.get() && !stream_url_.empty()) | 314 if (frame_source_.get() && !stream_url_.empty()) |
303 frame_source_->Close(frame_receiver_.get()); | 315 frame_source_->Close(frame_receiver_.get()); |
304 | 316 |
305 frame_source_.reset(NULL); | 317 frame_source_.reset(NULL); |
306 stream_url_.clear(); | 318 stream_url_.clear(); |
307 | 319 |
308 shared_image_ = NULL; | 320 shared_image_ = NULL; |
309 } | 321 } |
310 | 322 |
311 } // namespace content | 323 } // namespace content |
OLD | NEW |