Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Unified Diff: content/browser/renderer_host/media/web_contents_video_capture_device.cc

Issue 23551011: From Video Capture, abolish OnFrameInfo and enable resolution changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix constant declaration issue. Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/media/web_contents_video_capture_device.cc
diff --git a/content/browser/renderer_host/media/web_contents_video_capture_device.cc b/content/browser/renderer_host/media/web_contents_video_capture_device.cc
index 7aca8df58809a3f1ee994bd96bc5f9b650e1cdca..6537661b0332f05ae0eead497411dac90f129665 100644
--- a/content/browser/renderer_host/media/web_contents_video_capture_device.cc
+++ b/content/browser/renderer_host/media/web_contents_video_capture_device.cc
@@ -139,7 +139,8 @@ class ThreadSafeCaptureOracle
: public base::RefCountedThreadSafe<ThreadSafeCaptureOracle> {
public:
ThreadSafeCaptureOracle(scoped_ptr<media::VideoCaptureDevice::Client> client,
- scoped_ptr<VideoCaptureOracle> oracle);
+ scoped_ptr<VideoCaptureOracle> oracle,
+ const gfx::Size& capture_size);
bool ObserveEventAndDecideCapture(
VideoCaptureOracle::Event event,
@@ -174,6 +175,9 @@ class ThreadSafeCaptureOracle
// Makes the decision to capture a frame.
const scoped_ptr<VideoCaptureOracle> oracle_;
+
+ // The resolution at which we're capturing.
+ const gfx::Size capture_size_;
};
// FrameSubscriber is a proxy to the ThreadSafeCaptureOracle that's compatible
@@ -396,8 +400,12 @@ class VideoFrameDeliveryLog {
ThreadSafeCaptureOracle::ThreadSafeCaptureOracle(
scoped_ptr<media::VideoCaptureDevice::Client> client,
- scoped_ptr<VideoCaptureOracle> oracle)
- : client_(client.Pass()), oracle_(oracle.Pass()) {}
+ scoped_ptr<VideoCaptureOracle> oracle,
+ const gfx::Size& capture_size)
+ : client_(client.Pass()),
+ oracle_(oracle.Pass()),
+ capture_size_(capture_size) {
+}
bool ThreadSafeCaptureOracle::ObserveEventAndDecideCapture(
VideoCaptureOracle::Event event,
@@ -410,7 +418,7 @@ bool ThreadSafeCaptureOracle::ObserveEventAndDecideCapture(
return false; // Capture is stopped.
scoped_refptr<media::VideoFrame> output_buffer =
- client_->ReserveOutputBuffer();
+ client_->ReserveOutputBuffer(capture_size_);
const bool should_capture =
oracle_->ObserveEventAndDecideCapture(event, event_time);
const bool content_is_dirty =
@@ -1028,27 +1036,20 @@ void WebContentsVideoCaptureDevice::Impl::AllocateAndStart(
return;
}
- // Initialize capture settings which will be consistent for the
- // duration of the capture.
+ // Need to call OnFrameInfo just to set the frame rate.
+ // The other parameters of this struct are ignored.
media::VideoCaptureCapability settings;
-
- settings.width = width;
- settings.height = height;
settings.frame_rate = frame_rate;
- // Note: the value of |settings.color| doesn't matter if we use only the
- // VideoFrame based methods on |client|.
- settings.color = media::PIXEL_FORMAT_I420;
- settings.expected_capture_delay = 0;
- settings.interlaced = false;
+ client->OnFrameInfo(settings);
base::TimeDelta capture_period = base::TimeDelta::FromMicroseconds(
- 1000000.0 / settings.frame_rate + 0.5);
+ 1000000.0 / frame_rate + 0.5);
- client->OnFrameInfo(settings);
scoped_ptr<VideoCaptureOracle> oracle(
new VideoCaptureOracle(capture_period,
kAcceleratedSubscriberIsSupported));
- oracle_proxy_ = new ThreadSafeCaptureOracle(client.Pass(), oracle.Pass());
+ oracle_proxy_ = new ThreadSafeCaptureOracle(
+ client.Pass(), oracle.Pass(), gfx::Size(width, height));
// Allocates the CaptureMachine. The CaptureMachine will be tracking render
// view swapping over its lifetime, and we don't want to lose our reference to

Powered by Google App Engine
This is Rietveld 408576698