| Index: talk/session/media/channel_unittest.cc
|
| diff --git a/talk/session/media/channel_unittest.cc b/talk/session/media/channel_unittest.cc
|
| index b861d0a4efee8f76f6ba21073a4bb368581e8231..99462db6180215253a3d253169145545c412c650 100644
|
| --- a/talk/session/media/channel_unittest.cc
|
| +++ b/talk/session/media/channel_unittest.cc
|
| @@ -33,7 +33,8 @@
|
| #include "talk/media/base/rtpdump.h"
|
| #include "talk/media/base/screencastid.h"
|
| #include "talk/media/base/testutils.h"
|
| -#include "webrtc/p2p/base/faketransportcontroller.h"
|
| +#include "talk/media/webrtc/fakewebrtccall.h"
|
| +#include "talk/app/webrtc/mediacontroller.h"
|
| #include "talk/session/media/channel.h"
|
| #include "webrtc/base/fileutils.h"
|
| #include "webrtc/base/gunit.h"
|
| @@ -44,6 +45,7 @@
|
| #include "webrtc/base/ssladapter.h"
|
| #include "webrtc/base/sslidentity.h"
|
| #include "webrtc/base/window.h"
|
| +#include "webrtc/p2p/base/faketransportcontroller.h"
|
|
|
| #define MAYBE_SKIP_TEST(feature) \
|
| if (!(rtc::SSLStreamAdapter::feature())) { \
|
| @@ -119,6 +121,13 @@ rtc::StreamInterface* Open(const std::string& path) {
|
| rtc::Pathname(path), "wb");
|
| }
|
|
|
| +class FakeCallFactory : public webrtc::CallFactory {
|
| + public:
|
| + webrtc::Call* CreateCall(const webrtc::Call::Config& config) override {
|
| + return new cricket::FakeCall(config);
|
| + }
|
| +};
|
| +
|
| // Base class for Voice/VideoChannel tests
|
| template<class T>
|
| class ChannelTest : public testing::Test, public sigslot::has_slots<> {
|
| @@ -134,6 +143,10 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
|
| : verify_playout_(verify_playout),
|
| transport_controller1_(cricket::ICEROLE_CONTROLLING),
|
| transport_controller2_(cricket::ICEROLE_CONTROLLED),
|
| + media_controller_(
|
| + webrtc::MediaControllerInterface::Create(new FakeCallFactory(),
|
| + rtc::Thread::Current(),
|
| + nullptr)),
|
| media_channel1_(NULL),
|
| media_channel2_(NULL),
|
| rtp_packet_(reinterpret_cast<const char*>(rtp_data), rtp_len),
|
| @@ -157,6 +170,10 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
|
| channel2_.reset(CreateChannel(thread, &media_engine_, ch2,
|
| &transport_controller2_,
|
| (flags2 & RTCP) != 0));
|
| + media_controller_->ConnectToSignalSentPacket_w(
|
| + channel1_->transport_channel());
|
| + media_controller_->ConnectToSignalSentPacket_w(
|
| + channel2_->transport_channel());
|
| channel1_->SignalMediaMonitor.connect(
|
| this, &ChannelTest<T>::OnMediaMonitor);
|
| channel2_->SignalMediaMonitor.connect(
|
| @@ -294,11 +311,21 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
|
|
|
| bool SendRtp1() {
|
| return media_channel1_->SendRtp(rtp_packet_.c_str(),
|
| - static_cast<int>(rtp_packet_.size()));
|
| + static_cast<int>(rtp_packet_.size()),
|
| + rtc::PacketOptions());
|
| + }
|
| + bool SendRtpWithOptions1(const rtc::PacketOptions& options) {
|
| + return media_channel1_->SendRtp(
|
| + rtp_packet_.c_str(), static_cast<int>(rtp_packet_.size()), options);
|
| }
|
| bool SendRtp2() {
|
| return media_channel2_->SendRtp(rtp_packet_.c_str(),
|
| - static_cast<int>(rtp_packet_.size()));
|
| + static_cast<int>(rtp_packet_.size()),
|
| + rtc::PacketOptions());
|
| + }
|
| + bool SendRtpWithOptions2(const rtc::PacketOptions& options) {
|
| + return media_channel2_->SendRtp(
|
| + rtp_packet_.c_str(), static_cast<int>(rtp_packet_.size()), options);
|
| }
|
| bool SendRtcp1() {
|
| return media_channel1_->SendRtcp(rtcp_packet_.c_str(),
|
| @@ -311,13 +338,13 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
|
| // Methods to send custom data.
|
| bool SendCustomRtp1(uint32_t ssrc, int sequence_number, int pl_type = -1) {
|
| std::string data(CreateRtpData(ssrc, sequence_number, pl_type));
|
| - return media_channel1_->SendRtp(data.c_str(),
|
| - static_cast<int>(data.size()));
|
| + return media_channel1_->SendRtp(data.c_str(), static_cast<int>(data.size()),
|
| + rtc::PacketOptions());
|
| }
|
| bool SendCustomRtp2(uint32_t ssrc, int sequence_number, int pl_type = -1) {
|
| std::string data(CreateRtpData(ssrc, sequence_number, pl_type));
|
| - return media_channel2_->SendRtp(data.c_str(),
|
| - static_cast<int>(data.size()));
|
| + return media_channel2_->SendRtp(data.c_str(), static_cast<int>(data.size()),
|
| + rtc::PacketOptions());
|
| }
|
| bool SendCustomRtcp1(uint32_t ssrc) {
|
| std::string data(CreateRtcpData(ssrc));
|
| @@ -957,7 +984,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
|
| public:
|
| LastWordMediaChannel() : T::MediaChannel(NULL, typename T::Options()) {}
|
| ~LastWordMediaChannel() {
|
| - T::MediaChannel::SendRtp(kPcmuFrame, sizeof(kPcmuFrame));
|
| + T::MediaChannel::SendRtp(kPcmuFrame, sizeof(kPcmuFrame),
|
| + rtc::PacketOptions());
|
| T::MediaChannel::SendRtcp(kRtcpReport, sizeof(kRtcpReport));
|
| }
|
| };
|
| @@ -986,6 +1014,32 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
|
| EXPECT_TRUE(CheckNoRtp2());
|
| }
|
|
|
| + // Send voice RTP data (with packet options) to the other side and ensure it
|
| + // gets there.
|
| + void SendRtpToRtpWithPacketIds() {
|
| + CreateChannels(0, 0);
|
| + EXPECT_TRUE(SendInitiate());
|
| + EXPECT_TRUE(SendAccept());
|
| + ASSERT_TRUE(GetTransport1());
|
| + ASSERT_TRUE(GetTransport2());
|
| + EXPECT_EQ(1U, GetTransport1()->channels().size());
|
| + EXPECT_EQ(1U, GetTransport2()->channels().size());
|
| + rtc::PacketOptions options1;
|
| + options1.packet_id = 10;
|
| + rtc::PacketOptions options2;
|
| + options2.packet_id = 30;
|
| + EXPECT_TRUE(SendRtpWithOptions1(options1));
|
| + cricket::FakeCall* call =
|
| + static_cast<cricket::FakeCall*>(media_controller_->call_w());
|
| + EXPECT_EQ(options1.packet_id, call->last_sent_packet().packet_id);
|
| + EXPECT_TRUE(SendRtpWithOptions2(options2));
|
| + EXPECT_EQ(options2.packet_id, call->last_sent_packet().packet_id);
|
| + EXPECT_TRUE(CheckRtp1());
|
| + EXPECT_TRUE(CheckRtp2());
|
| + EXPECT_TRUE(CheckNoRtp1());
|
| + EXPECT_TRUE(CheckNoRtp2());
|
| + }
|
| +
|
| // Check that RTCP is not transmitted if both sides don't support RTCP.
|
| void SendNoRtcpToNoRtcp() {
|
| CreateChannels(0, 0);
|
| @@ -1709,21 +1763,24 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
|
| &error_handler, &SrtpErrorHandler::OnSrtpError);
|
|
|
| // Testing failures in sending packets.
|
| - EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket)));
|
| + EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket),
|
| + rtc::PacketOptions()));
|
| // The first failure will trigger an error.
|
| EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500);
|
| EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_);
|
| error_handler.error_ = cricket::SrtpFilter::ERROR_NONE;
|
| error_handler.mode_ = cricket::SrtpFilter::UNPROTECT;
|
| // The next 250 ms failures will not trigger an error.
|
| - EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket)));
|
| + EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket),
|
| + rtc::PacketOptions()));
|
| // Wait for a while to ensure no message comes in.
|
| rtc::Thread::Current()->ProcessMessages(200);
|
| EXPECT_EQ(cricket::SrtpFilter::ERROR_NONE, error_handler.error_);
|
| EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_);
|
| // Wait for a little more - the error will be triggered again.
|
| rtc::Thread::Current()->ProcessMessages(200);
|
| - EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket)));
|
| + EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket),
|
| + rtc::PacketOptions()));
|
| EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500);
|
| EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_);
|
|
|
| @@ -1791,6 +1848,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
|
| cricket::FakeTransportController transport_controller1_;
|
| cricket::FakeTransportController transport_controller2_;
|
| cricket::FakeMediaEngine media_engine_;
|
| + rtc::scoped_ptr<webrtc::MediaControllerInterface> media_controller_;
|
| // The media channels are owned by the voice channel objects below.
|
| typename T::MediaChannel* media_channel1_;
|
| typename T::MediaChannel* media_channel2_;
|
| @@ -2536,6 +2594,10 @@ TEST_F(VideoChannelTest, TestOnReadyToSendWithRtcpMux) {
|
| Base::TestOnReadyToSendWithRtcpMux();
|
| }
|
|
|
| +TEST_F(VideoChannelTest, OnSentPacketIsCalled) {
|
| + Base::SendRtpToRtpWithPacketIds();
|
| +}
|
| +
|
| TEST_F(VideoChannelTest, TestApplyViewRequest) {
|
| CreateChannels(0, 0);
|
| cricket::StreamParams stream2;
|
|
|