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:
@ -74,13 +74,23 @@ class CapturerTrackSource : public webrtc::VideoTrackSource {
|
|||||||
const size_t kWidth = 640;
|
const size_t kWidth = 640;
|
||||||
const size_t kHeight = 480;
|
const size_t kHeight = 480;
|
||||||
const size_t kFps = 30;
|
const size_t kFps = 30;
|
||||||
const size_t kDeviceIndex = 0;
|
std::unique_ptr<webrtc::test::VcmCapturer> capturer;
|
||||||
std::unique_ptr<webrtc::test::VcmCapturer> capturer = absl::WrapUnique(
|
std::unique_ptr<webrtc::VideoCaptureModule::DeviceInfo> info(
|
||||||
webrtc::test::VcmCapturer::Create(kWidth, kHeight, kFps, kDeviceIndex));
|
webrtc::VideoCaptureFactory::CreateDeviceInfo());
|
||||||
if (!capturer) {
|
if (!info) {
|
||||||
return nullptr;
|
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:
|
protected:
|
||||||
|
@ -39,6 +39,9 @@ bool VcmCapturer::Init(size_t width,
|
|||||||
}
|
}
|
||||||
|
|
||||||
vcm_ = webrtc::VideoCaptureFactory::Create(unique_name);
|
vcm_ = webrtc::VideoCaptureFactory::Create(unique_name);
|
||||||
|
if (!vcm_) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
vcm_->RegisterCaptureDataCallback(this);
|
vcm_->RegisterCaptureDataCallback(this);
|
||||||
|
|
||||||
device_info->GetCapability(vcm_->CurrentDeviceName(), 0, capability_);
|
device_info->GetCapability(vcm_->CurrentDeviceName(), 0, capability_);
|
||||||
|
Reference in New Issue
Block a user