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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2009 Google Inc. 3 * Copyright 2009 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 15 matching lines...) Expand all
26 */ 26 */
27 27
28 #include "talk/media/base/fakemediaengine.h" 28 #include "talk/media/base/fakemediaengine.h"
29 #include "talk/media/base/fakertp.h" 29 #include "talk/media/base/fakertp.h"
30 #include "talk/media/base/fakescreencapturerfactory.h" 30 #include "talk/media/base/fakescreencapturerfactory.h"
31 #include "talk/media/base/fakevideocapturer.h" 31 #include "talk/media/base/fakevideocapturer.h"
32 #include "talk/media/base/mediachannel.h" 32 #include "talk/media/base/mediachannel.h"
33 #include "talk/media/base/rtpdump.h" 33 #include "talk/media/base/rtpdump.h"
34 #include "talk/media/base/screencastid.h" 34 #include "talk/media/base/screencastid.h"
35 #include "talk/media/base/testutils.h" 35 #include "talk/media/base/testutils.h"
36 #include "webrtc/p2p/base/fakesession.h" 36 #include "webrtc/p2p/base/faketransportcontroller.h"
37 #include "talk/session/media/channel.h" 37 #include "talk/session/media/channel.h"
38 #include "talk/session/media/typingmonitor.h" 38 #include "talk/session/media/typingmonitor.h"
39 #include "webrtc/base/fileutils.h" 39 #include "webrtc/base/fileutils.h"
40 #include "webrtc/base/gunit.h" 40 #include "webrtc/base/gunit.h"
41 #include "webrtc/base/helpers.h" 41 #include "webrtc/base/helpers.h"
42 #include "webrtc/base/logging.h" 42 #include "webrtc/base/logging.h"
43 #include "webrtc/base/pathutils.h" 43 #include "webrtc/base/pathutils.h"
44 #include "webrtc/base/signalthread.h" 44 #include "webrtc/base/signalthread.h"
45 #include "webrtc/base/ssladapter.h" 45 #include "webrtc/base/ssladapter.h"
46 #include "webrtc/base/sslidentity.h" 46 #include "webrtc/base/sslidentity.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 121
122 // Base class for Voice/VideoChannel tests 122 // Base class for Voice/VideoChannel tests
123 template<class T> 123 template<class T>
124 class ChannelTest : public testing::Test, public sigslot::has_slots<> { 124 class ChannelTest : public testing::Test, public sigslot::has_slots<> {
125 public: 125 public:
126 enum Flags { RTCP = 0x1, RTCP_MUX = 0x2, SECURE = 0x4, SSRC_MUX = 0x8, 126 enum Flags { RTCP = 0x1, RTCP_MUX = 0x2, SECURE = 0x4, SSRC_MUX = 0x8,
127 DTLS = 0x10 }; 127 DTLS = 0x10 };
128 128
129 ChannelTest(const uint8* rtp_data, int rtp_len, 129 ChannelTest(const uint8* rtp_data, int rtp_len,
130 const uint8* rtcp_data, int rtcp_len) 130 const uint8* rtcp_data, int rtcp_len)
131 : session1_(true), 131 : transport_controller1_(true),
132 session2_(false), 132 transport_controller2_(false),
133 media_channel1_(NULL), 133 media_channel1_(NULL),
134 media_channel2_(NULL), 134 media_channel2_(NULL),
135 rtp_packet_(reinterpret_cast<const char*>(rtp_data), rtp_len), 135 rtp_packet_(reinterpret_cast<const char*>(rtp_data), rtp_len),
136 rtcp_packet_(reinterpret_cast<const char*>(rtcp_data), rtcp_len), 136 rtcp_packet_(reinterpret_cast<const char*>(rtcp_data), rtcp_len),
137 media_info_callbacks1_(), 137 media_info_callbacks1_(),
138 media_info_callbacks2_(), 138 media_info_callbacks2_(),
139 mute_callback_recved_(false), 139 mute_callback_recved_(false),
140 mute_callback_value_(false), 140 mute_callback_value_(false),
141 ssrc_(0), 141 ssrc_(0),
142 error_(T::MediaChannel::ERROR_NONE) { 142 error_(T::MediaChannel::ERROR_NONE) {
(...skipping 19 matching lines...) Expand all
162 rtc::Thread* thread) { 162 rtc::Thread* thread) {
163 CreateChannels(new typename T::MediaChannel(NULL), 163 CreateChannels(new typename T::MediaChannel(NULL),
164 new typename T::MediaChannel(NULL), 164 new typename T::MediaChannel(NULL),
165 flags, thread); 165 flags, thread);
166 } 166 }
167 void CreateChannels( 167 void CreateChannels(
168 typename T::MediaChannel* ch1, typename T::MediaChannel* ch2, 168 typename T::MediaChannel* ch1, typename T::MediaChannel* ch2,
169 int flags1, int flags2, rtc::Thread* thread) { 169 int flags1, int flags2, rtc::Thread* thread) {
170 media_channel1_ = ch1; 170 media_channel1_ = ch1;
171 media_channel2_ = ch2; 171 media_channel2_ = ch2;
172 channel1_.reset(CreateChannel(thread, &media_engine_, ch1, &session1_, 172 channel1_.reset(CreateChannel(
173 (flags1 & RTCP) != 0)); 173 thread, &media_engine_, ch1, &transport_controller1_,
174 channel2_.reset(CreateChannel(thread, &media_engine_, ch2, &session2_, 174 (flags1 & RTCP) != 0));
175 (flags2 & RTCP) != 0)); 175 channel2_.reset(CreateChannel(
176 thread, &media_engine_, ch2, &transport_controller2_,
177 (flags2 & RTCP) != 0));
176 channel1_->SignalMediaMonitor.connect( 178 channel1_->SignalMediaMonitor.connect(
177 this, &ChannelTest<T>::OnMediaMonitor); 179 this, &ChannelTest<T>::OnMediaMonitor);
178 channel2_->SignalMediaMonitor.connect( 180 channel2_->SignalMediaMonitor.connect(
179 this, &ChannelTest<T>::OnMediaMonitor); 181 this, &ChannelTest<T>::OnMediaMonitor);
180 channel1_->SignalMediaError.connect( 182 channel1_->SignalMediaError.connect(
181 this, &ChannelTest<T>::OnMediaChannelError); 183 this, &ChannelTest<T>::OnMediaChannelError);
182 channel2_->SignalMediaError.connect( 184 channel2_->SignalMediaError.connect(
183 this, &ChannelTest<T>::OnMediaChannelError); 185 this, &ChannelTest<T>::OnMediaChannelError);
184 channel1_->SignalAutoMuted.connect( 186 channel1_->SignalAutoMuted.connect(
185 this, &ChannelTest<T>::OnMediaMuted); 187 this, &ChannelTest<T>::OnMediaMuted);
186 if ((flags1 & DTLS) && (flags2 & DTLS)) { 188 if ((flags1 & DTLS) && (flags2 & DTLS)) {
187 flags1 = (flags1 & ~SECURE); 189 flags1 = (flags1 & ~SECURE);
188 flags2 = (flags2 & ~SECURE); 190 flags2 = (flags2 & ~SECURE);
189 } 191 }
190 CreateContent(flags1, kPcmuCodec, kH264Codec, 192 CreateContent(flags1, kPcmuCodec, kH264Codec,
191 &local_media_content1_); 193 &local_media_content1_);
192 CreateContent(flags2, kPcmuCodec, kH264Codec, 194 CreateContent(flags2, kPcmuCodec, kH264Codec,
193 &local_media_content2_); 195 &local_media_content2_);
194 CopyContent(local_media_content1_, &remote_media_content1_); 196 CopyContent(local_media_content1_, &remote_media_content1_);
195 CopyContent(local_media_content2_, &remote_media_content2_); 197 CopyContent(local_media_content2_, &remote_media_content2_);
196 198
197 if (flags1 & DTLS) { 199 if (flags1 & DTLS) {
198 identity1_.reset(rtc::SSLIdentity::Generate("session1")); 200 identity1_.reset(rtc::SSLIdentity::Generate("session1"));
199 session1_.set_ssl_identity(identity1_.get()); 201 transport_controller1_.SetIdentity(identity1_.get()->GetReference());
200 } 202 }
201 if (flags2 & DTLS) { 203 if (flags2 & DTLS) {
202 identity2_.reset(rtc::SSLIdentity::Generate("session2")); 204 identity2_.reset(rtc::SSLIdentity::Generate("session2"));
203 session2_.set_ssl_identity(identity2_.get()); 205 transport_controller2_.SetIdentity(identity2_.get()->GetReference());
204 } 206 }
205 207
206 // Add stream information (SSRC) to the local content but not to the remote 208 // Add stream information (SSRC) to the local content but not to the remote
207 // content. This means that we per default know the SSRC of what we send but 209 // content. This means that we per default know the SSRC of what we send but
208 // not what we receive. 210 // not what we receive.
209 AddLegacyStreamInContent(kSsrc1, flags1, &local_media_content1_); 211 AddLegacyStreamInContent(kSsrc1, flags1, &local_media_content1_);
210 AddLegacyStreamInContent(kSsrc2, flags2, &local_media_content2_); 212 AddLegacyStreamInContent(kSsrc2, flags2, &local_media_content2_);
211 213
212 // If SSRC_MUX is used we also need to know the SSRC of the incoming stream. 214 // If SSRC_MUX is used we also need to know the SSRC of the incoming stream.
213 if (flags1 & SSRC_MUX) { 215 if (flags1 & SSRC_MUX) {
214 AddLegacyStreamInContent(kSsrc1, flags1, &remote_media_content1_); 216 AddLegacyStreamInContent(kSsrc1, flags1, &remote_media_content1_);
215 } 217 }
216 if (flags2 & SSRC_MUX) { 218 if (flags2 & SSRC_MUX) {
217 AddLegacyStreamInContent(kSsrc2, flags2, &remote_media_content2_); 219 AddLegacyStreamInContent(kSsrc2, flags2, &remote_media_content2_);
218 } 220 }
219 } 221 }
220 222
221 void CreateChannels( 223 void CreateChannels(
222 typename T::MediaChannel* ch1, typename T::MediaChannel* ch2, 224 typename T::MediaChannel* ch1, typename T::MediaChannel* ch2,
223 int flags, rtc::Thread* thread) { 225 int flags, rtc::Thread* thread) {
224 media_channel1_ = ch1; 226 media_channel1_ = ch1;
225 media_channel2_ = ch2; 227 media_channel2_ = ch2;
226 228
227 channel1_.reset(CreateChannel(thread, &media_engine_, ch1, &session1_, 229 channel1_.reset(CreateChannel(
228 (flags & RTCP) != 0)); 230 thread, &media_engine_, ch1, &transport_controller1_,
229 channel2_.reset(CreateChannel(thread, &media_engine_, ch2, &session1_, 231 (flags & RTCP) != 0));
230 (flags & RTCP) != 0)); 232 channel2_.reset(CreateChannel(
233 thread, &media_engine_, ch2, &transport_controller1_,
234 (flags & RTCP) != 0));
231 channel1_->SignalMediaMonitor.connect( 235 channel1_->SignalMediaMonitor.connect(
232 this, &ChannelTest<T>::OnMediaMonitor); 236 this, &ChannelTest<T>::OnMediaMonitor);
233 channel2_->SignalMediaMonitor.connect( 237 channel2_->SignalMediaMonitor.connect(
234 this, &ChannelTest<T>::OnMediaMonitor); 238 this, &ChannelTest<T>::OnMediaMonitor);
235 channel2_->SignalMediaError.connect( 239 channel2_->SignalMediaError.connect(
236 this, &ChannelTest<T>::OnMediaChannelError); 240 this, &ChannelTest<T>::OnMediaChannelError);
237 CreateContent(flags, kPcmuCodec, kH264Codec, 241 CreateContent(flags, kPcmuCodec, kH264Codec,
238 &local_media_content1_); 242 &local_media_content1_);
239 CreateContent(flags, kPcmuCodec, kH264Codec, 243 CreateContent(flags, kPcmuCodec, kH264Codec,
240 &local_media_content2_); 244 &local_media_content2_);
241 CopyContent(local_media_content1_, &remote_media_content1_); 245 CopyContent(local_media_content1_, &remote_media_content1_);
242 CopyContent(local_media_content2_, &remote_media_content2_); 246 CopyContent(local_media_content2_, &remote_media_content2_);
243 // Add stream information (SSRC) to the local content but not to the remote 247 // Add stream information (SSRC) to the local content but not to the remote
244 // content. This means that we per default know the SSRC of what we send but 248 // content. This means that we per default know the SSRC of what we send but
245 // not what we receive. 249 // not what we receive.
246 AddLegacyStreamInContent(kSsrc1, flags, &local_media_content1_); 250 AddLegacyStreamInContent(kSsrc1, flags, &local_media_content1_);
247 AddLegacyStreamInContent(kSsrc2, flags, &local_media_content2_); 251 AddLegacyStreamInContent(kSsrc2, flags, &local_media_content2_);
248 252
249 // If SSRC_MUX is used we also need to know the SSRC of the incoming stream. 253 // If SSRC_MUX is used we also need to know the SSRC of the incoming stream.
250 if (flags & SSRC_MUX) { 254 if (flags & SSRC_MUX) {
251 AddLegacyStreamInContent(kSsrc1, flags, &remote_media_content1_); 255 AddLegacyStreamInContent(kSsrc1, flags, &remote_media_content1_);
252 AddLegacyStreamInContent(kSsrc2, flags, &remote_media_content2_); 256 AddLegacyStreamInContent(kSsrc2, flags, &remote_media_content2_);
253 } 257 }
254 } 258 }
255 259
256 typename T::Channel* CreateChannel(rtc::Thread* thread, 260 typename T::Channel* CreateChannel(
257 cricket::MediaEngineInterface* engine, 261 rtc::Thread* thread,
258 typename T::MediaChannel* ch, 262 cricket::MediaEngineInterface* engine,
259 cricket::BaseSession* session, 263 typename T::MediaChannel* ch,
260 bool rtcp) { 264 cricket::TransportController* transport_controller,
265 bool rtcp) {
261 typename T::Channel* channel = new typename T::Channel( 266 typename T::Channel* channel = new typename T::Channel(
262 thread, engine, ch, session, cricket::CN_AUDIO, rtcp); 267 thread, engine, ch, transport_controller, cricket::CN_AUDIO, rtcp);
263 if (!channel->Init()) { 268 if (!channel->Init()) {
264 delete channel; 269 delete channel;
265 channel = NULL; 270 channel = NULL;
266 } 271 }
267 return channel; 272 return channel;
268 } 273 }
269 274
270 bool SendInitiate() { 275 bool SendInitiate() {
271 bool result = channel1_->SetLocalContent(&local_media_content1_, 276 bool result = channel1_->SetLocalContent(&local_media_content1_,
272 CA_OFFER, NULL); 277 CA_OFFER, NULL);
273 if (result) { 278 if (result) {
274 channel1_->Enable(true); 279 channel1_->Enable(true);
275 result = channel2_->SetRemoteContent(&remote_media_content1_, 280 result = channel2_->SetRemoteContent(&remote_media_content1_,
276 CA_OFFER, NULL); 281 CA_OFFER, NULL);
277 if (result) { 282 if (result) {
278 session1_.Connect(&session2_); 283 transport_controller1_.Connect(&transport_controller2_);
279 284
280 result = channel2_->SetLocalContent(&local_media_content2_, 285 result = channel2_->SetLocalContent(&local_media_content2_,
281 CA_ANSWER, NULL); 286 CA_ANSWER, NULL);
282 } 287 }
283 } 288 }
284 return result; 289 return result;
285 } 290 }
286 291
287 bool SendAccept() { 292 bool SendAccept() {
288 channel2_->Enable(true); 293 channel2_->Enable(true);
(...skipping 12 matching lines...) Expand all
301 return result; 306 return result;
302 } 307 }
303 308
304 bool SendProvisionalAnswer() { 309 bool SendProvisionalAnswer() {
305 bool result = channel2_->SetLocalContent(&local_media_content2_, 310 bool result = channel2_->SetLocalContent(&local_media_content2_,
306 CA_PRANSWER, NULL); 311 CA_PRANSWER, NULL);
307 if (result) { 312 if (result) {
308 channel2_->Enable(true); 313 channel2_->Enable(true);
309 result = channel1_->SetRemoteContent(&remote_media_content2_, 314 result = channel1_->SetRemoteContent(&remote_media_content2_,
310 CA_PRANSWER, NULL); 315 CA_PRANSWER, NULL);
311 session1_.Connect(&session2_); 316 transport_controller1_.Connect(&transport_controller2_);
312 } 317 }
313 return result; 318 return result;
314 } 319 }
315 320
316 bool SendFinalAnswer() { 321 bool SendFinalAnswer() {
317 bool result = channel2_->SetLocalContent(&local_media_content2_, 322 bool result = channel2_->SetLocalContent(&local_media_content2_,
318 CA_ANSWER, NULL); 323 CA_ANSWER, NULL);
319 if (result) 324 if (result)
320 result = channel1_->SetRemoteContent(&remote_media_content2_, 325 result = channel1_->SetRemoteContent(&remote_media_content2_,
321 CA_ANSWER, NULL); 326 CA_ANSWER, NULL);
322 return result; 327 return result;
323 } 328 }
324 329
325 bool SendTerminate() { 330 bool SendTerminate() {
326 channel1_.reset(); 331 channel1_.reset();
327 channel2_.reset(); 332 channel2_.reset();
328 return true; 333 return true;
329 } 334 }
330 335
331 bool AddStream1(int id) { 336 bool AddStream1(int id) {
332 return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id)); 337 return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id));
333 } 338 }
334 bool RemoveStream1(int id) { 339 bool RemoveStream1(int id) {
335 return channel1_->RemoveRecvStream(id); 340 return channel1_->RemoveRecvStream(id);
336 } 341 }
337 342
343 // Calling "_w" method here is ok since we only use one thread for this test
338 cricket::FakeTransport* GetTransport1() { 344 cricket::FakeTransport* GetTransport1() {
339 return session1_.GetTransport(channel1_->content_name()); 345 return transport_controller1_.GetTransport_w(channel1_->content_name());
340 } 346 }
341 cricket::FakeTransport* GetTransport2() { 347 cricket::FakeTransport* GetTransport2() {
342 return session2_.GetTransport(channel2_->content_name()); 348 return transport_controller2_.GetTransport_w(channel2_->content_name());
343 } 349 }
344 350
345 bool SendRtp1() { 351 bool SendRtp1() {
346 return media_channel1_->SendRtp(rtp_packet_.c_str(), 352 return media_channel1_->SendRtp(rtp_packet_.c_str(),
347 static_cast<int>(rtp_packet_.size())); 353 static_cast<int>(rtp_packet_.size()));
348 } 354 }
349 bool SendRtp2() { 355 bool SendRtp2() {
350 return media_channel2_->SendRtp(rtp_packet_.c_str(), 356 return media_channel2_->SendRtp(rtp_packet_.c_str(),
351 static_cast<int>(rtp_packet_.size())); 357 static_cast<int>(rtp_packet_.size()));
352 } 358 }
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 CreateChannels(0, 0); 822 CreateChannels(0, 0);
817 typename T::Content content1; 823 typename T::Content content1;
818 CreateContent(0, kPcmuCodec, kH264Codec, &content1); 824 CreateContent(0, kPcmuCodec, kH264Codec, &content1);
819 content1.AddStream(stream1); 825 content1.AddStream(stream1);
820 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL)); 826 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL));
821 EXPECT_TRUE(channel1_->Enable(true)); 827 EXPECT_TRUE(channel1_->Enable(true));
822 EXPECT_EQ(1u, media_channel1_->send_streams().size()); 828 EXPECT_EQ(1u, media_channel1_->send_streams().size());
823 829
824 EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, NULL)); 830 EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, NULL));
825 EXPECT_EQ(1u, media_channel2_->recv_streams().size()); 831 EXPECT_EQ(1u, media_channel2_->recv_streams().size());
826 session1_.Connect(&session2_); 832 transport_controller1_.Connect(&transport_controller2_);
827 833
828 // Channel 2 do not send anything. 834 // Channel 2 do not send anything.
829 typename T::Content content2; 835 typename T::Content content2;
830 CreateContent(0, kPcmuCodec, kH264Codec, &content2); 836 CreateContent(0, kPcmuCodec, kH264Codec, &content2);
831 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_ANSWER, NULL)); 837 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_ANSWER, NULL));
832 EXPECT_EQ(0u, media_channel1_->recv_streams().size()); 838 EXPECT_EQ(0u, media_channel1_->recv_streams().size());
833 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_ANSWER, NULL)); 839 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_ANSWER, NULL));
834 EXPECT_TRUE(channel2_->Enable(true)); 840 EXPECT_TRUE(channel2_->Enable(true));
835 EXPECT_EQ(0u, media_channel2_->send_streams().size()); 841 EXPECT_EQ(0u, media_channel2_->send_streams().size());
836 842
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 EXPECT_TRUE(media_channel1_->playout()); 885 EXPECT_TRUE(media_channel1_->playout());
880 EXPECT_FALSE(media_channel1_->sending()); 886 EXPECT_FALSE(media_channel1_->sending());
881 EXPECT_TRUE(channel2_->SetRemoteContent(&local_media_content1_, 887 EXPECT_TRUE(channel2_->SetRemoteContent(&local_media_content1_,
882 CA_OFFER, NULL)); 888 CA_OFFER, NULL));
883 EXPECT_FALSE(media_channel2_->playout()); 889 EXPECT_FALSE(media_channel2_->playout());
884 EXPECT_FALSE(media_channel2_->sending()); 890 EXPECT_FALSE(media_channel2_->sending());
885 EXPECT_TRUE(channel2_->SetLocalContent(&local_media_content2_, 891 EXPECT_TRUE(channel2_->SetLocalContent(&local_media_content2_,
886 CA_ANSWER, NULL)); 892 CA_ANSWER, NULL));
887 EXPECT_FALSE(media_channel2_->playout()); 893 EXPECT_FALSE(media_channel2_->playout());
888 EXPECT_FALSE(media_channel2_->sending()); 894 EXPECT_FALSE(media_channel2_->sending());
889 session1_.Connect(&session2_); 895 transport_controller1_.Connect(&transport_controller2_);
890 EXPECT_TRUE(media_channel1_->playout()); 896 EXPECT_TRUE(media_channel1_->playout());
891 EXPECT_FALSE(media_channel1_->sending()); 897 EXPECT_FALSE(media_channel1_->sending());
892 EXPECT_FALSE(media_channel2_->playout()); 898 EXPECT_FALSE(media_channel2_->playout());
893 EXPECT_FALSE(media_channel2_->sending()); 899 EXPECT_FALSE(media_channel2_->sending());
894 EXPECT_TRUE(channel2_->Enable(true)); 900 EXPECT_TRUE(channel2_->Enable(true));
895 EXPECT_TRUE(media_channel2_->playout()); 901 EXPECT_TRUE(media_channel2_->playout());
896 EXPECT_TRUE(media_channel2_->sending()); 902 EXPECT_TRUE(media_channel2_->sending());
897 EXPECT_TRUE(channel1_->SetRemoteContent(&local_media_content2_, 903 EXPECT_TRUE(channel1_->SetRemoteContent(&local_media_content2_,
898 CA_ANSWER, NULL)); 904 CA_ANSWER, NULL));
899 EXPECT_TRUE(media_channel1_->playout()); 905 EXPECT_TRUE(media_channel1_->playout());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 EXPECT_TRUE(channel2_->Enable(true)); 943 EXPECT_TRUE(channel2_->Enable(true));
938 EXPECT_FALSE(media_channel1_->playout()); 944 EXPECT_FALSE(media_channel1_->playout());
939 EXPECT_FALSE(media_channel1_->sending()); 945 EXPECT_FALSE(media_channel1_->sending());
940 EXPECT_FALSE(media_channel2_->playout()); 946 EXPECT_FALSE(media_channel2_->playout());
941 EXPECT_FALSE(media_channel2_->sending()); 947 EXPECT_FALSE(media_channel2_->sending());
942 948
943 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL)); 949 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL));
944 EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, NULL)); 950 EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, NULL));
945 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_PRANSWER, NULL)); 951 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_PRANSWER, NULL));
946 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_PRANSWER, NULL)); 952 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_PRANSWER, NULL));
947 session1_.Connect(&session2_); 953 transport_controller1_.Connect(&transport_controller2_);
948 954
949 EXPECT_TRUE(media_channel1_->playout()); 955 EXPECT_TRUE(media_channel1_->playout());
950 EXPECT_FALSE(media_channel1_->sending()); // remote InActive 956 EXPECT_FALSE(media_channel1_->sending()); // remote InActive
951 EXPECT_FALSE(media_channel2_->playout()); // local InActive 957 EXPECT_FALSE(media_channel2_->playout()); // local InActive
952 EXPECT_FALSE(media_channel2_->sending()); // local InActive 958 EXPECT_FALSE(media_channel2_->sending()); // local InActive
953 959
954 // Update |content2| to be RecvOnly. 960 // Update |content2| to be RecvOnly.
955 content2.set_direction(cricket::MD_RECVONLY); 961 content2.set_direction(cricket::MD_RECVONLY);
956 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_PRANSWER, NULL)); 962 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_PRANSWER, NULL));
957 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_PRANSWER, NULL)); 963 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_PRANSWER, NULL));
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 EXPECT_TRUE(SendInitiate()); 1013 EXPECT_TRUE(SendInitiate());
1008 EXPECT_TRUE(SendAccept()); 1014 EXPECT_TRUE(SendAccept());
1009 EXPECT_TRUE(SendTerminate()); 1015 EXPECT_TRUE(SendTerminate());
1010 } 1016 }
1011 1017
1012 // Send voice RTP data to the other side and ensure it gets there. 1018 // Send voice RTP data to the other side and ensure it gets there.
1013 void SendRtpToRtp() { 1019 void SendRtpToRtp() {
1014 CreateChannels(0, 0); 1020 CreateChannels(0, 0);
1015 EXPECT_TRUE(SendInitiate()); 1021 EXPECT_TRUE(SendInitiate());
1016 EXPECT_TRUE(SendAccept()); 1022 EXPECT_TRUE(SendAccept());
1023 ASSERT_TRUE(GetTransport1());
1024 ASSERT_TRUE(GetTransport2());
1017 EXPECT_EQ(1U, GetTransport1()->channels().size()); 1025 EXPECT_EQ(1U, GetTransport1()->channels().size());
1018 EXPECT_EQ(1U, GetTransport2()->channels().size()); 1026 EXPECT_EQ(1U, GetTransport2()->channels().size());
1019 EXPECT_TRUE(SendRtp1()); 1027 EXPECT_TRUE(SendRtp1());
1020 EXPECT_TRUE(SendRtp2()); 1028 EXPECT_TRUE(SendRtp2());
1021 EXPECT_TRUE(CheckRtp1()); 1029 EXPECT_TRUE(CheckRtp1());
1022 EXPECT_TRUE(CheckRtp2()); 1030 EXPECT_TRUE(CheckRtp2());
1023 EXPECT_TRUE(CheckNoRtp1()); 1031 EXPECT_TRUE(CheckNoRtp1());
1024 EXPECT_TRUE(CheckNoRtp2()); 1032 EXPECT_TRUE(CheckNoRtp2());
1025 } 1033 }
1026 1034
1027 // Check that RTCP is not transmitted if both sides don't support RTCP. 1035 // Check that RTCP is not transmitted if both sides don't support RTCP.
1028 void SendNoRtcpToNoRtcp() { 1036 void SendNoRtcpToNoRtcp() {
1029 CreateChannels(0, 0); 1037 CreateChannels(0, 0);
1030 EXPECT_TRUE(SendInitiate()); 1038 EXPECT_TRUE(SendInitiate());
1031 EXPECT_TRUE(SendAccept()); 1039 EXPECT_TRUE(SendAccept());
1040 ASSERT_TRUE(GetTransport1());
1041 ASSERT_TRUE(GetTransport2());
1032 EXPECT_EQ(1U, GetTransport1()->channels().size()); 1042 EXPECT_EQ(1U, GetTransport1()->channels().size());
1033 EXPECT_EQ(1U, GetTransport2()->channels().size()); 1043 EXPECT_EQ(1U, GetTransport2()->channels().size());
1034 EXPECT_FALSE(SendRtcp1()); 1044 EXPECT_FALSE(SendRtcp1());
1035 EXPECT_FALSE(SendRtcp2()); 1045 EXPECT_FALSE(SendRtcp2());
1036 EXPECT_TRUE(CheckNoRtcp1()); 1046 EXPECT_TRUE(CheckNoRtcp1());
1037 EXPECT_TRUE(CheckNoRtcp2()); 1047 EXPECT_TRUE(CheckNoRtcp2());
1038 } 1048 }
1039 1049
1040 // Check that RTCP is not transmitted if the callee doesn't support RTCP. 1050 // Check that RTCP is not transmitted if the callee doesn't support RTCP.
1041 void SendNoRtcpToRtcp() { 1051 void SendNoRtcpToRtcp() {
1042 CreateChannels(0, RTCP); 1052 CreateChannels(0, RTCP);
1043 EXPECT_TRUE(SendInitiate()); 1053 EXPECT_TRUE(SendInitiate());
1044 EXPECT_TRUE(SendAccept()); 1054 EXPECT_TRUE(SendAccept());
1055 ASSERT_TRUE(GetTransport1());
1056 ASSERT_TRUE(GetTransport2());
1045 EXPECT_EQ(1U, GetTransport1()->channels().size()); 1057 EXPECT_EQ(1U, GetTransport1()->channels().size());
1046 EXPECT_EQ(2U, GetTransport2()->channels().size()); 1058 EXPECT_EQ(2U, GetTransport2()->channels().size());
1047 EXPECT_FALSE(SendRtcp1()); 1059 EXPECT_FALSE(SendRtcp1());
1048 EXPECT_FALSE(SendRtcp2()); 1060 EXPECT_FALSE(SendRtcp2());
1049 EXPECT_TRUE(CheckNoRtcp1()); 1061 EXPECT_TRUE(CheckNoRtcp1());
1050 EXPECT_TRUE(CheckNoRtcp2()); 1062 EXPECT_TRUE(CheckNoRtcp2());
1051 } 1063 }
1052 1064
1053 // Check that RTCP is not transmitted if the caller doesn't support RTCP. 1065 // Check that RTCP is not transmitted if the caller doesn't support RTCP.
1054 void SendRtcpToNoRtcp() { 1066 void SendRtcpToNoRtcp() {
1055 CreateChannels(RTCP, 0); 1067 CreateChannels(RTCP, 0);
1056 EXPECT_TRUE(SendInitiate()); 1068 EXPECT_TRUE(SendInitiate());
1057 EXPECT_TRUE(SendAccept()); 1069 EXPECT_TRUE(SendAccept());
1070 ASSERT_TRUE(GetTransport1());
1071 ASSERT_TRUE(GetTransport2());
1058 EXPECT_EQ(2U, GetTransport1()->channels().size()); 1072 EXPECT_EQ(2U, GetTransport1()->channels().size());
1059 EXPECT_EQ(1U, GetTransport2()->channels().size()); 1073 EXPECT_EQ(1U, GetTransport2()->channels().size());
1060 EXPECT_FALSE(SendRtcp1()); 1074 EXPECT_FALSE(SendRtcp1());
1061 EXPECT_FALSE(SendRtcp2()); 1075 EXPECT_FALSE(SendRtcp2());
1062 EXPECT_TRUE(CheckNoRtcp1()); 1076 EXPECT_TRUE(CheckNoRtcp1());
1063 EXPECT_TRUE(CheckNoRtcp2()); 1077 EXPECT_TRUE(CheckNoRtcp2());
1064 } 1078 }
1065 1079
1066 // Check that RTCP is transmitted if both sides support RTCP. 1080 // Check that RTCP is transmitted if both sides support RTCP.
1067 void SendRtcpToRtcp() { 1081 void SendRtcpToRtcp() {
1068 CreateChannels(RTCP, RTCP); 1082 CreateChannels(RTCP, RTCP);
1069 EXPECT_TRUE(SendInitiate()); 1083 EXPECT_TRUE(SendInitiate());
1070 EXPECT_TRUE(SendAccept()); 1084 EXPECT_TRUE(SendAccept());
1085 ASSERT_TRUE(GetTransport1());
1086 ASSERT_TRUE(GetTransport2());
1071 EXPECT_EQ(2U, GetTransport1()->channels().size()); 1087 EXPECT_EQ(2U, GetTransport1()->channels().size());
1072 EXPECT_EQ(2U, GetTransport2()->channels().size()); 1088 EXPECT_EQ(2U, GetTransport2()->channels().size());
1073 EXPECT_TRUE(SendRtcp1()); 1089 EXPECT_TRUE(SendRtcp1());
1074 EXPECT_TRUE(SendRtcp2()); 1090 EXPECT_TRUE(SendRtcp2());
1075 EXPECT_TRUE(CheckRtcp1()); 1091 EXPECT_TRUE(CheckRtcp1());
1076 EXPECT_TRUE(CheckRtcp2()); 1092 EXPECT_TRUE(CheckRtcp2());
1077 EXPECT_TRUE(CheckNoRtcp1()); 1093 EXPECT_TRUE(CheckNoRtcp1());
1078 EXPECT_TRUE(CheckNoRtcp2()); 1094 EXPECT_TRUE(CheckNoRtcp2());
1079 } 1095 }
1080 1096
1081 // Check that RTCP is transmitted if only the initiator supports mux. 1097 // Check that RTCP is transmitted if only the initiator supports mux.
1082 void SendRtcpMuxToRtcp() { 1098 void SendRtcpMuxToRtcp() {
1083 CreateChannels(RTCP | RTCP_MUX, RTCP); 1099 CreateChannels(RTCP | RTCP_MUX, RTCP);
1084 EXPECT_TRUE(SendInitiate()); 1100 EXPECT_TRUE(SendInitiate());
1085 EXPECT_TRUE(SendAccept()); 1101 EXPECT_TRUE(SendAccept());
1102 ASSERT_TRUE(GetTransport1());
1103 ASSERT_TRUE(GetTransport2());
1086 EXPECT_EQ(2U, GetTransport1()->channels().size()); 1104 EXPECT_EQ(2U, GetTransport1()->channels().size());
1087 EXPECT_EQ(2U, GetTransport2()->channels().size()); 1105 EXPECT_EQ(2U, GetTransport2()->channels().size());
1088 EXPECT_TRUE(SendRtcp1()); 1106 EXPECT_TRUE(SendRtcp1());
1089 EXPECT_TRUE(SendRtcp2()); 1107 EXPECT_TRUE(SendRtcp2());
1090 EXPECT_TRUE(CheckRtcp1()); 1108 EXPECT_TRUE(CheckRtcp1());
1091 EXPECT_TRUE(CheckRtcp2()); 1109 EXPECT_TRUE(CheckRtcp2());
1092 EXPECT_TRUE(CheckNoRtcp1()); 1110 EXPECT_TRUE(CheckNoRtcp1());
1093 EXPECT_TRUE(CheckNoRtcp2()); 1111 EXPECT_TRUE(CheckNoRtcp2());
1094 } 1112 }
1095 1113
1096 // Check that RTP and RTCP are transmitted ok when both sides support mux. 1114 // Check that RTP and RTCP are transmitted ok when both sides support mux.
1097 void SendRtcpMuxToRtcpMux() { 1115 void SendRtcpMuxToRtcpMux() {
1098 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); 1116 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
1099 EXPECT_TRUE(SendInitiate()); 1117 EXPECT_TRUE(SendInitiate());
1118 ASSERT_TRUE(GetTransport1());
1119 ASSERT_TRUE(GetTransport2());
1100 EXPECT_EQ(2U, GetTransport1()->channels().size()); 1120 EXPECT_EQ(2U, GetTransport1()->channels().size());
1101 EXPECT_EQ(1U, GetTransport2()->channels().size()); 1121 EXPECT_EQ(1U, GetTransport2()->channels().size());
1102 EXPECT_TRUE(SendAccept()); 1122 EXPECT_TRUE(SendAccept());
1103 EXPECT_EQ(1U, GetTransport1()->channels().size()); 1123 EXPECT_EQ(1U, GetTransport1()->channels().size());
1104 EXPECT_TRUE(SendRtp1()); 1124 EXPECT_TRUE(SendRtp1());
1105 EXPECT_TRUE(SendRtp2()); 1125 EXPECT_TRUE(SendRtp2());
1106 EXPECT_TRUE(SendRtcp1()); 1126 EXPECT_TRUE(SendRtcp1());
1107 EXPECT_TRUE(SendRtcp2()); 1127 EXPECT_TRUE(SendRtcp2());
1108 EXPECT_TRUE(CheckRtp1()); 1128 EXPECT_TRUE(CheckRtp1());
1109 EXPECT_TRUE(CheckRtp2()); 1129 EXPECT_TRUE(CheckRtp2());
1110 EXPECT_TRUE(CheckNoRtp1()); 1130 EXPECT_TRUE(CheckNoRtp1());
1111 EXPECT_TRUE(CheckNoRtp2()); 1131 EXPECT_TRUE(CheckNoRtp2());
1112 EXPECT_TRUE(CheckRtcp1()); 1132 EXPECT_TRUE(CheckRtcp1());
1113 EXPECT_TRUE(CheckRtcp2()); 1133 EXPECT_TRUE(CheckRtcp2());
1114 EXPECT_TRUE(CheckNoRtcp1()); 1134 EXPECT_TRUE(CheckNoRtcp1());
1115 EXPECT_TRUE(CheckNoRtcp2()); 1135 EXPECT_TRUE(CheckNoRtcp2());
1116 } 1136 }
1117 1137
1118 // Check that RTP and RTCP are transmitted ok when both sides 1138 // Check that RTP and RTCP are transmitted ok when both sides
1119 // support mux and one the offerer requires mux. 1139 // support mux and one the offerer requires mux.
1120 void SendRequireRtcpMuxToRtcpMux() { 1140 void SendRequireRtcpMuxToRtcpMux() {
1121 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); 1141 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
1122 channel1_->ActivateRtcpMux(); 1142 channel1_->ActivateRtcpMux();
1123 EXPECT_TRUE(SendInitiate()); 1143 EXPECT_TRUE(SendInitiate());
1144 ASSERT_TRUE(GetTransport1());
1145 ASSERT_TRUE(GetTransport2());
1124 EXPECT_EQ(1U, GetTransport1()->channels().size()); 1146 EXPECT_EQ(1U, GetTransport1()->channels().size());
1125 EXPECT_EQ(1U, GetTransport2()->channels().size()); 1147 EXPECT_EQ(1U, GetTransport2()->channels().size());
1126 EXPECT_TRUE(SendAccept()); 1148 EXPECT_TRUE(SendAccept());
1127 EXPECT_TRUE(SendRtp1()); 1149 EXPECT_TRUE(SendRtp1());
1128 EXPECT_TRUE(SendRtp2()); 1150 EXPECT_TRUE(SendRtp2());
1129 EXPECT_TRUE(SendRtcp1()); 1151 EXPECT_TRUE(SendRtcp1());
1130 EXPECT_TRUE(SendRtcp2()); 1152 EXPECT_TRUE(SendRtcp2());
1131 EXPECT_TRUE(CheckRtp1()); 1153 EXPECT_TRUE(CheckRtp1());
1132 EXPECT_TRUE(CheckRtp2()); 1154 EXPECT_TRUE(CheckRtp2());
1133 EXPECT_TRUE(CheckNoRtp1()); 1155 EXPECT_TRUE(CheckNoRtp1());
1134 EXPECT_TRUE(CheckNoRtp2()); 1156 EXPECT_TRUE(CheckNoRtp2());
1135 EXPECT_TRUE(CheckRtcp1()); 1157 EXPECT_TRUE(CheckRtcp1());
1136 EXPECT_TRUE(CheckRtcp2()); 1158 EXPECT_TRUE(CheckRtcp2());
1137 EXPECT_TRUE(CheckNoRtcp1()); 1159 EXPECT_TRUE(CheckNoRtcp1());
1138 EXPECT_TRUE(CheckNoRtcp2()); 1160 EXPECT_TRUE(CheckNoRtcp2());
1139 } 1161 }
1140 1162
1141 // Check that RTP and RTCP are transmitted ok when both sides 1163 // Check that RTP and RTCP are transmitted ok when both sides
1142 // support mux and one the answerer requires rtcp mux. 1164 // support mux and one the answerer requires rtcp mux.
1143 void SendRtcpMuxToRequireRtcpMux() { 1165 void SendRtcpMuxToRequireRtcpMux() {
1144 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); 1166 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
1145 channel2_->ActivateRtcpMux(); 1167 channel2_->ActivateRtcpMux();
1146 EXPECT_TRUE(SendInitiate()); 1168 EXPECT_TRUE(SendInitiate());
1169 ASSERT_TRUE(GetTransport1());
1170 ASSERT_TRUE(GetTransport2());
1147 EXPECT_EQ(2U, GetTransport1()->channels().size()); 1171 EXPECT_EQ(2U, GetTransport1()->channels().size());
1148 EXPECT_EQ(1U, GetTransport2()->channels().size()); 1172 EXPECT_EQ(1U, GetTransport2()->channels().size());
1149 EXPECT_TRUE(SendAccept()); 1173 EXPECT_TRUE(SendAccept());
1150 EXPECT_EQ(1U, GetTransport1()->channels().size()); 1174 EXPECT_EQ(1U, GetTransport1()->channels().size());
1151 EXPECT_TRUE(SendRtp1()); 1175 EXPECT_TRUE(SendRtp1());
1152 EXPECT_TRUE(SendRtp2()); 1176 EXPECT_TRUE(SendRtp2());
1153 EXPECT_TRUE(SendRtcp1()); 1177 EXPECT_TRUE(SendRtcp1());
1154 EXPECT_TRUE(SendRtcp2()); 1178 EXPECT_TRUE(SendRtcp2());
1155 EXPECT_TRUE(CheckRtp1()); 1179 EXPECT_TRUE(CheckRtp1());
1156 EXPECT_TRUE(CheckRtp2()); 1180 EXPECT_TRUE(CheckRtp2());
1157 EXPECT_TRUE(CheckNoRtp1()); 1181 EXPECT_TRUE(CheckNoRtp1());
1158 EXPECT_TRUE(CheckNoRtp2()); 1182 EXPECT_TRUE(CheckNoRtp2());
1159 EXPECT_TRUE(CheckRtcp1()); 1183 EXPECT_TRUE(CheckRtcp1());
1160 EXPECT_TRUE(CheckRtcp2()); 1184 EXPECT_TRUE(CheckRtcp2());
1161 EXPECT_TRUE(CheckNoRtcp1()); 1185 EXPECT_TRUE(CheckNoRtcp1());
1162 EXPECT_TRUE(CheckNoRtcp2()); 1186 EXPECT_TRUE(CheckNoRtcp2());
1163 } 1187 }
1164 1188
1165 // Check that RTP and RTCP are transmitted ok when both sides 1189 // Check that RTP and RTCP are transmitted ok when both sides
1166 // require mux. 1190 // require mux.
1167 void SendRequireRtcpMuxToRequireRtcpMux() { 1191 void SendRequireRtcpMuxToRequireRtcpMux() {
1168 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); 1192 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
1169 channel1_->ActivateRtcpMux(); 1193 channel1_->ActivateRtcpMux();
1170 channel2_->ActivateRtcpMux(); 1194 channel2_->ActivateRtcpMux();
1171 EXPECT_TRUE(SendInitiate()); 1195 EXPECT_TRUE(SendInitiate());
1196 ASSERT_TRUE(GetTransport1());
1197 ASSERT_TRUE(GetTransport2());
1172 EXPECT_EQ(1U, GetTransport1()->channels().size()); 1198 EXPECT_EQ(1U, GetTransport1()->channels().size());
1173 EXPECT_EQ(1U, GetTransport2()->channels().size()); 1199 EXPECT_EQ(1U, GetTransport2()->channels().size());
1174 EXPECT_TRUE(SendAccept()); 1200 EXPECT_TRUE(SendAccept());
1175 EXPECT_EQ(1U, GetTransport1()->channels().size()); 1201 EXPECT_EQ(1U, GetTransport1()->channels().size());
1176 EXPECT_TRUE(SendRtp1()); 1202 EXPECT_TRUE(SendRtp1());
1177 EXPECT_TRUE(SendRtp2()); 1203 EXPECT_TRUE(SendRtp2());
1178 EXPECT_TRUE(SendRtcp1()); 1204 EXPECT_TRUE(SendRtcp1());
1179 EXPECT_TRUE(SendRtcp2()); 1205 EXPECT_TRUE(SendRtcp2());
1180 EXPECT_TRUE(CheckRtp1()); 1206 EXPECT_TRUE(CheckRtp1());
1181 EXPECT_TRUE(CheckRtp2()); 1207 EXPECT_TRUE(CheckRtp2());
1182 EXPECT_TRUE(CheckNoRtp1()); 1208 EXPECT_TRUE(CheckNoRtp1());
1183 EXPECT_TRUE(CheckNoRtp2()); 1209 EXPECT_TRUE(CheckNoRtp2());
1184 EXPECT_TRUE(CheckRtcp1()); 1210 EXPECT_TRUE(CheckRtcp1());
1185 EXPECT_TRUE(CheckRtcp2()); 1211 EXPECT_TRUE(CheckRtcp2());
1186 EXPECT_TRUE(CheckNoRtcp1()); 1212 EXPECT_TRUE(CheckNoRtcp1());
1187 EXPECT_TRUE(CheckNoRtcp2()); 1213 EXPECT_TRUE(CheckNoRtcp2());
1188 } 1214 }
1189 1215
1190 // Check that SendAccept fails if the answerer doesn't support mux 1216 // Check that SendAccept fails if the answerer doesn't support mux
1191 // and the offerer requires it. 1217 // and the offerer requires it.
1192 void SendRequireRtcpMuxToNoRtcpMux() { 1218 void SendRequireRtcpMuxToNoRtcpMux() {
1193 CreateChannels(RTCP | RTCP_MUX, RTCP); 1219 CreateChannels(RTCP | RTCP_MUX, RTCP);
1194 channel1_->ActivateRtcpMux(); 1220 channel1_->ActivateRtcpMux();
1195 EXPECT_TRUE(SendInitiate()); 1221 EXPECT_TRUE(SendInitiate());
1222 ASSERT_TRUE(GetTransport1());
1223 ASSERT_TRUE(GetTransport2());
1196 EXPECT_EQ(1U, GetTransport1()->channels().size()); 1224 EXPECT_EQ(1U, GetTransport1()->channels().size());
1197 EXPECT_EQ(2U, GetTransport2()->channels().size()); 1225 EXPECT_EQ(2U, GetTransport2()->channels().size());
1198 EXPECT_FALSE(SendAccept()); 1226 EXPECT_FALSE(SendAccept());
1199 } 1227 }
1200 1228
1201 // Check that RTCP data sent by the initiator before the accept is not muxed. 1229 // Check that RTCP data sent by the initiator before the accept is not muxed.
1202 void SendEarlyRtcpMuxToRtcp() { 1230 void SendEarlyRtcpMuxToRtcp() {
1203 CreateChannels(RTCP | RTCP_MUX, RTCP); 1231 CreateChannels(RTCP | RTCP_MUX, RTCP);
1204 EXPECT_TRUE(SendInitiate()); 1232 EXPECT_TRUE(SendInitiate());
1233 ASSERT_TRUE(GetTransport1());
1234 ASSERT_TRUE(GetTransport2());
1205 EXPECT_EQ(2U, GetTransport1()->channels().size()); 1235 EXPECT_EQ(2U, GetTransport1()->channels().size());
1206 EXPECT_EQ(2U, GetTransport2()->channels().size()); 1236 EXPECT_EQ(2U, GetTransport2()->channels().size());
1207 1237
1208 // RTCP can be sent before the call is accepted, if the transport is ready. 1238 // RTCP can be sent before the call is accepted, if the transport is ready.
1209 // It should not be muxed though, as the remote side doesn't support mux. 1239 // It should not be muxed though, as the remote side doesn't support mux.
1210 EXPECT_TRUE(SendRtcp1()); 1240 EXPECT_TRUE(SendRtcp1());
1211 EXPECT_TRUE(CheckNoRtp2()); 1241 EXPECT_TRUE(CheckNoRtp2());
1212 EXPECT_TRUE(CheckRtcp2()); 1242 EXPECT_TRUE(CheckRtcp2());
1213 1243
1214 // Send RTCP packet from callee and verify that it is received. 1244 // Send RTCP packet from callee and verify that it is received.
(...skipping 10 matching lines...) Expand all
1225 EXPECT_TRUE(CheckRtcp1()); 1255 EXPECT_TRUE(CheckRtcp1());
1226 } 1256 }
1227 1257
1228 1258
1229 // Check that RTCP data is not muxed until both sides have enabled muxing, 1259 // Check that RTCP data is not muxed until both sides have enabled muxing,
1230 // but that we properly demux before we get the accept message, since there 1260 // but that we properly demux before we get the accept message, since there
1231 // is a race between RTP data and the jingle accept. 1261 // is a race between RTP data and the jingle accept.
1232 void SendEarlyRtcpMuxToRtcpMux() { 1262 void SendEarlyRtcpMuxToRtcpMux() {
1233 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); 1263 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
1234 EXPECT_TRUE(SendInitiate()); 1264 EXPECT_TRUE(SendInitiate());
1265 ASSERT_TRUE(GetTransport1());
1266 ASSERT_TRUE(GetTransport2());
1235 EXPECT_EQ(2U, GetTransport1()->channels().size()); 1267 EXPECT_EQ(2U, GetTransport1()->channels().size());
1236 EXPECT_EQ(1U, GetTransport2()->channels().size()); 1268 EXPECT_EQ(1U, GetTransport2()->channels().size());
1237 1269
1238 // RTCP can't be sent yet, since the RTCP transport isn't writable, and 1270 // RTCP can't be sent yet, since the RTCP transport isn't writable, and
1239 // we haven't yet received the accept that says we should mux. 1271 // we haven't yet received the accept that says we should mux.
1240 EXPECT_FALSE(SendRtcp1()); 1272 EXPECT_FALSE(SendRtcp1());
1241 1273
1242 // Send muxed RTCP packet from callee and verify that it is received. 1274 // Send muxed RTCP packet from callee and verify that it is received.
1243 EXPECT_TRUE(SendRtcp2()); 1275 EXPECT_TRUE(SendRtcp2());
1244 EXPECT_TRUE(CheckNoRtp1()); 1276 EXPECT_TRUE(CheckNoRtp1());
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 // sent and received. The test uses SRTP, RTCP mux and SSRC mux. 1347 // sent and received. The test uses SRTP, RTCP mux and SSRC mux.
1316 void SendEarlyMediaUsingRtcpMuxSrtp() { 1348 void SendEarlyMediaUsingRtcpMuxSrtp() {
1317 int sequence_number1_1 = 0, sequence_number2_2 = 0; 1349 int sequence_number1_1 = 0, sequence_number2_2 = 0;
1318 1350
1319 CreateChannels(SSRC_MUX | RTCP | RTCP_MUX | SECURE, 1351 CreateChannels(SSRC_MUX | RTCP | RTCP_MUX | SECURE,
1320 SSRC_MUX | RTCP | RTCP_MUX | SECURE); 1352 SSRC_MUX | RTCP | RTCP_MUX | SECURE);
1321 EXPECT_TRUE(SendOffer()); 1353 EXPECT_TRUE(SendOffer());
1322 EXPECT_TRUE(SendProvisionalAnswer()); 1354 EXPECT_TRUE(SendProvisionalAnswer());
1323 EXPECT_TRUE(channel1_->secure()); 1355 EXPECT_TRUE(channel1_->secure());
1324 EXPECT_TRUE(channel2_->secure()); 1356 EXPECT_TRUE(channel2_->secure());
1357 ASSERT_TRUE(GetTransport1());
1358 ASSERT_TRUE(GetTransport2());
1325 EXPECT_EQ(2U, GetTransport1()->channels().size()); 1359 EXPECT_EQ(2U, GetTransport1()->channels().size());
1326 EXPECT_EQ(2U, GetTransport2()->channels().size()); 1360 EXPECT_EQ(2U, GetTransport2()->channels().size());
1327 EXPECT_TRUE(SendCustomRtcp1(kSsrc1)); 1361 EXPECT_TRUE(SendCustomRtcp1(kSsrc1));
1328 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1)); 1362 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1));
1329 EXPECT_TRUE(SendCustomRtp1(kSsrc1, ++sequence_number1_1)); 1363 EXPECT_TRUE(SendCustomRtp1(kSsrc1, ++sequence_number1_1));
1330 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1)); 1364 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1));
1331 1365
1332 // Send packets from callee and verify that it is received. 1366 // Send packets from callee and verify that it is received.
1333 EXPECT_TRUE(SendCustomRtcp2(kSsrc2)); 1367 EXPECT_TRUE(SendCustomRtcp2(kSsrc2));
1334 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2)); 1368 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2));
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 EXPECT_TRUE(CheckNoRtcp1()); 1432 EXPECT_TRUE(CheckNoRtcp1());
1399 EXPECT_TRUE(CheckNoRtcp2()); 1433 EXPECT_TRUE(CheckNoRtcp2());
1400 } 1434 }
1401 1435
1402 // Test that the mediachannel retains its sending state after the transport 1436 // Test that the mediachannel retains its sending state after the transport
1403 // becomes non-writable. 1437 // becomes non-writable.
1404 void SendWithWritabilityLoss() { 1438 void SendWithWritabilityLoss() {
1405 CreateChannels(0, 0); 1439 CreateChannels(0, 0);
1406 EXPECT_TRUE(SendInitiate()); 1440 EXPECT_TRUE(SendInitiate());
1407 EXPECT_TRUE(SendAccept()); 1441 EXPECT_TRUE(SendAccept());
1442 ASSERT_TRUE(GetTransport1());
1443 ASSERT_TRUE(GetTransport2());
1408 EXPECT_EQ(1U, GetTransport1()->channels().size()); 1444 EXPECT_EQ(1U, GetTransport1()->channels().size());
1409 EXPECT_EQ(1U, GetTransport2()->channels().size()); 1445 EXPECT_EQ(1U, GetTransport2()->channels().size());
1410 EXPECT_TRUE(SendRtp1()); 1446 EXPECT_TRUE(SendRtp1());
1411 EXPECT_TRUE(SendRtp2()); 1447 EXPECT_TRUE(SendRtp2());
1412 EXPECT_TRUE(CheckRtp1()); 1448 EXPECT_TRUE(CheckRtp1());
1413 EXPECT_TRUE(CheckRtp2()); 1449 EXPECT_TRUE(CheckRtp2());
1414 EXPECT_TRUE(CheckNoRtp1()); 1450 EXPECT_TRUE(CheckNoRtp1());
1415 EXPECT_TRUE(CheckNoRtp2()); 1451 EXPECT_TRUE(CheckNoRtp2());
1416 1452
1417 // Lose writability, which should fail. 1453 // Lose writability, which should fail.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 int pl_type2 = pl_types[1]; 1498 int pl_type2 = pl_types[1];
1463 int flags = SSRC_MUX | RTCP; 1499 int flags = SSRC_MUX | RTCP;
1464 if (secure) flags |= SECURE; 1500 if (secure) flags |= SECURE;
1465 uint32 expected_channels = 2U; 1501 uint32 expected_channels = 2U;
1466 if (rtcp_mux) { 1502 if (rtcp_mux) {
1467 flags |= RTCP_MUX; 1503 flags |= RTCP_MUX;
1468 expected_channels = 1U; 1504 expected_channels = 1U;
1469 } 1505 }
1470 CreateChannels(flags, flags); 1506 CreateChannels(flags, flags);
1471 EXPECT_TRUE(SendInitiate()); 1507 EXPECT_TRUE(SendInitiate());
1508 ASSERT_TRUE(GetTransport1());
1509 ASSERT_TRUE(GetTransport2());
1472 EXPECT_EQ(2U, GetTransport1()->channels().size()); 1510 EXPECT_EQ(2U, GetTransport1()->channels().size());
1473 EXPECT_EQ(expected_channels, GetTransport2()->channels().size()); 1511 EXPECT_EQ(expected_channels, GetTransport2()->channels().size());
1474 EXPECT_TRUE(SendAccept()); 1512 EXPECT_TRUE(SendAccept());
1475 EXPECT_EQ(expected_channels, GetTransport1()->channels().size()); 1513 EXPECT_EQ(expected_channels, GetTransport1()->channels().size());
1476 EXPECT_EQ(expected_channels, GetTransport2()->channels().size()); 1514 EXPECT_EQ(expected_channels, GetTransport2()->channels().size());
1477 EXPECT_TRUE(channel1_->bundle_filter()->FindPayloadType(pl_type1)); 1515 EXPECT_TRUE(channel1_->bundle_filter()->FindPayloadType(pl_type1));
1478 EXPECT_TRUE(channel2_->bundle_filter()->FindPayloadType(pl_type1)); 1516 EXPECT_TRUE(channel2_->bundle_filter()->FindPayloadType(pl_type1));
1479 EXPECT_FALSE(channel1_->bundle_filter()->FindPayloadType(pl_type2)); 1517 EXPECT_FALSE(channel1_->bundle_filter()->FindPayloadType(pl_type2));
1480 EXPECT_FALSE(channel2_->bundle_filter()->FindPayloadType(pl_type2)); 1518 EXPECT_FALSE(channel2_->bundle_filter()->FindPayloadType(pl_type2));
1481 // channel1 - should only have media_content2 as remote. i.e. kSsrc2 1519 // channel1 - should only have media_content2 as remote. i.e. kSsrc2
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1650 EXPECT_FALSE(media_channel1_->HasRecvStream(2)); 1688 EXPECT_FALSE(media_channel1_->HasRecvStream(2));
1651 EXPECT_TRUE(media_channel1_->HasRecvStream(3)); 1689 EXPECT_TRUE(media_channel1_->HasRecvStream(3));
1652 } 1690 }
1653 1691
1654 void TestFlushRtcp() { 1692 void TestFlushRtcp() {
1655 bool send_rtcp1; 1693 bool send_rtcp1;
1656 1694
1657 CreateChannels(RTCP, RTCP); 1695 CreateChannels(RTCP, RTCP);
1658 EXPECT_TRUE(SendInitiate()); 1696 EXPECT_TRUE(SendInitiate());
1659 EXPECT_TRUE(SendAccept()); 1697 EXPECT_TRUE(SendAccept());
1698 ASSERT_TRUE(GetTransport1());
1699 ASSERT_TRUE(GetTransport2());
1660 EXPECT_EQ(2U, GetTransport1()->channels().size()); 1700 EXPECT_EQ(2U, GetTransport1()->channels().size());
1661 EXPECT_EQ(2U, GetTransport2()->channels().size()); 1701 EXPECT_EQ(2U, GetTransport2()->channels().size());
1662 1702
1663 // Send RTCP1 from a different thread. 1703 // Send RTCP1 from a different thread.
1664 CallOnThreadAndWaitForDone(&ChannelTest<T>::SendRtcp1, &send_rtcp1); 1704 CallOnThreadAndWaitForDone(&ChannelTest<T>::SendRtcp1, &send_rtcp1);
1665 EXPECT_TRUE(send_rtcp1); 1705 EXPECT_TRUE(send_rtcp1);
1666 // The sending message is only posted. channel2_ should be empty. 1706 // The sending message is only posted. channel2_ should be empty.
1667 EXPECT_TRUE(CheckNoRtcp2()); 1707 EXPECT_TRUE(CheckNoRtcp2());
1668 1708
1669 // When channel1_ is deleted, the RTCP packet should be sent out to 1709 // When channel1_ is deleted, the RTCP packet should be sent out to
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1770 EXPECT_FALSE(media_channel1_->ready_to_send()); 1810 EXPECT_FALSE(media_channel1_->ready_to_send());
1771 // In the case of rtcp mux, the SignalReadyToSend() from rtp channel 1811 // In the case of rtcp mux, the SignalReadyToSend() from rtp channel
1772 // should trigger the MediaChannel's OnReadyToSend. 1812 // should trigger the MediaChannel's OnReadyToSend.
1773 rtp->SignalReadyToSend(rtp); 1813 rtp->SignalReadyToSend(rtp);
1774 EXPECT_TRUE(media_channel1_->ready_to_send()); 1814 EXPECT_TRUE(media_channel1_->ready_to_send());
1775 channel1_->SetReadyToSend(rtp, false); 1815 channel1_->SetReadyToSend(rtp, false);
1776 EXPECT_FALSE(media_channel1_->ready_to_send()); 1816 EXPECT_FALSE(media_channel1_->ready_to_send());
1777 } 1817 }
1778 1818
1779 protected: 1819 protected:
1780 cricket::FakeSession session1_; 1820 cricket::FakeTransportController transport_controller1_;
1781 cricket::FakeSession session2_; 1821 cricket::FakeTransportController transport_controller2_;
1782 cricket::FakeMediaEngine media_engine_; 1822 cricket::FakeMediaEngine media_engine_;
1783 // The media channels are owned by the voice channel objects below. 1823 // The media channels are owned by the voice channel objects below.
1784 typename T::MediaChannel* media_channel1_; 1824 typename T::MediaChannel* media_channel1_;
1785 typename T::MediaChannel* media_channel2_; 1825 typename T::MediaChannel* media_channel2_;
1786 rtc::scoped_ptr<typename T::Channel> channel1_; 1826 rtc::scoped_ptr<typename T::Channel> channel1_;
1787 rtc::scoped_ptr<typename T::Channel> channel2_; 1827 rtc::scoped_ptr<typename T::Channel> channel2_;
1788 typename T::Content local_media_content1_; 1828 typename T::Content local_media_content1_;
1789 typename T::Content local_media_content2_; 1829 typename T::Content local_media_content2_;
1790 typename T::Content remote_media_content1_; 1830 typename T::Content remote_media_content1_;
1791 typename T::Content remote_media_content2_; 1831 typename T::Content remote_media_content2_;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1869 ASSERT_TRUE(media_channel1_->GetOptions(&actual_options)); 1909 ASSERT_TRUE(media_channel1_->GetOptions(&actual_options));
1870 EXPECT_EQ(options2, actual_options); 1910 EXPECT_EQ(options2, actual_options);
1871 ASSERT_TRUE(media_channel2_->GetOptions(&actual_options)); 1911 ASSERT_TRUE(media_channel2_->GetOptions(&actual_options));
1872 EXPECT_EQ(options2, actual_options); 1912 EXPECT_EQ(options2, actual_options);
1873 } 1913 }
1874 }; 1914 };
1875 1915
1876 // override to add NULL parameter 1916 // override to add NULL parameter
1877 template<> 1917 template<>
1878 cricket::VideoChannel* ChannelTest<VideoTraits>::CreateChannel( 1918 cricket::VideoChannel* ChannelTest<VideoTraits>::CreateChannel(
1879 rtc::Thread* thread, cricket::MediaEngineInterface* engine, 1919 rtc::Thread* thread,
1880 cricket::FakeVideoMediaChannel* ch, cricket::BaseSession* session, 1920 cricket::MediaEngineInterface* engine,
1921 cricket::FakeVideoMediaChannel* ch,
1922 cricket::TransportController* transport_controller,
1881 bool rtcp) { 1923 bool rtcp) {
1882 cricket::VideoChannel* channel = new cricket::VideoChannel( 1924 cricket::VideoChannel* channel = new cricket::VideoChannel(
1883 thread, ch, session, cricket::CN_VIDEO, rtcp); 1925 thread, ch, transport_controller, cricket::CN_VIDEO, rtcp);
1884 if (!channel->Init()) { 1926 if (!channel->Init()) {
1885 delete channel; 1927 delete channel;
1886 channel = NULL; 1928 channel = NULL;
1887 } 1929 }
1888 return channel; 1930 return channel;
1889 } 1931 }
1890 1932
1891 // override to add 0 parameter 1933 // override to add 0 parameter
1892 template<> 1934 template<>
1893 bool ChannelTest<VideoTraits>::AddStream1(int id) { 1935 bool ChannelTest<VideoTraits>::AddStream1(int id) {
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
2684 typedef ChannelTest<DataTraits> 2726 typedef ChannelTest<DataTraits>
2685 Base; 2727 Base;
2686 DataChannelTest() : Base(kDataPacket, sizeof(kDataPacket), 2728 DataChannelTest() : Base(kDataPacket, sizeof(kDataPacket),
2687 kRtcpReport, sizeof(kRtcpReport)) { 2729 kRtcpReport, sizeof(kRtcpReport)) {
2688 } 2730 }
2689 }; 2731 };
2690 2732
2691 // Override to avoid engine channel parameter. 2733 // Override to avoid engine channel parameter.
2692 template<> 2734 template<>
2693 cricket::DataChannel* ChannelTest<DataTraits>::CreateChannel( 2735 cricket::DataChannel* ChannelTest<DataTraits>::CreateChannel(
2694 rtc::Thread* thread, cricket::MediaEngineInterface* engine, 2736 rtc::Thread* thread,
2695 cricket::FakeDataMediaChannel* ch, cricket::BaseSession* session, 2737 cricket::MediaEngineInterface* engine,
2738 cricket::FakeDataMediaChannel* ch,
2739 cricket::TransportController* transport_controller,
2696 bool rtcp) { 2740 bool rtcp) {
2697 cricket::DataChannel* channel = new cricket::DataChannel( 2741 cricket::DataChannel* channel = new cricket::DataChannel(
2698 thread, ch, session, cricket::CN_DATA, rtcp); 2742 thread, ch, transport_controller, cricket::CN_DATA, rtcp);
2699 if (!channel->Init()) { 2743 if (!channel->Init()) {
2700 delete channel; 2744 delete channel;
2701 channel = NULL; 2745 channel = NULL;
2702 } 2746 }
2703 return channel; 2747 return channel;
2704 } 2748 }
2705 2749
2706 template<> 2750 template<>
2707 void ChannelTest<DataTraits>::CreateContent( 2751 void ChannelTest<DataTraits>::CreateContent(
2708 int flags, 2752 int flags,
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
2874 }; 2918 };
2875 rtc::Buffer payload(data, 3); 2919 rtc::Buffer payload(data, 3);
2876 cricket::SendDataResult result; 2920 cricket::SendDataResult result;
2877 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); 2921 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result));
2878 EXPECT_EQ(params.ssrc, 2922 EXPECT_EQ(params.ssrc,
2879 media_channel1_->last_sent_data_params().ssrc); 2923 media_channel1_->last_sent_data_params().ssrc);
2880 EXPECT_EQ("foo", media_channel1_->last_sent_data()); 2924 EXPECT_EQ("foo", media_channel1_->last_sent_data());
2881 } 2925 }
2882 2926
2883 // TODO(pthatcher): TestSetReceiver? 2927 // TODO(pthatcher): TestSetReceiver?
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698