Rename EngineTest to CallTest.
There's no real notion of VideoEngine left in these classes. They're end-to-end tests built on Call, so CallTest makes more sense. This also contains a modification to RtpRtcpObserver moving the responsibility of creating the event that signals when the observation is complete to RtpRtcpObserver. New tests are about to be introduced and this will reduce code duplication. BUG= R=stefan@webrtc.org Review URL: https://webrtc-codereview.appspot.com/2258005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4793 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
a03e34e9ab
commit
6917e19ad4
@ -28,21 +28,21 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
struct EngineTestParams {
|
||||
struct CallTestParams {
|
||||
size_t width, height;
|
||||
struct {
|
||||
unsigned int min, start, max;
|
||||
} bitrate;
|
||||
};
|
||||
|
||||
class EngineTest : public ::testing::TestWithParam<EngineTestParams> {
|
||||
class CallTest : public ::testing::TestWithParam<CallTestParams> {
|
||||
public:
|
||||
EngineTest()
|
||||
CallTest()
|
||||
: send_stream_(NULL),
|
||||
receive_stream_(NULL),
|
||||
fake_encoder_(Clock::GetRealTimeClock()) {}
|
||||
|
||||
~EngineTest() {
|
||||
~CallTest() {
|
||||
EXPECT_EQ(NULL, send_stream_);
|
||||
EXPECT_EQ(NULL, receive_stream_);
|
||||
}
|
||||
@ -135,13 +135,13 @@ class EngineTest : public ::testing::TestWithParam<EngineTestParams> {
|
||||
|
||||
// TODO(pbos): What are sane values here for bitrate? Are we missing any
|
||||
// important resolutions?
|
||||
EngineTestParams video_1080p = {1920, 1080, {300, 600, 800}};
|
||||
EngineTestParams video_720p = {1280, 720, {300, 600, 800}};
|
||||
EngineTestParams video_vga = {640, 480, {300, 600, 800}};
|
||||
EngineTestParams video_qvga = {320, 240, {300, 600, 800}};
|
||||
EngineTestParams video_4cif = {704, 576, {300, 600, 800}};
|
||||
EngineTestParams video_cif = {352, 288, {300, 600, 800}};
|
||||
EngineTestParams video_qcif = {176, 144, {300, 600, 800}};
|
||||
CallTestParams video_1080p = {1920, 1080, {300, 600, 800}};
|
||||
CallTestParams video_720p = {1280, 720, {300, 600, 800}};
|
||||
CallTestParams video_vga = {640, 480, {300, 600, 800}};
|
||||
CallTestParams video_qvga = {320, 240, {300, 600, 800}};
|
||||
CallTestParams video_4cif = {704, 576, {300, 600, 800}};
|
||||
CallTestParams video_cif = {352, 288, {300, 600, 800}};
|
||||
CallTestParams video_qcif = {176, 144, {300, 600, 800}};
|
||||
|
||||
class NackObserver : public test::RtpRtcpObserver {
|
||||
static const int kNumberOfNacksToObserve = 4;
|
||||
@ -150,17 +150,12 @@ class NackObserver : public test::RtpRtcpObserver {
|
||||
|
||||
public:
|
||||
NackObserver()
|
||||
: received_all_retransmissions_(EventWrapper::Create()),
|
||||
: test::RtpRtcpObserver(120 * 1000),
|
||||
rtp_parser_(RtpHeaderParser::Create()),
|
||||
drop_burst_count_(0),
|
||||
sent_rtp_packets_(0),
|
||||
nacks_left_(kNumberOfNacksToObserve) {}
|
||||
|
||||
EventTypeWrapper Wait() {
|
||||
// 2 minutes should be more than enough time for the test to finish.
|
||||
return received_all_retransmissions_->Wait(2 * 60 * 1000);
|
||||
}
|
||||
|
||||
private:
|
||||
virtual Action OnSendRtp(const uint8_t* packet, size_t length) OVERRIDE {
|
||||
EXPECT_FALSE(RtpHeaderParser::IsRtcp(packet, static_cast<int>(length)));
|
||||
@ -236,12 +231,10 @@ class NackObserver : public test::RtpRtcpObserver {
|
||||
// All packets retransmitted and no recent NACKs.
|
||||
if (dropped_packets_.size() == retransmitted_packets_.size() &&
|
||||
rtcp_without_nack_count_ >= kRequiredRtcpsWithoutNack) {
|
||||
received_all_retransmissions_->Set();
|
||||
observation_complete_->Set();
|
||||
}
|
||||
}
|
||||
|
||||
scoped_ptr<EventWrapper> received_all_retransmissions_;
|
||||
|
||||
scoped_ptr<RtpHeaderParser> rtp_parser_;
|
||||
std::set<uint16_t> dropped_packets_;
|
||||
std::set<uint16_t> retransmitted_packets_;
|
||||
@ -252,7 +245,7 @@ class NackObserver : public test::RtpRtcpObserver {
|
||||
static const int kRequiredRtcpsWithoutNack = 2;
|
||||
};
|
||||
|
||||
TEST_P(EngineTest, ReceivesAndRetransmitsNack) {
|
||||
TEST_P(CallTest, ReceivesAndRetransmitsNack) {
|
||||
NackObserver observer;
|
||||
|
||||
CreateCalls(observer.SendTransport(), observer.ReceiveTransport());
|
||||
@ -280,12 +273,12 @@ TEST_P(EngineTest, ReceivesAndRetransmitsNack) {
|
||||
DestroyStreams();
|
||||
}
|
||||
|
||||
class PliObserver : public test::RtpRtcpObserver {
|
||||
class PliObserver : public test::RtpRtcpObserver, public VideoRenderer {
|
||||
static const int kInverseDropProbability = 16;
|
||||
|
||||
public:
|
||||
PliObserver(bool nack_enabled)
|
||||
: renderer_(this),
|
||||
explicit PliObserver(bool nack_enabled)
|
||||
: test::RtpRtcpObserver(120 * 1000),
|
||||
rtp_header_parser_(RtpHeaderParser::Create()),
|
||||
nack_enabled_(nack_enabled),
|
||||
first_retransmitted_timestamp_(0),
|
||||
@ -332,29 +325,15 @@ class PliObserver : public test::RtpRtcpObserver {
|
||||
return SEND_PACKET;
|
||||
}
|
||||
|
||||
class ReceiverRenderer : public VideoRenderer {
|
||||
public:
|
||||
ReceiverRenderer(PliObserver* observer)
|
||||
: rendered_retransmission_(EventWrapper::Create()),
|
||||
observer_(observer) {}
|
||||
|
||||
virtual void RenderFrame(const I420VideoFrame& video_frame,
|
||||
int time_to_render_ms) {
|
||||
CriticalSectionScoped crit_(observer_->lock_.get());
|
||||
if (observer_->first_retransmitted_timestamp_ != 0 &&
|
||||
video_frame.timestamp() > observer_->first_retransmitted_timestamp_) {
|
||||
EXPECT_TRUE(observer_->received_pli_);
|
||||
rendered_retransmission_->Set();
|
||||
}
|
||||
observer_->rendered_frame_ = true;
|
||||
virtual void RenderFrame(const I420VideoFrame& video_frame,
|
||||
int time_to_render_ms) OVERRIDE {
|
||||
CriticalSectionScoped crit_(lock_.get());
|
||||
if (first_retransmitted_timestamp_ != 0 &&
|
||||
video_frame.timestamp() > first_retransmitted_timestamp_) {
|
||||
EXPECT_TRUE(received_pli_);
|
||||
observation_complete_->Set();
|
||||
}
|
||||
scoped_ptr<EventWrapper> rendered_retransmission_;
|
||||
PliObserver* observer_;
|
||||
} renderer_;
|
||||
|
||||
EventTypeWrapper Wait() {
|
||||
// 120 seconds should be plenty of time.
|
||||
return renderer_.rendered_retransmission_->Wait(2 * 60 * 1000);
|
||||
rendered_frame_ = true;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -368,7 +347,7 @@ class PliObserver : public test::RtpRtcpObserver {
|
||||
bool received_pli_;
|
||||
};
|
||||
|
||||
void EngineTest::ReceivesPliAndRecovers(int rtp_history_ms) {
|
||||
void CallTest::ReceivesPliAndRecovers(int rtp_history_ms) {
|
||||
PliObserver observer(rtp_history_ms > 0);
|
||||
|
||||
CreateCalls(observer.SendTransport(), observer.ReceiveTransport());
|
||||
@ -378,7 +357,7 @@ void EngineTest::ReceivesPliAndRecovers(int rtp_history_ms) {
|
||||
CreateTestConfigs();
|
||||
send_config_.rtp.nack.rtp_history_ms = rtp_history_ms;
|
||||
receive_config_.rtp.nack.rtp_history_ms = rtp_history_ms;
|
||||
receive_config_.renderer = &observer.renderer_;
|
||||
receive_config_.renderer = &observer;
|
||||
|
||||
CreateStreams();
|
||||
CreateFrameGenerator();
|
||||
@ -396,16 +375,16 @@ void EngineTest::ReceivesPliAndRecovers(int rtp_history_ms) {
|
||||
DestroyStreams();
|
||||
}
|
||||
|
||||
TEST_P(EngineTest, ReceivesPliAndRecoversWithNack) {
|
||||
TEST_P(CallTest, ReceivesPliAndRecoversWithNack) {
|
||||
ReceivesPliAndRecovers(1000);
|
||||
}
|
||||
|
||||
// TODO(pbos): Enable this when 2250 is resolved.
|
||||
TEST_P(EngineTest, DISABLED_ReceivesPliAndRecoversWithoutNack) {
|
||||
TEST_P(CallTest, DISABLED_ReceivesPliAndRecoversWithoutNack) {
|
||||
ReceivesPliAndRecovers(0);
|
||||
}
|
||||
|
||||
TEST_P(EngineTest, SurvivesIncomingRtpPacketsToDestroyedReceiveStream) {
|
||||
TEST_P(CallTest, SurvivesIncomingRtpPacketsToDestroyedReceiveStream) {
|
||||
class PacketInputObserver : public PacketReceiver {
|
||||
public:
|
||||
explicit PacketInputObserver(PacketReceiver* receiver)
|
||||
@ -457,5 +436,5 @@ TEST_P(EngineTest, SurvivesIncomingRtpPacketsToDestroyedReceiveStream) {
|
||||
receive_transport.StopSending();
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(EngineTest, EngineTest, ::testing::Values(video_vga));
|
||||
INSTANTIATE_TEST_CASE_P(CallTest, CallTest, ::testing::Values(video_vga));
|
||||
} // namespace webrtc
|
@ -40,17 +40,21 @@ class RtpRtcpObserver {
|
||||
receive_transport_.StopSending();
|
||||
}
|
||||
|
||||
EventTypeWrapper Wait() { return observation_complete_->Wait(timeout_ms_); }
|
||||
|
||||
protected:
|
||||
RtpRtcpObserver()
|
||||
RtpRtcpObserver(unsigned int event_timeout_ms)
|
||||
: lock_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
observation_complete_(EventWrapper::Create()),
|
||||
send_transport_(lock_.get(),
|
||||
this,
|
||||
&RtpRtcpObserver::OnSendRtp,
|
||||
&RtpRtcpObserver::OnSendRtcp),
|
||||
this,
|
||||
&RtpRtcpObserver::OnSendRtp,
|
||||
&RtpRtcpObserver::OnSendRtcp),
|
||||
receive_transport_(lock_.get(),
|
||||
this,
|
||||
&RtpRtcpObserver::OnReceiveRtp,
|
||||
&RtpRtcpObserver::OnReceiveRtcp) {}
|
||||
this,
|
||||
&RtpRtcpObserver::OnReceiveRtp,
|
||||
&RtpRtcpObserver::OnReceiveRtcp),
|
||||
timeout_ms_(event_timeout_ms) {}
|
||||
|
||||
enum Action {
|
||||
SEND_PACKET,
|
||||
@ -130,9 +134,11 @@ class RtpRtcpObserver {
|
||||
|
||||
protected:
|
||||
scoped_ptr<CriticalSectionWrapper> lock_;
|
||||
scoped_ptr<EventWrapper> observation_complete_;
|
||||
|
||||
private:
|
||||
PacketTransport send_transport_, receive_transport_;
|
||||
unsigned int timeout_ms_;
|
||||
};
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
|
@ -134,7 +134,7 @@
|
||||
'target_name': 'video_engine_tests',
|
||||
'type': 'executable',
|
||||
'sources': [
|
||||
'engine_tests.cc',
|
||||
'call_tests.cc',
|
||||
'full_stack.cc',
|
||||
'rampup_tests.cc',
|
||||
'send_stream_tests.cc',
|
||||
|
Loading…
Reference in New Issue
Block a user