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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 #include "content/browser/media/capture/web_contents_tracker.h" | 70 #include "content/browser/media/capture/web_contents_tracker.h" |
71 #include "content/browser/renderer_host/render_widget_host_impl.h" | 71 #include "content/browser/renderer_host/render_widget_host_impl.h" |
72 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 72 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
73 #include "content/public/browser/browser_thread.h" | 73 #include "content/public/browser/browser_thread.h" |
74 #include "content/public/browser/render_process_host.h" | 74 #include "content/public/browser/render_process_host.h" |
75 #include "content/public/browser/render_widget_host_view.h" | 75 #include "content/public/browser/render_widget_host_view.h" |
76 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" | 76 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
77 #include "content/public/browser/web_contents.h" | 77 #include "content/public/browser/web_contents.h" |
78 #include "media/base/bind_to_current_loop.h" | 78 #include "media/base/bind_to_current_loop.h" |
79 #include "media/base/video_capture_types.h" | 79 #include "media/base/video_capture_types.h" |
80 #include "media/base/video_frame_metadata.h" | |
80 #include "media/base/video_util.h" | 81 #include "media/base/video_util.h" |
81 #include "media/capture/content/screen_capture_device_core.h" | 82 #include "media/capture/content/screen_capture_device_core.h" |
82 #include "media/capture/content/thread_safe_capture_oracle.h" | 83 #include "media/capture/content/thread_safe_capture_oracle.h" |
83 #include "media/capture/content/video_capture_oracle.h" | 84 #include "media/capture/content/video_capture_oracle.h" |
84 #include "skia/ext/image_operations.h" | 85 #include "skia/ext/image_operations.h" |
85 #include "third_party/skia/include/core/SkBitmap.h" | 86 #include "third_party/skia/include/core/SkBitmap.h" |
86 #include "third_party/skia/include/core/SkColor.h" | 87 #include "third_party/skia/include/core/SkColor.h" |
87 #include "ui/base/layout.h" | 88 #include "ui/base/layout.h" |
88 #include "ui/gfx/geometry/dip_util.h" | 89 #include "ui/gfx/geometry/dip_util.h" |
89 #include "ui/gfx/geometry/size_conversions.h" | 90 #include "ui/gfx/geometry/size_conversions.h" |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
354 capture_frame_cb, | 355 capture_frame_cb, |
355 const scoped_refptr<media::VideoFrame>& frame, | 356 const scoped_refptr<media::VideoFrame>& frame, |
356 base::TimeTicks timestamp, | 357 base::TimeTicks timestamp, |
357 const gfx::Rect& region_in_frame, | 358 const gfx::Rect& region_in_frame, |
358 bool success) { | 359 bool success) { |
359 // We can get a callback in the shutdown sequence for the browser main loop | 360 // We can get a callback in the shutdown sequence for the browser main loop |
360 // and this can result in a DCHECK failure. Avoid this by doing DCHECK only | 361 // and this can result in a DCHECK failure. Avoid this by doing DCHECK only |
361 // on success. | 362 // on success. |
362 if (success) { | 363 if (success) { |
363 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 364 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
365 bool ui_event_detected = false; | |
366 bool animation_content = true; | |
364 // TODO(isheriff): Unclear if taking a snapshot of cursor here affects user | 367 // TODO(isheriff): Unclear if taking a snapshot of cursor here affects user |
365 // experience in any particular scenarios. Doing it prior to capture may | 368 // experience in any particular scenarios. Doing it prior to capture may |
366 // require evaluating region_in_frame in this file. | 369 // require evaluating region_in_frame in this file. |
367 if (frame_subscriber_ && frame_subscriber_->cursor_renderer_) { | 370 if (frame_subscriber_ && frame_subscriber_->cursor_renderer_) { |
368 if (frame_subscriber_->cursor_renderer_->SnapshotCursorState( | 371 CursorRenderer* cursor_renderer = |
369 region_in_frame)) | 372 frame_subscriber_->cursor_renderer_.get(); |
370 frame_subscriber_->cursor_renderer_->RenderOnVideoFrame(frame); | 373 if (cursor_renderer->SnapshotCursorState(region_in_frame)) |
374 cursor_renderer->RenderOnVideoFrame(frame); | |
375 ui_event_detected = cursor_renderer->ui_event_detected(); | |
376 animation_content = frame_subscriber_->oracle_proxy_->IsAnimationActive(); | |
371 } | 377 } |
378 frame->metadata()->SetBoolean(media::VideoFrameMetadata::ANIMATION_CONTENT, | |
miu
2015/12/01 21:15:27
In-line with other comments (video_sender.cc), I t
Irfan
2015/12/02 22:32:44
As discussed will look at moving to a single boole
| |
379 animation_content); | |
380 frame->metadata()->SetBoolean(media::VideoFrameMetadata::USER_INTERACTION, | |
381 ui_event_detected); | |
372 } | 382 } |
373 capture_frame_cb.Run(frame, timestamp, success); | 383 capture_frame_cb.Run(frame, timestamp, success); |
374 } | 384 } |
375 | 385 |
376 ContentCaptureSubscription::ContentCaptureSubscription( | 386 ContentCaptureSubscription::ContentCaptureSubscription( |
377 const RenderWidgetHost& source, | 387 const RenderWidgetHost& source, |
378 const scoped_refptr<media::ThreadSafeCaptureOracle>& oracle_proxy, | 388 const scoped_refptr<media::ThreadSafeCaptureOracle>& oracle_proxy, |
379 const CaptureCallback& capture_callback) | 389 const CaptureCallback& capture_callback) |
380 : render_process_id_(source.GetProcess()->GetID()), | 390 : render_process_id_(source.GetProcess()->GetID()), |
381 render_widget_id_(source.GetRoutingID()), | 391 render_widget_id_(source.GetRoutingID()), |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
909 scoped_ptr<Client> client) { | 919 scoped_ptr<Client> client) { |
910 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); | 920 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); |
911 core_->AllocateAndStart(params, client.Pass()); | 921 core_->AllocateAndStart(params, client.Pass()); |
912 } | 922 } |
913 | 923 |
914 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { | 924 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { |
915 core_->StopAndDeAllocate(); | 925 core_->StopAndDeAllocate(); |
916 } | 926 } |
917 | 927 |
918 } // namespace content | 928 } // namespace content |
OLD | NEW |