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

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

Issue 100313002: Fix screen capture slowness in Chrome OS feedback report. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments by sergeyu. Created 7 years 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
« no previous file with comments | « content/browser/renderer_host/media/video_capture_device_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/media/video_capture_device_impl.cc
diff --git a/content/browser/renderer_host/media/video_capture_device_impl.cc b/content/browser/renderer_host/media/video_capture_device_impl.cc
index 54af30f71b461e6ad74bfa760c18c8dcc832cb45..ad9034f2985c83be5610aaea0fa7f0fda50d47e5 100644
--- a/content/browser/renderer_host/media/video_capture_device_impl.cc
+++ b/content/browser/renderer_host/media/video_capture_device_impl.cc
@@ -44,12 +44,18 @@ void DeleteCaptureMachineOnUIThread(
ThreadSafeCaptureOracle::ThreadSafeCaptureOracle(
scoped_ptr<media::VideoCaptureDevice::Client> client,
scoped_ptr<VideoCaptureOracle> oracle,
- const gfx::Size& capture_size,
- int frame_rate)
+ const media::VideoCaptureParams& params)
: client_(client.Pass()),
oracle_(oracle.Pass()),
- capture_size_(capture_size),
- frame_rate_(frame_rate) {}
+ params_(params),
+ capture_size_updated_(false) {
+ // Frame dimensions must each be an even integer since the client wants (or
+ // will convert to) YUV420.
+ capture_size_ = gfx::Size(
+ MakeEven(params.requested_format.frame_size.width()),
+ MakeEven(params.requested_format.frame_size.height()));
+ frame_rate_ = params.requested_format.frame_rate;
+}
ThreadSafeCaptureOracle::~ThreadSafeCaptureOracle() {}
@@ -122,6 +128,23 @@ bool ThreadSafeCaptureOracle::ObserveEventAndDecideCapture(
return true;
}
+void ThreadSafeCaptureOracle::UpdateCaptureSize(const gfx::Size& source_size) {
+ base::AutoLock guard(lock_);
+
+ // If this is the first call to UpdateCaptureSize(), or the receiver supports
+ // variable resolution, then determine the capture size by treating the
+ // requested width and height as maxima.
+ if (!capture_size_updated_ || params_.allow_resolution_change) {
+ // The capture resolution should not exceed the source frame size.
+ // In other words it should downscale the image but not upscale it.
+ gfx::Size capture_size = params_.requested_format.frame_size;
+ capture_size.SetToMin(source_size);
Sergey Ulanov 2013/12/03 02:14:23 SetToMin() doesn't preserve aspect ratio. I think
hshi1 2013/12/03 02:19:36 Done.
+ capture_size_ = gfx::Size(MakeEven(capture_size.width()),
+ MakeEven(capture_size.height()));
+ capture_size_updated_ = true;
+ }
+}
+
void ThreadSafeCaptureOracle::Stop() {
base::AutoLock guard(lock_);
client_.reset();
@@ -173,13 +196,10 @@ void VideoCaptureDeviceImpl::AllocateAndStart(
return;
}
- // Frame dimensions must each be a positive, even integer, since the client
- // wants (or will convert to) YUV420.
- gfx::Size frame_size(MakeEven(params.requested_format.frame_size.width()),
- MakeEven(params.requested_format.frame_size.height()));
- if (frame_size.width() < kMinFrameWidth ||
- frame_size.height() < kMinFrameHeight) {
- DVLOG(1) << "invalid frame size: " << frame_size.ToString();
+ if (params.requested_format.frame_size.width() < kMinFrameWidth ||
+ params.requested_format.frame_size.height() < kMinFrameHeight) {
+ DVLOG(1) << "invalid frame size: "
+ << params.requested_format.frame_size.ToString();
client->OnError();
return;
}
@@ -193,8 +213,7 @@ void VideoCaptureDeviceImpl::AllocateAndStart(
oracle_proxy_ =
new ThreadSafeCaptureOracle(client.Pass(),
oracle.Pass(),
- frame_size,
- params.requested_format.frame_rate);
+ params);
// Starts the capture machine asynchronously.
BrowserThread::PostTaskAndReplyWithResult(
« no previous file with comments | « content/browser/renderer_host/media/video_capture_device_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698