| 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 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 std::unique_ptr<media::VideoCaptureMachine>( | 985 std::unique_ptr<media::VideoCaptureMachine>( |
| 986 new WebContentsCaptureMachine(render_process_id, | 986 new WebContentsCaptureMachine(render_process_id, |
| 987 main_render_frame_id, | 987 main_render_frame_id, |
| 988 enable_auto_throttling)))) {} | 988 enable_auto_throttling)))) {} |
| 989 | 989 |
| 990 WebContentsVideoCaptureDevice::~WebContentsVideoCaptureDevice() { | 990 WebContentsVideoCaptureDevice::~WebContentsVideoCaptureDevice() { |
| 991 DVLOG(2) << "WebContentsVideoCaptureDevice@" << this << " destroying."; | 991 DVLOG(2) << "WebContentsVideoCaptureDevice@" << this << " destroying."; |
| 992 } | 992 } |
| 993 | 993 |
| 994 // static | 994 // static |
| 995 media::VideoCaptureDevice* WebContentsVideoCaptureDevice::Create( | 995 std::unique_ptr<media::VideoCaptureDevice> |
| 996 const std::string& device_id) { | 996 WebContentsVideoCaptureDevice::Create(const std::string& device_id) { |
| 997 // Parse device_id into render_process_id and main_render_frame_id. | 997 // Parse device_id into render_process_id and main_render_frame_id. |
| 998 int render_process_id = -1; | 998 WebContentsMediaCaptureId media_id; |
| 999 int main_render_frame_id = -1; | 999 if (!WebContentsMediaCaptureId::Parse(device_id, &media_id)) { |
| 1000 if (!WebContentsMediaCaptureId::ExtractTabCaptureTarget( | |
| 1001 device_id, &render_process_id, &main_render_frame_id)) { | |
| 1002 return NULL; | 1000 return NULL; |
| 1003 } | 1001 } |
| 1004 | 1002 |
| 1005 return new WebContentsVideoCaptureDevice( | 1003 return std::unique_ptr<media::VideoCaptureDevice>( |
| 1006 render_process_id, main_render_frame_id, | 1004 new WebContentsVideoCaptureDevice(media_id.render_process_id, |
| 1007 WebContentsMediaCaptureId::IsAutoThrottlingOptionSet(device_id)); | 1005 media_id.main_render_frame_id, |
| 1006 media_id.enable_auto_throttling)); |
| 1008 } | 1007 } |
| 1009 | 1008 |
| 1010 void WebContentsVideoCaptureDevice::AllocateAndStart( | 1009 void WebContentsVideoCaptureDevice::AllocateAndStart( |
| 1011 const media::VideoCaptureParams& params, | 1010 const media::VideoCaptureParams& params, |
| 1012 std::unique_ptr<Client> client) { | 1011 std::unique_ptr<Client> client) { |
| 1013 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); | 1012 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); |
| 1014 core_->AllocateAndStart(params, std::move(client)); | 1013 core_->AllocateAndStart(params, std::move(client)); |
| 1015 } | 1014 } |
| 1016 | 1015 |
| 1017 void WebContentsVideoCaptureDevice::RequestRefreshFrame() { | 1016 void WebContentsVideoCaptureDevice::RequestRefreshFrame() { |
| 1018 core_->RequestRefreshFrame(); | 1017 core_->RequestRefreshFrame(); |
| 1019 } | 1018 } |
| 1020 | 1019 |
| 1021 void WebContentsVideoCaptureDevice::MaybeSuspend() { | 1020 void WebContentsVideoCaptureDevice::MaybeSuspend() { |
| 1022 core_->Suspend(); | 1021 core_->Suspend(); |
| 1023 } | 1022 } |
| 1024 | 1023 |
| 1025 void WebContentsVideoCaptureDevice::Resume() { | 1024 void WebContentsVideoCaptureDevice::Resume() { |
| 1026 core_->Resume(); | 1025 core_->Resume(); |
| 1027 } | 1026 } |
| 1028 | 1027 |
| 1029 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { | 1028 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { |
| 1030 core_->StopAndDeAllocate(); | 1029 core_->StopAndDeAllocate(); |
| 1031 } | 1030 } |
| 1032 | 1031 |
| 1033 } // namespace content | 1032 } // namespace content |
| OLD | NEW |