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 // Implementation notes: This needs to work on a variety of hardware | 5 // Implementation notes: This needs to work on a variety of hardware |
6 // configurations where the speed of the CPU and GPU greatly affect overall | 6 // configurations where the speed of the CPU and GPU greatly affect overall |
7 // performance. Spanning several threads, the process of capturing has been | 7 // performance. Spanning several threads, the process of capturing has been |
8 // split up into four conceptual stages: | 8 // split up into four conceptual stages: |
9 // | 9 // |
10 // 1. Reserve Buffer: Before a frame can be captured, a slot in the client's | 10 // 1. Reserve Buffer: Before a frame can be captured, a slot in the client's |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 VideoFrameDeliveryLog* delivery_log) | 140 VideoFrameDeliveryLog* delivery_log) |
141 : event_type_(event_type), | 141 : event_type_(event_type), |
142 oracle_proxy_(oracle), | 142 oracle_proxy_(oracle), |
143 delivery_log_(delivery_log) {} | 143 delivery_log_(delivery_log) {} |
144 | 144 |
145 virtual bool ShouldCaptureFrame( | 145 virtual bool ShouldCaptureFrame( |
146 const gfx::Rect& damage_rect, | 146 const gfx::Rect& damage_rect, |
147 base::TimeTicks present_time, | 147 base::TimeTicks present_time, |
148 scoped_refptr<media::VideoFrame>* storage, | 148 scoped_refptr<media::VideoFrame>* storage, |
149 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback* | 149 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback* |
150 deliver_frame_cb) OVERRIDE; | 150 deliver_frame_cb) override; |
151 | 151 |
152 private: | 152 private: |
153 const VideoCaptureOracle::Event event_type_; | 153 const VideoCaptureOracle::Event event_type_; |
154 scoped_refptr<ThreadSafeCaptureOracle> oracle_proxy_; | 154 scoped_refptr<ThreadSafeCaptureOracle> oracle_proxy_; |
155 VideoFrameDeliveryLog* const delivery_log_; | 155 VideoFrameDeliveryLog* const delivery_log_; |
156 }; | 156 }; |
157 | 157 |
158 // ContentCaptureSubscription is the relationship between a RenderWidgetHost | 158 // ContentCaptureSubscription is the relationship between a RenderWidgetHost |
159 // whose content is updating, a subscriber that is deciding which of these | 159 // whose content is updating, a subscriber that is deciding which of these |
160 // updates to capture (and where to deliver them to), and a callback that | 160 // updates to capture (and where to deliver them to), and a callback that |
(...skipping 22 matching lines...) Expand all Loading... |
183 // work. | 183 // work. |
184 ContentCaptureSubscription( | 184 ContentCaptureSubscription( |
185 const RenderWidgetHost& source, | 185 const RenderWidgetHost& source, |
186 const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy, | 186 const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy, |
187 const CaptureCallback& capture_callback); | 187 const CaptureCallback& capture_callback); |
188 virtual ~ContentCaptureSubscription(); | 188 virtual ~ContentCaptureSubscription(); |
189 | 189 |
190 // content::NotificationObserver implementation. | 190 // content::NotificationObserver implementation. |
191 virtual void Observe(int type, | 191 virtual void Observe(int type, |
192 const content::NotificationSource& source, | 192 const content::NotificationSource& source, |
193 const content::NotificationDetails& details) OVERRIDE; | 193 const content::NotificationDetails& details) override; |
194 | 194 |
195 private: | 195 private: |
196 void OnTimer(); | 196 void OnTimer(); |
197 | 197 |
198 // Maintain a weak reference to the RenderWidgetHost (via its routing ID), | 198 // Maintain a weak reference to the RenderWidgetHost (via its routing ID), |
199 // since the instance could be destroyed externally during the lifetime of | 199 // since the instance could be destroyed externally during the lifetime of |
200 // |this|. | 200 // |this|. |
201 const int render_process_id_; | 201 const int render_process_id_; |
202 const int render_widget_id_; | 202 const int render_widget_id_; |
203 | 203 |
(...skipping 22 matching lines...) Expand all Loading... |
226 | 226 |
227 // Renews capture subscriptions based on feedback from WebContentsTracker, and | 227 // Renews capture subscriptions based on feedback from WebContentsTracker, and |
228 // also executes copying of the backing store on the UI BrowserThread. | 228 // also executes copying of the backing store on the UI BrowserThread. |
229 class WebContentsCaptureMachine : public VideoCaptureMachine { | 229 class WebContentsCaptureMachine : public VideoCaptureMachine { |
230 public: | 230 public: |
231 WebContentsCaptureMachine(int render_process_id, int main_render_frame_id); | 231 WebContentsCaptureMachine(int render_process_id, int main_render_frame_id); |
232 virtual ~WebContentsCaptureMachine(); | 232 virtual ~WebContentsCaptureMachine(); |
233 | 233 |
234 // VideoCaptureMachine overrides. | 234 // VideoCaptureMachine overrides. |
235 virtual bool Start(const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy, | 235 virtual bool Start(const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy, |
236 const media::VideoCaptureParams& params) OVERRIDE; | 236 const media::VideoCaptureParams& params) override; |
237 virtual void Stop(const base::Closure& callback) OVERRIDE; | 237 virtual void Stop(const base::Closure& callback) override; |
238 | 238 |
239 // Starts a copy from the backing store or the composited surface. Must be run | 239 // Starts a copy from the backing store or the composited surface. Must be run |
240 // on the UI BrowserThread. |deliver_frame_cb| will be run when the operation | 240 // on the UI BrowserThread. |deliver_frame_cb| will be run when the operation |
241 // completes. The copy will occur to |target|. | 241 // completes. The copy will occur to |target|. |
242 // | 242 // |
243 // This may be used as a ContentCaptureSubscription::CaptureCallback. | 243 // This may be used as a ContentCaptureSubscription::CaptureCallback. |
244 void Capture(const base::TimeTicks& start_time, | 244 void Capture(const base::TimeTicks& start_time, |
245 const scoped_refptr<media::VideoFrame>& target, | 245 const scoped_refptr<media::VideoFrame>& target, |
246 const RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback& | 246 const RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback& |
247 deliver_frame_cb); | 247 deliver_frame_cb); |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 scoped_ptr<Client> client) { | 788 scoped_ptr<Client> client) { |
789 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); | 789 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); |
790 core_->AllocateAndStart(params, client.Pass()); | 790 core_->AllocateAndStart(params, client.Pass()); |
791 } | 791 } |
792 | 792 |
793 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { | 793 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { |
794 core_->StopAndDeAllocate(); | 794 core_->StopAndDeAllocate(); |
795 } | 795 } |
796 | 796 |
797 } // namespace content | 797 } // namespace content |
OLD | NEW |