summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-21 22:31:35 +0000
committerzork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-21 22:31:35 +0000
commit462c125556981700f2d64f4fc155f5d0c474c92f (patch)
treeac458f450033e443e55e6a91d4ee64f5b115d78d
parent927c7514f21717cb2e8daef633058702bf8fe4d1 (diff)
downloadchromium_src-462c125556981700f2d64f4fc155f5d0c474c92f.zip
chromium_src-462c125556981700f2d64f4fc155f5d0c474c92f.tar.gz
chromium_src-462c125556981700f2d64f4fc155f5d0c474c92f.tar.bz2
Merge 271560 "Add a ChromeOS implementation of VideoCaptureDevic..."
> Add a ChromeOS implementation of VideoCaptureDevice that is aware of the rotation of the internal display, and updates the rotation of captured frames to match. > > BUG=360048 > > Review URL: https://codereview.chromium.org/270263008 TBR=zork@chromium.org Review URL: https://codereview.chromium.org/292663010 git-svn-id: svn://svn.chromium.org/chrome/branches/1985/src@271990 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/renderer_host/media/video_capture_manager.cc4
-rw-r--r--media/media.gyp2
-rw-r--r--media/video/capture/android/video_capture_device_android.cc4
-rw-r--r--media/video/capture/fake_video_capture_device_factory.cc1
-rw-r--r--media/video/capture/fake_video_capture_device_factory.h1
-rw-r--r--media/video/capture/file_video_capture_device_factory.cc1
-rw-r--r--media/video/capture/file_video_capture_device_factory.h1
-rw-r--r--media/video/capture/linux/video_capture_device_chromeos.cc112
-rw-r--r--media/video/capture/linux/video_capture_device_chromeos.h37
-rw-r--r--media/video/capture/linux/video_capture_device_linux.cc38
-rw-r--r--media/video/capture/linux/video_capture_device_linux.h11
-rw-r--r--media/video/capture/mac/video_capture_device_mac.mm4
-rw-r--r--media/video/capture/video_capture_device.h5
-rw-r--r--media/video/capture/video_capture_device_factory.cc3
-rw-r--r--media/video/capture/video_capture_device_factory.h1
-rw-r--r--media/video/capture/video_capture_device_unittest.cc34
-rw-r--r--media/video/capture/win/video_capture_device_win.cc4
17 files changed, 244 insertions, 19 deletions
diff --git a/content/browser/renderer_host/media/video_capture_manager.cc b/content/browser/renderer_host/media/video_capture_manager.cc
index 6568407..6c90c91 100644
--- a/content/browser/renderer_host/media/video_capture_manager.cc
+++ b/content/browser/renderer_host/media/video_capture_manager.cc
@@ -200,7 +200,9 @@ void VideoCaptureManager::DoStartDeviceOnDeviceThread(
DeviceInfo* found = FindDeviceInfoById(entry->id, devices_info_cache_);
if (found) {
video_capture_device =
- video_capture_device_factory_->Create(found->name);
+ video_capture_device_factory_->Create(
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
+ found->name);
}
break;
}
diff --git a/media/media.gyp b/media/media.gyp
index 5a974aa..1724c97 100644
--- a/media/media.gyp
+++ b/media/media.gyp
@@ -470,6 +470,8 @@
'video/capture/file_video_capture_device_factory.cc',
'video/capture/linux/video_capture_device_linux.cc',
'video/capture/linux/video_capture_device_linux.h',
+ 'video/capture/linux/video_capture_device_chromeos.cc',
+ 'video/capture/linux/video_capture_device_chromeos.h',
'video/capture/mac/avfoundation_glue.h',
'video/capture/mac/avfoundation_glue.mm',
'video/capture/mac/coremedia_glue.h',
diff --git a/media/video/capture/android/video_capture_device_android.cc b/media/video/capture/android/video_capture_device_android.cc
index 426be13..2becfc4 100644
--- a/media/video/capture/android/video_capture_device_android.cc
+++ b/media/video/capture/android/video_capture_device_android.cc
@@ -35,7 +35,9 @@ void VideoCaptureDevice::GetDeviceSupportedFormats(
}
// static
-VideoCaptureDevice* VideoCaptureDevice::Create(const Name& device_name) {
+VideoCaptureDevice* VideoCaptureDevice::Create(
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
+ const Name& device_name) {
return VideoCaptureDeviceAndroid::Create(device_name);
}
diff --git a/media/video/capture/fake_video_capture_device_factory.cc b/media/video/capture/fake_video_capture_device_factory.cc
index 79e528f..fc11d47 100644
--- a/media/video/capture/fake_video_capture_device_factory.cc
+++ b/media/video/capture/fake_video_capture_device_factory.cc
@@ -14,6 +14,7 @@ FakeVideoCaptureDeviceFactory::FakeVideoCaptureDeviceFactory()
}
scoped_ptr<VideoCaptureDevice> FakeVideoCaptureDeviceFactory::Create(
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
const VideoCaptureDevice::Name& device_name) {
for (int n = 0; n < number_of_devices_; ++n) {
std::string possible_id = base::StringPrintf("/dev/video%d", n);
diff --git a/media/video/capture/fake_video_capture_device_factory.h b/media/video/capture/fake_video_capture_device_factory.h
index 5c7312b..89e3b0f 100644
--- a/media/video/capture/fake_video_capture_device_factory.h
+++ b/media/video/capture/fake_video_capture_device_factory.h
@@ -20,6 +20,7 @@ class MEDIA_EXPORT FakeVideoCaptureDeviceFactory :
virtual ~FakeVideoCaptureDeviceFactory() {}
virtual scoped_ptr<VideoCaptureDevice> Create(
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
const VideoCaptureDevice::Name& device_name) OVERRIDE;
virtual void GetDeviceNames(VideoCaptureDevice::Names* device_names) OVERRIDE;
virtual void GetDeviceSupportedFormats(
diff --git a/media/video/capture/file_video_capture_device_factory.cc b/media/video/capture/file_video_capture_device_factory.cc
index dab9a51..772f4f6 100644
--- a/media/video/capture/file_video_capture_device_factory.cc
+++ b/media/video/capture/file_video_capture_device_factory.cc
@@ -25,6 +25,7 @@ base::FilePath GetFilePathFromCommandLine() {
}
scoped_ptr<VideoCaptureDevice> FileVideoCaptureDeviceFactory::Create(
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
const VideoCaptureDevice::Name& device_name) {
#if defined(OS_WIN)
return scoped_ptr<VideoCaptureDevice>(new FileVideoCaptureDevice(
diff --git a/media/video/capture/file_video_capture_device_factory.h b/media/video/capture/file_video_capture_device_factory.h
index 986a266..6455ea3 100644
--- a/media/video/capture/file_video_capture_device_factory.h
+++ b/media/video/capture/file_video_capture_device_factory.h
@@ -19,6 +19,7 @@ class MEDIA_EXPORT FileVideoCaptureDeviceFactory :
virtual ~FileVideoCaptureDeviceFactory() {}
virtual scoped_ptr<VideoCaptureDevice> Create(
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
const VideoCaptureDevice::Name& device_name) OVERRIDE;
virtual void GetDeviceNames(VideoCaptureDevice::Names* device_names) OVERRIDE;
virtual void GetDeviceSupportedFormats(
diff --git a/media/video/capture/linux/video_capture_device_chromeos.cc b/media/video/capture/linux/video_capture_device_chromeos.cc
new file mode 100644
index 0000000..40e6eaa
--- /dev/null
+++ b/media/video/capture/linux/video_capture_device_chromeos.cc
@@ -0,0 +1,112 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/video/capture/linux/video_capture_device_chromeos.h"
+
+#include "base/bind.h"
+#include "base/memory/ref_counted.h"
+#include "base/message_loop/message_loop_proxy.h"
+#include "ui/gfx/display.h"
+#include "ui/gfx/display_observer.h"
+#include "ui/gfx/screen.h"
+
+namespace media {
+
+// This is a delegate class used to transfer Display change events from the UI
+// thread to the media thread.
+class VideoCaptureDeviceChromeOS::ScreenObserverDelegate
+ : public gfx::DisplayObserver,
+ public base::RefCountedThreadSafe<ScreenObserverDelegate> {
+ public:
+ ScreenObserverDelegate(
+ VideoCaptureDeviceChromeOS* capture_device,
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner)
+ : capture_device_(capture_device),
+ ui_task_runner_(ui_task_runner),
+ capture_task_runner_(base::MessageLoopProxy::current()) {
+ ui_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&ScreenObserverDelegate::AddObserverOnUIThread, this));
+ }
+
+ void RemoveObserver() {
+ DCHECK(capture_task_runner_->BelongsToCurrentThread());
+ capture_device_ = NULL;
+ ui_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&ScreenObserverDelegate::RemoveObserverOnUIThread, this));
+ }
+
+ private:
+ friend class base::RefCountedThreadSafe<ScreenObserverDelegate>;
+
+ virtual ~ScreenObserverDelegate() {
+ DCHECK(!capture_device_);
+ }
+
+ // gfx::DisplayObserver:
+ virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE {
+ SendDisplayRotation(display);
+ }
+
+ virtual void OnDisplayAdded(const gfx::Display& /*new_display*/) OVERRIDE {}
+ virtual void OnDisplayRemoved(const gfx::Display& /*old_display*/) OVERRIDE {}
+
+ void AddObserverOnUIThread() {
+ DCHECK(ui_task_runner_->BelongsToCurrentThread());
+ gfx::Screen* screen =
+ gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE);
+ if (screen) {
+ screen->AddObserver(this);
+ SendDisplayRotation(screen->GetPrimaryDisplay());
+ }
+ }
+
+ void RemoveObserverOnUIThread() {
+ DCHECK(ui_task_runner_->BelongsToCurrentThread());
+ gfx::Screen* screen =
+ gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE);
+ if (screen)
+ screen->RemoveObserver(this);
+ }
+
+ void SendDisplayRotation(const gfx::Display& display) {
+ DCHECK(capture_task_runner_->BelongsToCurrentThread());
+ capture_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&ScreenObserverDelegate::SendDisplayRotationOnCaptureThread,
+ this, display));
+ }
+
+ void SendDisplayRotationOnCaptureThread(const gfx::Display& display) {
+ DCHECK(capture_task_runner_->BelongsToCurrentThread());
+ capture_device_->SetDisplayRotation(display);
+ }
+
+ VideoCaptureDeviceChromeOS* capture_device_;
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
+ scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_;
+ DISALLOW_IMPLICIT_CONSTRUCTORS(ScreenObserverDelegate);
+};
+
+
+VideoCaptureDeviceChromeOS::VideoCaptureDeviceChromeOS(
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
+ const Name& device_name)
+ : VideoCaptureDeviceLinux(device_name),
+ screen_observer_delegate_(new ScreenObserverDelegate(this,
+ ui_task_runner)) {
+}
+
+VideoCaptureDeviceChromeOS::~VideoCaptureDeviceChromeOS() {
+ screen_observer_delegate_->RemoveObserver();
+}
+
+void VideoCaptureDeviceChromeOS::SetDisplayRotation(
+ const gfx::Display& display) {
+ if (display.IsInternal())
+ SetRotation(display.rotation() * 90);
+}
+
+} // namespace media
diff --git a/media/video/capture/linux/video_capture_device_chromeos.h b/media/video/capture/linux/video_capture_device_chromeos.h
new file mode 100644
index 0000000..3a0c293
--- /dev/null
+++ b/media/video/capture/linux/video_capture_device_chromeos.h
@@ -0,0 +1,37 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_DEVICE_CHROMEOS_H_
+#define MEDIA_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_DEVICE_CHROMEOS_H_
+
+#include "media/video/capture/linux/video_capture_device_linux.h"
+
+namespace gfx {
+class Display;
+} // namespace gfx
+
+namespace media {
+
+// This class is functionally the same as VideoCaptureDeviceLinux, with the
+// exception that it is aware of the orientation of the internal Display. When
+// the internal Display is rotated, the frames captured are rotated to match.
+class VideoCaptureDeviceChromeOS : public VideoCaptureDeviceLinux {
+ public:
+ explicit VideoCaptureDeviceChromeOS(
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
+ const Name& device_name);
+ virtual ~VideoCaptureDeviceChromeOS();
+
+ void SetDisplayRotation(const gfx::Display& display);
+
+ private:
+ class ScreenObserverDelegate;
+
+ scoped_refptr<ScreenObserverDelegate> screen_observer_delegate_;
+ DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceChromeOS);
+};
+
+} // namespace media
+
+#endif // MEDIA_VIDEO_CAPTURE_LINUX_VIDEO_CAPTURE_DEVICE_CHROMEOS_H_
diff --git a/media/video/capture/linux/video_capture_device_linux.cc b/media/video/capture/linux/video_capture_device_linux.cc
index 6893743..7e2dd88 100644
--- a/media/video/capture/linux/video_capture_device_linux.cc
+++ b/media/video/capture/linux/video_capture_device_linux.cc
@@ -23,6 +23,10 @@
#include "base/posix/eintr_wrapper.h"
#include "base/strings/stringprintf.h"
+#if defined(OS_CHROMEOS)
+#include "media/video/capture/linux/video_capture_device_chromeos.h"
+#endif
+
namespace media {
// Max number of video buffers VideoCaptureDeviceLinux can allocate.
@@ -248,8 +252,15 @@ const std::string VideoCaptureDevice::Name::GetModel() const {
return usb_id;
}
-VideoCaptureDevice* VideoCaptureDevice::Create(const Name& device_name) {
+VideoCaptureDevice* VideoCaptureDevice::Create(
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
+ const Name& device_name) {
+#if defined(OS_CHROMEOS)
+ VideoCaptureDeviceChromeOS* self =
+ new VideoCaptureDeviceChromeOS(ui_task_runner, device_name);
+#else
VideoCaptureDeviceLinux* self = new VideoCaptureDeviceLinux(device_name);
+#endif
if (!self)
return NULL;
// Test opening the device driver. This is to make sure it is available.
@@ -271,7 +282,9 @@ VideoCaptureDeviceLinux::VideoCaptureDeviceLinux(const Name& device_name)
v4l2_thread_("V4L2Thread"),
buffer_pool_(NULL),
buffer_pool_size_(0),
- timeout_count_(0) {}
+ timeout_count_(0),
+ rotation_(0) {
+}
VideoCaptureDeviceLinux::~VideoCaptureDeviceLinux() {
state_ = kIdle;
@@ -313,6 +326,25 @@ void VideoCaptureDeviceLinux::StopAndDeAllocate() {
DeAllocateVideoBuffers();
}
+void VideoCaptureDeviceLinux::SetRotation(int rotation) {
+ if (v4l2_thread_.IsRunning()) {
+ v4l2_thread_.message_loop()->PostTask(
+ FROM_HERE,
+ base::Bind(&VideoCaptureDeviceLinux::SetRotationOnV4L2Thread,
+ base::Unretained(this), rotation));
+ } else {
+ // If the |v4l2_thread_| is not running, there's no race condition and
+ // |rotation_| can be set directly.
+ rotation_ = rotation;
+ }
+}
+
+void VideoCaptureDeviceLinux::SetRotationOnV4L2Thread(int rotation) {
+ DCHECK_EQ(v4l2_thread_.message_loop(), base::MessageLoop::current());
+ DCHECK(rotation >= 0 && rotation < 360 && rotation % 90 == 0);
+ rotation_ = rotation;
+}
+
void VideoCaptureDeviceLinux::OnAllocateAndStart(int width,
int height,
int frame_rate,
@@ -521,7 +553,7 @@ void VideoCaptureDeviceLinux::OnCaptureTask() {
static_cast<uint8*>(buffer_pool_[buffer.index].start),
buffer.bytesused,
capture_format_,
- 0,
+ rotation_,
base::TimeTicks::Now());
// Enqueue the buffer again.
diff --git a/media/video/capture/linux/video_capture_device_linux.h b/media/video/capture/linux/video_capture_device_linux.h
index 6a8dcee..bc8c38a 100644
--- a/media/video/capture/linux/video_capture_device_linux.h
+++ b/media/video/capture/linux/video_capture_device_linux.h
@@ -31,6 +31,12 @@ class VideoCaptureDeviceLinux : public VideoCaptureDevice {
virtual void StopAndDeAllocate() OVERRIDE;
+ protected:
+ void SetRotation(int rotation);
+
+ // Once |v4l2_thread_| is started, only called on that thread.
+ void SetRotationOnV4L2Thread(int rotation);
+
private:
enum InternalState {
kIdle, // The device driver is opened but camera is not in use.
@@ -68,6 +74,11 @@ class VideoCaptureDeviceLinux : public VideoCaptureDevice {
int timeout_count_;
VideoCaptureFormat capture_format_;
+ // Clockwise rotation in degrees. This value should be 0, 90, 180, or 270.
+ // This is only used on |v4l2_thread_| when it is running, or the constructor
+ // thread otherwise.
+ int rotation_;
+
DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceLinux);
};
diff --git a/media/video/capture/mac/video_capture_device_mac.mm b/media/video/capture/mac/video_capture_device_mac.mm
index bc3d541..354348a 100644
--- a/media/video/capture/mac/video_capture_device_mac.mm
+++ b/media/video/capture/mac/video_capture_device_mac.mm
@@ -150,7 +150,9 @@ const std::string VideoCaptureDevice::Name::GetModel() const {
return id_vendor + ":" + id_product;
}
-VideoCaptureDevice* VideoCaptureDevice::Create(const Name& device_name) {
+VideoCaptureDevice* VideoCaptureDevice::Create(
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
+ const Name& device_name) {
VideoCaptureDeviceMac* capture_device =
new VideoCaptureDeviceMac(device_name);
if (!capture_device->Init()) {
diff --git a/media/video/capture/video_capture_device.h b/media/video/capture/video_capture_device.h
index 8229716..7651d04 100644
--- a/media/video/capture/video_capture_device.h
+++ b/media/video/capture/video_capture_device.h
@@ -18,6 +18,7 @@
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/single_thread_task_runner.h"
#include "base/time/time.h"
#include "media/base/media_export.h"
#include "media/base/video_frame.h"
@@ -190,7 +191,9 @@ class MEDIA_EXPORT VideoCaptureDevice {
// Creates a VideoCaptureDevice object.
// Return NULL if the hardware is not available.
- static VideoCaptureDevice* Create(const Name& device_name);
+ static VideoCaptureDevice* Create(
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
+ const Name& device_name);
virtual ~VideoCaptureDevice();
// Gets the names of all video capture devices connected to this computer.
diff --git a/media/video/capture/video_capture_device_factory.cc b/media/video/capture/video_capture_device_factory.cc
index e63225d..22ad7b6 100644
--- a/media/video/capture/video_capture_device_factory.cc
+++ b/media/video/capture/video_capture_device_factory.cc
@@ -11,10 +11,11 @@ VideoCaptureDeviceFactory::VideoCaptureDeviceFactory() {
};
scoped_ptr<VideoCaptureDevice> VideoCaptureDeviceFactory::Create(
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
const VideoCaptureDevice::Name& device_name) {
DCHECK(thread_checker_.CalledOnValidThread());
return scoped_ptr<VideoCaptureDevice>(
- VideoCaptureDevice::Create(device_name));
+ VideoCaptureDevice::Create(ui_task_runner, device_name));
}
void VideoCaptureDeviceFactory::GetDeviceNames(
diff --git a/media/video/capture/video_capture_device_factory.h b/media/video/capture/video_capture_device_factory.h
index ab58ad6..de4f8ae 100644
--- a/media/video/capture/video_capture_device_factory.h
+++ b/media/video/capture/video_capture_device_factory.h
@@ -21,6 +21,7 @@ class MEDIA_EXPORT VideoCaptureDeviceFactory {
// Creates a VideoCaptureDevice object. Returns NULL if something goes wrong.
virtual scoped_ptr<VideoCaptureDevice> Create(
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
const VideoCaptureDevice::Name& device_name);
// Gets the names of all video capture devices connected to this computer.
diff --git a/media/video/capture/video_capture_device_unittest.cc b/media/video/capture/video_capture_device_unittest.cc
index f079a1f..b89be25 100644
--- a/media/video/capture/video_capture_device_unittest.cc
+++ b/media/video/capture/video_capture_device_unittest.cc
@@ -5,6 +5,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/memory/scoped_ptr.h"
+#include "base/message_loop/message_loop_proxy.h"
#include "base/run_loop.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/test_timeouts.h"
@@ -177,7 +178,9 @@ TEST_F(VideoCaptureDeviceTest, OpenInvalidDevice) {
#else
VideoCaptureDevice::Name device_name("jibberish", "jibberish");
#endif
- VideoCaptureDevice* device = VideoCaptureDevice::Create(device_name);
+ VideoCaptureDevice* device = VideoCaptureDevice::Create(
+ base::MessageLoopProxy::current(),
+ device_name);
EXPECT_TRUE(device == NULL);
}
@@ -189,7 +192,9 @@ TEST_F(VideoCaptureDeviceTest, CaptureVGA) {
}
scoped_ptr<VideoCaptureDevice> device(
- VideoCaptureDevice::Create(names_.front()));
+ VideoCaptureDevice::Create(
+ base::MessageLoopProxy::current(),
+ names_.front()));
ASSERT_TRUE(device);
DVLOG(1) << names_.front().id();
@@ -217,7 +222,9 @@ TEST_F(VideoCaptureDeviceTest, Capture720p) {
}
scoped_ptr<VideoCaptureDevice> device(
- VideoCaptureDevice::Create(names_.front()));
+ VideoCaptureDevice::Create(
+ base::MessageLoopProxy::current(),
+ names_.front()));
ASSERT_TRUE(device);
EXPECT_CALL(*client_, OnErr())
@@ -241,7 +248,8 @@ TEST_F(VideoCaptureDeviceTest, MAYBE_AllocateBadSize) {
return;
}
scoped_ptr<VideoCaptureDevice> device(
- VideoCaptureDevice::Create(names_.front()));
+ VideoCaptureDevice::Create(base::MessageLoopProxy::current(),
+ names_.front()));
ASSERT_TRUE(device);
EXPECT_CALL(*client_, OnErr())
@@ -270,7 +278,8 @@ TEST_F(VideoCaptureDeviceTest, ReAllocateCamera) {
for (int i = 0; i <= 5; i++) {
ResetWithNewClient();
scoped_ptr<VideoCaptureDevice> device(
- VideoCaptureDevice::Create(names_.front()));
+ VideoCaptureDevice::Create(base::MessageLoopProxy::current(),
+ names_.front()));
gfx::Size resolution;
if (i % 2) {
resolution = gfx::Size(640, 480);
@@ -295,7 +304,8 @@ TEST_F(VideoCaptureDeviceTest, ReAllocateCamera) {
ResetWithNewClient();
scoped_ptr<VideoCaptureDevice> device(
- VideoCaptureDevice::Create(names_.front()));
+ VideoCaptureDevice::Create(base::MessageLoopProxy::current(),
+ names_.front()));
device->AllocateAndStart(capture_params, client_.PassAs<Client>());
WaitForCapturedFrame();
@@ -312,7 +322,8 @@ TEST_F(VideoCaptureDeviceTest, DeAllocateCameraWhileRunning) {
return;
}
scoped_ptr<VideoCaptureDevice> device(
- VideoCaptureDevice::Create(names_.front()));
+ VideoCaptureDevice::Create(base::MessageLoopProxy::current(),
+ names_.front()));
ASSERT_TRUE(device);
EXPECT_CALL(*client_, OnErr())
@@ -340,7 +351,8 @@ TEST_F(VideoCaptureDeviceTest, FakeCapture) {
ASSERT_GT(static_cast<int>(names.size()), 0);
scoped_ptr<VideoCaptureDevice> device(
- video_capture_device_factory_->Create(names.front()));
+ video_capture_device_factory_->Create(base::MessageLoopProxy::current(),
+ names.front()));
ASSERT_TRUE(device);
EXPECT_CALL(*client_, OnErr())
@@ -367,7 +379,8 @@ TEST_F(VideoCaptureDeviceTest, MAYBE_CaptureMjpeg) {
DVLOG(1) << "No camera supports MJPEG format. Exiting test.";
return;
}
- scoped_ptr<VideoCaptureDevice> device(VideoCaptureDevice::Create(*name));
+ scoped_ptr<VideoCaptureDevice> device(
+ VideoCaptureDevice::Create(base::MessageLoopProxy::current(), *name));
ASSERT_TRUE(device);
EXPECT_CALL(*client_, OnErr())
@@ -410,7 +423,8 @@ TEST_F(VideoCaptureDeviceTest, FakeCaptureVariableResolution) {
ASSERT_GT(static_cast<int>(names.size()), 0);
scoped_ptr<VideoCaptureDevice> device(
- video_capture_device_factory_->Create(names.front()));
+ video_capture_device_factory_->Create(base::MessageLoopProxy::current(),
+ names.front()));
ASSERT_TRUE(device);
// Configure the FakeVideoCaptureDevice to use all its formats as roster.
diff --git a/media/video/capture/win/video_capture_device_win.cc b/media/video/capture/win/video_capture_device_win.cc
index e78c604..76c4c60 100644
--- a/media/video/capture/win/video_capture_device_win.cc
+++ b/media/video/capture/win/video_capture_device_win.cc
@@ -245,7 +245,9 @@ void VideoCaptureDevice::GetDeviceSupportedFormats(const Name& device,
}
// static
-VideoCaptureDevice* VideoCaptureDevice::Create(const Name& device_name) {
+VideoCaptureDevice* VideoCaptureDevice::Create(
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
+ const Name& device_name) {
VideoCaptureDevice* ret = NULL;
if (device_name.capture_api_type() == Name::MEDIA_FOUNDATION) {
DCHECK(VideoCaptureDeviceMFWin::PlatformSupported());