You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

449 lines
17 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * libjingle
  3. * Copyright 2004 Google Inc.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright notice,
  9. * this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright notice,
  11. * this list of conditions and the following disclaimer in the documentation
  12. * and/or other materials provided with the distribution.
  13. * 3. The name of the author may not be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  17. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  18. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  19. * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  20. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  21. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  22. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  23. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  24. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  25. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. #include "talk/media/devices/devicemanager.h"
  28. #ifdef WIN32
  29. #include "talk/base/win32.h"
  30. #include <objbase.h>
  31. #endif
  32. #include <string>
  33. #include "talk/base/fileutils.h"
  34. #include "talk/base/gunit.h"
  35. #include "talk/base/logging.h"
  36. #include "talk/base/pathutils.h"
  37. #include "talk/base/scoped_ptr.h"
  38. #include "talk/base/stream.h"
  39. #include "talk/base/windowpickerfactory.h"
  40. #include "talk/media/base/fakevideocapturer.h"
  41. #include "talk/media/base/testutils.h"
  42. #include "talk/media/devices/filevideocapturer.h"
  43. #include "talk/media/devices/v4llookup.h"
  44. #ifdef LINUX
  45. // TODO(juberti): Figure out why this doesn't compile on Windows.
  46. #include "talk/base/fileutils_mock.h"
  47. #endif // LINUX
  48. using talk_base::Pathname;
  49. using talk_base::FileTimeType;
  50. using talk_base::scoped_ptr;
  51. using cricket::Device;
  52. using cricket::DeviceManager;
  53. using cricket::DeviceManagerFactory;
  54. using cricket::DeviceManagerInterface;
  55. const cricket::VideoFormat kVgaFormat(640, 480,
  56. cricket::VideoFormat::FpsToInterval(30),
  57. cricket::FOURCC_I420);
  58. const cricket::VideoFormat kHdFormat(1280, 720,
  59. cricket::VideoFormat::FpsToInterval(30),
  60. cricket::FOURCC_I420);
  61. class FakeVideoCapturerFactory : public cricket::VideoCapturerFactory {
  62. public:
  63. FakeVideoCapturerFactory() {}
  64. virtual ~FakeVideoCapturerFactory() {}
  65. virtual cricket::VideoCapturer* Create(const cricket::Device& device) {
  66. return new cricket::FakeVideoCapturer;
  67. }
  68. };
  69. class DeviceManagerTestFake : public testing::Test {
  70. public:
  71. virtual void SetUp() {
  72. dm_.reset(DeviceManagerFactory::Create());
  73. EXPECT_TRUE(dm_->Init());
  74. DeviceManager* device_manager = static_cast<DeviceManager*>(dm_.get());
  75. device_manager->set_device_video_capturer_factory(
  76. new FakeVideoCapturerFactory());
  77. }
  78. virtual void TearDown() {
  79. dm_->Terminate();
  80. }
  81. protected:
  82. scoped_ptr<DeviceManagerInterface> dm_;
  83. };
  84. // Test that we startup/shutdown properly.
  85. TEST(DeviceManagerTest, StartupShutdown) {
  86. scoped_ptr<DeviceManagerInterface> dm(DeviceManagerFactory::Create());
  87. EXPECT_TRUE(dm->Init());
  88. dm->Terminate();
  89. }
  90. // Test CoInitEx behavior
  91. #ifdef WIN32
  92. TEST(DeviceManagerTest, CoInitialize) {
  93. scoped_ptr<DeviceManagerInterface> dm(DeviceManagerFactory::Create());
  94. std::vector<Device> devices;
  95. // Ensure that calls to video device work if COM is not yet initialized.
  96. EXPECT_TRUE(dm->Init());
  97. EXPECT_TRUE(dm->GetVideoCaptureDevices(&devices));
  98. dm->Terminate();
  99. // Ensure that the ref count is correct.
  100. EXPECT_EQ(S_OK, CoInitializeEx(NULL, COINIT_MULTITHREADED));
  101. CoUninitialize();
  102. // Ensure that Init works in COINIT_APARTMENTTHREADED setting.
  103. EXPECT_EQ(S_OK, CoInitializeEx(NULL, COINIT_APARTMENTTHREADED));
  104. EXPECT_TRUE(dm->Init());
  105. dm->Terminate();
  106. CoUninitialize();
  107. // Ensure that the ref count is correct.
  108. EXPECT_EQ(S_OK, CoInitializeEx(NULL, COINIT_APARTMENTTHREADED));
  109. CoUninitialize();
  110. // Ensure that Init works in COINIT_MULTITHREADED setting.
  111. EXPECT_EQ(S_OK, CoInitializeEx(NULL, COINIT_MULTITHREADED));
  112. EXPECT_TRUE(dm->Init());
  113. dm->Terminate();
  114. CoUninitialize();
  115. // Ensure that the ref count is correct.
  116. EXPECT_EQ(S_OK, CoInitializeEx(NULL, COINIT_MULTITHREADED));
  117. CoUninitialize();
  118. }
  119. #endif
  120. // Test enumerating devices (although we may not find any).
  121. TEST(DeviceManagerTest, GetDevices) {
  122. scoped_ptr<DeviceManagerInterface> dm(DeviceManagerFactory::Create());
  123. std::vector<Device> audio_ins, audio_outs, video_ins;
  124. std::vector<cricket::Device> video_in_devs;
  125. cricket::Device def_video;
  126. EXPECT_TRUE(dm->Init());
  127. EXPECT_TRUE(dm->GetAudioInputDevices(&audio_ins));
  128. EXPECT_TRUE(dm->GetAudioOutputDevices(&audio_outs));
  129. EXPECT_TRUE(dm->GetVideoCaptureDevices(&video_ins));
  130. EXPECT_TRUE(dm->GetVideoCaptureDevices(&video_in_devs));
  131. EXPECT_EQ(video_ins.size(), video_in_devs.size());
  132. // If we have any video devices, we should be able to pick a default.
  133. EXPECT_TRUE(dm->GetVideoCaptureDevice(
  134. cricket::DeviceManagerInterface::kDefaultDeviceName, &def_video)
  135. != video_ins.empty());
  136. }
  137. // Test that we return correct ids for default and bogus devices.
  138. TEST(DeviceManagerTest, GetAudioDeviceIds) {
  139. scoped_ptr<DeviceManagerInterface> dm(DeviceManagerFactory::Create());
  140. Device device;
  141. EXPECT_TRUE(dm->Init());
  142. EXPECT_TRUE(dm->GetAudioInputDevice(
  143. cricket::DeviceManagerInterface::kDefaultDeviceName, &device));
  144. EXPECT_EQ("-1", device.id);
  145. EXPECT_TRUE(dm->GetAudioOutputDevice(
  146. cricket::DeviceManagerInterface::kDefaultDeviceName, &device));
  147. EXPECT_EQ("-1", device.id);
  148. EXPECT_FALSE(dm->GetAudioInputDevice("_NOT A REAL DEVICE_", &device));
  149. EXPECT_FALSE(dm->GetAudioOutputDevice("_NOT A REAL DEVICE_", &device));
  150. }
  151. // Test that we get the video capture device by name properly.
  152. TEST(DeviceManagerTest, GetVideoDeviceIds) {
  153. scoped_ptr<DeviceManagerInterface> dm(DeviceManagerFactory::Create());
  154. Device device;
  155. EXPECT_TRUE(dm->Init());
  156. EXPECT_FALSE(dm->GetVideoCaptureDevice("_NOT A REAL DEVICE_", &device));
  157. std::vector<Device> video_ins;
  158. EXPECT_TRUE(dm->GetVideoCaptureDevices(&video_ins));
  159. if (!video_ins.empty()) {
  160. // Get the default device with the parameter kDefaultDeviceName.
  161. EXPECT_TRUE(dm->GetVideoCaptureDevice(
  162. cricket::DeviceManagerInterface::kDefaultDeviceName, &device));
  163. // Get the first device with the parameter video_ins[0].name.
  164. EXPECT_TRUE(dm->GetVideoCaptureDevice(video_ins[0].name, &device));
  165. EXPECT_EQ(device.name, video_ins[0].name);
  166. EXPECT_EQ(device.id, video_ins[0].id);
  167. }
  168. }
  169. TEST(DeviceManagerTest, GetVideoDeviceIds_File) {
  170. scoped_ptr<DeviceManagerInterface> dm(DeviceManagerFactory::Create());
  171. EXPECT_TRUE(dm->Init());
  172. Device device;
  173. const std::string test_file =
  174. cricket::GetTestFilePath("captured-320x240-2s-48.frames");
  175. EXPECT_TRUE(dm->GetVideoCaptureDevice(test_file, &device));
  176. EXPECT_TRUE(cricket::FileVideoCapturer::IsFileVideoCapturerDevice(device));
  177. }
  178. TEST(DeviceManagerTest, VerifyDevicesListsAreCleared) {
  179. const std::string imaginary("_NOT A REAL DEVICE_");
  180. scoped_ptr<DeviceManagerInterface> dm(DeviceManagerFactory::Create());
  181. std::vector<Device> audio_ins, audio_outs, video_ins;
  182. audio_ins.push_back(Device(imaginary, imaginary));
  183. audio_outs.push_back(Device(imaginary, imaginary));
  184. video_ins.push_back(Device(imaginary, imaginary));
  185. EXPECT_TRUE(dm->Init());
  186. EXPECT_TRUE(dm->GetAudioInputDevices(&audio_ins));
  187. EXPECT_TRUE(dm->GetAudioOutputDevices(&audio_outs));
  188. EXPECT_TRUE(dm->GetVideoCaptureDevices(&video_ins));
  189. for (size_t i = 0; i < audio_ins.size(); ++i) {
  190. EXPECT_NE(imaginary, audio_ins[i].name);
  191. }
  192. for (size_t i = 0; i < audio_outs.size(); ++i) {
  193. EXPECT_NE(imaginary, audio_outs[i].name);
  194. }
  195. for (size_t i = 0; i < video_ins.size(); ++i) {
  196. EXPECT_NE(imaginary, video_ins[i].name);
  197. }
  198. }
  199. static bool CompareDeviceList(std::vector<Device>& devices,
  200. const char* const device_list[], int list_size) {
  201. if (list_size != static_cast<int>(devices.size())) {
  202. return false;
  203. }
  204. for (int i = 0; i < list_size; ++i) {
  205. if (devices[i].name.compare(device_list[i]) != 0) {
  206. return false;
  207. }
  208. }
  209. return true;
  210. }
  211. TEST(DeviceManagerTest, VerifyFilterDevices) {
  212. static const char* const kTotalDevicesName[] = {
  213. "Google Camera Adapters are tons of fun.",
  214. "device1",
  215. "device2",
  216. "device3",
  217. "device4",
  218. "device5",
  219. "Google Camera Adapter 0",
  220. "Google Camera Adapter 1",
  221. };
  222. static const char* const kFilteredDevicesName[] = {
  223. "device2",
  224. "device4",
  225. "Google Camera Adapter",
  226. NULL,
  227. };
  228. static const char* const kDevicesName[] = {
  229. "device1",
  230. "device3",
  231. "device5",
  232. };
  233. std::vector<Device> devices;
  234. for (int i = 0; i < ARRAY_SIZE(kTotalDevicesName); ++i) {
  235. devices.push_back(Device(kTotalDevicesName[i], i));
  236. }
  237. EXPECT_TRUE(CompareDeviceList(devices, kTotalDevicesName,
  238. ARRAY_SIZE(kTotalDevicesName)));
  239. // Return false if given NULL as the exclusion list.
  240. EXPECT_TRUE(DeviceManager::FilterDevices(&devices, NULL));
  241. // The devices should not change.
  242. EXPECT_TRUE(CompareDeviceList(devices, kTotalDevicesName,
  243. ARRAY_SIZE(kTotalDevicesName)));
  244. EXPECT_TRUE(DeviceManager::FilterDevices(&devices, kFilteredDevicesName));
  245. EXPECT_TRUE(CompareDeviceList(devices, kDevicesName,
  246. ARRAY_SIZE(kDevicesName)));
  247. }
  248. #ifdef LINUX
  249. class FakeV4LLookup : public cricket::V4LLookup {
  250. public:
  251. explicit FakeV4LLookup(std::vector<std::string> device_paths)
  252. : device_paths_(device_paths) {}
  253. protected:
  254. bool CheckIsV4L2Device(const std::string& device) {
  255. return std::find(device_paths_.begin(), device_paths_.end(), device)
  256. != device_paths_.end();
  257. }
  258. private:
  259. std::vector<std::string> device_paths_;
  260. };
  261. TEST(DeviceManagerTest, GetVideoCaptureDevices_K2_6) {
  262. std::vector<std::string> devices;
  263. devices.push_back("/dev/video0");
  264. devices.push_back("/dev/video5");
  265. cricket::V4LLookup::SetV4LLookup(new FakeV4LLookup(devices));
  266. std::vector<talk_base::FakeFileSystem::File> files;
  267. files.push_back(talk_base::FakeFileSystem::File("/dev/video0", ""));
  268. files.push_back(talk_base::FakeFileSystem::File("/dev/video5", ""));
  269. files.push_back(talk_base::FakeFileSystem::File(
  270. "/sys/class/video4linux/video0/name", "Video Device 1"));
  271. files.push_back(talk_base::FakeFileSystem::File(
  272. "/sys/class/video4linux/video1/model", "Bad Device"));
  273. files.push_back(
  274. talk_base::FakeFileSystem::File("/sys/class/video4linux/video5/model",
  275. "Video Device 2"));
  276. talk_base::FilesystemScope fs(new talk_base::FakeFileSystem(files));
  277. scoped_ptr<DeviceManagerInterface> dm(DeviceManagerFactory::Create());
  278. std::vector<Device> video_ins;
  279. EXPECT_TRUE(dm->Init());
  280. EXPECT_TRUE(dm->GetVideoCaptureDevices(&video_ins));
  281. EXPECT_EQ(2u, video_ins.size());
  282. EXPECT_EQ("Video Device 1", video_ins.at(0).name);
  283. EXPECT_EQ("Video Device 2", video_ins.at(1).name);
  284. }
  285. TEST(DeviceManagerTest, GetVideoCaptureDevices_K2_4) {
  286. std::vector<std::string> devices;
  287. devices.push_back("/dev/video0");
  288. devices.push_back("/dev/video5");
  289. cricket::V4LLookup::SetV4LLookup(new FakeV4LLookup(devices));
  290. std::vector<talk_base::FakeFileSystem::File> files;
  291. files.push_back(talk_base::FakeFileSystem::File("/dev/video0", ""));
  292. files.push_back(talk_base::FakeFileSystem::File("/dev/video5", ""));
  293. files.push_back(talk_base::FakeFileSystem::File(
  294. "/proc/video/dev/video0",
  295. "param1: value1\nname: Video Device 1\n param2: value2\n"));
  296. files.push_back(talk_base::FakeFileSystem::File(
  297. "/proc/video/dev/video1",
  298. "param1: value1\nname: Bad Device\n param2: value2\n"));
  299. files.push_back(talk_base::FakeFileSystem::File(
  300. "/proc/video/dev/video5",
  301. "param1: value1\nname: Video Device 2\n param2: value2\n"));
  302. talk_base::FilesystemScope fs(new talk_base::FakeFileSystem(files));
  303. scoped_ptr<DeviceManagerInterface> dm(DeviceManagerFactory::Create());
  304. std::vector<Device> video_ins;
  305. EXPECT_TRUE(dm->Init());
  306. EXPECT_TRUE(dm->GetVideoCaptureDevices(&video_ins));
  307. EXPECT_EQ(2u, video_ins.size());
  308. EXPECT_EQ("Video Device 1", video_ins.at(0).name);
  309. EXPECT_EQ("Video Device 2", video_ins.at(1).name);
  310. }
  311. TEST(DeviceManagerTest, GetVideoCaptureDevices_KUnknown) {
  312. std::vector<std::string> devices;
  313. devices.push_back("/dev/video0");
  314. devices.push_back("/dev/video5");
  315. cricket::V4LLookup::SetV4LLookup(new FakeV4LLookup(devices));
  316. std::vector<talk_base::FakeFileSystem::File> files;
  317. files.push_back(talk_base::FakeFileSystem::File("/dev/video0", ""));
  318. files.push_back(talk_base::FakeFileSystem::File("/dev/video1", ""));
  319. files.push_back(talk_base::FakeFileSystem::File("/dev/video5", ""));
  320. talk_base::FilesystemScope fs(new talk_base::FakeFileSystem(files));
  321. scoped_ptr<DeviceManagerInterface> dm(DeviceManagerFactory::Create());
  322. std::vector<Device> video_ins;
  323. EXPECT_TRUE(dm->Init());
  324. EXPECT_TRUE(dm->GetVideoCaptureDevices(&video_ins));
  325. EXPECT_EQ(2u, video_ins.size());
  326. EXPECT_EQ("/dev/video0", video_ins.at(0).name);
  327. EXPECT_EQ("/dev/video5", video_ins.at(1).name);
  328. }
  329. #endif // LINUX
  330. TEST(DeviceManagerTest, GetWindows) {
  331. if (!talk_base::WindowPickerFactory::IsSupported()) {
  332. LOG(LS_INFO) << "skipping test: window capturing is not supported with "
  333. << "current configuration.";
  334. return;
  335. }
  336. scoped_ptr<DeviceManagerInterface> dm(DeviceManagerFactory::Create());
  337. std::vector<talk_base::WindowDescription> descriptions;
  338. EXPECT_TRUE(dm->Init());
  339. if (!dm->GetWindows(&descriptions) || descriptions.empty()) {
  340. LOG(LS_INFO) << "skipping test: window capturing. Does not have any "
  341. << "windows to capture.";
  342. return;
  343. }
  344. scoped_ptr<cricket::VideoCapturer> capturer(dm->CreateWindowCapturer(
  345. descriptions.front().id()));
  346. EXPECT_FALSE(capturer.get() == NULL);
  347. // TODO(hellner): creating a window capturer and immediately deleting it
  348. // results in "Continuous Build and Test Mainline - Mac opt" failure (crash).
  349. // Remove the following line as soon as this has been resolved.
  350. talk_base::Thread::Current()->ProcessMessages(1);
  351. }
  352. TEST(DeviceManagerTest, GetDesktops) {
  353. if (!talk_base::WindowPickerFactory::IsSupported()) {
  354. LOG(LS_INFO) << "skipping test: desktop capturing is not supported with "
  355. << "current configuration.";
  356. return;
  357. }
  358. scoped_ptr<DeviceManagerInterface> dm(DeviceManagerFactory::Create());
  359. std::vector<talk_base::DesktopDescription> descriptions;
  360. EXPECT_TRUE(dm->Init());
  361. if (!dm->GetDesktops(&descriptions) || descriptions.empty()) {
  362. LOG(LS_INFO) << "skipping test: desktop capturing. Does not have any "
  363. << "desktops to capture.";
  364. return;
  365. }
  366. scoped_ptr<cricket::VideoCapturer> capturer(dm->CreateDesktopCapturer(
  367. descriptions.front().id()));
  368. EXPECT_FALSE(capturer.get() == NULL);
  369. }
  370. TEST_F(DeviceManagerTestFake, CaptureConstraintsWhitelisted) {
  371. const Device device("white", "white_id");
  372. dm_->SetVideoCaptureDeviceMaxFormat(device.name, kHdFormat);
  373. scoped_ptr<cricket::VideoCapturer> capturer(
  374. dm_->CreateVideoCapturer(device));
  375. cricket::VideoFormat best_format;
  376. capturer->set_enable_camera_list(true);
  377. EXPECT_TRUE(capturer->GetBestCaptureFormat(kHdFormat, &best_format));
  378. EXPECT_EQ(kHdFormat, best_format);
  379. }
  380. TEST_F(DeviceManagerTestFake, CaptureConstraintsNotWhitelisted) {
  381. const Device device("regular", "regular_id");
  382. scoped_ptr<cricket::VideoCapturer> capturer(
  383. dm_->CreateVideoCapturer(device));
  384. cricket::VideoFormat best_format;
  385. capturer->set_enable_camera_list(true);
  386. EXPECT_TRUE(capturer->GetBestCaptureFormat(kHdFormat, &best_format));
  387. EXPECT_EQ(kVgaFormat, best_format);
  388. }
  389. TEST_F(DeviceManagerTestFake, CaptureConstraintsUnWhitelisted) {
  390. const Device device("un_white", "un_white_id");
  391. dm_->SetVideoCaptureDeviceMaxFormat(device.name, kHdFormat);
  392. dm_->ClearVideoCaptureDeviceMaxFormat(device.name);
  393. scoped_ptr<cricket::VideoCapturer> capturer(
  394. dm_->CreateVideoCapturer(device));
  395. cricket::VideoFormat best_format;
  396. capturer->set_enable_camera_list(true);
  397. EXPECT_TRUE(capturer->GetBestCaptureFormat(kHdFormat, &best_format));
  398. EXPECT_EQ(kVgaFormat, best_format);
  399. }
  400. TEST_F(DeviceManagerTestFake, CaptureConstraintsWildcard) {
  401. const Device device("any_device", "any_device");
  402. dm_->SetVideoCaptureDeviceMaxFormat("*", kHdFormat);
  403. scoped_ptr<cricket::VideoCapturer> capturer(
  404. dm_->CreateVideoCapturer(device));
  405. cricket::VideoFormat best_format;
  406. capturer->set_enable_camera_list(true);
  407. EXPECT_TRUE(capturer->GetBestCaptureFormat(kHdFormat, &best_format));
  408. EXPECT_EQ(kHdFormat, best_format);
  409. }