Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1448)

Unified Diff: talk/session/media/channel_unittest.cc

Issue 1246913005: TransportController refactoring (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: minor cleanup Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: talk/session/media/channel_unittest.cc
diff --git a/talk/session/media/channel_unittest.cc b/talk/session/media/channel_unittest.cc
index 84a14e15519e753cf3c727392cee061325adb619..6031e63752a8a4d6f7044f63bed8b39c6d2365ff 100644
--- a/talk/session/media/channel_unittest.cc
+++ b/talk/session/media/channel_unittest.cc
@@ -33,7 +33,7 @@
#include "talk/media/base/rtpdump.h"
#include "talk/media/base/screencastid.h"
#include "talk/media/base/testutils.h"
-#include "webrtc/p2p/base/fakesession.h"
+#include "webrtc/p2p/base/faketransportcontroller.h"
#include "talk/session/media/channel.h"
#include "talk/session/media/typingmonitor.h"
#include "webrtc/base/fileutils.h"
@@ -128,8 +128,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
ChannelTest(const uint8* rtp_data, int rtp_len,
const uint8* rtcp_data, int rtcp_len)
- : session1_(true),
- session2_(false),
+ : transport_controller1_(true),
+ transport_controller2_(false),
media_channel1_(NULL),
media_channel2_(NULL),
rtp_packet_(reinterpret_cast<const char*>(rtp_data), rtp_len),
@@ -169,10 +169,12 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
int flags1, int flags2, rtc::Thread* thread) {
media_channel1_ = ch1;
media_channel2_ = ch2;
- channel1_.reset(CreateChannel(thread, &media_engine_, ch1, &session1_,
- (flags1 & RTCP) != 0));
- channel2_.reset(CreateChannel(thread, &media_engine_, ch2, &session2_,
- (flags2 & RTCP) != 0));
+ channel1_.reset(CreateChannel(
+ thread, &media_engine_, ch1, &transport_controller1_,
+ (flags1 & RTCP) != 0));
+ channel2_.reset(CreateChannel(
+ thread, &media_engine_, ch2, &transport_controller2_,
+ (flags2 & RTCP) != 0));
channel1_->SignalMediaMonitor.connect(
this, &ChannelTest<T>::OnMediaMonitor);
channel2_->SignalMediaMonitor.connect(
@@ -196,11 +198,11 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
if (flags1 & DTLS) {
identity1_.reset(rtc::SSLIdentity::Generate("session1"));
- session1_.set_ssl_identity(identity1_.get());
+ transport_controller1_.SetIdentity(identity1_.get()->GetReference());
}
if (flags2 & DTLS) {
identity2_.reset(rtc::SSLIdentity::Generate("session2"));
- session2_.set_ssl_identity(identity2_.get());
+ transport_controller2_.SetIdentity(identity2_.get()->GetReference());
}
// Add stream information (SSRC) to the local content but not to the remote
@@ -224,10 +226,12 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
media_channel1_ = ch1;
media_channel2_ = ch2;
- channel1_.reset(CreateChannel(thread, &media_engine_, ch1, &session1_,
- (flags & RTCP) != 0));
- channel2_.reset(CreateChannel(thread, &media_engine_, ch2, &session1_,
- (flags & RTCP) != 0));
+ channel1_.reset(CreateChannel(
+ thread, &media_engine_, ch1, &transport_controller1_,
+ (flags & RTCP) != 0));
+ channel2_.reset(CreateChannel(
+ thread, &media_engine_, ch2, &transport_controller1_,
+ (flags & RTCP) != 0));
channel1_->SignalMediaMonitor.connect(
this, &ChannelTest<T>::OnMediaMonitor);
channel2_->SignalMediaMonitor.connect(
@@ -253,13 +257,14 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
}
}
- typename T::Channel* CreateChannel(rtc::Thread* thread,
- cricket::MediaEngineInterface* engine,
- typename T::MediaChannel* ch,
- cricket::BaseSession* session,
- bool rtcp) {
+ typename T::Channel* CreateChannel(
+ rtc::Thread* thread,
+ cricket::MediaEngineInterface* engine,
+ typename T::MediaChannel* ch,
+ cricket::TransportController* transport_controller,
+ bool rtcp) {
typename T::Channel* channel = new typename T::Channel(
- thread, engine, ch, session, cricket::CN_AUDIO, rtcp);
+ thread, engine, ch, transport_controller, cricket::CN_AUDIO, rtcp);
if (!channel->Init()) {
delete channel;
channel = NULL;
@@ -275,7 +280,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
result = channel2_->SetRemoteContent(&remote_media_content1_,
CA_OFFER, NULL);
if (result) {
- session1_.Connect(&session2_);
+ transport_controller1_.Connect(&transport_controller2_);
result = channel2_->SetLocalContent(&local_media_content2_,
CA_ANSWER, NULL);
@@ -308,7 +313,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
channel2_->Enable(true);
result = channel1_->SetRemoteContent(&remote_media_content2_,
CA_PRANSWER, NULL);
- session1_.Connect(&session2_);
+ transport_controller1_.Connect(&transport_controller2_);
}
return result;
}
@@ -335,11 +340,12 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
return channel1_->RemoveRecvStream(id);
}
+ // Calling "_w" method here is ok since we only use one thread for this test
cricket::FakeTransport* GetTransport1() {
- return session1_.GetTransport(channel1_->content_name());
+ return transport_controller1_.GetTransport_w(channel1_->content_name());
}
cricket::FakeTransport* GetTransport2() {
- return session2_.GetTransport(channel2_->content_name());
+ return transport_controller2_.GetTransport_w(channel2_->content_name());
}
bool SendRtp1() {
@@ -823,7 +829,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, NULL));
EXPECT_EQ(1u, media_channel2_->recv_streams().size());
- session1_.Connect(&session2_);
+ transport_controller1_.Connect(&transport_controller2_);
// Channel 2 do not send anything.
typename T::Content content2;
@@ -886,7 +892,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
CA_ANSWER, NULL));
EXPECT_FALSE(media_channel2_->playout());
EXPECT_FALSE(media_channel2_->sending());
- session1_.Connect(&session2_);
+ transport_controller1_.Connect(&transport_controller2_);
EXPECT_TRUE(media_channel1_->playout());
EXPECT_FALSE(media_channel1_->sending());
EXPECT_FALSE(media_channel2_->playout());
@@ -944,7 +950,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, NULL));
EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_PRANSWER, NULL));
EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_PRANSWER, NULL));
- session1_.Connect(&session2_);
+ transport_controller1_.Connect(&transport_controller2_);
EXPECT_TRUE(media_channel1_->playout());
EXPECT_FALSE(media_channel1_->sending()); // remote InActive
@@ -1014,6 +1020,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
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());
EXPECT_TRUE(SendRtp1());
@@ -1029,6 +1037,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
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());
EXPECT_FALSE(SendRtcp1());
@@ -1042,6 +1052,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
CreateChannels(0, RTCP);
EXPECT_TRUE(SendInitiate());
EXPECT_TRUE(SendAccept());
+ ASSERT_TRUE(GetTransport1());
+ ASSERT_TRUE(GetTransport2());
EXPECT_EQ(1U, GetTransport1()->channels().size());
EXPECT_EQ(2U, GetTransport2()->channels().size());
EXPECT_FALSE(SendRtcp1());
@@ -1055,6 +1067,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
CreateChannels(RTCP, 0);
EXPECT_TRUE(SendInitiate());
EXPECT_TRUE(SendAccept());
+ ASSERT_TRUE(GetTransport1());
+ ASSERT_TRUE(GetTransport2());
EXPECT_EQ(2U, GetTransport1()->channels().size());
EXPECT_EQ(1U, GetTransport2()->channels().size());
EXPECT_FALSE(SendRtcp1());
@@ -1068,6 +1082,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
CreateChannels(RTCP, RTCP);
EXPECT_TRUE(SendInitiate());
EXPECT_TRUE(SendAccept());
+ ASSERT_TRUE(GetTransport1());
+ ASSERT_TRUE(GetTransport2());
EXPECT_EQ(2U, GetTransport1()->channels().size());
EXPECT_EQ(2U, GetTransport2()->channels().size());
EXPECT_TRUE(SendRtcp1());
@@ -1083,6 +1099,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
CreateChannels(RTCP | RTCP_MUX, RTCP);
EXPECT_TRUE(SendInitiate());
EXPECT_TRUE(SendAccept());
+ ASSERT_TRUE(GetTransport1());
+ ASSERT_TRUE(GetTransport2());
EXPECT_EQ(2U, GetTransport1()->channels().size());
EXPECT_EQ(2U, GetTransport2()->channels().size());
EXPECT_TRUE(SendRtcp1());
@@ -1097,6 +1115,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
void SendRtcpMuxToRtcpMux() {
CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
EXPECT_TRUE(SendInitiate());
+ ASSERT_TRUE(GetTransport1());
+ ASSERT_TRUE(GetTransport2());
EXPECT_EQ(2U, GetTransport1()->channels().size());
EXPECT_EQ(1U, GetTransport2()->channels().size());
EXPECT_TRUE(SendAccept());
@@ -1121,6 +1141,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
channel1_->ActivateRtcpMux();
EXPECT_TRUE(SendInitiate());
+ ASSERT_TRUE(GetTransport1());
+ ASSERT_TRUE(GetTransport2());
EXPECT_EQ(1U, GetTransport1()->channels().size());
EXPECT_EQ(1U, GetTransport2()->channels().size());
EXPECT_TRUE(SendAccept());
@@ -1144,6 +1166,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
channel2_->ActivateRtcpMux();
EXPECT_TRUE(SendInitiate());
+ ASSERT_TRUE(GetTransport1());
+ ASSERT_TRUE(GetTransport2());
EXPECT_EQ(2U, GetTransport1()->channels().size());
EXPECT_EQ(1U, GetTransport2()->channels().size());
EXPECT_TRUE(SendAccept());
@@ -1169,6 +1193,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
channel1_->ActivateRtcpMux();
channel2_->ActivateRtcpMux();
EXPECT_TRUE(SendInitiate());
+ ASSERT_TRUE(GetTransport1());
+ ASSERT_TRUE(GetTransport2());
EXPECT_EQ(1U, GetTransport1()->channels().size());
EXPECT_EQ(1U, GetTransport2()->channels().size());
EXPECT_TRUE(SendAccept());
@@ -1193,6 +1219,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
CreateChannels(RTCP | RTCP_MUX, RTCP);
channel1_->ActivateRtcpMux();
EXPECT_TRUE(SendInitiate());
+ ASSERT_TRUE(GetTransport1());
+ ASSERT_TRUE(GetTransport2());
EXPECT_EQ(1U, GetTransport1()->channels().size());
EXPECT_EQ(2U, GetTransport2()->channels().size());
EXPECT_FALSE(SendAccept());
@@ -1202,6 +1230,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
void SendEarlyRtcpMuxToRtcp() {
CreateChannels(RTCP | RTCP_MUX, RTCP);
EXPECT_TRUE(SendInitiate());
+ ASSERT_TRUE(GetTransport1());
+ ASSERT_TRUE(GetTransport2());
EXPECT_EQ(2U, GetTransport1()->channels().size());
EXPECT_EQ(2U, GetTransport2()->channels().size());
@@ -1232,6 +1262,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
void SendEarlyRtcpMuxToRtcpMux() {
CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
EXPECT_TRUE(SendInitiate());
+ ASSERT_TRUE(GetTransport1());
+ ASSERT_TRUE(GetTransport2());
EXPECT_EQ(2U, GetTransport1()->channels().size());
EXPECT_EQ(1U, GetTransport2()->channels().size());
@@ -1322,6 +1354,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
EXPECT_TRUE(SendProvisionalAnswer());
EXPECT_TRUE(channel1_->secure());
EXPECT_TRUE(channel2_->secure());
+ ASSERT_TRUE(GetTransport1());
+ ASSERT_TRUE(GetTransport2());
EXPECT_EQ(2U, GetTransport1()->channels().size());
EXPECT_EQ(2U, GetTransport2()->channels().size());
EXPECT_TRUE(SendCustomRtcp1(kSsrc1));
@@ -1405,6 +1439,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
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());
EXPECT_TRUE(SendRtp1());
@@ -1469,6 +1505,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
}
CreateChannels(flags, flags);
EXPECT_TRUE(SendInitiate());
+ ASSERT_TRUE(GetTransport1());
+ ASSERT_TRUE(GetTransport2());
EXPECT_EQ(2U, GetTransport1()->channels().size());
EXPECT_EQ(expected_channels, GetTransport2()->channels().size());
EXPECT_TRUE(SendAccept());
@@ -1657,6 +1695,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
CreateChannels(RTCP, RTCP);
EXPECT_TRUE(SendInitiate());
EXPECT_TRUE(SendAccept());
+ ASSERT_TRUE(GetTransport1());
+ ASSERT_TRUE(GetTransport2());
EXPECT_EQ(2U, GetTransport1()->channels().size());
EXPECT_EQ(2U, GetTransport2()->channels().size());
@@ -1777,8 +1817,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
}
protected:
- cricket::FakeSession session1_;
- cricket::FakeSession session2_;
+ cricket::FakeTransportController transport_controller1_;
+ cricket::FakeTransportController transport_controller2_;
cricket::FakeMediaEngine media_engine_;
// The media channels are owned by the voice channel objects below.
typename T::MediaChannel* media_channel1_;
@@ -1876,11 +1916,13 @@ class VoiceChannelTest
// override to add NULL parameter
template<>
cricket::VideoChannel* ChannelTest<VideoTraits>::CreateChannel(
- rtc::Thread* thread, cricket::MediaEngineInterface* engine,
- cricket::FakeVideoMediaChannel* ch, cricket::BaseSession* session,
+ rtc::Thread* thread,
+ cricket::MediaEngineInterface* engine,
+ cricket::FakeVideoMediaChannel* ch,
+ cricket::TransportController* transport_controller,
bool rtcp) {
cricket::VideoChannel* channel = new cricket::VideoChannel(
- thread, ch, session, cricket::CN_VIDEO, rtcp);
+ thread, ch, transport_controller, cricket::CN_VIDEO, rtcp);
if (!channel->Init()) {
delete channel;
channel = NULL;
@@ -2691,11 +2733,13 @@ class DataChannelTest
// Override to avoid engine channel parameter.
template<>
cricket::DataChannel* ChannelTest<DataTraits>::CreateChannel(
- rtc::Thread* thread, cricket::MediaEngineInterface* engine,
- cricket::FakeDataMediaChannel* ch, cricket::BaseSession* session,
+ rtc::Thread* thread,
+ cricket::MediaEngineInterface* engine,
+ cricket::FakeDataMediaChannel* ch,
+ cricket::TransportController* transport_controller,
bool rtcp) {
cricket::DataChannel* channel = new cricket::DataChannel(
- thread, ch, session, cricket::CN_DATA, rtcp);
+ thread, ch, transport_controller, cricket::CN_DATA, rtcp);
if (!channel->Init()) {
delete channel;
channel = NULL;

Powered by Google App Engine
This is Rietveld 408576698