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

Unified Diff: content/browser/media/capture/desktop_capture_device.cc

Issue 268123003: Enables using the magnification API for screen capturing on Windows under a Finch experiment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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/media/capture/desktop_capture_device.cc
diff --git a/content/browser/media/capture/desktop_capture_device.cc b/content/browser/media/capture/desktop_capture_device.cc
index f5c5c65cb3463dfc43f8a3f71bd36fc4e31e7943..e1992012de96cd05951abb168204a98bfdde8874 100644
--- a/content/browser/media/capture/desktop_capture_device.cc
+++ b/content/browser/media/capture/desktop_capture_device.cc
@@ -7,11 +7,13 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/logging.h"
+#include "base/metrics/field_trial.h"
#include "base/metrics/histogram.h"
#include "base/sequenced_task_runner.h"
#include "base/strings/string_number_conversions.h"
#include "base/synchronization/lock.h"
#include "base/threading/sequenced_worker_pool.h"
+#include "base/threading/thread.h"
#include "content/browser/media/capture/desktop_capture_device_uma_types.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/desktop_media_id.h"
@@ -55,6 +57,10 @@ class DesktopCaptureDevice::Core
scoped_ptr<webrtc::DesktopCapturer> capturer,
DesktopMediaID::Type type);
+ Core(scoped_ptr<base::Thread> thread,
+ scoped_ptr<webrtc::DesktopCapturer> capturer,
+ DesktopMediaID::Type type);
+
// Implementation of VideoCaptureDevice methods.
void AllocateAndStart(const media::VideoCaptureParams& params,
scoped_ptr<Client> client);
@@ -93,6 +99,9 @@ class DesktopCaptureDevice::Core
void DoSetNotificationWindowId(gfx::NativeViewId window_id);
+ // The thread on which the capturer is running.
+ scoped_ptr<base::Thread> thread_;
+
// Task runner used for capturing operations.
scoped_refptr<base::SequencedTaskRunner> task_runner_;
@@ -145,6 +154,17 @@ DesktopCaptureDevice::Core::Core(
capturer_type_(type) {
}
+DesktopCaptureDevice::Core::Core(scoped_ptr<base::Thread> thread,
Sergey Ulanov 2014/05/05 20:10:06 Same as with DesktopCaptureDevice, better to avoid
+ scoped_ptr<webrtc::DesktopCapturer> capturer,
+ DesktopMediaID::Type type)
+ : thread_(thread.Pass()),
+ task_runner_(thread_->message_loop_proxy()),
+ desktop_capturer_(capturer.Pass()),
+ capture_task_posted_(false),
+ capture_in_progress_(false),
+ capturer_type_(type) {
+}
+
DesktopCaptureDevice::Core::~Core() {
}
@@ -401,6 +421,7 @@ scoped_ptr<media::VideoCaptureDevice> DesktopCaptureDevice::Create(
scoped_refptr<base::SequencedTaskRunner> task_runner =
Sergey Ulanov 2014/05/05 20:10:06 There is no point creating task runner if it's not
blocking_pool->GetSequencedTaskRunner(
blocking_pool->GetSequenceToken());
+ scoped_ptr<base::Thread> ui_thread;
webrtc::DesktopCaptureOptions options =
webrtc::DesktopCaptureOptions::CreateDefault();
@@ -412,6 +433,22 @@ scoped_ptr<media::VideoCaptureDevice> DesktopCaptureDevice::Create(
switch (source.type) {
case DesktopMediaID::TYPE_SCREEN: {
scoped_ptr<webrtc::ScreenCapturer> screen_capturer;
+
+#if defined(OS_WIN)
+ bool magnification_allowed = base::FieldTrialList::FindFullName(
Sergey Ulanov 2014/05/05 20:10:06 indent 2 spaces.
+ "ScreenCaptureUseMagnification") == "Enabled";
+
+ if (magnification_allowed) {
+ // The magnification capturer requires running on a dedicated UI thread.
+ ui_thread.reset(new base::Thread("screenCaptureUIThread"));
+ base::Thread::Options thread_options(base::MessageLoop::TYPE_UI, 0);
+ ui_thread->StartWithOptions(thread_options);
+ task_runner.reset();
+
+ options.set_allow_use_magnification_api(true);
+ }
+#endif
+
screen_capturer.reset(webrtc::ScreenCapturer::Create(options));
if (screen_capturer && screen_capturer->SelectScreen(source.id)) {
capturer.reset(new webrtc::DesktopAndCursorComposer(
@@ -442,8 +479,13 @@ scoped_ptr<media::VideoCaptureDevice> DesktopCaptureDevice::Create(
scoped_ptr<media::VideoCaptureDevice> result;
if (capturer) {
- result.reset(
- new DesktopCaptureDevice(task_runner, capturer.Pass(), source.type));
+ if (task_runner.get()) {
Sergey Ulanov 2014/05/05 20:10:06 if (!ui_thread)
+ result.reset(
+ new DesktopCaptureDevice(task_runner, capturer.Pass(), source.type));
+ } else {
+ result.reset(new DesktopCaptureDevice(
+ ui_thread.Pass(), capturer.Pass(), source.type));
+ }
}
return result.Pass();
@@ -456,6 +498,13 @@ DesktopCaptureDevice::DesktopCaptureDevice(
: core_(new Core(task_runner, capturer.Pass(), type)) {
}
+DesktopCaptureDevice::DesktopCaptureDevice(
+ scoped_ptr<base::Thread> thread,
+ scoped_ptr<webrtc::DesktopCapturer> capturer,
+ DesktopMediaID::Type type)
+ : core_(new Core(thread.Pass(), capturer.Pass(), type)) {
+}
+
DesktopCaptureDevice::~DesktopCaptureDevice() {
StopAndDeAllocate();
}

Powered by Google App Engine
This is Rietveld 408576698