Chromium Code Reviews| 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 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 946 enable_auto_throttling)))) {} | 946 enable_auto_throttling)))) {} |
| 947 | 947 |
| 948 WebContentsVideoCaptureDevice::~WebContentsVideoCaptureDevice() { | 948 WebContentsVideoCaptureDevice::~WebContentsVideoCaptureDevice() { |
| 949 DVLOG(2) << "WebContentsVideoCaptureDevice@" << this << " destroying."; | 949 DVLOG(2) << "WebContentsVideoCaptureDevice@" << this << " destroying."; |
| 950 } | 950 } |
| 951 | 951 |
| 952 // static | 952 // static |
| 953 media::VideoCaptureDevice* WebContentsVideoCaptureDevice::Create( | 953 media::VideoCaptureDevice* WebContentsVideoCaptureDevice::Create( |
| 954 const std::string& device_id) { | 954 const std::string& device_id) { |
| 955 // Parse device_id into render_process_id and main_render_frame_id. | 955 // Parse device_id into render_process_id and main_render_frame_id. |
| 956 int render_process_id = -1; | 956 WebContentsMediaCaptureId media_id; |
| 957 int main_render_frame_id = -1; | 957 if (!WebContentsMediaCaptureId::Parse(device_id, &media_id)) { |
| 958 if (!WebContentsMediaCaptureId::ExtractTabCaptureTarget( | |
| 959 device_id, &render_process_id, &main_render_frame_id)) { | |
| 960 return NULL; | 958 return NULL; |
| 961 } | 959 } |
| 962 | 960 |
| 963 return new WebContentsVideoCaptureDevice( | 961 return new WebContentsVideoCaptureDevice(media_id.render_process_id, |
| 964 render_process_id, main_render_frame_id, | 962 media_id.main_render_frame_id, |
| 965 WebContentsMediaCaptureId::IsAutoThrottlingOptionSet(device_id)); | 963 media_id.enable_auto_throttling); |
|
Avi (use Gerrit)
2016/09/22 18:19:36
If you return a new object, make it return a std::
qiangchen
2016/09/22 20:40:59
Done.
| |
| 966 } | 964 } |
| 967 | 965 |
| 968 void WebContentsVideoCaptureDevice::AllocateAndStart( | 966 void WebContentsVideoCaptureDevice::AllocateAndStart( |
| 969 const media::VideoCaptureParams& params, | 967 const media::VideoCaptureParams& params, |
| 970 std::unique_ptr<Client> client) { | 968 std::unique_ptr<Client> client) { |
| 971 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); | 969 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); |
| 972 core_->AllocateAndStart(params, std::move(client)); | 970 core_->AllocateAndStart(params, std::move(client)); |
| 973 } | 971 } |
| 974 | 972 |
| 975 void WebContentsVideoCaptureDevice::RequestRefreshFrame() { | 973 void WebContentsVideoCaptureDevice::RequestRefreshFrame() { |
| 976 core_->RequestRefreshFrame(); | 974 core_->RequestRefreshFrame(); |
| 977 } | 975 } |
| 978 | 976 |
| 979 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { | 977 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { |
| 980 core_->StopAndDeAllocate(); | 978 core_->StopAndDeAllocate(); |
| 981 } | 979 } |
| 982 | 980 |
| 983 } // namespace content | 981 } // namespace content |
| OLD | NEW |