Control new VideoEngine tests with gflags.
BUG=1703 R=mflodman@webrtc.org Review URL: https://webrtc-codereview.appspot.com/1497005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4092 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
191c596912
commit
771cdcbb09
68
webrtc/video_engine/test/common/flags.cc
Normal file
68
webrtc/video_engine/test/common/flags.cc
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/video_engine/test/common/flags.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "gflags/gflags.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
namespace flags {
|
||||
|
||||
bool flags_are_init = false;
|
||||
|
||||
void Init(int* argc, char ***argv) {
|
||||
assert(!flags_are_init);
|
||||
google::ParseCommandLineFlags(argc, argv, true);
|
||||
|
||||
// stuff;
|
||||
flags_are_init = true;
|
||||
}
|
||||
|
||||
DEFINE_int32(width, 640, "Video width.");
|
||||
size_t Width() {
|
||||
assert(flags_are_init);
|
||||
return static_cast<size_t>(FLAGS_width);
|
||||
}
|
||||
|
||||
DEFINE_int32(height, 480, "Video height.");
|
||||
size_t Height() {
|
||||
assert(flags_are_init);
|
||||
return static_cast<size_t>(FLAGS_height);
|
||||
}
|
||||
|
||||
DEFINE_int32(fps, 30, "Frames per second.");
|
||||
size_t Fps() {
|
||||
assert(flags_are_init);
|
||||
return static_cast<size_t>(FLAGS_fps);
|
||||
}
|
||||
|
||||
DEFINE_int32(min_bitrate, 50, "Minimum video bitrate.");
|
||||
size_t MinBitrate() {
|
||||
assert(flags_are_init);
|
||||
return static_cast<size_t>(FLAGS_min_bitrate);
|
||||
}
|
||||
|
||||
DEFINE_int32(start_bitrate, 300, "Video starting bitrate.");
|
||||
size_t StartBitrate() {
|
||||
assert(flags_are_init);
|
||||
return static_cast<size_t>(FLAGS_start_bitrate);
|
||||
}
|
||||
|
||||
DEFINE_int32(max_bitrate, 800, "Maximum video bitrate.");
|
||||
size_t MaxBitrate() {
|
||||
assert(flags_are_init);
|
||||
return static_cast<size_t>(FLAGS_max_bitrate);
|
||||
}
|
||||
} // flags
|
||||
} // test
|
||||
} // webrtc
|
32
webrtc/video_engine/test/common/flags.h
Normal file
32
webrtc/video_engine/test/common/flags.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_VIDEO_ENGINE_TEST_COMMON_FLAGS_H_
|
||||
#define WEBRTC_VIDEO_ENGINE_TEST_COMMON_FLAGS_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
namespace flags {
|
||||
|
||||
void Init(int* argc, char ***argv);
|
||||
|
||||
size_t Width();
|
||||
size_t Height();
|
||||
size_t Fps();
|
||||
size_t MinBitrate();
|
||||
size_t StartBitrate();
|
||||
size_t MaxBitrate();
|
||||
} // flags
|
||||
} // test
|
||||
} // webrtc
|
||||
|
||||
#endif // WEBRTC_VIDEO_ENGINE_TEST_COMMON_FLAGS_H_
|
@ -26,14 +26,12 @@ class NullCapturer : public VideoCapturer {
|
||||
VideoCapturer::VideoCapturer(newapi::VideoSendStreamInput* input)
|
||||
: input_(input) {}
|
||||
|
||||
VideoCapturer* VideoCapturer::Create(newapi::VideoSendStreamInput* input) {
|
||||
// TODO(pbos): These should be specified by command-line parameters.
|
||||
size_t width = 640;
|
||||
size_t height = 480;
|
||||
size_t target_fps = 30;
|
||||
VideoCapturer* VideoCapturer::Create(newapi::VideoSendStreamInput* input,
|
||||
size_t width,
|
||||
size_t height,
|
||||
size_t fps) {
|
||||
VcmCapturer* vcm_capturer = VcmCapturer::Create(input, width, height, fps);
|
||||
|
||||
VcmCapturer* vcm_capturer = VcmCapturer::Create(input, width, height,
|
||||
target_fps);
|
||||
if (vcm_capturer != NULL) {
|
||||
return vcm_capturer;
|
||||
}
|
||||
|
@ -20,7 +20,10 @@ namespace test {
|
||||
|
||||
class VideoCapturer {
|
||||
public:
|
||||
static VideoCapturer* Create(newapi::VideoSendStreamInput* input);
|
||||
static VideoCapturer* Create(newapi::VideoSendStreamInput* input,
|
||||
size_t width,
|
||||
size_t height,
|
||||
size_t fps);
|
||||
virtual ~VideoCapturer() {}
|
||||
|
||||
virtual void Start() = 0;
|
||||
|
@ -34,11 +34,9 @@ class NullRenderer : public VideoRenderer {
|
||||
int time_to_render_ms) OVERRIDE {}
|
||||
};
|
||||
|
||||
VideoRenderer* VideoRenderer::Create(const char* window_title) {
|
||||
// TODO(pbos): Get these from command-line parameters.
|
||||
int width = 640;
|
||||
int height = 480;
|
||||
|
||||
VideoRenderer* VideoRenderer::Create(const char* window_title,
|
||||
size_t width,
|
||||
size_t height) {
|
||||
#ifdef WEBRTC_TEST_XV
|
||||
XvRenderer* xv_renderer = XvRenderer::Create(window_title, width, height);
|
||||
if (xv_renderer != NULL) {
|
||||
|
@ -17,7 +17,9 @@ namespace test {
|
||||
|
||||
class VideoRenderer : public newapi::VideoRenderer {
|
||||
public:
|
||||
static VideoRenderer* Create(const char* window_title);
|
||||
static VideoRenderer* Create(const char* window_title,
|
||||
size_t width,
|
||||
size_t height);
|
||||
virtual ~VideoRenderer() {}
|
||||
};
|
||||
} // test
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "webrtc/typedefs.h"
|
||||
#include "webrtc/video_engine/new_include/video_engine.h"
|
||||
#include "webrtc/video_engine/test/common/direct_transport.h"
|
||||
#include "webrtc/video_engine/test/common/flags.h"
|
||||
#include "webrtc/video_engine/test/common/generate_ssrcs.h"
|
||||
#include "webrtc/video_engine/test/common/video_capturer.h"
|
||||
#include "webrtc/video_engine/test/common/video_renderer.h"
|
||||
@ -28,10 +29,10 @@ class LoopbackTest : public ::testing::Test {
|
||||
};
|
||||
|
||||
TEST_F(LoopbackTest, Test) {
|
||||
test::VideoRenderer* local_preview =
|
||||
test::VideoRenderer::Create("Local Preview");
|
||||
test::VideoRenderer* loopback_video =
|
||||
test::VideoRenderer::Create("Loopback Video");
|
||||
test::VideoRenderer* local_preview = test::VideoRenderer::Create(
|
||||
"Local Preview", test::flags::Width(), test::flags::Height());
|
||||
test::VideoRenderer* loopback_video = test::VideoRenderer::Create(
|
||||
"Loopback Video", test::flags::Width(), test::flags::Height());
|
||||
|
||||
newapi::VideoEngine* video_engine =
|
||||
newapi::VideoEngine::Create(webrtc::newapi::VideoEngineConfig());
|
||||
@ -48,19 +49,24 @@ TEST_F(LoopbackTest, Test) {
|
||||
|
||||
send_config.local_renderer = local_preview;
|
||||
|
||||
// TODO(pbos): Should be specified by command-line parameters. And not even
|
||||
// visible in the test. Break it out to some get-test-defaults
|
||||
// class
|
||||
send_config.codec.width = 640;
|
||||
send_config.codec.height = 480;
|
||||
send_config.codec.minBitrate = 1000;
|
||||
send_config.codec.startBitrate = 1500;
|
||||
send_config.codec.maxBitrate = 2000;
|
||||
// TODO(pbos): static_cast shouldn't be required after mflodman refactors the
|
||||
// VideoCodec struct.
|
||||
send_config.codec.width = static_cast<unsigned short>(test::flags::Width());
|
||||
send_config.codec.height = static_cast<unsigned short>(test::flags::Height());
|
||||
send_config.codec.minBitrate =
|
||||
static_cast<unsigned int>(test::flags::MinBitrate());
|
||||
send_config.codec.startBitrate =
|
||||
static_cast<unsigned int>(test::flags::StartBitrate());
|
||||
send_config.codec.maxBitrate =
|
||||
static_cast<unsigned int>(test::flags::MaxBitrate());
|
||||
|
||||
newapi::VideoSendStream* send_stream = call->CreateSendStream(send_config);
|
||||
|
||||
test::VideoCapturer* camera =
|
||||
test::VideoCapturer::Create(send_stream->Input());
|
||||
test::VideoCapturer::Create(send_stream->Input(),
|
||||
test::flags::Width(),
|
||||
test::flags::Height(),
|
||||
test::flags::Fps());
|
||||
|
||||
newapi::VideoReceiveStreamConfig receive_config;
|
||||
call->GetDefaultReceiveConfig(&receive_config);
|
||||
@ -98,6 +104,7 @@ TEST_F(LoopbackTest, Test) {
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
webrtc::test::flags::Init(&argc, &argv);
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
@ -27,6 +27,8 @@
|
||||
'target_name': 'video_tests_common',
|
||||
'type': 'static_library',
|
||||
'sources': [
|
||||
'common/flags.cc',
|
||||
'common/flags.h',
|
||||
'common/generate_ssrcs.h',
|
||||
'common/vcm_capturer.h',
|
||||
'common/vcm_capturer.cc',
|
||||
@ -95,6 +97,7 @@
|
||||
],
|
||||
},
|
||||
'dependencies': [
|
||||
'<(DEPTH)/third_party/google-gflags/google-gflags.gyp:google-gflags',
|
||||
'<(webrtc_root)/modules/modules.gyp:video_capture_module',
|
||||
'video_engine_core',
|
||||
],
|
||||
|
Loading…
x
Reference in New Issue
Block a user