| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 #include "base/memory/scoped_ptr.h" | 62 #include "base/memory/scoped_ptr.h" |
| 63 #include "base/memory/weak_ptr.h" | 63 #include "base/memory/weak_ptr.h" |
| 64 #include "base/metrics/histogram.h" | 64 #include "base/metrics/histogram.h" |
| 65 #include "base/sequenced_task_runner.h" | 65 #include "base/sequenced_task_runner.h" |
| 66 #include "base/single_thread_task_runner.h" | 66 #include "base/single_thread_task_runner.h" |
| 67 #include "base/threading/thread.h" | 67 #include "base/threading/thread.h" |
| 68 #include "base/threading/thread_checker.h" | 68 #include "base/threading/thread_checker.h" |
| 69 #include "base/time/time.h" | 69 #include "base/time/time.h" |
| 70 #include "build/build_config.h" | 70 #include "build/build_config.h" |
| 71 #include "content/browser/media/capture/cursor_renderer.h" | 71 #include "content/browser/media/capture/cursor_renderer.h" |
| 72 #include "content/browser/media/capture/web_contents_capture_util.h" | |
| 73 #include "content/browser/media/capture/web_contents_tracker.h" | 72 #include "content/browser/media/capture/web_contents_tracker.h" |
| 74 #include "content/browser/media/capture/window_activity_tracker.h" | 73 #include "content/browser/media/capture/window_activity_tracker.h" |
| 75 #include "content/browser/renderer_host/render_widget_host_impl.h" | 74 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 76 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 75 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 77 #include "content/public/browser/browser_thread.h" | 76 #include "content/public/browser/browser_thread.h" |
| 78 #include "content/public/browser/render_process_host.h" | 77 #include "content/public/browser/render_process_host.h" |
| 79 #include "content/public/browser/render_widget_host_view.h" | 78 #include "content/public/browser/render_widget_host_view.h" |
| 80 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" | 79 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
| 81 #include "content/public/browser/web_contents.h" | 80 #include "content/public/browser/web_contents.h" |
| 81 #include "content/public/browser/web_contents_media_capture_id.h" |
| 82 #include "media/base/bind_to_current_loop.h" | 82 #include "media/base/bind_to_current_loop.h" |
| 83 #include "media/base/video_capture_types.h" | 83 #include "media/base/video_capture_types.h" |
| 84 #include "media/base/video_frame_metadata.h" | 84 #include "media/base/video_frame_metadata.h" |
| 85 #include "media/base/video_util.h" | 85 #include "media/base/video_util.h" |
| 86 #include "media/capture/content/screen_capture_device_core.h" | 86 #include "media/capture/content/screen_capture_device_core.h" |
| 87 #include "media/capture/content/thread_safe_capture_oracle.h" | 87 #include "media/capture/content/thread_safe_capture_oracle.h" |
| 88 #include "media/capture/content/video_capture_oracle.h" | 88 #include "media/capture/content/video_capture_oracle.h" |
| 89 #include "skia/ext/image_operations.h" | 89 #include "skia/ext/image_operations.h" |
| 90 #include "third_party/skia/include/core/SkBitmap.h" | 90 #include "third_party/skia/include/core/SkBitmap.h" |
| 91 #include "third_party/skia/include/core/SkColor.h" | 91 #include "third_party/skia/include/core/SkColor.h" |
| (...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 WebContentsVideoCaptureDevice::~WebContentsVideoCaptureDevice() { | 946 WebContentsVideoCaptureDevice::~WebContentsVideoCaptureDevice() { |
| 947 DVLOG(2) << "WebContentsVideoCaptureDevice@" << this << " destroying."; | 947 DVLOG(2) << "WebContentsVideoCaptureDevice@" << this << " destroying."; |
| 948 } | 948 } |
| 949 | 949 |
| 950 // static | 950 // static |
| 951 media::VideoCaptureDevice* WebContentsVideoCaptureDevice::Create( | 951 media::VideoCaptureDevice* WebContentsVideoCaptureDevice::Create( |
| 952 const std::string& device_id) { | 952 const std::string& device_id) { |
| 953 // Parse device_id into render_process_id and main_render_frame_id. | 953 // Parse device_id into render_process_id and main_render_frame_id. |
| 954 int render_process_id = -1; | 954 int render_process_id = -1; |
| 955 int main_render_frame_id = -1; | 955 int main_render_frame_id = -1; |
| 956 if (!WebContentsCaptureUtil::ExtractTabCaptureTarget( | 956 if (!WebContentsMediaCaptureId::ExtractTabCaptureTarget( |
| 957 device_id, &render_process_id, &main_render_frame_id)) { | 957 device_id, &render_process_id, &main_render_frame_id)) { |
| 958 return NULL; | 958 return NULL; |
| 959 } | 959 } |
| 960 | 960 |
| 961 return new WebContentsVideoCaptureDevice( | 961 return new WebContentsVideoCaptureDevice( |
| 962 render_process_id, | 962 render_process_id, main_render_frame_id, |
| 963 main_render_frame_id, | 963 WebContentsMediaCaptureId::IsAutoThrottlingOptionSet(device_id)); |
| 964 WebContentsCaptureUtil::IsAutoThrottlingOptionSet(device_id)); | |
| 965 } | 964 } |
| 966 | 965 |
| 967 void WebContentsVideoCaptureDevice::AllocateAndStart( | 966 void WebContentsVideoCaptureDevice::AllocateAndStart( |
| 968 const media::VideoCaptureParams& params, | 967 const media::VideoCaptureParams& params, |
| 969 scoped_ptr<Client> client) { | 968 scoped_ptr<Client> client) { |
| 970 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); | 969 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); |
| 971 core_->AllocateAndStart(params, std::move(client)); | 970 core_->AllocateAndStart(params, std::move(client)); |
| 972 } | 971 } |
| 973 | 972 |
| 974 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { | 973 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { |
| 975 core_->StopAndDeAllocate(); | 974 core_->StopAndDeAllocate(); |
| 976 } | 975 } |
| 977 | 976 |
| 978 } // namespace content | 977 } // namespace content |
| OLD | NEW |