| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // | 43 // |
| 44 // In the above example, both capturing and rendering *each* take almost the | 44 // In the above example, both capturing and rendering *each* take almost the |
| 45 // full 33 ms available between frames, yet we see that the required throughput | 45 // full 33 ms available between frames, yet we see that the required throughput |
| 46 // is obtained. | 46 // is obtained. |
| 47 // | 47 // |
| 48 // Turning on verbose logging will cause the effective frame rate to be logged | 48 // Turning on verbose logging will cause the effective frame rate to be logged |
| 49 // at 5-second intervals. | 49 // at 5-second intervals. |
| 50 | 50 |
| 51 #include "content/browser/media/capture/web_contents_video_capture_device.h" | 51 #include "content/browser/media/capture/web_contents_video_capture_device.h" |
| 52 | 52 |
| 53 #include <stdint.h> |
| 53 #include <algorithm> | 54 #include <algorithm> |
| 54 | 55 #include <utility> |
| 55 #include <stdint.h> | |
| 56 | 56 |
| 57 #include "base/bind.h" | 57 #include "base/bind.h" |
| 58 #include "base/callback_helpers.h" | 58 #include "base/callback_helpers.h" |
| 59 #include "base/location.h" | 59 #include "base/location.h" |
| 60 #include "base/logging.h" | 60 #include "base/logging.h" |
| 61 #include "base/macros.h" | 61 #include "base/macros.h" |
| 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" |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 // Subscribe to compositor updates. These will be serviced directly by the | 459 // Subscribe to compositor updates. These will be serviced directly by the |
| 460 // oracle. | 460 // oracle. |
| 461 if (view) { | 461 if (view) { |
| 462 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber( | 462 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber( |
| 463 new FrameSubscriber( | 463 new FrameSubscriber( |
| 464 media::VideoCaptureOracle::kCompositorUpdate, oracle_proxy, | 464 media::VideoCaptureOracle::kCompositorUpdate, oracle_proxy, |
| 465 &delivery_log_, cursor_renderer_ ? cursor_renderer_->GetWeakPtr() | 465 &delivery_log_, cursor_renderer_ ? cursor_renderer_->GetWeakPtr() |
| 466 : base::WeakPtr<CursorRenderer>(), | 466 : base::WeakPtr<CursorRenderer>(), |
| 467 window_activity_tracker_ ? window_activity_tracker_->GetWeakPtr() | 467 window_activity_tracker_ ? window_activity_tracker_->GetWeakPtr() |
| 468 : base::WeakPtr<WindowActivityTracker>())); | 468 : base::WeakPtr<WindowActivityTracker>())); |
| 469 view->BeginFrameSubscription(subscriber.Pass()); | 469 view->BeginFrameSubscription(std::move(subscriber)); |
| 470 } | 470 } |
| 471 | 471 |
| 472 // Subscribe to timer events. This instance will service these as well. | 472 // Subscribe to timer events. This instance will service these as well. |
| 473 timer_.Start(FROM_HERE, | 473 timer_.Start(FROM_HERE, |
| 474 std::max(oracle_proxy->min_capture_period(), | 474 std::max(oracle_proxy->min_capture_period(), |
| 475 base::TimeDelta::FromMilliseconds(media | 475 base::TimeDelta::FromMilliseconds(media |
| 476 ::VideoCaptureOracle::kMinTimerPollPeriodMillis)), | 476 ::VideoCaptureOracle::kMinTimerPollPeriodMillis)), |
| 477 base::Bind(&ContentCaptureSubscription::OnTimer, | 477 base::Bind(&ContentCaptureSubscription::OnTimer, |
| 478 base::Unretained(this))); | 478 base::Unretained(this))); |
| 479 } | 479 } |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 return new WebContentsVideoCaptureDevice( | 959 return new WebContentsVideoCaptureDevice( |
| 960 render_process_id, | 960 render_process_id, |
| 961 main_render_frame_id, | 961 main_render_frame_id, |
| 962 WebContentsCaptureUtil::IsAutoThrottlingOptionSet(device_id)); | 962 WebContentsCaptureUtil::IsAutoThrottlingOptionSet(device_id)); |
| 963 } | 963 } |
| 964 | 964 |
| 965 void WebContentsVideoCaptureDevice::AllocateAndStart( | 965 void WebContentsVideoCaptureDevice::AllocateAndStart( |
| 966 const media::VideoCaptureParams& params, | 966 const media::VideoCaptureParams& params, |
| 967 scoped_ptr<Client> client) { | 967 scoped_ptr<Client> client) { |
| 968 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); | 968 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); |
| 969 core_->AllocateAndStart(params, client.Pass()); | 969 core_->AllocateAndStart(params, std::move(client)); |
| 970 } | 970 } |
| 971 | 971 |
| 972 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { | 972 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { |
| 973 core_->StopAndDeAllocate(); | 973 core_->StopAndDeAllocate(); |
| 974 } | 974 } |
| 975 | 975 |
| 976 } // namespace content | 976 } // namespace content |
| OLD | NEW |