Add FakeEncoder to VideoSendStream tests.
Breaks out config part of FakeEncoder from VideoSendStream tests to FakeEncoder. Also sets FakeEncoder as encoder for VideoSendStream tests. Anticipated speedup didn't happen as VP8 is still initialized by default when creating channels in the old API. This will be sped up when moving off the old API as VP8 won't be enabled by default. BUG=2312 R=stefan@webrtc.org Review URL: https://webrtc-codereview.appspot.com/2155004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4659 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
8fb89533af
commit
cb5118c14c
@ -13,6 +13,7 @@
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
FakeEncoder::FakeEncoder(Clock* clock)
|
||||
: clock_(clock),
|
||||
@ -24,6 +25,37 @@ FakeEncoder::FakeEncoder(Clock* clock)
|
||||
|
||||
FakeEncoder::~FakeEncoder() {}
|
||||
|
||||
void FakeEncoder::SetCodecStreamSettings(VideoCodec* codec,
|
||||
size_t num_streams) {
|
||||
assert(num_streams > 0);
|
||||
assert(num_streams <= kMaxSimulcastStreams);
|
||||
|
||||
static const SimulcastStream stream_settings[] = {
|
||||
{320, 180, 0, 150, 150, 50, codec->qpMax},
|
||||
{640, 360, 0, 500, 500, 150, codec->qpMax},
|
||||
{1280, 720, 0, 1200, 1200, 600, codec->qpMax}};
|
||||
// Add more streams to the settings above with reasonable values if required.
|
||||
assert(num_streams <= sizeof(stream_settings) / sizeof(stream_settings[0]));
|
||||
|
||||
codec->numberOfSimulcastStreams = static_cast<unsigned char>(num_streams);
|
||||
|
||||
unsigned int sum_of_max_bitrates = 0;
|
||||
for (size_t i = 0; i < num_streams; ++i) {
|
||||
codec->simulcastStream[i] = stream_settings[i];
|
||||
sum_of_max_bitrates += stream_settings[i].maxBitrate;
|
||||
}
|
||||
|
||||
size_t last_stream = num_streams - 1;
|
||||
codec->width = stream_settings[last_stream].width;
|
||||
codec->height = stream_settings[last_stream].height;
|
||||
// Start with the average for the middle stream's max/min settings.
|
||||
codec->startBitrate = (stream_settings[last_stream / 2].maxBitrate +
|
||||
stream_settings[last_stream / 2].minBitrate) /
|
||||
2;
|
||||
codec->minBitrate = stream_settings[0].minBitrate;
|
||||
codec->maxBitrate = sum_of_max_bitrates;
|
||||
}
|
||||
|
||||
int32_t FakeEncoder::InitEncode(const VideoCodec* config,
|
||||
int32_t number_of_cores,
|
||||
uint32_t max_payload_size) {
|
||||
@ -96,4 +128,5 @@ int32_t FakeEncoder::SetRates(uint32_t new_target_bitrate, uint32_t framerate) {
|
||||
target_bitrate_kbps_ = new_target_bitrate;
|
||||
return 0;
|
||||
}
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
|
@ -17,13 +17,15 @@
|
||||
#include "webrtc/system_wrappers/interface/clock.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
class FakeEncoder : public VideoEncoder {
|
||||
public:
|
||||
explicit FakeEncoder(Clock* clock);
|
||||
|
||||
virtual ~FakeEncoder();
|
||||
|
||||
static void SetCodecStreamSettings(VideoCodec* codec, size_t num_streams);
|
||||
|
||||
virtual int32_t InitEncode(const VideoCodec* config,
|
||||
int32_t number_of_cores,
|
||||
uint32_t max_payload_size) OVERRIDE;
|
||||
@ -51,6 +53,7 @@ class FakeEncoder : public VideoEncoder {
|
||||
int64_t last_encode_time_ms_;
|
||||
uint8_t encoded_buffer_[100000];
|
||||
};
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_VIDEO_ENGINE_TEST_COMMON_FAKE_ENCODER_H_
|
||||
|
@ -133,39 +133,6 @@ class RampUpTest : public ::testing::TestWithParam<bool> {
|
||||
reserved_ssrcs_.clear();
|
||||
}
|
||||
|
||||
static void SetCodecStreamSettings(VideoCodec* video_codec) {
|
||||
video_codec->width = 1280;
|
||||
video_codec->height = 720;
|
||||
video_codec->startBitrate = 300;
|
||||
video_codec->minBitrate = 50;
|
||||
video_codec->maxBitrate = 1800;
|
||||
|
||||
video_codec->numberOfSimulcastStreams = 3;
|
||||
video_codec->simulcastStream[0].width = 320;
|
||||
video_codec->simulcastStream[0].height = 180;
|
||||
video_codec->simulcastStream[0].numberOfTemporalLayers = 0;
|
||||
video_codec->simulcastStream[0].maxBitrate = 150;
|
||||
video_codec->simulcastStream[0].targetBitrate = 150;
|
||||
video_codec->simulcastStream[0].minBitrate = 50;
|
||||
video_codec->simulcastStream[0].qpMax = video_codec->qpMax;
|
||||
|
||||
video_codec->simulcastStream[1].width = 640;
|
||||
video_codec->simulcastStream[1].height = 360;
|
||||
video_codec->simulcastStream[1].numberOfTemporalLayers = 0;
|
||||
video_codec->simulcastStream[1].maxBitrate = 500;
|
||||
video_codec->simulcastStream[1].targetBitrate = 500;
|
||||
video_codec->simulcastStream[1].minBitrate = 150;
|
||||
video_codec->simulcastStream[1].qpMax = video_codec->qpMax;
|
||||
|
||||
video_codec->simulcastStream[2].width = 1280;
|
||||
video_codec->simulcastStream[2].height = 720;
|
||||
video_codec->simulcastStream[2].numberOfTemporalLayers = 0;
|
||||
video_codec->simulcastStream[2].maxBitrate = 1200;
|
||||
video_codec->simulcastStream[2].targetBitrate = 1200;
|
||||
video_codec->simulcastStream[2].minBitrate = 600;
|
||||
video_codec->simulcastStream[2].qpMax = video_codec->qpMax;
|
||||
}
|
||||
|
||||
protected:
|
||||
std::map<uint32_t, bool> reserved_ssrcs_;
|
||||
};
|
||||
@ -181,10 +148,10 @@ TEST_P(RampUpTest, RampUpWithPadding) {
|
||||
|
||||
receiver_transport.SetReceiver(call->Receiver());
|
||||
|
||||
FakeEncoder encoder(Clock::GetRealTimeClock());
|
||||
test::FakeEncoder encoder(Clock::GetRealTimeClock());
|
||||
send_config.encoder = &encoder;
|
||||
send_config.internal_source = false;
|
||||
SetCodecStreamSettings(&send_config.codec);
|
||||
test::FakeEncoder::SetCodecStreamSettings(&send_config.codec, 3);
|
||||
send_config.codec.plType = 100;
|
||||
send_config.pacing = GetParam();
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
|
||||
#include "webrtc/system_wrappers/interface/event_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
|
||||
#include "webrtc/video_engine/test/common/fake_encoder.h"
|
||||
#include "webrtc/video_engine/test/common/frame_generator.h"
|
||||
#include "webrtc/video_engine/test/common/frame_generator_capturer.h"
|
||||
#include "webrtc/video_engine/test/common/null_transport.h"
|
||||
@ -40,6 +41,8 @@ class SendTransportObserver : public test::NullTransport {
|
||||
};
|
||||
|
||||
class VideoSendStreamTest : public ::testing::Test {
|
||||
public:
|
||||
VideoSendStreamTest() : fake_encoder_(Clock::GetRealTimeClock()) {}
|
||||
protected:
|
||||
static const uint32_t kSendSsrc;
|
||||
void RunSendTest(VideoCall* call,
|
||||
@ -60,6 +63,17 @@ class VideoSendStreamTest : public ::testing::Test {
|
||||
send_stream->StopSend();
|
||||
call->DestroySendStream(send_stream);
|
||||
}
|
||||
|
||||
VideoSendStream::Config GetSendTestConfig(VideoCall* call) {
|
||||
VideoSendStream::Config config = call->GetDefaultSendConfig();
|
||||
config.encoder = &fake_encoder_;
|
||||
config.internal_source = false;
|
||||
test::FakeEncoder::SetCodecStreamSettings(&config.codec, 1);
|
||||
config.codec.plType = 100;
|
||||
return config;
|
||||
}
|
||||
|
||||
test::FakeEncoder fake_encoder_;
|
||||
};
|
||||
|
||||
const uint32_t VideoSendStreamTest::kSendSsrc = 0xC0FFEE;
|
||||
@ -84,7 +98,7 @@ TEST_F(VideoSendStreamTest, SendsSetSsrc) {
|
||||
VideoCall::Config call_config(&observer);
|
||||
scoped_ptr<VideoCall> call(VideoCall::Create(call_config));
|
||||
|
||||
VideoSendStream::Config send_config = call->GetDefaultSendConfig();
|
||||
VideoSendStream::Config send_config = GetSendTestConfig(call.get());
|
||||
send_config.rtp.ssrcs.push_back(kSendSsrc);
|
||||
|
||||
RunSendTest(call.get(), send_config, &observer);
|
||||
@ -117,7 +131,7 @@ TEST_F(VideoSendStreamTest, SupportsCName) {
|
||||
VideoCall::Config call_config(&observer);
|
||||
scoped_ptr<VideoCall> call(VideoCall::Create(call_config));
|
||||
|
||||
VideoSendStream::Config send_config = call->GetDefaultSendConfig();
|
||||
VideoSendStream::Config send_config = GetSendTestConfig(call.get());
|
||||
send_config.rtp.ssrcs.push_back(kSendSsrc);
|
||||
send_config.rtp.c_name = kCName;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user