diff --git a/examples/peerconnection/client/conductor.cc b/examples/peerconnection/client/conductor.cc index 03f820a60a..8fc07228d9 100644 --- a/examples/peerconnection/client/conductor.cc +++ b/examples/peerconnection/client/conductor.cc @@ -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 capturer = absl::WrapUnique( - webrtc::test::VcmCapturer::Create(kWidth, kHeight, kFps, kDeviceIndex)); - if (!capturer) { + std::unique_ptr capturer; + std::unique_ptr info( + webrtc::VideoCaptureFactory::CreateDeviceInfo()); + if (!info) { return nullptr; } - return new rtc::RefCountedObject(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(std::move(capturer)); + } + } + + return nullptr; } protected: diff --git a/test/vcm_capturer.cc b/test/vcm_capturer.cc index 353be0a317..3854e9fadd 100644 --- a/test/vcm_capturer.cc +++ b/test/vcm_capturer.cc @@ -39,6 +39,9 @@ bool VcmCapturer::Init(size_t width, } vcm_ = webrtc::VideoCaptureFactory::Create(unique_name); + if (!vcm_) { + return false; + } vcm_->RegisterCaptureDataCallback(this); device_info->GetCapability(vcm_->CurrentDeviceName(), 0, capability_);