VideoSendStream SSRC test.

Verifies that the VideoSendStream starts sending the set SSRC over RTP.

BUG=2227
R=stefan@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/2074004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4573 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
pbos@webrtc.org 2013-08-20 13:14:07 +00:00
parent e6dc38ea9b
commit 119a1ccdca
4 changed files with 138 additions and 0 deletions

View File

@ -0,0 +1,24 @@
/*
* 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/null_transport.h"
namespace webrtc {
namespace test {
bool NullTransport::SendRTP(const uint8_t* packet, size_t length) {
return true;
}
bool NullTransport::SendRTCP(const uint8_t* packet, size_t length) {
return true;
}
} // namespace test
} // namespace webrtc

View File

@ -0,0 +1,30 @@
/*
* 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_NULL_TRANSPORT_H_
#define WEBRTC_VIDEO_ENGINE_TEST_COMMON_NULL_TRANSPORT_H_
#include "webrtc/video_engine/new_include/transport.h"
namespace webrtc {
namespace newapi {
class PacketReceiver;
} // namespace newapi
namespace test {
class NullTransport : public newapi::Transport {
public:
virtual bool SendRTP(const uint8_t* packet, size_t length) OVERRIDE;
virtual bool SendRTCP(const uint8_t* packet, size_t length) OVERRIDE;
};
} // namespace test
} // namespace webrtc
#endif // WEBRTC_VIDEO_ENGINE_TEST_COMMON_NULL_TRANSPORT_H_

View File

@ -0,0 +1,81 @@
/*
* 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 "testing/gtest/include/gtest/gtest.h"
#include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h"
#include "webrtc/system_wrappers/interface/event_wrapper.h"
#include "webrtc/system_wrappers/interface/scoped_ptr.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"
#include "webrtc/video_engine/new_include/video_call.h"
#include "webrtc/video_engine/new_include/video_send_stream.h"
namespace webrtc {
class VideoSendStreamTest : public ::testing::Test {};
class SendTransportObserver : public test::NullTransport {
public:
explicit SendTransportObserver(unsigned long timeout_ms)
: rtp_header_parser_(RtpHeaderParser::Create()),
send_test_complete_(EventWrapper::Create()),
timeout_ms_(timeout_ms) {}
EventTypeWrapper Wait() {
return send_test_complete_->Wait(timeout_ms_);
}
protected:
scoped_ptr<RtpHeaderParser> rtp_header_parser_;
scoped_ptr<EventWrapper> send_test_complete_;
private:
unsigned long timeout_ms_;
};
TEST_F(VideoSendStreamTest, SendsSetSsrc) {
static const uint32_t kSendSsrc = 0xC0FFEE;
class SendSsrcObserver : public SendTransportObserver {
public:
SendSsrcObserver() : SendTransportObserver(30 * 1000) {}
virtual bool SendRTP(const uint8_t* packet, size_t length) OVERRIDE {
RTPHeader header;
EXPECT_TRUE(
rtp_header_parser_->Parse(packet, static_cast<int>(length), &header));
if (header.ssrc == kSendSsrc)
send_test_complete_->Set();
return true;
}
} observer;
newapi::VideoCall::Config call_config(&observer);
scoped_ptr<newapi::VideoCall> call(newapi::VideoCall::Create(call_config));
newapi::VideoSendStream::Config send_config = call->GetDefaultSendConfig();
send_config.rtp.ssrcs.push_back(kSendSsrc);
newapi::VideoSendStream* send_stream = call->CreateSendStream(send_config);
scoped_ptr<test::FrameGeneratorCapturer> frame_generator_capturer(
test::FrameGeneratorCapturer::Create(
send_stream->Input(),
test::FrameGenerator::Create(320, 240, Clock::GetRealTimeClock()),
30));
send_stream->StartSend();
frame_generator_capturer->Start();
EXPECT_EQ(kEventSignaled, observer.Wait());
frame_generator_capturer->Stop();
send_stream->StopSend();
call->DestroySendStream(send_stream);
}
} // namespace webrtc

View File

@ -32,6 +32,8 @@
'common/mac/video_renderer_mac.h',
'common/mac/video_renderer_mac.mm',
'common/null_platform_renderer.cc',
'common/null_transport.cc',
'common/null_transport.h',
'common/rtp_rtcp_observer.h',
'common/run_tests.cc',
'common/run_tests.h',
@ -144,6 +146,7 @@
'type': 'executable',
'sources': [
'engine_tests.cc',
'send_stream_tests.cc',
'test_main.cc',
],
'dependencies': [