Adding capture device selection capability for video_loopback. It will help to select any capture device to test the utility. In future we can add screen share as capture device.
BUG=webrtc:7719 Change-Id: Iddc66188341c0c90e96766dff671ac3863bf3f5d Reviewed-on: https://chromium-review.googlesource.com/517523 Commit-Queue: Peter Boström <pbos@webrtc.org> Reviewed-by: Peter Boström <pbos@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/master@{#18392}
This commit is contained in:
parent
3dcf0e93fa
commit
8e857d10fd
1
AUTHORS
1
AUTHORS
@ -46,6 +46,7 @@ Saul Kravitz <Saul.Kravitz@celera.com>
|
||||
Silviu Caragea <silviu.cpp@gmail.com>
|
||||
Stefan Gula <steweg@gmail.com>
|
||||
Steve Reid <sreid@sea-to-sky.net>
|
||||
Tarun Chawla <trnkumarchawla@gmail.com>
|
||||
Vladimir Beloborodov <VladimirTechMan@gmail.com>
|
||||
Vicken Simonian <vsimon@gmail.com>
|
||||
Victor Costan <costan@gmail.com>
|
||||
|
||||
@ -13,21 +13,23 @@
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/modules/video_capture/video_capture_factory.h"
|
||||
#include "webrtc/video_send_stream.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
VcmCapturer::VcmCapturer() : started_(false), sink_(nullptr), vcm_(nullptr) {}
|
||||
|
||||
bool VcmCapturer::Init(size_t width, size_t height, size_t target_fps) {
|
||||
bool VcmCapturer::Init(size_t width,
|
||||
size_t height,
|
||||
size_t target_fps,
|
||||
size_t capture_device_index) {
|
||||
std::unique_ptr<VideoCaptureModule::DeviceInfo> device_info(
|
||||
VideoCaptureFactory::CreateDeviceInfo());
|
||||
|
||||
char device_name[256];
|
||||
char unique_name[256];
|
||||
if (device_info->GetDeviceName(0, device_name, sizeof(device_name),
|
||||
unique_name, sizeof(unique_name)) !=
|
||||
0) {
|
||||
if (device_info->GetDeviceName(static_cast<uint32_t>(capture_device_index),
|
||||
device_name, sizeof(device_name), unique_name,
|
||||
sizeof(unique_name)) != 0) {
|
||||
Destroy();
|
||||
return false;
|
||||
}
|
||||
@ -54,9 +56,10 @@ bool VcmCapturer::Init(size_t width, size_t height, size_t target_fps) {
|
||||
|
||||
VcmCapturer* VcmCapturer::Create(size_t width,
|
||||
size_t height,
|
||||
size_t target_fps) {
|
||||
size_t target_fps,
|
||||
size_t capture_device_index) {
|
||||
std::unique_ptr<VcmCapturer> vcm_capturer(new VcmCapturer());
|
||||
if (!vcm_capturer->Init(width, height, target_fps)) {
|
||||
if (!vcm_capturer->Init(width, height, target_fps, capture_device_index)) {
|
||||
LOG(LS_WARNING) << "Failed to create VcmCapturer(w = " << width
|
||||
<< ", h = " << height << ", fps = " << target_fps << ")";
|
||||
return nullptr;
|
||||
|
||||
@ -26,7 +26,10 @@ class VcmCapturer
|
||||
: public VideoCapturer,
|
||||
public rtc::VideoSinkInterface<VideoFrame> {
|
||||
public:
|
||||
static VcmCapturer* Create(size_t width, size_t height, size_t target_fps);
|
||||
static VcmCapturer* Create(size_t width,
|
||||
size_t height,
|
||||
size_t target_fps,
|
||||
size_t capture_device_index);
|
||||
virtual ~VcmCapturer();
|
||||
|
||||
void Start() override;
|
||||
@ -39,7 +42,10 @@ class VcmCapturer
|
||||
|
||||
private:
|
||||
VcmCapturer();
|
||||
bool Init(size_t width, size_t height, size_t target_fps);
|
||||
bool Init(size_t width,
|
||||
size_t height,
|
||||
size_t target_fps,
|
||||
size_t capture_device_index);
|
||||
void Destroy();
|
||||
|
||||
rtc::CriticalSection crit_;
|
||||
|
||||
@ -35,6 +35,11 @@ int Fps() {
|
||||
return static_cast<int>(FLAGS_fps);
|
||||
}
|
||||
|
||||
DEFINE_int32(capture_device_index, 0, "Capture device to select");
|
||||
size_t GetCaptureDevice() {
|
||||
return static_cast<size_t>(FLAGS_capture_device_index);
|
||||
}
|
||||
|
||||
DEFINE_int32(min_bitrate, 50, "Call and stream min bitrate in kbps.");
|
||||
int MinBitrateKbps() {
|
||||
return static_cast<int>(FLAGS_min_bitrate);
|
||||
@ -259,7 +264,8 @@ void Loopback() {
|
||||
flags::FLAGS_use_ulpfec,
|
||||
flags::FLAGS_use_flexfec,
|
||||
flags::EncodedFramePath(),
|
||||
flags::Clip()};
|
||||
flags::Clip(),
|
||||
flags::GetCaptureDevice()};
|
||||
params.audio = {flags::FLAGS_audio, flags::FLAGS_audio_video_sync,
|
||||
flags::FLAGS_audio_dtx};
|
||||
params.screenshare.enabled = false;
|
||||
|
||||
@ -1566,7 +1566,8 @@ void VideoQualityTest::CreateCapturer() {
|
||||
} else {
|
||||
if (params_.video.clip_name.empty()) {
|
||||
video_capturer_.reset(test::VcmCapturer::Create(
|
||||
params_.video.width, params_.video.height, params_.video.fps));
|
||||
params_.video.width, params_.video.height, params_.video.fps,
|
||||
params_.video.capture_device_index));
|
||||
if (!video_capturer_) {
|
||||
// Failed to get actual camera, use chroma generator as backup.
|
||||
video_capturer_.reset(test::FrameGeneratorCapturer::Create(
|
||||
|
||||
@ -52,6 +52,7 @@ class VideoQualityTest : public test::CallTest {
|
||||
bool flexfec;
|
||||
std::string encoded_frame_base_path;
|
||||
std::string clip_name;
|
||||
size_t capture_device_index;
|
||||
} video;
|
||||
struct Audio {
|
||||
bool enabled;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user