Added VcmCapturer::Create loop to allow nonzero device index.

Bug: webrtc:10181
Change-Id: I29c701ed756416b63d377e9b9137fffeba1f7f2e
Reviewed-on: https://webrtc-review.googlesource.com/c/116440
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26437}
This commit is contained in:
Johnny Lee
2019-01-28 11:29:26 -05:00
committed by Commit Bot
parent f7f227c6f9
commit 7248b40344
2 changed files with 18 additions and 5 deletions

View File

@ -74,13 +74,23 @@ class CapturerTrackSource : public webrtc::VideoTrackSource {
const size_t kWidth = 640;
const size_t kHeight = 480;
const size_t kFps = 30;
const size_t kDeviceIndex = 0;
std::unique_ptr<webrtc::test::VcmCapturer> capturer = absl::WrapUnique(
webrtc::test::VcmCapturer::Create(kWidth, kHeight, kFps, kDeviceIndex));
if (!capturer) {
std::unique_ptr<webrtc::test::VcmCapturer> capturer;
std::unique_ptr<webrtc::VideoCaptureModule::DeviceInfo> info(
webrtc::VideoCaptureFactory::CreateDeviceInfo());
if (!info) {
return nullptr;
}
return new rtc::RefCountedObject<CapturerTrackSource>(std::move(capturer));
int num_devices = info->NumberOfDevices();
for (int i = 0; i < num_devices; ++i) {
capturer = absl::WrapUnique(
webrtc::test::VcmCapturer::Create(kWidth, kHeight, kFps, i));
if (capturer) {
return new
rtc::RefCountedObject<CapturerTrackSource>(std::move(capturer));
}
}
return nullptr;
}
protected: