OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_platform_video_capture.h" | 5 #include "content/renderer/pepper/pepper_platform_video_capture.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "content/renderer/media/video_capture_impl_manager.h" | 10 #include "content/renderer/media/video_capture_impl_manager.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 DCHECK(handler == handler_); | 64 DCHECK(handler == handler_); |
65 if (!unbalanced_start_) | 65 if (!unbalanced_start_) |
66 return; | 66 return; |
67 | 67 |
68 if (video_capture_) { | 68 if (video_capture_) { |
69 unbalanced_start_ = false; | 69 unbalanced_start_ = false; |
70 video_capture_->StopCapture(handler_proxy_.get()); | 70 video_capture_->StopCapture(handler_proxy_.get()); |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 void PepperPlatformVideoCapture::FeedBuffer( | |
75 scoped_refptr<VideoFrameBuffer> buffer) { | |
76 if (video_capture_) | |
77 video_capture_->FeedBuffer(buffer); | |
78 } | |
79 | |
80 bool PepperPlatformVideoCapture::CaptureStarted() { | 74 bool PepperPlatformVideoCapture::CaptureStarted() { |
81 return handler_proxy_->state().started; | 75 return handler_proxy_->state().started; |
82 } | 76 } |
83 | 77 |
84 int PepperPlatformVideoCapture::CaptureWidth() { | 78 int PepperPlatformVideoCapture::CaptureWidth() { |
85 return handler_proxy_->state().width; | 79 return handler_proxy_->state().width; |
86 } | 80 } |
87 | 81 |
88 int PepperPlatformVideoCapture::CaptureHeight() { | 82 int PepperPlatformVideoCapture::CaptureHeight() { |
89 return handler_proxy_->state().height; | 83 return handler_proxy_->state().height; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 handler_->OnError(capture, error_code); | 132 handler_->OnError(capture, error_code); |
139 } | 133 } |
140 | 134 |
141 void PepperPlatformVideoCapture::OnRemoved(VideoCapture* capture) { | 135 void PepperPlatformVideoCapture::OnRemoved(VideoCapture* capture) { |
142 if (handler_) | 136 if (handler_) |
143 handler_->OnRemoved(capture); | 137 handler_->OnRemoved(capture); |
144 | 138 |
145 Release(); // Balance the AddRef() in StartCapture(). | 139 Release(); // Balance the AddRef() in StartCapture(). |
146 } | 140 } |
147 | 141 |
148 void PepperPlatformVideoCapture::OnBufferReady( | 142 void PepperPlatformVideoCapture::OnFrameReady( |
149 VideoCapture* capture, | 143 VideoCapture* capture, |
150 scoped_refptr<VideoFrameBuffer> buffer) { | 144 const scoped_refptr<media::VideoFrame>& frame) { |
151 if (handler_) { | 145 if (handler_) |
152 handler_->OnBufferReady(capture, buffer); | 146 handler_->OnFrameReady(capture, frame); |
153 } else { | |
154 // Even after handler_ is detached, we have to return buffers that are in | |
155 // flight to us. Otherwise VideoCaptureController will not tear down. | |
156 FeedBuffer(buffer); | |
157 } | |
158 } | 147 } |
159 | 148 |
160 void PepperPlatformVideoCapture::OnDeviceInfoReceived( | 149 void PepperPlatformVideoCapture::OnDeviceInfoReceived( |
161 VideoCapture* capture, | 150 VideoCapture* capture, |
162 const media::VideoCaptureParams& device_info) { | 151 const media::VideoCaptureParams& device_info) { |
163 if (handler_) | 152 if (handler_) |
164 handler_->OnDeviceInfoReceived(capture, device_info); | 153 handler_->OnDeviceInfoReceived(capture, device_info); |
165 } | 154 } |
166 | 155 |
167 PepperPlatformVideoCapture::~PepperPlatformVideoCapture() { | 156 PepperPlatformVideoCapture::~PepperPlatformVideoCapture() { |
(...skipping 25 matching lines...) Expand all Loading... |
193 if (handler_) | 182 if (handler_) |
194 handler_->OnInitialized(this, succeeded); | 183 handler_->OnInitialized(this, succeeded); |
195 } | 184 } |
196 | 185 |
197 PepperMediaDeviceManager* | 186 PepperMediaDeviceManager* |
198 PepperPlatformVideoCapture::GetMediaDeviceManager() { | 187 PepperPlatformVideoCapture::GetMediaDeviceManager() { |
199 return PepperMediaDeviceManager::GetForRenderView(render_view_.get()); | 188 return PepperMediaDeviceManager::GetForRenderView(render_view_.get()); |
200 } | 189 } |
201 | 190 |
202 } // namespace content | 191 } // namespace content |
OLD | NEW |