blob: 5de3c945558fabd40402021529697d07f34b66c4 [file] [log] [blame]
jlmiller@webrtc.org5f93d0a2015-01-20 21:36:13 +00001/*
kjellander65c7f672016-02-12 00:05:01 -08002 * Copyright 2009 The WebRTC project authors. All Rights Reserved.
jlmiller@webrtc.org5f93d0a2015-01-20 21:36:13 +00003 *
kjellander65c7f672016-02-12 00:05:01 -08004 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
jlmiller@webrtc.org5f93d0a2015-01-20 21:36:13 +00009 */
henrike@webrtc.org28e20752013-07-10 00:45:36 +000010
kwiberg31022942016-03-11 14:18:21 -080011#include <memory>
12
Danil Chapovalov33b01f22016-05-11 19:55:27 +020013#include "webrtc/base/array_view.h"
14#include "webrtc/base/buffer.h"
Taylor Brandstetter88532892016-08-01 14:17:27 -070015#include "webrtc/base/fakeclock.h"
buildbot@webrtc.org65b98d12014-08-07 22:09:08 +000016#include "webrtc/base/gunit.h"
buildbot@webrtc.org65b98d12014-08-07 22:09:08 +000017#include "webrtc/base/logging.h"
jbauchcb560652016-08-04 05:20:32 -070018#include "webrtc/base/sslstreamadapter.h"
kjellandera96e2d72016-02-04 23:52:28 -080019#include "webrtc/media/base/fakemediaengine.h"
20#include "webrtc/media/base/fakertp.h"
kjellandera96e2d72016-02-04 23:52:28 -080021#include "webrtc/media/base/mediachannel.h"
kjellandera96e2d72016-02-04 23:52:28 -080022#include "webrtc/media/base/testutils.h"
Tommif888bb52015-12-12 01:37:01 +010023#include "webrtc/p2p/base/faketransportcontroller.h"
deadbeef49f34fd2016-12-06 16:22:06 -080024#include "webrtc/p2p/base/transportchannelimpl.h"
kjellander@webrtc.org9b8df252016-02-12 06:47:59 +010025#include "webrtc/pc/channel.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000026
27#define MAYBE_SKIP_TEST(feature) \
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000028 if (!(rtc::SSLStreamAdapter::feature())) { \
henrike@webrtc.org28e20752013-07-10 00:45:36 +000029 LOG(LS_INFO) << "Feature disabled... skipping"; \
30 return; \
31 }
32
33using cricket::CA_OFFER;
34using cricket::CA_PRANSWER;
35using cricket::CA_ANSWER;
36using cricket::CA_UPDATE;
37using cricket::FakeVoiceMediaChannel;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000038using cricket::StreamParams;
39using cricket::TransportChannel;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000040
Danil Chapovalov33b01f22016-05-11 19:55:27 +020041namespace {
42const cricket::AudioCodec kPcmuCodec(0, "PCMU", 64000, 8000, 1);
43const cricket::AudioCodec kPcmaCodec(8, "PCMA", 64000, 8000, 1);
44const cricket::AudioCodec kIsacCodec(103, "ISAC", 40000, 16000, 1);
perkj26752742016-10-24 01:21:16 -070045const cricket::VideoCodec kH264Codec(97, "H264");
46const cricket::VideoCodec kH264SvcCodec(99, "H264-SVC");
Danil Chapovalov33b01f22016-05-11 19:55:27 +020047const cricket::DataCodec kGoogleDataCodec(101, "google-data");
48const uint32_t kSsrc1 = 0x1111;
49const uint32_t kSsrc2 = 0x2222;
50const uint32_t kSsrc3 = 0x3333;
51const int kAudioPts[] = {0, 8};
52const int kVideoPts[] = {97, 99};
53enum class NetworkIsWorker { Yes, No };
deadbeefc6b6e092016-12-01 12:49:20 -080054const int kDefaultTimeout = 10000; // 10 seconds.
Danil Chapovalov33b01f22016-05-11 19:55:27 +020055} // namespace
henrike@webrtc.org28e20752013-07-10 00:45:36 +000056
deadbeefcbecd352015-09-23 11:50:27 -070057template <class ChannelT,
58 class MediaChannelT,
59 class ContentT,
60 class CodecT,
61 class MediaInfoT,
62 class OptionsT>
henrike@webrtc.org28e20752013-07-10 00:45:36 +000063class Traits {
64 public:
65 typedef ChannelT Channel;
66 typedef MediaChannelT MediaChannel;
67 typedef ContentT Content;
68 typedef CodecT Codec;
69 typedef MediaInfoT MediaInfo;
Fredrik Solenbergb071a192015-09-17 16:42:56 +020070 typedef OptionsT Options;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000071};
72
henrike@webrtc.org28e20752013-07-10 00:45:36 +000073class VoiceTraits : public Traits<cricket::VoiceChannel,
74 cricket::FakeVoiceMediaChannel,
75 cricket::AudioContentDescription,
76 cricket::AudioCodec,
Fredrik Solenbergb071a192015-09-17 16:42:56 +020077 cricket::VoiceMediaInfo,
deadbeefcbecd352015-09-23 11:50:27 -070078 cricket::AudioOptions> {};
henrike@webrtc.org28e20752013-07-10 00:45:36 +000079
80class VideoTraits : public Traits<cricket::VideoChannel,
81 cricket::FakeVideoMediaChannel,
82 cricket::VideoContentDescription,
83 cricket::VideoCodec,
Fredrik Solenbergb071a192015-09-17 16:42:56 +020084 cricket::VideoMediaInfo,
deadbeefcbecd352015-09-23 11:50:27 -070085 cricket::VideoOptions> {};
henrike@webrtc.org28e20752013-07-10 00:45:36 +000086
deadbeefc0dad892017-01-04 20:28:21 -080087class DataTraits : public Traits<cricket::DataChannel,
henrike@webrtc.org28e20752013-07-10 00:45:36 +000088 cricket::FakeDataMediaChannel,
89 cricket::DataContentDescription,
90 cricket::DataCodec,
Fredrik Solenbergb071a192015-09-17 16:42:56 +020091 cricket::DataMediaInfo,
deadbeefcbecd352015-09-23 11:50:27 -070092 cricket::DataOptions> {};
henrike@webrtc.org28e20752013-07-10 00:45:36 +000093
deadbeefc0dad892017-01-04 20:28:21 -080094// Base class for Voice/Video/DataChannel tests
henrike@webrtc.org28e20752013-07-10 00:45:36 +000095template<class T>
96class ChannelTest : public testing::Test, public sigslot::has_slots<> {
97 public:
98 enum Flags { RTCP = 0x1, RTCP_MUX = 0x2, SECURE = 0x4, SSRC_MUX = 0x8,
jbauchcb560652016-08-04 05:20:32 -070099 DTLS = 0x10, GCM_CIPHER = 0x20 };
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000100
Peter Boström34fbfff2015-09-24 19:20:30 +0200101 ChannelTest(bool verify_playout,
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200102 rtc::ArrayView<const uint8_t> rtp_data,
103 rtc::ArrayView<const uint8_t> rtcp_data,
104 NetworkIsWorker network_is_worker)
Peter Boström34fbfff2015-09-24 19:20:30 +0200105 : verify_playout_(verify_playout),
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000106 media_channel1_(NULL),
107 media_channel2_(NULL),
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200108 rtp_packet_(rtp_data.data(), rtp_data.size()),
109 rtcp_packet_(rtcp_data.data(), rtcp_data.size()),
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000110 media_info_callbacks1_(),
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200111 media_info_callbacks2_() {
112 if (network_is_worker == NetworkIsWorker::Yes) {
113 network_thread_ = rtc::Thread::Current();
114 } else {
115 network_thread_keeper_ = rtc::Thread::Create();
116 network_thread_keeper_->SetName("Network", nullptr);
117 network_thread_keeper_->Start();
118 network_thread_ = network_thread_keeper_.get();
119 }
120 transport_controller1_.reset(new cricket::FakeTransportController(
121 network_thread_, cricket::ICEROLE_CONTROLLING));
122 transport_controller2_.reset(new cricket::FakeTransportController(
123 network_thread_, cricket::ICEROLE_CONTROLLED));
124 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000125
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000126 void CreateChannels(int flags1, int flags2) {
Fredrik Solenbergb071a192015-09-17 16:42:56 +0200127 CreateChannels(new typename T::MediaChannel(NULL, typename T::Options()),
128 new typename T::MediaChannel(NULL, typename T::Options()),
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200129 flags1, flags2);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000130 }
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200131 void CreateChannels(typename T::MediaChannel* ch1,
132 typename T::MediaChannel* ch2,
133 int flags1,
134 int flags2) {
135 rtc::Thread* worker_thread = rtc::Thread::Current();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000136 media_channel1_ = ch1;
137 media_channel2_ = ch2;
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200138 channel1_.reset(
139 CreateChannel(worker_thread, network_thread_, &media_engine_, ch1,
jbauchcb560652016-08-04 05:20:32 -0700140 transport_controller1_.get(), flags1));
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200141 channel2_.reset(
142 CreateChannel(worker_thread, network_thread_, &media_engine_, ch2,
jbauchcb560652016-08-04 05:20:32 -0700143 transport_controller2_.get(), flags2));
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200144 channel1_->SignalMediaMonitor.connect(this,
145 &ChannelTest<T>::OnMediaMonitor1);
146 channel2_->SignalMediaMonitor.connect(this,
147 &ChannelTest<T>::OnMediaMonitor2);
mallinath@webrtc.org19f27e62013-10-13 17:18:27 +0000148 if ((flags1 & DTLS) && (flags2 & DTLS)) {
149 flags1 = (flags1 & ~SECURE);
150 flags2 = (flags2 & ~SECURE);
151 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000152 CreateContent(flags1, kPcmuCodec, kH264Codec,
153 &local_media_content1_);
154 CreateContent(flags2, kPcmuCodec, kH264Codec,
155 &local_media_content2_);
156 CopyContent(local_media_content1_, &remote_media_content1_);
157 CopyContent(local_media_content2_, &remote_media_content2_);
158
159 if (flags1 & DTLS) {
Torbjorn Granlundb6d4ec42015-08-17 14:08:59 +0200160 // Confirmed to work with KT_RSA and KT_ECDSA.
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200161 transport_controller1_->SetLocalCertificate(
jbauch555604a2016-04-26 03:13:22 -0700162 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>(
kwiberg0eb15ed2015-12-17 03:04:15 -0800163 rtc::SSLIdentity::Generate("session1", rtc::KT_DEFAULT))));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000164 }
165 if (flags2 & DTLS) {
Torbjorn Granlundb6d4ec42015-08-17 14:08:59 +0200166 // Confirmed to work with KT_RSA and KT_ECDSA.
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200167 transport_controller2_->SetLocalCertificate(
jbauch555604a2016-04-26 03:13:22 -0700168 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>(
kwiberg0eb15ed2015-12-17 03:04:15 -0800169 rtc::SSLIdentity::Generate("session2", rtc::KT_DEFAULT))));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000170 }
171
172 // Add stream information (SSRC) to the local content but not to the remote
173 // content. This means that we per default know the SSRC of what we send but
174 // not what we receive.
175 AddLegacyStreamInContent(kSsrc1, flags1, &local_media_content1_);
176 AddLegacyStreamInContent(kSsrc2, flags2, &local_media_content2_);
177
178 // If SSRC_MUX is used we also need to know the SSRC of the incoming stream.
179 if (flags1 & SSRC_MUX) {
180 AddLegacyStreamInContent(kSsrc1, flags1, &remote_media_content1_);
181 }
182 if (flags2 & SSRC_MUX) {
183 AddLegacyStreamInContent(kSsrc2, flags2, &remote_media_content2_);
184 }
185 }
deadbeefcbecd352015-09-23 11:50:27 -0700186 typename T::Channel* CreateChannel(
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200187 rtc::Thread* worker_thread,
188 rtc::Thread* network_thread,
deadbeefcbecd352015-09-23 11:50:27 -0700189 cricket::MediaEngineInterface* engine,
190 typename T::MediaChannel* ch,
191 cricket::TransportController* transport_controller,
jbauchcb560652016-08-04 05:20:32 -0700192 int flags) {
deadbeef7af91dd2016-12-13 11:29:11 -0800193 typename T::Channel* channel = new typename T::Channel(
194 worker_thread, network_thread, engine, ch, transport_controller,
195 cricket::CN_AUDIO, (flags & RTCP) != 0, (flags & SECURE) != 0);
jbauchcb560652016-08-04 05:20:32 -0700196 rtc::CryptoOptions crypto_options;
197 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0;
198 channel->SetCryptoOptions(crypto_options);
skvlad6c87a672016-05-17 17:49:52 -0700199 if (!channel->Init_w(nullptr)) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000200 delete channel;
201 channel = NULL;
202 }
203 return channel;
204 }
205
206 bool SendInitiate() {
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000207 bool result = channel1_->SetLocalContent(&local_media_content1_,
208 CA_OFFER, NULL);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000209 if (result) {
210 channel1_->Enable(true);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000211 result = channel2_->SetRemoteContent(&remote_media_content1_,
212 CA_OFFER, NULL);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000213 if (result) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200214 transport_controller1_->Connect(transport_controller2_.get());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000215
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000216 result = channel2_->SetLocalContent(&local_media_content2_,
217 CA_ANSWER, NULL);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000218 }
219 }
220 return result;
221 }
222
223 bool SendAccept() {
224 channel2_->Enable(true);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000225 return channel1_->SetRemoteContent(&remote_media_content2_,
226 CA_ANSWER, NULL);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000227 }
228
229 bool SendOffer() {
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000230 bool result = channel1_->SetLocalContent(&local_media_content1_,
231 CA_OFFER, NULL);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000232 if (result) {
233 channel1_->Enable(true);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000234 result = channel2_->SetRemoteContent(&remote_media_content1_,
235 CA_OFFER, NULL);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000236 }
237 return result;
238 }
239
240 bool SendProvisionalAnswer() {
241 bool result = channel2_->SetLocalContent(&local_media_content2_,
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000242 CA_PRANSWER, NULL);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000243 if (result) {
244 channel2_->Enable(true);
245 result = channel1_->SetRemoteContent(&remote_media_content2_,
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000246 CA_PRANSWER, NULL);
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200247 transport_controller1_->Connect(transport_controller2_.get());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000248 }
249 return result;
250 }
251
252 bool SendFinalAnswer() {
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000253 bool result = channel2_->SetLocalContent(&local_media_content2_,
254 CA_ANSWER, NULL);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000255 if (result)
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000256 result = channel1_->SetRemoteContent(&remote_media_content2_,
257 CA_ANSWER, NULL);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000258 return result;
259 }
260
261 bool SendTerminate() {
262 channel1_.reset();
263 channel2_.reset();
264 return true;
265 }
266
267 bool AddStream1(int id) {
268 return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id));
269 }
270 bool RemoveStream1(int id) {
271 return channel1_->RemoveRecvStream(id);
272 }
273
deadbeef49f34fd2016-12-06 16:22:06 -0800274 std::vector<cricket::TransportChannelImpl*> GetChannels1() {
275 return transport_controller1_->channels_for_testing();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000276 }
deadbeef49f34fd2016-12-06 16:22:06 -0800277
278 std::vector<cricket::TransportChannelImpl*> GetChannels2() {
279 return transport_controller2_->channels_for_testing();
280 }
281
282 cricket::FakeTransportChannel* GetFakeChannel1(int component) {
283 return transport_controller1_->GetFakeTransportChannel_n(
284 channel1_->content_name(), component);
285 }
286
287 cricket::FakeTransportChannel* GetFakeChannel2(int component) {
288 return transport_controller2_->GetFakeTransportChannel_n(
289 channel2_->content_name(), component);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000290 }
291
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200292 void SendRtp1() {
293 media_channel1_->SendRtp(rtp_packet_.data(), rtp_packet_.size(),
294 rtc::PacketOptions());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000295 }
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200296 void SendRtp2() {
297 media_channel2_->SendRtp(rtp_packet_.data(), rtp_packet_.size(),
298 rtc::PacketOptions());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000299 }
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200300 void SendRtcp1() {
301 media_channel1_->SendRtcp(rtcp_packet_.data(), rtcp_packet_.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000302 }
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200303 void SendRtcp2() {
304 media_channel2_->SendRtcp(rtcp_packet_.data(), rtcp_packet_.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000305 }
306 // Methods to send custom data.
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200307 void SendCustomRtp1(uint32_t ssrc, int sequence_number, int pl_type = -1) {
308 rtc::Buffer data = CreateRtpData(ssrc, sequence_number, pl_type);
309 media_channel1_->SendRtp(data.data(), data.size(), rtc::PacketOptions());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000310 }
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200311 void SendCustomRtp2(uint32_t ssrc, int sequence_number, int pl_type = -1) {
312 rtc::Buffer data = CreateRtpData(ssrc, sequence_number, pl_type);
313 media_channel2_->SendRtp(data.data(), data.size(), rtc::PacketOptions());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000314 }
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200315 void SendCustomRtcp1(uint32_t ssrc) {
316 rtc::Buffer data = CreateRtcpData(ssrc);
317 media_channel1_->SendRtcp(data.data(), data.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000318 }
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200319 void SendCustomRtcp2(uint32_t ssrc) {
320 rtc::Buffer data = CreateRtcpData(ssrc);
321 media_channel2_->SendRtcp(data.data(), data.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000322 }
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200323
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000324 bool CheckRtp1() {
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200325 return media_channel1_->CheckRtp(rtp_packet_.data(), rtp_packet_.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000326 }
327 bool CheckRtp2() {
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200328 return media_channel2_->CheckRtp(rtp_packet_.data(), rtp_packet_.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000329 }
330 bool CheckRtcp1() {
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200331 return media_channel1_->CheckRtcp(rtcp_packet_.data(), rtcp_packet_.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000332 }
333 bool CheckRtcp2() {
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200334 return media_channel2_->CheckRtcp(rtcp_packet_.data(), rtcp_packet_.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000335 }
336 // Methods to check custom data.
Peter Boström0c4e06b2015-10-07 12:23:21 +0200337 bool CheckCustomRtp1(uint32_t ssrc, int sequence_number, int pl_type = -1) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200338 rtc::Buffer data = CreateRtpData(ssrc, sequence_number, pl_type);
339 return media_channel1_->CheckRtp(data.data(), data.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000340 }
Peter Boström0c4e06b2015-10-07 12:23:21 +0200341 bool CheckCustomRtp2(uint32_t ssrc, int sequence_number, int pl_type = -1) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200342 rtc::Buffer data = CreateRtpData(ssrc, sequence_number, pl_type);
343 return media_channel2_->CheckRtp(data.data(), data.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000344 }
Peter Boström0c4e06b2015-10-07 12:23:21 +0200345 bool CheckCustomRtcp1(uint32_t ssrc) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200346 rtc::Buffer data = CreateRtcpData(ssrc);
347 return media_channel1_->CheckRtcp(data.data(), data.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000348 }
Peter Boström0c4e06b2015-10-07 12:23:21 +0200349 bool CheckCustomRtcp2(uint32_t ssrc) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200350 rtc::Buffer data = CreateRtcpData(ssrc);
351 return media_channel2_->CheckRtcp(data.data(), data.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000352 }
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200353 rtc::Buffer CreateRtpData(uint32_t ssrc, int sequence_number, int pl_type) {
354 rtc::Buffer data(rtp_packet_.data(), rtp_packet_.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000355 // Set SSRC in the rtp packet copy.
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200356 rtc::SetBE32(data.data() + 8, ssrc);
357 rtc::SetBE16(data.data() + 2, sequence_number);
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +0000358 if (pl_type >= 0) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200359 rtc::Set8(data.data(), 1, static_cast<uint8_t>(pl_type));
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +0000360 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000361 return data;
362 }
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200363 rtc::Buffer CreateRtcpData(uint32_t ssrc) {
364 rtc::Buffer data(rtcp_packet_.data(), rtcp_packet_.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000365 // Set SSRC in the rtcp packet copy.
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200366 rtc::SetBE32(data.data() + 4, ssrc);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000367 return data;
368 }
369
370 bool CheckNoRtp1() {
371 return media_channel1_->CheckNoRtp();
372 }
373 bool CheckNoRtp2() {
374 return media_channel2_->CheckNoRtp();
375 }
376 bool CheckNoRtcp1() {
377 return media_channel1_->CheckNoRtcp();
378 }
379 bool CheckNoRtcp2() {
380 return media_channel2_->CheckNoRtcp();
381 }
jbauchcb560652016-08-04 05:20:32 -0700382 // Checks that the channel is using GCM iff GCM_CIPHER is set in flags.
383 // Returns true if so.
384 bool CheckGcmCipher(typename T::Channel* channel, int flags) {
385 int suite;
386 if (!channel->transport_channel()->GetSrtpCryptoSuite(&suite)) {
387 return false;
388 }
389
390 if (flags & GCM_CIPHER) {
391 return rtc::IsGcmCryptoSuite(suite);
392 } else {
393 return (suite != rtc::SRTP_INVALID_CRYPTO_SUITE &&
394 !rtc::IsGcmCryptoSuite(suite));
395 }
396 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000397
398 void CreateContent(int flags,
399 const cricket::AudioCodec& audio_codec,
400 const cricket::VideoCodec& video_codec,
401 typename T::Content* content) {
402 // overridden in specialized classes
403 }
404 void CopyContent(const typename T::Content& source,
405 typename T::Content* content) {
406 // overridden in specialized classes
407 }
408
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000409 // Creates a cricket::SessionDescription with one MediaContent and one stream.
410 // kPcmuCodec is used as audio codec and kH264Codec is used as video codec.
Peter Boström0c4e06b2015-10-07 12:23:21 +0200411 cricket::SessionDescription* CreateSessionDescriptionWithStream(
412 uint32_t ssrc) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000413 typename T::Content content;
414 cricket::SessionDescription* sdesc = new cricket::SessionDescription();
415 CreateContent(SECURE, kPcmuCodec, kH264Codec, &content);
416 AddLegacyStreamInContent(ssrc, 0, &content);
417 sdesc->AddContent("DUMMY_CONTENT_NAME",
418 cricket::NS_JINGLE_RTP, content.Copy());
419 return sdesc;
420 }
421
ossu292d6582016-03-17 02:31:13 -0700422 // Will manage the lifetime of a CallThread, making sure it's
423 // destroyed before this object goes out of scope.
424 class ScopedCallThread {
425 public:
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200426 template <class FunctorT>
427 ScopedCallThread(const FunctorT& functor)
428 : thread_(rtc::Thread::Create()),
429 task_(new rtc::FunctorMessageHandler<void, FunctorT>(functor)) {
ossu292d6582016-03-17 02:31:13 -0700430 thread_->Start();
Taylor Brandstetter5d97a9a2016-06-10 14:17:27 -0700431 thread_->Post(RTC_FROM_HERE, task_.get());
ossu292d6582016-03-17 02:31:13 -0700432 }
433
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200434 ~ScopedCallThread() { thread_->Stop(); }
ossu292d6582016-03-17 02:31:13 -0700435
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200436 rtc::Thread* thread() { return thread_.get(); }
ossu292d6582016-03-17 02:31:13 -0700437
438 private:
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200439 std::unique_ptr<rtc::Thread> thread_;
440 std::unique_ptr<rtc::MessageHandler> task_;
ossu292d6582016-03-17 02:31:13 -0700441 };
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000442
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000443 bool CodecMatches(const typename T::Codec& c1, const typename T::Codec& c2) {
444 return false; // overridden in specialized classes
445 }
446
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200447 void OnMediaMonitor1(typename T::Channel* channel,
448 const typename T::MediaInfo& info) {
449 RTC_DCHECK_EQ(channel, channel1_.get());
450 media_info_callbacks1_++;
451 }
452 void OnMediaMonitor2(typename T::Channel* channel,
453 const typename T::MediaInfo& info) {
454 RTC_DCHECK_EQ(channel, channel2_.get());
455 media_info_callbacks2_++;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000456 }
457
Honghai Zhangcc411c02016-03-29 17:27:21 -0700458 cricket::CandidatePairInterface* last_selected_candidate_pair() {
459 return last_selected_candidate_pair_;
460 }
461
Peter Boström0c4e06b2015-10-07 12:23:21 +0200462 void AddLegacyStreamInContent(uint32_t ssrc,
463 int flags,
464 typename T::Content* content) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000465 // Base implementation.
466 }
467
468 // Tests that can be used by derived classes.
469
470 // Basic sanity check.
471 void TestInit() {
472 CreateChannels(0, 0);
473 EXPECT_FALSE(channel1_->secure());
474 EXPECT_FALSE(media_channel1_->sending());
Peter Boström34fbfff2015-09-24 19:20:30 +0200475 if (verify_playout_) {
476 EXPECT_FALSE(media_channel1_->playout());
477 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000478 EXPECT_TRUE(media_channel1_->codecs().empty());
479 EXPECT_TRUE(media_channel1_->recv_streams().empty());
480 EXPECT_TRUE(media_channel1_->rtp_packets().empty());
481 EXPECT_TRUE(media_channel1_->rtcp_packets().empty());
482 }
483
484 // Test that SetLocalContent and SetRemoteContent properly configure
485 // the codecs.
486 void TestSetContents() {
487 CreateChannels(0, 0);
488 typename T::Content content;
489 CreateContent(0, kPcmuCodec, kH264Codec, &content);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000490 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000491 EXPECT_EQ(0U, media_channel1_->codecs().size());
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000492 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000493 ASSERT_EQ(1U, media_channel1_->codecs().size());
494 EXPECT_TRUE(CodecMatches(content.codecs()[0],
495 media_channel1_->codecs()[0]));
496 }
497
498 // Test that SetLocalContent and SetRemoteContent properly deals
499 // with an empty offer.
500 void TestSetContentsNullOffer() {
501 CreateChannels(0, 0);
502 typename T::Content content;
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000503 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000504 CreateContent(0, kPcmuCodec, kH264Codec, &content);
505 EXPECT_EQ(0U, media_channel1_->codecs().size());
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000506 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000507 ASSERT_EQ(1U, media_channel1_->codecs().size());
508 EXPECT_TRUE(CodecMatches(content.codecs()[0],
509 media_channel1_->codecs()[0]));
510 }
511
512 // Test that SetLocalContent and SetRemoteContent properly set RTCP
513 // mux.
514 void TestSetContentsRtcpMux() {
515 CreateChannels(RTCP, RTCP);
516 EXPECT_TRUE(channel1_->rtcp_transport_channel() != NULL);
517 EXPECT_TRUE(channel2_->rtcp_transport_channel() != NULL);
518 typename T::Content content;
519 CreateContent(0, kPcmuCodec, kH264Codec, &content);
520 // Both sides agree on mux. Should no longer be a separate RTCP channel.
521 content.set_rtcp_mux(true);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000522 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL));
523 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000524 EXPECT_TRUE(channel1_->rtcp_transport_channel() == NULL);
525 // Only initiator supports mux. Should still have a separate RTCP channel.
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000526 EXPECT_TRUE(channel2_->SetLocalContent(&content, CA_OFFER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000527 content.set_rtcp_mux(false);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000528 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_ANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000529 EXPECT_TRUE(channel2_->rtcp_transport_channel() != NULL);
530 }
531
532 // Test that SetLocalContent and SetRemoteContent properly set RTCP
533 // mux when a provisional answer is received.
534 void TestSetContentsRtcpMuxWithPrAnswer() {
535 CreateChannels(RTCP, RTCP);
536 EXPECT_TRUE(channel1_->rtcp_transport_channel() != NULL);
537 EXPECT_TRUE(channel2_->rtcp_transport_channel() != NULL);
538 typename T::Content content;
539 CreateContent(0, kPcmuCodec, kH264Codec, &content);
540 content.set_rtcp_mux(true);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000541 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL));
542 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_PRANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000543 EXPECT_TRUE(channel1_->rtcp_transport_channel() != NULL);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000544 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000545 // Both sides agree on mux. Should no longer be a separate RTCP channel.
546 EXPECT_TRUE(channel1_->rtcp_transport_channel() == NULL);
547 // Only initiator supports mux. Should still have a separate RTCP channel.
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000548 EXPECT_TRUE(channel2_->SetLocalContent(&content, CA_OFFER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000549 content.set_rtcp_mux(false);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000550 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_PRANSWER, NULL));
551 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_ANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000552 EXPECT_TRUE(channel2_->rtcp_transport_channel() != NULL);
553 }
554
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000555 // Test that SetRemoteContent properly deals with a content update.
556 void TestSetRemoteContentUpdate() {
557 CreateChannels(0, 0);
558 typename T::Content content;
559 CreateContent(RTCP | RTCP_MUX | SECURE,
560 kPcmuCodec, kH264Codec,
561 &content);
562 EXPECT_EQ(0U, media_channel1_->codecs().size());
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000563 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL));
564 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000565 ASSERT_EQ(1U, media_channel1_->codecs().size());
566 EXPECT_TRUE(CodecMatches(content.codecs()[0],
567 media_channel1_->codecs()[0]));
568 // Now update with other codecs.
569 typename T::Content update_content;
570 update_content.set_partial(true);
571 CreateContent(0, kIsacCodec, kH264SvcCodec,
572 &update_content);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000573 EXPECT_TRUE(channel1_->SetRemoteContent(&update_content, CA_UPDATE, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000574 ASSERT_EQ(1U, media_channel1_->codecs().size());
575 EXPECT_TRUE(CodecMatches(update_content.codecs()[0],
576 media_channel1_->codecs()[0]));
577 // Now update without any codecs. This is ignored.
578 typename T::Content empty_content;
579 empty_content.set_partial(true);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000580 EXPECT_TRUE(channel1_->SetRemoteContent(&empty_content, CA_UPDATE, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000581 ASSERT_EQ(1U, media_channel1_->codecs().size());
582 EXPECT_TRUE(CodecMatches(update_content.codecs()[0],
583 media_channel1_->codecs()[0]));
584 }
585
586 // Test that Add/RemoveStream properly forward to the media channel.
587 void TestStreams() {
588 CreateChannels(0, 0);
589 EXPECT_TRUE(AddStream1(1));
590 EXPECT_TRUE(AddStream1(2));
591 EXPECT_EQ(2U, media_channel1_->recv_streams().size());
592 EXPECT_TRUE(RemoveStream1(2));
593 EXPECT_EQ(1U, media_channel1_->recv_streams().size());
594 EXPECT_TRUE(RemoveStream1(1));
595 EXPECT_EQ(0U, media_channel1_->recv_streams().size());
596 }
597
598 // Test that SetLocalContent properly handles adding and removing StreamParams
599 // to the local content description.
600 // This test uses the CA_UPDATE action that don't require a full
601 // MediaContentDescription to do an update.
602 void TestUpdateStreamsInLocalContent() {
603 cricket::StreamParams stream1;
604 stream1.groupid = "group1";
605 stream1.id = "stream1";
606 stream1.ssrcs.push_back(kSsrc1);
607 stream1.cname = "stream1_cname";
608
609 cricket::StreamParams stream2;
610 stream2.groupid = "group2";
611 stream2.id = "stream2";
612 stream2.ssrcs.push_back(kSsrc2);
613 stream2.cname = "stream2_cname";
614
615 cricket::StreamParams stream3;
616 stream3.groupid = "group3";
617 stream3.id = "stream3";
618 stream3.ssrcs.push_back(kSsrc3);
619 stream3.cname = "stream3_cname";
620
621 CreateChannels(0, 0);
622 typename T::Content content1;
623 CreateContent(0, kPcmuCodec, kH264Codec, &content1);
624 content1.AddStream(stream1);
625 EXPECT_EQ(0u, media_channel1_->send_streams().size());
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000626 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000627
628 ASSERT_EQ(1u, media_channel1_->send_streams().size());
629 EXPECT_EQ(stream1, media_channel1_->send_streams()[0]);
630
631 // Update the local streams by adding another sending stream.
632 // Use a partial updated session description.
633 typename T::Content content2;
634 content2.AddStream(stream2);
635 content2.AddStream(stream3);
636 content2.set_partial(true);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000637 EXPECT_TRUE(channel1_->SetLocalContent(&content2, CA_UPDATE, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000638 ASSERT_EQ(3u, media_channel1_->send_streams().size());
639 EXPECT_EQ(stream1, media_channel1_->send_streams()[0]);
640 EXPECT_EQ(stream2, media_channel1_->send_streams()[1]);
641 EXPECT_EQ(stream3, media_channel1_->send_streams()[2]);
642
643 // Update the local streams by removing the first sending stream.
644 // This is done by removing all SSRCS for this particular stream.
645 typename T::Content content3;
646 stream1.ssrcs.clear();
647 content3.AddStream(stream1);
648 content3.set_partial(true);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000649 EXPECT_TRUE(channel1_->SetLocalContent(&content3, CA_UPDATE, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000650 ASSERT_EQ(2u, media_channel1_->send_streams().size());
651 EXPECT_EQ(stream2, media_channel1_->send_streams()[0]);
652 EXPECT_EQ(stream3, media_channel1_->send_streams()[1]);
653
654 // Update the local streams with a stream that does not change.
655 // THe update is ignored.
656 typename T::Content content4;
657 content4.AddStream(stream2);
658 content4.set_partial(true);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000659 EXPECT_TRUE(channel1_->SetLocalContent(&content4, CA_UPDATE, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000660 ASSERT_EQ(2u, media_channel1_->send_streams().size());
661 EXPECT_EQ(stream2, media_channel1_->send_streams()[0]);
662 EXPECT_EQ(stream3, media_channel1_->send_streams()[1]);
663 }
664
665 // Test that SetRemoteContent properly handles adding and removing
666 // StreamParams to the remote content description.
667 // This test uses the CA_UPDATE action that don't require a full
668 // MediaContentDescription to do an update.
669 void TestUpdateStreamsInRemoteContent() {
670 cricket::StreamParams stream1;
671 stream1.id = "Stream1";
672 stream1.groupid = "1";
673 stream1.ssrcs.push_back(kSsrc1);
674 stream1.cname = "stream1_cname";
675
676 cricket::StreamParams stream2;
677 stream2.id = "Stream2";
678 stream2.groupid = "2";
679 stream2.ssrcs.push_back(kSsrc2);
680 stream2.cname = "stream2_cname";
681
682 cricket::StreamParams stream3;
683 stream3.id = "Stream3";
684 stream3.groupid = "3";
685 stream3.ssrcs.push_back(kSsrc3);
686 stream3.cname = "stream3_cname";
687
688 CreateChannels(0, 0);
689 typename T::Content content1;
690 CreateContent(0, kPcmuCodec, kH264Codec, &content1);
691 content1.AddStream(stream1);
692 EXPECT_EQ(0u, media_channel1_->recv_streams().size());
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000693 EXPECT_TRUE(channel1_->SetRemoteContent(&content1, CA_OFFER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000694
695 ASSERT_EQ(1u, media_channel1_->codecs().size());
696 ASSERT_EQ(1u, media_channel1_->recv_streams().size());
697 EXPECT_EQ(stream1, media_channel1_->recv_streams()[0]);
698
699 // Update the remote streams by adding another sending stream.
700 // Use a partial updated session description.
701 typename T::Content content2;
702 content2.AddStream(stream2);
703 content2.AddStream(stream3);
704 content2.set_partial(true);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000705 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_UPDATE, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000706 ASSERT_EQ(3u, media_channel1_->recv_streams().size());
707 EXPECT_EQ(stream1, media_channel1_->recv_streams()[0]);
708 EXPECT_EQ(stream2, media_channel1_->recv_streams()[1]);
709 EXPECT_EQ(stream3, media_channel1_->recv_streams()[2]);
710
711 // Update the remote streams by removing the first stream.
712 // This is done by removing all SSRCS for this particular stream.
713 typename T::Content content3;
714 stream1.ssrcs.clear();
715 content3.AddStream(stream1);
716 content3.set_partial(true);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000717 EXPECT_TRUE(channel1_->SetRemoteContent(&content3, CA_UPDATE, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000718 ASSERT_EQ(2u, media_channel1_->recv_streams().size());
719 EXPECT_EQ(stream2, media_channel1_->recv_streams()[0]);
720 EXPECT_EQ(stream3, media_channel1_->recv_streams()[1]);
721
722 // Update the remote streams with a stream that does not change.
723 // The update is ignored.
724 typename T::Content content4;
725 content4.AddStream(stream2);
726 content4.set_partial(true);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000727 EXPECT_TRUE(channel1_->SetRemoteContent(&content4, CA_UPDATE, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000728 ASSERT_EQ(2u, media_channel1_->recv_streams().size());
729 EXPECT_EQ(stream2, media_channel1_->recv_streams()[0]);
730 EXPECT_EQ(stream3, media_channel1_->recv_streams()[1]);
731 }
732
733 // Test that SetLocalContent and SetRemoteContent properly
734 // handles adding and removing StreamParams when the action is a full
735 // CA_OFFER / CA_ANSWER.
736 void TestChangeStreamParamsInContent() {
737 cricket::StreamParams stream1;
738 stream1.groupid = "group1";
739 stream1.id = "stream1";
740 stream1.ssrcs.push_back(kSsrc1);
741 stream1.cname = "stream1_cname";
742
743 cricket::StreamParams stream2;
744 stream2.groupid = "group1";
745 stream2.id = "stream2";
746 stream2.ssrcs.push_back(kSsrc2);
747 stream2.cname = "stream2_cname";
748
749 // Setup a call where channel 1 send |stream1| to channel 2.
750 CreateChannels(0, 0);
751 typename T::Content content1;
752 CreateContent(0, kPcmuCodec, kH264Codec, &content1);
753 content1.AddStream(stream1);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000754 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000755 EXPECT_TRUE(channel1_->Enable(true));
756 EXPECT_EQ(1u, media_channel1_->send_streams().size());
757
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000758 EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000759 EXPECT_EQ(1u, media_channel2_->recv_streams().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200760 transport_controller1_->Connect(transport_controller2_.get());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000761
762 // Channel 2 do not send anything.
763 typename T::Content content2;
764 CreateContent(0, kPcmuCodec, kH264Codec, &content2);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000765 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_ANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000766 EXPECT_EQ(0u, media_channel1_->recv_streams().size());
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000767 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_ANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000768 EXPECT_TRUE(channel2_->Enable(true));
769 EXPECT_EQ(0u, media_channel2_->send_streams().size());
770
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200771 SendCustomRtp1(kSsrc1, 0);
772 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000773 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, 0));
774
775 // Let channel 2 update the content by sending |stream2| and enable SRTP.
776 typename T::Content content3;
777 CreateContent(SECURE, kPcmuCodec, kH264Codec, &content3);
778 content3.AddStream(stream2);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000779 EXPECT_TRUE(channel2_->SetLocalContent(&content3, CA_OFFER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000780 ASSERT_EQ(1u, media_channel2_->send_streams().size());
781 EXPECT_EQ(stream2, media_channel2_->send_streams()[0]);
782
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000783 EXPECT_TRUE(channel1_->SetRemoteContent(&content3, CA_OFFER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000784 ASSERT_EQ(1u, media_channel1_->recv_streams().size());
785 EXPECT_EQ(stream2, media_channel1_->recv_streams()[0]);
786
787 // Channel 1 replies but stop sending stream1.
788 typename T::Content content4;
789 CreateContent(SECURE, kPcmuCodec, kH264Codec, &content4);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000790 EXPECT_TRUE(channel1_->SetLocalContent(&content4, CA_ANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000791 EXPECT_EQ(0u, media_channel1_->send_streams().size());
792
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000793 EXPECT_TRUE(channel2_->SetRemoteContent(&content4, CA_ANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000794 EXPECT_EQ(0u, media_channel2_->recv_streams().size());
795
796 EXPECT_TRUE(channel1_->secure());
797 EXPECT_TRUE(channel2_->secure());
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200798 SendCustomRtp2(kSsrc2, 0);
799 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000800 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, 0));
801 }
802
803 // Test that we only start playout and sending at the right times.
804 void TestPlayoutAndSendingStates() {
805 CreateChannels(0, 0);
Peter Boström34fbfff2015-09-24 19:20:30 +0200806 if (verify_playout_) {
807 EXPECT_FALSE(media_channel1_->playout());
808 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000809 EXPECT_FALSE(media_channel1_->sending());
Peter Boström34fbfff2015-09-24 19:20:30 +0200810 if (verify_playout_) {
811 EXPECT_FALSE(media_channel2_->playout());
812 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000813 EXPECT_FALSE(media_channel2_->sending());
814 EXPECT_TRUE(channel1_->Enable(true));
Peter Boström34fbfff2015-09-24 19:20:30 +0200815 if (verify_playout_) {
816 EXPECT_FALSE(media_channel1_->playout());
817 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000818 EXPECT_FALSE(media_channel1_->sending());
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000819 EXPECT_TRUE(channel1_->SetLocalContent(&local_media_content1_,
820 CA_OFFER, NULL));
Peter Boström34fbfff2015-09-24 19:20:30 +0200821 if (verify_playout_) {
822 EXPECT_TRUE(media_channel1_->playout());
823 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000824 EXPECT_FALSE(media_channel1_->sending());
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000825 EXPECT_TRUE(channel2_->SetRemoteContent(&local_media_content1_,
826 CA_OFFER, NULL));
Peter Boström34fbfff2015-09-24 19:20:30 +0200827 if (verify_playout_) {
828 EXPECT_FALSE(media_channel2_->playout());
829 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000830 EXPECT_FALSE(media_channel2_->sending());
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000831 EXPECT_TRUE(channel2_->SetLocalContent(&local_media_content2_,
832 CA_ANSWER, NULL));
Peter Boström34fbfff2015-09-24 19:20:30 +0200833 if (verify_playout_) {
834 EXPECT_FALSE(media_channel2_->playout());
835 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000836 EXPECT_FALSE(media_channel2_->sending());
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200837 transport_controller1_->Connect(transport_controller2_.get());
Peter Boström34fbfff2015-09-24 19:20:30 +0200838 if (verify_playout_) {
839 EXPECT_TRUE(media_channel1_->playout());
840 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000841 EXPECT_FALSE(media_channel1_->sending());
Peter Boström34fbfff2015-09-24 19:20:30 +0200842 if (verify_playout_) {
843 EXPECT_FALSE(media_channel2_->playout());
844 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000845 EXPECT_FALSE(media_channel2_->sending());
846 EXPECT_TRUE(channel2_->Enable(true));
Peter Boström34fbfff2015-09-24 19:20:30 +0200847 if (verify_playout_) {
848 EXPECT_TRUE(media_channel2_->playout());
849 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000850 EXPECT_TRUE(media_channel2_->sending());
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000851 EXPECT_TRUE(channel1_->SetRemoteContent(&local_media_content2_,
852 CA_ANSWER, NULL));
Peter Boström34fbfff2015-09-24 19:20:30 +0200853 if (verify_playout_) {
854 EXPECT_TRUE(media_channel1_->playout());
855 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000856 EXPECT_TRUE(media_channel1_->sending());
857 }
858
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000859 // Test that changing the MediaContentDirection in the local and remote
860 // session description start playout and sending at the right time.
861 void TestMediaContentDirection() {
862 CreateChannels(0, 0);
863 typename T::Content content1;
864 CreateContent(0, kPcmuCodec, kH264Codec, &content1);
865 typename T::Content content2;
866 CreateContent(0, kPcmuCodec, kH264Codec, &content2);
867 // Set |content2| to be InActive.
868 content2.set_direction(cricket::MD_INACTIVE);
869
870 EXPECT_TRUE(channel1_->Enable(true));
871 EXPECT_TRUE(channel2_->Enable(true));
Peter Boström34fbfff2015-09-24 19:20:30 +0200872 if (verify_playout_) {
873 EXPECT_FALSE(media_channel1_->playout());
874 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000875 EXPECT_FALSE(media_channel1_->sending());
Peter Boström34fbfff2015-09-24 19:20:30 +0200876 if (verify_playout_) {
877 EXPECT_FALSE(media_channel2_->playout());
878 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000879 EXPECT_FALSE(media_channel2_->sending());
880
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000881 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL));
882 EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, NULL));
883 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_PRANSWER, NULL));
884 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_PRANSWER, NULL));
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200885 transport_controller1_->Connect(transport_controller2_.get());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000886
Peter Boström34fbfff2015-09-24 19:20:30 +0200887 if (verify_playout_) {
888 EXPECT_TRUE(media_channel1_->playout());
889 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000890 EXPECT_FALSE(media_channel1_->sending()); // remote InActive
Peter Boström34fbfff2015-09-24 19:20:30 +0200891 if (verify_playout_) {
892 EXPECT_FALSE(media_channel2_->playout()); // local InActive
893 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000894 EXPECT_FALSE(media_channel2_->sending()); // local InActive
895
896 // Update |content2| to be RecvOnly.
897 content2.set_direction(cricket::MD_RECVONLY);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000898 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_PRANSWER, NULL));
899 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_PRANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000900
Peter Boström34fbfff2015-09-24 19:20:30 +0200901 if (verify_playout_) {
902 EXPECT_TRUE(media_channel1_->playout());
903 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000904 EXPECT_TRUE(media_channel1_->sending());
Peter Boström34fbfff2015-09-24 19:20:30 +0200905 if (verify_playout_) {
906 EXPECT_TRUE(media_channel2_->playout()); // local RecvOnly
907 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000908 EXPECT_FALSE(media_channel2_->sending()); // local RecvOnly
909
910 // Update |content2| to be SendRecv.
911 content2.set_direction(cricket::MD_SENDRECV);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000912 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_ANSWER, NULL));
913 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_ANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000914
Peter Boström34fbfff2015-09-24 19:20:30 +0200915 if (verify_playout_) {
916 EXPECT_TRUE(media_channel1_->playout());
917 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000918 EXPECT_TRUE(media_channel1_->sending());
Peter Boström34fbfff2015-09-24 19:20:30 +0200919 if (verify_playout_) {
920 EXPECT_TRUE(media_channel2_->playout());
921 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000922 EXPECT_TRUE(media_channel2_->sending());
923 }
924
Honghai Zhangcc411c02016-03-29 17:27:21 -0700925 // Tests that when the transport channel signals a candidate pair change
926 // event, the media channel will receive a call on the network route change.
927 void TestNetworkRouteChanges() {
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200928 constexpr uint16_t kLocalNetId = 1;
929 constexpr uint16_t kRemoteNetId = 2;
930 constexpr int kLastPacketId = 100;
931
Honghai Zhangcc411c02016-03-29 17:27:21 -0700932 CreateChannels(0, 0);
933
934 cricket::TransportChannel* transport_channel1 =
935 channel1_->transport_channel();
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200936 ASSERT_TRUE(transport_channel1);
Honghai Zhangcc411c02016-03-29 17:27:21 -0700937 typename T::MediaChannel* media_channel1 =
938 static_cast<typename T::MediaChannel*>(channel1_->media_channel());
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200939 ASSERT_TRUE(media_channel1);
Honghai Zhangcc411c02016-03-29 17:27:21 -0700940
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200941 media_channel1->set_num_network_route_changes(0);
Taylor Brandstetter5d97a9a2016-06-10 14:17:27 -0700942 network_thread_->Invoke<void>(RTC_FROM_HERE, [transport_channel1] {
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200943 // The transport channel becomes disconnected.
Taylor Brandstetter6bb1ef22016-06-27 18:09:03 -0700944 transport_channel1->SignalSelectedCandidatePairChanged(
945 transport_channel1, nullptr, -1, false);
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200946 });
947 WaitForThreads();
948 EXPECT_EQ(1, media_channel1->num_network_route_changes());
Honghai Zhangcc411c02016-03-29 17:27:21 -0700949 EXPECT_FALSE(media_channel1->last_network_route().connected);
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200950 media_channel1->set_num_network_route_changes(0);
Honghai Zhangcc411c02016-03-29 17:27:21 -0700951
Taylor Brandstetter5d97a9a2016-06-10 14:17:27 -0700952 network_thread_->Invoke<void>(RTC_FROM_HERE, [this, transport_channel1,
953 media_channel1, kLocalNetId,
954 kRemoteNetId, kLastPacketId] {
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200955 // The transport channel becomes connected.
956 rtc::SocketAddress local_address("192.168.1.1", 1000 /* port number */);
957 rtc::SocketAddress remote_address("192.168.1.2", 2000 /* port number */);
958 std::unique_ptr<cricket::CandidatePairInterface> candidate_pair(
959 transport_controller1_->CreateFakeCandidatePair(
960 local_address, kLocalNetId, remote_address, kRemoteNetId));
961 transport_channel1->SignalSelectedCandidatePairChanged(
Taylor Brandstetter6bb1ef22016-06-27 18:09:03 -0700962 transport_channel1, candidate_pair.get(), kLastPacketId, true);
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200963 });
964 WaitForThreads();
965 EXPECT_EQ(1, media_channel1->num_network_route_changes());
honghaiz059e1832016-06-24 11:03:55 -0700966 rtc::NetworkRoute expected_network_route(true, kLocalNetId, kRemoteNetId,
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200967 kLastPacketId);
Honghai Zhangcc411c02016-03-29 17:27:21 -0700968 EXPECT_EQ(expected_network_route, media_channel1->last_network_route());
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200969 EXPECT_EQ(kLastPacketId,
Honghai Zhang52dce732016-03-31 12:37:31 -0700970 media_channel1->last_network_route().last_sent_packet_id);
michaelt79e05882016-11-08 02:50:09 -0800971 constexpr int kTransportOverheadPerPacket = 28; // Ipv4(20) + UDP(8).
972 EXPECT_EQ(kTransportOverheadPerPacket,
973 media_channel1->transport_overhead_per_packet());
Honghai Zhangcc411c02016-03-29 17:27:21 -0700974 }
975
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000976 // Test setting up a call.
977 void TestCallSetup() {
978 CreateChannels(0, 0);
979 EXPECT_FALSE(channel1_->secure());
980 EXPECT_TRUE(SendInitiate());
Peter Boström34fbfff2015-09-24 19:20:30 +0200981 if (verify_playout_) {
982 EXPECT_TRUE(media_channel1_->playout());
983 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000984 EXPECT_FALSE(media_channel1_->sending());
985 EXPECT_TRUE(SendAccept());
986 EXPECT_FALSE(channel1_->secure());
987 EXPECT_TRUE(media_channel1_->sending());
988 EXPECT_EQ(1U, media_channel1_->codecs().size());
Peter Boström34fbfff2015-09-24 19:20:30 +0200989 if (verify_playout_) {
990 EXPECT_TRUE(media_channel2_->playout());
991 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000992 EXPECT_TRUE(media_channel2_->sending());
993 EXPECT_EQ(1U, media_channel2_->codecs().size());
994 }
995
996 // Test that we don't crash if packets are sent during call teardown
997 // when RTCP mux is enabled. This is a regression test against a specific
998 // race condition that would only occur when a RTCP packet was sent during
999 // teardown of a channel on which RTCP mux was enabled.
1000 void TestCallTeardownRtcpMux() {
1001 class LastWordMediaChannel : public T::MediaChannel {
1002 public:
Fredrik Solenbergb071a192015-09-17 16:42:56 +02001003 LastWordMediaChannel() : T::MediaChannel(NULL, typename T::Options()) {}
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001004 ~LastWordMediaChannel() {
stefanc1aeaf02015-10-15 07:26:07 -07001005 T::MediaChannel::SendRtp(kPcmuFrame, sizeof(kPcmuFrame),
1006 rtc::PacketOptions());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001007 T::MediaChannel::SendRtcp(kRtcpReport, sizeof(kRtcpReport));
1008 }
1009 };
1010 CreateChannels(new LastWordMediaChannel(), new LastWordMediaChannel(),
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001011 RTCP | RTCP_MUX, RTCP | RTCP_MUX);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001012 EXPECT_TRUE(SendInitiate());
1013 EXPECT_TRUE(SendAccept());
1014 EXPECT_TRUE(SendTerminate());
1015 }
1016
1017 // Send voice RTP data to the other side and ensure it gets there.
1018 void SendRtpToRtp() {
1019 CreateChannels(0, 0);
1020 EXPECT_TRUE(SendInitiate());
1021 EXPECT_TRUE(SendAccept());
deadbeef49f34fd2016-12-06 16:22:06 -08001022 EXPECT_EQ(1U, GetChannels1().size());
1023 EXPECT_EQ(1U, GetChannels2().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001024 SendRtp1();
1025 SendRtp2();
1026 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001027 EXPECT_TRUE(CheckRtp1());
1028 EXPECT_TRUE(CheckRtp2());
1029 EXPECT_TRUE(CheckNoRtp1());
1030 EXPECT_TRUE(CheckNoRtp2());
1031 }
1032
Danil Chapovalovdae07ba2016-05-14 01:43:50 +02001033 void TestDeinit() {
1034 CreateChannels(RTCP, RTCP);
1035 EXPECT_TRUE(SendInitiate());
1036 EXPECT_TRUE(SendAccept());
1037 SendRtp1();
1038 SendRtp2();
1039 SendRtcp1();
1040 SendRtcp2();
1041 // Do not wait, destroy channels.
1042 channel1_.reset(nullptr);
1043 channel2_.reset(nullptr);
1044 }
1045
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001046 // Check that RTCP is not transmitted if both sides don't support RTCP.
1047 void SendNoRtcpToNoRtcp() {
1048 CreateChannels(0, 0);
1049 EXPECT_TRUE(SendInitiate());
1050 EXPECT_TRUE(SendAccept());
deadbeef49f34fd2016-12-06 16:22:06 -08001051 EXPECT_EQ(1U, GetChannels1().size());
1052 EXPECT_EQ(1U, GetChannels2().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001053 SendRtcp1();
1054 SendRtcp2();
1055 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001056 EXPECT_TRUE(CheckNoRtcp1());
1057 EXPECT_TRUE(CheckNoRtcp2());
1058 }
1059
1060 // Check that RTCP is not transmitted if the callee doesn't support RTCP.
1061 void SendNoRtcpToRtcp() {
1062 CreateChannels(0, RTCP);
1063 EXPECT_TRUE(SendInitiate());
1064 EXPECT_TRUE(SendAccept());
deadbeef49f34fd2016-12-06 16:22:06 -08001065 EXPECT_EQ(1U, GetChannels1().size());
1066 EXPECT_EQ(2U, GetChannels2().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001067 SendRtcp1();
1068 SendRtcp2();
1069 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001070 EXPECT_TRUE(CheckNoRtcp1());
1071 EXPECT_TRUE(CheckNoRtcp2());
1072 }
1073
1074 // Check that RTCP is not transmitted if the caller doesn't support RTCP.
1075 void SendRtcpToNoRtcp() {
1076 CreateChannels(RTCP, 0);
1077 EXPECT_TRUE(SendInitiate());
1078 EXPECT_TRUE(SendAccept());
deadbeef49f34fd2016-12-06 16:22:06 -08001079 EXPECT_EQ(2U, GetChannels1().size());
1080 EXPECT_EQ(1U, GetChannels2().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001081 SendRtcp1();
1082 SendRtcp2();
1083 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001084 EXPECT_TRUE(CheckNoRtcp1());
1085 EXPECT_TRUE(CheckNoRtcp2());
1086 }
1087
1088 // Check that RTCP is transmitted if both sides support RTCP.
1089 void SendRtcpToRtcp() {
1090 CreateChannels(RTCP, RTCP);
1091 EXPECT_TRUE(SendInitiate());
1092 EXPECT_TRUE(SendAccept());
deadbeef49f34fd2016-12-06 16:22:06 -08001093 EXPECT_EQ(2U, GetChannels1().size());
1094 EXPECT_EQ(2U, GetChannels2().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001095 SendRtcp1();
1096 SendRtcp2();
1097 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001098 EXPECT_TRUE(CheckRtcp1());
1099 EXPECT_TRUE(CheckRtcp2());
1100 EXPECT_TRUE(CheckNoRtcp1());
1101 EXPECT_TRUE(CheckNoRtcp2());
1102 }
1103
1104 // Check that RTCP is transmitted if only the initiator supports mux.
1105 void SendRtcpMuxToRtcp() {
1106 CreateChannels(RTCP | RTCP_MUX, RTCP);
1107 EXPECT_TRUE(SendInitiate());
1108 EXPECT_TRUE(SendAccept());
deadbeef49f34fd2016-12-06 16:22:06 -08001109 EXPECT_EQ(2U, GetChannels1().size());
1110 EXPECT_EQ(2U, GetChannels2().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001111 SendRtcp1();
1112 SendRtcp2();
1113 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001114 EXPECT_TRUE(CheckRtcp1());
1115 EXPECT_TRUE(CheckRtcp2());
1116 EXPECT_TRUE(CheckNoRtcp1());
1117 EXPECT_TRUE(CheckNoRtcp2());
1118 }
1119
1120 // Check that RTP and RTCP are transmitted ok when both sides support mux.
1121 void SendRtcpMuxToRtcpMux() {
1122 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
1123 EXPECT_TRUE(SendInitiate());
deadbeef49f34fd2016-12-06 16:22:06 -08001124 EXPECT_EQ(2U, GetChannels1().size());
1125 EXPECT_EQ(1U, GetChannels2().size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001126 EXPECT_TRUE(SendAccept());
deadbeef49f34fd2016-12-06 16:22:06 -08001127 EXPECT_EQ(1U, GetChannels1().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001128 SendRtp1();
1129 SendRtp2();
1130 SendRtcp1();
1131 SendRtcp2();
1132 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001133 EXPECT_TRUE(CheckRtp1());
1134 EXPECT_TRUE(CheckRtp2());
1135 EXPECT_TRUE(CheckNoRtp1());
1136 EXPECT_TRUE(CheckNoRtp2());
1137 EXPECT_TRUE(CheckRtcp1());
1138 EXPECT_TRUE(CheckRtcp2());
1139 EXPECT_TRUE(CheckNoRtcp1());
1140 EXPECT_TRUE(CheckNoRtcp2());
1141 }
1142
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07001143 // Check that RTP and RTCP are transmitted ok when both sides
1144 // support mux and one the offerer requires mux.
1145 void SendRequireRtcpMuxToRtcpMux() {
1146 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
1147 channel1_->ActivateRtcpMux();
1148 EXPECT_TRUE(SendInitiate());
deadbeef49f34fd2016-12-06 16:22:06 -08001149 EXPECT_EQ(1U, GetChannels1().size());
1150 EXPECT_EQ(1U, GetChannels2().size());
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07001151 EXPECT_TRUE(SendAccept());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001152 SendRtp1();
1153 SendRtp2();
1154 SendRtcp1();
1155 SendRtcp2();
1156 WaitForThreads();
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07001157 EXPECT_TRUE(CheckRtp1());
1158 EXPECT_TRUE(CheckRtp2());
1159 EXPECT_TRUE(CheckNoRtp1());
1160 EXPECT_TRUE(CheckNoRtp2());
1161 EXPECT_TRUE(CheckRtcp1());
1162 EXPECT_TRUE(CheckRtcp2());
1163 EXPECT_TRUE(CheckNoRtcp1());
1164 EXPECT_TRUE(CheckNoRtcp2());
1165 }
1166
1167 // Check that RTP and RTCP are transmitted ok when both sides
1168 // support mux and one the answerer requires rtcp mux.
1169 void SendRtcpMuxToRequireRtcpMux() {
1170 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
1171 channel2_->ActivateRtcpMux();
1172 EXPECT_TRUE(SendInitiate());
deadbeef49f34fd2016-12-06 16:22:06 -08001173 EXPECT_EQ(2U, GetChannels1().size());
1174 EXPECT_EQ(1U, GetChannels2().size());
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07001175 EXPECT_TRUE(SendAccept());
deadbeef49f34fd2016-12-06 16:22:06 -08001176 EXPECT_EQ(1U, GetChannels1().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001177 SendRtp1();
1178 SendRtp2();
1179 SendRtcp1();
1180 SendRtcp2();
1181 WaitForThreads();
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07001182 EXPECT_TRUE(CheckRtp1());
1183 EXPECT_TRUE(CheckRtp2());
1184 EXPECT_TRUE(CheckNoRtp1());
1185 EXPECT_TRUE(CheckNoRtp2());
1186 EXPECT_TRUE(CheckRtcp1());
1187 EXPECT_TRUE(CheckRtcp2());
1188 EXPECT_TRUE(CheckNoRtcp1());
1189 EXPECT_TRUE(CheckNoRtcp2());
1190 }
1191
1192 // Check that RTP and RTCP are transmitted ok when both sides
1193 // require mux.
1194 void SendRequireRtcpMuxToRequireRtcpMux() {
1195 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
1196 channel1_->ActivateRtcpMux();
1197 channel2_->ActivateRtcpMux();
1198 EXPECT_TRUE(SendInitiate());
deadbeef49f34fd2016-12-06 16:22:06 -08001199 EXPECT_EQ(1U, GetChannels1().size());
1200 EXPECT_EQ(1U, GetChannels2().size());
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07001201 EXPECT_TRUE(SendAccept());
deadbeef49f34fd2016-12-06 16:22:06 -08001202 EXPECT_EQ(1U, GetChannels1().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001203 SendRtp1();
1204 SendRtp2();
1205 SendRtcp1();
1206 SendRtcp2();
1207 WaitForThreads();
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07001208 EXPECT_TRUE(CheckRtp1());
1209 EXPECT_TRUE(CheckRtp2());
1210 EXPECT_TRUE(CheckNoRtp1());
1211 EXPECT_TRUE(CheckNoRtp2());
1212 EXPECT_TRUE(CheckRtcp1());
1213 EXPECT_TRUE(CheckRtcp2());
1214 EXPECT_TRUE(CheckNoRtcp1());
1215 EXPECT_TRUE(CheckNoRtcp2());
1216 }
1217
1218 // Check that SendAccept fails if the answerer doesn't support mux
1219 // and the offerer requires it.
1220 void SendRequireRtcpMuxToNoRtcpMux() {
1221 CreateChannels(RTCP | RTCP_MUX, RTCP);
1222 channel1_->ActivateRtcpMux();
1223 EXPECT_TRUE(SendInitiate());
deadbeef49f34fd2016-12-06 16:22:06 -08001224 EXPECT_EQ(1U, GetChannels1().size());
1225 EXPECT_EQ(2U, GetChannels2().size());
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07001226 EXPECT_FALSE(SendAccept());
1227 }
1228
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001229 // Check that RTCP data sent by the initiator before the accept is not muxed.
1230 void SendEarlyRtcpMuxToRtcp() {
1231 CreateChannels(RTCP | RTCP_MUX, RTCP);
1232 EXPECT_TRUE(SendInitiate());
deadbeef49f34fd2016-12-06 16:22:06 -08001233 EXPECT_EQ(2U, GetChannels1().size());
1234 EXPECT_EQ(2U, GetChannels2().size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001235
1236 // RTCP can be sent before the call is accepted, if the transport is ready.
1237 // It should not be muxed though, as the remote side doesn't support mux.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001238 SendRtcp1();
1239 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001240 EXPECT_TRUE(CheckNoRtp2());
1241 EXPECT_TRUE(CheckRtcp2());
1242
1243 // Send RTCP packet from callee and verify that it is received.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001244 SendRtcp2();
1245 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001246 EXPECT_TRUE(CheckNoRtp1());
1247 EXPECT_TRUE(CheckRtcp1());
1248
1249 // Complete call setup and ensure everything is still OK.
1250 EXPECT_TRUE(SendAccept());
deadbeef49f34fd2016-12-06 16:22:06 -08001251 EXPECT_EQ(2U, GetChannels1().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001252 SendRtcp1();
1253 SendRtcp2();
1254 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001255 EXPECT_TRUE(CheckRtcp2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001256 EXPECT_TRUE(CheckRtcp1());
1257 }
1258
1259
1260 // Check that RTCP data is not muxed until both sides have enabled muxing,
1261 // but that we properly demux before we get the accept message, since there
1262 // is a race between RTP data and the jingle accept.
1263 void SendEarlyRtcpMuxToRtcpMux() {
1264 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
1265 EXPECT_TRUE(SendInitiate());
deadbeef49f34fd2016-12-06 16:22:06 -08001266 EXPECT_EQ(2U, GetChannels1().size());
1267 EXPECT_EQ(1U, GetChannels2().size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001268
1269 // RTCP can't be sent yet, since the RTCP transport isn't writable, and
1270 // we haven't yet received the accept that says we should mux.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001271 SendRtcp1();
1272 WaitForThreads();
1273 EXPECT_TRUE(CheckNoRtcp2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001274
1275 // Send muxed RTCP packet from callee and verify that it is received.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001276 SendRtcp2();
1277 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001278 EXPECT_TRUE(CheckNoRtp1());
1279 EXPECT_TRUE(CheckRtcp1());
1280
1281 // Complete call setup and ensure everything is still OK.
1282 EXPECT_TRUE(SendAccept());
deadbeef49f34fd2016-12-06 16:22:06 -08001283 EXPECT_EQ(1U, GetChannels1().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001284 SendRtcp1();
1285 SendRtcp2();
1286 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001287 EXPECT_TRUE(CheckRtcp2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001288 EXPECT_TRUE(CheckRtcp1());
1289 }
1290
1291 // Test that we properly send SRTP with RTCP in both directions.
1292 // You can pass in DTLS and/or RTCP_MUX as flags.
1293 void SendSrtpToSrtp(int flags1_in = 0, int flags2_in = 0) {
jbauchcb560652016-08-04 05:20:32 -07001294 ASSERT((flags1_in & ~(RTCP_MUX | DTLS | GCM_CIPHER)) == 0);
1295 ASSERT((flags2_in & ~(RTCP_MUX | DTLS | GCM_CIPHER)) == 0);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001296
1297 int flags1 = RTCP | SECURE | flags1_in;
1298 int flags2 = RTCP | SECURE | flags2_in;
1299 bool dtls1 = !!(flags1_in & DTLS);
1300 bool dtls2 = !!(flags2_in & DTLS);
1301 CreateChannels(flags1, flags2);
1302 EXPECT_FALSE(channel1_->secure());
1303 EXPECT_FALSE(channel2_->secure());
1304 EXPECT_TRUE(SendInitiate());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001305 WaitForThreads();
1306 EXPECT_TRUE(channel1_->writable());
1307 EXPECT_TRUE(channel2_->writable());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001308 EXPECT_TRUE(SendAccept());
1309 EXPECT_TRUE(channel1_->secure());
1310 EXPECT_TRUE(channel2_->secure());
1311 EXPECT_EQ(dtls1 && dtls2, channel1_->secure_dtls());
1312 EXPECT_EQ(dtls1 && dtls2, channel2_->secure_dtls());
jbauchcb560652016-08-04 05:20:32 -07001313 // We can only query the negotiated cipher suite for DTLS-SRTP transport
1314 // channels.
1315 if (dtls1 && dtls2) {
1316 // A GCM cipher is only used if both channels support GCM ciphers.
1317 int common_gcm_flags = flags1 & flags2 & GCM_CIPHER;
1318 EXPECT_TRUE(CheckGcmCipher(channel1_.get(), common_gcm_flags));
1319 EXPECT_TRUE(CheckGcmCipher(channel2_.get(), common_gcm_flags));
1320 }
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001321 SendRtp1();
1322 SendRtp2();
1323 SendRtcp1();
1324 SendRtcp2();
1325 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001326 EXPECT_TRUE(CheckRtp1());
1327 EXPECT_TRUE(CheckRtp2());
1328 EXPECT_TRUE(CheckNoRtp1());
1329 EXPECT_TRUE(CheckNoRtp2());
1330 EXPECT_TRUE(CheckRtcp1());
1331 EXPECT_TRUE(CheckRtcp2());
1332 EXPECT_TRUE(CheckNoRtcp1());
1333 EXPECT_TRUE(CheckNoRtcp2());
1334 }
1335
1336 // Test that we properly handling SRTP negotiating down to RTP.
1337 void SendSrtpToRtp() {
1338 CreateChannels(RTCP | SECURE, RTCP);
1339 EXPECT_FALSE(channel1_->secure());
1340 EXPECT_FALSE(channel2_->secure());
1341 EXPECT_TRUE(SendInitiate());
1342 EXPECT_TRUE(SendAccept());
1343 EXPECT_FALSE(channel1_->secure());
1344 EXPECT_FALSE(channel2_->secure());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001345 SendRtp1();
1346 SendRtp2();
1347 SendRtcp1();
1348 SendRtcp2();
1349 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001350 EXPECT_TRUE(CheckRtp1());
1351 EXPECT_TRUE(CheckRtp2());
1352 EXPECT_TRUE(CheckNoRtp1());
1353 EXPECT_TRUE(CheckNoRtp2());
1354 EXPECT_TRUE(CheckRtcp1());
1355 EXPECT_TRUE(CheckRtcp2());
1356 EXPECT_TRUE(CheckNoRtcp1());
1357 EXPECT_TRUE(CheckNoRtcp2());
1358 }
1359
1360 // Test that we can send and receive early media when a provisional answer is
1361 // sent and received. The test uses SRTP, RTCP mux and SSRC mux.
1362 void SendEarlyMediaUsingRtcpMuxSrtp() {
1363 int sequence_number1_1 = 0, sequence_number2_2 = 0;
1364
1365 CreateChannels(SSRC_MUX | RTCP | RTCP_MUX | SECURE,
1366 SSRC_MUX | RTCP | RTCP_MUX | SECURE);
1367 EXPECT_TRUE(SendOffer());
1368 EXPECT_TRUE(SendProvisionalAnswer());
1369 EXPECT_TRUE(channel1_->secure());
1370 EXPECT_TRUE(channel2_->secure());
deadbeef49f34fd2016-12-06 16:22:06 -08001371 EXPECT_EQ(2U, GetChannels1().size());
1372 EXPECT_EQ(2U, GetChannels2().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001373 WaitForThreads(); // Wait for 'sending' flag go through network thread.
1374 SendCustomRtcp1(kSsrc1);
1375 SendCustomRtp1(kSsrc1, ++sequence_number1_1);
1376 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001377 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001378 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1));
1379
1380 // Send packets from callee and verify that it is received.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001381 SendCustomRtcp2(kSsrc2);
1382 SendCustomRtp2(kSsrc2, ++sequence_number2_2);
1383 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001384 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001385 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2));
1386
1387 // Complete call setup and ensure everything is still OK.
1388 EXPECT_TRUE(SendFinalAnswer());
deadbeef49f34fd2016-12-06 16:22:06 -08001389 EXPECT_EQ(1U, GetChannels1().size());
1390 EXPECT_EQ(1U, GetChannels2().size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001391 EXPECT_TRUE(channel1_->secure());
1392 EXPECT_TRUE(channel2_->secure());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001393 SendCustomRtcp1(kSsrc1);
1394 SendCustomRtp1(kSsrc1, ++sequence_number1_1);
1395 SendCustomRtcp2(kSsrc2);
1396 SendCustomRtp2(kSsrc2, ++sequence_number2_2);
1397 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001398 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001399 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001400 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001401 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2));
1402 }
1403
1404 // Test that we properly send RTP without SRTP from a thread.
1405 void SendRtpToRtpOnThread() {
buildbot@webrtc.org6bfd6192014-05-15 16:15:59 +00001406 CreateChannels(RTCP, RTCP);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001407 EXPECT_TRUE(SendInitiate());
1408 EXPECT_TRUE(SendAccept());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001409 ScopedCallThread send_rtp1([this] { SendRtp1(); });
1410 ScopedCallThread send_rtp2([this] { SendRtp2(); });
1411 ScopedCallThread send_rtcp1([this] { SendRtcp1(); });
1412 ScopedCallThread send_rtcp2([this] { SendRtcp2(); });
1413 rtc::Thread* involved_threads[] = {send_rtp1.thread(), send_rtp2.thread(),
1414 send_rtcp1.thread(),
1415 send_rtcp2.thread()};
1416 WaitForThreads(involved_threads);
1417 EXPECT_TRUE(CheckRtp1());
1418 EXPECT_TRUE(CheckRtp2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001419 EXPECT_TRUE(CheckNoRtp1());
1420 EXPECT_TRUE(CheckNoRtp2());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001421 EXPECT_TRUE(CheckRtcp1());
1422 EXPECT_TRUE(CheckRtcp2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001423 EXPECT_TRUE(CheckNoRtcp1());
1424 EXPECT_TRUE(CheckNoRtcp2());
1425 }
1426
1427 // Test that we properly send SRTP with RTCP from a thread.
1428 void SendSrtpToSrtpOnThread() {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001429 CreateChannels(RTCP | SECURE, RTCP | SECURE);
1430 EXPECT_TRUE(SendInitiate());
1431 EXPECT_TRUE(SendAccept());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001432 ScopedCallThread send_rtp1([this] { SendRtp1(); });
1433 ScopedCallThread send_rtp2([this] { SendRtp2(); });
1434 ScopedCallThread send_rtcp1([this] { SendRtcp1(); });
1435 ScopedCallThread send_rtcp2([this] { SendRtcp2(); });
1436 rtc::Thread* involved_threads[] = {send_rtp1.thread(), send_rtp2.thread(),
1437 send_rtcp1.thread(),
1438 send_rtcp2.thread()};
1439 WaitForThreads(involved_threads);
1440 EXPECT_TRUE(CheckRtp1());
1441 EXPECT_TRUE(CheckRtp2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001442 EXPECT_TRUE(CheckNoRtp1());
1443 EXPECT_TRUE(CheckNoRtp2());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001444 EXPECT_TRUE(CheckRtcp1());
1445 EXPECT_TRUE(CheckRtcp2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001446 EXPECT_TRUE(CheckNoRtcp1());
1447 EXPECT_TRUE(CheckNoRtcp2());
1448 }
1449
1450 // Test that the mediachannel retains its sending state after the transport
1451 // becomes non-writable.
1452 void SendWithWritabilityLoss() {
1453 CreateChannels(0, 0);
1454 EXPECT_TRUE(SendInitiate());
1455 EXPECT_TRUE(SendAccept());
deadbeef49f34fd2016-12-06 16:22:06 -08001456 EXPECT_EQ(1U, GetChannels1().size());
1457 EXPECT_EQ(1U, GetChannels2().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001458 SendRtp1();
1459 SendRtp2();
1460 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001461 EXPECT_TRUE(CheckRtp1());
1462 EXPECT_TRUE(CheckRtp2());
1463 EXPECT_TRUE(CheckNoRtp1());
1464 EXPECT_TRUE(CheckNoRtp2());
1465
wu@webrtc.org97077a32013-10-25 21:18:33 +00001466 // Lose writability, which should fail.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001467 network_thread_->Invoke<void>(
deadbeef49f34fd2016-12-06 16:22:06 -08001468 RTC_FROM_HERE, [this] { GetFakeChannel1(1)->SetWritable(false); });
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001469 SendRtp1();
1470 SendRtp2();
1471 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001472 EXPECT_TRUE(CheckRtp1());
1473 EXPECT_TRUE(CheckNoRtp2());
1474
1475 // Regain writability
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001476 network_thread_->Invoke<void>(
deadbeef49f34fd2016-12-06 16:22:06 -08001477 RTC_FROM_HERE, [this] { GetFakeChannel1(1)->SetWritable(true); });
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001478 EXPECT_TRUE(media_channel1_->sending());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001479 SendRtp1();
1480 SendRtp2();
1481 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001482 EXPECT_TRUE(CheckRtp1());
1483 EXPECT_TRUE(CheckRtp2());
1484 EXPECT_TRUE(CheckNoRtp1());
1485 EXPECT_TRUE(CheckNoRtp2());
1486
1487 // Lose writability completely
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001488 network_thread_->Invoke<void>(
deadbeef49f34fd2016-12-06 16:22:06 -08001489 RTC_FROM_HERE, [this] { GetFakeChannel1(1)->SetDestination(nullptr); });
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001490 EXPECT_TRUE(media_channel1_->sending());
1491
wu@webrtc.org97077a32013-10-25 21:18:33 +00001492 // Should fail also.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001493 SendRtp1();
1494 SendRtp2();
1495 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001496 EXPECT_TRUE(CheckRtp1());
1497 EXPECT_TRUE(CheckNoRtp2());
1498
1499 // Gain writability back
Taylor Brandstetter5d97a9a2016-06-10 14:17:27 -07001500 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
deadbeef49f34fd2016-12-06 16:22:06 -08001501 GetFakeChannel1(1)->SetDestination(GetFakeChannel2(1));
Taylor Brandstetter5d97a9a2016-06-10 14:17:27 -07001502 });
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001503 EXPECT_TRUE(media_channel1_->sending());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001504 SendRtp1();
1505 SendRtp2();
1506 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001507 EXPECT_TRUE(CheckRtp1());
1508 EXPECT_TRUE(CheckRtp2());
1509 EXPECT_TRUE(CheckNoRtp1());
1510 EXPECT_TRUE(CheckNoRtp2());
1511 }
1512
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00001513 void SendBundleToBundle(
1514 const int* pl_types, int len, bool rtcp_mux, bool secure) {
1515 ASSERT_EQ(2, len);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001516 int sequence_number1_1 = 0, sequence_number2_2 = 0;
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00001517 // Only pl_type1 was added to the bundle filter for both |channel1_|
1518 // and |channel2_|.
1519 int pl_type1 = pl_types[0];
1520 int pl_type2 = pl_types[1];
1521 int flags = SSRC_MUX | RTCP;
1522 if (secure) flags |= SECURE;
Peter Boström0c4e06b2015-10-07 12:23:21 +02001523 uint32_t expected_channels = 2U;
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00001524 if (rtcp_mux) {
1525 flags |= RTCP_MUX;
1526 expected_channels = 1U;
1527 }
1528 CreateChannels(flags, flags);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001529 EXPECT_TRUE(SendInitiate());
deadbeef49f34fd2016-12-06 16:22:06 -08001530 EXPECT_EQ(2U, GetChannels1().size());
1531 EXPECT_EQ(expected_channels, GetChannels2().size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001532 EXPECT_TRUE(SendAccept());
deadbeef49f34fd2016-12-06 16:22:06 -08001533 EXPECT_EQ(expected_channels, GetChannels1().size());
1534 EXPECT_EQ(expected_channels, GetChannels2().size());
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00001535 EXPECT_TRUE(channel1_->bundle_filter()->FindPayloadType(pl_type1));
1536 EXPECT_TRUE(channel2_->bundle_filter()->FindPayloadType(pl_type1));
1537 EXPECT_FALSE(channel1_->bundle_filter()->FindPayloadType(pl_type2));
1538 EXPECT_FALSE(channel2_->bundle_filter()->FindPayloadType(pl_type2));
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00001539
1540 // Both channels can receive pl_type1 only.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001541 SendCustomRtp1(kSsrc1, ++sequence_number1_1, pl_type1);
1542 SendCustomRtp2(kSsrc2, ++sequence_number2_2, pl_type1);
1543 WaitForThreads();
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00001544 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1, pl_type1));
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00001545 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2, pl_type1));
1546 EXPECT_TRUE(CheckNoRtp1());
1547 EXPECT_TRUE(CheckNoRtp2());
1548
1549 // RTCP test
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001550 SendCustomRtp1(kSsrc1, ++sequence_number1_1, pl_type2);
1551 SendCustomRtp2(kSsrc2, ++sequence_number2_2, pl_type2);
1552 WaitForThreads();
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00001553 EXPECT_FALSE(CheckCustomRtp2(kSsrc1, sequence_number1_1, pl_type2));
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00001554 EXPECT_FALSE(CheckCustomRtp1(kSsrc2, sequence_number2_2, pl_type2));
1555
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001556 SendCustomRtcp1(kSsrc1);
1557 SendCustomRtcp2(kSsrc2);
1558 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001559 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2));
1560 EXPECT_TRUE(CheckNoRtcp1());
1561 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1));
1562 EXPECT_TRUE(CheckNoRtcp2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001563
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001564 SendCustomRtcp1(kSsrc2);
1565 SendCustomRtcp2(kSsrc1);
1566 WaitForThreads();
pbos482b12e2015-11-16 10:19:58 -08001567 // Bundle filter shouldn't filter out any RTCP.
1568 EXPECT_TRUE(CheckCustomRtcp1(kSsrc1));
1569 EXPECT_TRUE(CheckCustomRtcp2(kSsrc2));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001570 }
1571
deadbeefc6b6e092016-12-01 12:49:20 -08001572 // Test that the media monitor can be run and gives callbacks.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001573 void TestMediaMonitor() {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001574 CreateChannels(0, 0);
1575 EXPECT_TRUE(SendInitiate());
1576 EXPECT_TRUE(SendAccept());
1577 channel1_->StartMediaMonitor(100);
1578 channel2_->StartMediaMonitor(100);
1579 // Ensure we get callbacks and stop.
deadbeefc6b6e092016-12-01 12:49:20 -08001580 EXPECT_TRUE_WAIT(media_info_callbacks1_ > 0, kDefaultTimeout);
1581 EXPECT_TRUE_WAIT(media_info_callbacks2_ > 0, kDefaultTimeout);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001582 channel1_->StopMediaMonitor();
1583 channel2_->StopMediaMonitor();
1584 // Ensure a restart of a stopped monitor works.
1585 channel1_->StartMediaMonitor(100);
deadbeefc6b6e092016-12-01 12:49:20 -08001586 EXPECT_TRUE_WAIT(media_info_callbacks1_ > 0, kDefaultTimeout);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001587 channel1_->StopMediaMonitor();
1588 // Ensure stopping a stopped monitor is OK.
1589 channel1_->StopMediaMonitor();
1590 }
1591
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001592 void TestSetContentFailure() {
1593 CreateChannels(0, 0);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001594
Peter Thatchera6d24442015-07-09 21:26:36 -07001595 auto sdesc = cricket::SessionDescription();
1596 sdesc.AddContent(cricket::CN_AUDIO, cricket::NS_JINGLE_RTP,
1597 new cricket::AudioContentDescription());
1598 sdesc.AddContent(cricket::CN_VIDEO, cricket::NS_JINGLE_RTP,
1599 new cricket::VideoContentDescription());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001600
Peter Thatchera6d24442015-07-09 21:26:36 -07001601 std::string err;
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001602 media_channel1_->set_fail_set_recv_codecs(true);
Peter Thatchera6d24442015-07-09 21:26:36 -07001603 EXPECT_FALSE(channel1_->PushdownLocalDescription(
1604 &sdesc, cricket::CA_OFFER, &err));
1605 EXPECT_FALSE(channel1_->PushdownLocalDescription(
1606 &sdesc, cricket::CA_ANSWER, &err));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001607
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001608 media_channel1_->set_fail_set_send_codecs(true);
Peter Thatchera6d24442015-07-09 21:26:36 -07001609 EXPECT_FALSE(channel1_->PushdownRemoteDescription(
1610 &sdesc, cricket::CA_OFFER, &err));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001611 media_channel1_->set_fail_set_send_codecs(true);
Peter Thatchera6d24442015-07-09 21:26:36 -07001612 EXPECT_FALSE(channel1_->PushdownRemoteDescription(
1613 &sdesc, cricket::CA_ANSWER, &err));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001614 }
1615
1616 void TestSendTwoOffers() {
1617 CreateChannels(0, 0);
1618
Peter Thatchera6d24442015-07-09 21:26:36 -07001619 std::string err;
kwiberg31022942016-03-11 14:18:21 -08001620 std::unique_ptr<cricket::SessionDescription> sdesc1(
Peter Thatchera6d24442015-07-09 21:26:36 -07001621 CreateSessionDescriptionWithStream(1));
1622 EXPECT_TRUE(channel1_->PushdownLocalDescription(
1623 sdesc1.get(), cricket::CA_OFFER, &err));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001624 EXPECT_TRUE(media_channel1_->HasSendStream(1));
1625
kwiberg31022942016-03-11 14:18:21 -08001626 std::unique_ptr<cricket::SessionDescription> sdesc2(
Peter Thatchera6d24442015-07-09 21:26:36 -07001627 CreateSessionDescriptionWithStream(2));
1628 EXPECT_TRUE(channel1_->PushdownLocalDescription(
1629 sdesc2.get(), cricket::CA_OFFER, &err));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001630 EXPECT_FALSE(media_channel1_->HasSendStream(1));
1631 EXPECT_TRUE(media_channel1_->HasSendStream(2));
1632 }
1633
1634 void TestReceiveTwoOffers() {
1635 CreateChannels(0, 0);
1636
Peter Thatchera6d24442015-07-09 21:26:36 -07001637 std::string err;
kwiberg31022942016-03-11 14:18:21 -08001638 std::unique_ptr<cricket::SessionDescription> sdesc1(
Peter Thatchera6d24442015-07-09 21:26:36 -07001639 CreateSessionDescriptionWithStream(1));
1640 EXPECT_TRUE(channel1_->PushdownRemoteDescription(
1641 sdesc1.get(), cricket::CA_OFFER, &err));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001642 EXPECT_TRUE(media_channel1_->HasRecvStream(1));
1643
kwiberg31022942016-03-11 14:18:21 -08001644 std::unique_ptr<cricket::SessionDescription> sdesc2(
Peter Thatchera6d24442015-07-09 21:26:36 -07001645 CreateSessionDescriptionWithStream(2));
1646 EXPECT_TRUE(channel1_->PushdownRemoteDescription(
1647 sdesc2.get(), cricket::CA_OFFER, &err));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001648 EXPECT_FALSE(media_channel1_->HasRecvStream(1));
1649 EXPECT_TRUE(media_channel1_->HasRecvStream(2));
1650 }
1651
1652 void TestSendPrAnswer() {
1653 CreateChannels(0, 0);
1654
Peter Thatchera6d24442015-07-09 21:26:36 -07001655 std::string err;
1656 // Receive offer
kwiberg31022942016-03-11 14:18:21 -08001657 std::unique_ptr<cricket::SessionDescription> sdesc1(
Peter Thatchera6d24442015-07-09 21:26:36 -07001658 CreateSessionDescriptionWithStream(1));
1659 EXPECT_TRUE(channel1_->PushdownRemoteDescription(
1660 sdesc1.get(), cricket::CA_OFFER, &err));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001661 EXPECT_TRUE(media_channel1_->HasRecvStream(1));
1662
Peter Thatchera6d24442015-07-09 21:26:36 -07001663 // Send PR answer
kwiberg31022942016-03-11 14:18:21 -08001664 std::unique_ptr<cricket::SessionDescription> sdesc2(
Peter Thatchera6d24442015-07-09 21:26:36 -07001665 CreateSessionDescriptionWithStream(2));
1666 EXPECT_TRUE(channel1_->PushdownLocalDescription(
1667 sdesc2.get(), cricket::CA_PRANSWER, &err));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001668 EXPECT_TRUE(media_channel1_->HasRecvStream(1));
1669 EXPECT_TRUE(media_channel1_->HasSendStream(2));
1670
Peter Thatchera6d24442015-07-09 21:26:36 -07001671 // Send answer
kwiberg31022942016-03-11 14:18:21 -08001672 std::unique_ptr<cricket::SessionDescription> sdesc3(
Peter Thatchera6d24442015-07-09 21:26:36 -07001673 CreateSessionDescriptionWithStream(3));
1674 EXPECT_TRUE(channel1_->PushdownLocalDescription(
1675 sdesc3.get(), cricket::CA_ANSWER, &err));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001676 EXPECT_TRUE(media_channel1_->HasRecvStream(1));
1677 EXPECT_FALSE(media_channel1_->HasSendStream(2));
1678 EXPECT_TRUE(media_channel1_->HasSendStream(3));
1679 }
1680
1681 void TestReceivePrAnswer() {
1682 CreateChannels(0, 0);
1683
Peter Thatchera6d24442015-07-09 21:26:36 -07001684 std::string err;
1685 // Send offer
kwiberg31022942016-03-11 14:18:21 -08001686 std::unique_ptr<cricket::SessionDescription> sdesc1(
Peter Thatchera6d24442015-07-09 21:26:36 -07001687 CreateSessionDescriptionWithStream(1));
1688 EXPECT_TRUE(channel1_->PushdownLocalDescription(
1689 sdesc1.get(), cricket::CA_OFFER, &err));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001690 EXPECT_TRUE(media_channel1_->HasSendStream(1));
1691
Peter Thatchera6d24442015-07-09 21:26:36 -07001692 // Receive PR answer
kwiberg31022942016-03-11 14:18:21 -08001693 std::unique_ptr<cricket::SessionDescription> sdesc2(
Peter Thatchera6d24442015-07-09 21:26:36 -07001694 CreateSessionDescriptionWithStream(2));
1695 EXPECT_TRUE(channel1_->PushdownRemoteDescription(
1696 sdesc2.get(), cricket::CA_PRANSWER, &err));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001697 EXPECT_TRUE(media_channel1_->HasSendStream(1));
1698 EXPECT_TRUE(media_channel1_->HasRecvStream(2));
1699
Peter Thatchera6d24442015-07-09 21:26:36 -07001700 // Receive answer
kwiberg31022942016-03-11 14:18:21 -08001701 std::unique_ptr<cricket::SessionDescription> sdesc3(
Peter Thatchera6d24442015-07-09 21:26:36 -07001702 CreateSessionDescriptionWithStream(3));
1703 EXPECT_TRUE(channel1_->PushdownRemoteDescription(
1704 sdesc3.get(), cricket::CA_ANSWER, &err));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001705 EXPECT_TRUE(media_channel1_->HasSendStream(1));
1706 EXPECT_FALSE(media_channel1_->HasRecvStream(2));
1707 EXPECT_TRUE(media_channel1_->HasRecvStream(3));
1708 }
1709
1710 void TestFlushRtcp() {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001711 CreateChannels(RTCP, RTCP);
1712 EXPECT_TRUE(SendInitiate());
1713 EXPECT_TRUE(SendAccept());
deadbeef49f34fd2016-12-06 16:22:06 -08001714 EXPECT_EQ(2U, GetChannels1().size());
1715 EXPECT_EQ(2U, GetChannels2().size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001716
1717 // Send RTCP1 from a different thread.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001718 ScopedCallThread send_rtcp([this] { SendRtcp1(); });
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001719 // The sending message is only posted. channel2_ should be empty.
1720 EXPECT_TRUE(CheckNoRtcp2());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001721 rtc::Thread* wait_for[] = {send_rtcp.thread()};
1722 WaitForThreads(wait_for); // Ensure rtcp was posted
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001723
1724 // When channel1_ is deleted, the RTCP packet should be sent out to
1725 // channel2_.
1726 channel1_.reset();
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001727 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001728 EXPECT_TRUE(CheckRtcp2());
1729 }
1730
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00001731 void TestSrtpError(int pl_type) {
solenberg5b14b422015-10-01 04:10:31 -07001732 struct SrtpErrorHandler : public sigslot::has_slots<> {
1733 SrtpErrorHandler() :
1734 mode_(cricket::SrtpFilter::UNPROTECT),
1735 error_(cricket::SrtpFilter::ERROR_NONE) {}
1736 void OnSrtpError(uint32 ssrc, cricket::SrtpFilter::Mode mode,
1737 cricket::SrtpFilter::Error error) {
1738 mode_ = mode;
1739 error_ = error;
1740 }
1741 cricket::SrtpFilter::Mode mode_;
1742 cricket::SrtpFilter::Error error_;
1743 } error_handler;
1744
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00001745 // For Audio, only pl_type 0 is added to the bundle filter.
1746 // For Video, only pl_type 97 is added to the bundle filter.
1747 // So we need to pass in pl_type so that the packet can pass through
1748 // the bundle filter before it can be processed by the srtp filter.
1749 // The packet is not a valid srtp packet because it is too short.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001750 static unsigned const char kBadPacket[] = {
1751 0x84, static_cast<unsigned char>(pl_type),
1752 0x00, 0x01,
1753 0x00, 0x00,
1754 0x00, 0x00,
1755 0x00, 0x00,
1756 0x00, 0x01};
Taylor Brandstetter88532892016-08-01 14:17:27 -07001757
1758 // Using fake clock because this tests that SRTP errors are signaled at
1759 // specific times based on set_signal_silent_time.
1760 rtc::ScopedFakeClock fake_clock;
1761 // Some code uses a time of 0 as a special value, so we must start with
1762 // a non-zero time.
1763 // TODO(deadbeef): Fix this.
1764 fake_clock.AdvanceTime(rtc::TimeDelta::FromSeconds(1));
1765
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001766 CreateChannels(RTCP | SECURE, RTCP | SECURE);
1767 EXPECT_FALSE(channel1_->secure());
1768 EXPECT_FALSE(channel2_->secure());
1769 EXPECT_TRUE(SendInitiate());
1770 EXPECT_TRUE(SendAccept());
1771 EXPECT_TRUE(channel1_->secure());
1772 EXPECT_TRUE(channel2_->secure());
solenberg5629a1d2015-10-01 08:45:57 -07001773 channel2_->srtp_filter()->set_signal_silent_time(250);
solenberg5b14b422015-10-01 04:10:31 -07001774 channel2_->srtp_filter()->SignalSrtpError.connect(
1775 &error_handler, &SrtpErrorHandler::OnSrtpError);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001776
1777 // Testing failures in sending packets.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001778 media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket),
1779 rtc::PacketOptions());
1780 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001781 // The first failure will trigger an error.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001782 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_);
solenberg5b14b422015-10-01 04:10:31 -07001783 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_);
1784 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE;
solenberg5629a1d2015-10-01 08:45:57 -07001785 error_handler.mode_ = cricket::SrtpFilter::UNPROTECT;
1786 // The next 250 ms failures will not trigger an error.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001787 media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket),
1788 rtc::PacketOptions());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001789 // Wait for a while to ensure no message comes in.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001790 WaitForThreads();
Taylor Brandstetter88532892016-08-01 14:17:27 -07001791 fake_clock.AdvanceTime(rtc::TimeDelta::FromMilliseconds(200));
solenberg5b14b422015-10-01 04:10:31 -07001792 EXPECT_EQ(cricket::SrtpFilter::ERROR_NONE, error_handler.error_);
solenberg5629a1d2015-10-01 08:45:57 -07001793 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_);
1794 // Wait for a little more - the error will be triggered again.
Taylor Brandstetter88532892016-08-01 14:17:27 -07001795 fake_clock.AdvanceTime(rtc::TimeDelta::FromMilliseconds(200));
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001796 media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket),
1797 rtc::PacketOptions());
1798 WaitForThreads();
1799 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_);
solenberg5b14b422015-10-01 04:10:31 -07001800 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001801
1802 // Testing failures in receiving packets.
solenberg5b14b422015-10-01 04:10:31 -07001803 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE;
solenberg5629a1d2015-10-01 08:45:57 -07001804 error_handler.mode_ = cricket::SrtpFilter::UNPROTECT;
solenberg5b14b422015-10-01 04:10:31 -07001805
Taylor Brandstetter5d97a9a2016-06-10 14:17:27 -07001806 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001807 cricket::TransportChannel* transport_channel =
1808 channel2_->transport_channel();
1809 transport_channel->SignalReadPacket(
1810 transport_channel, reinterpret_cast<const char*>(kBadPacket),
1811 sizeof(kBadPacket), rtc::PacketTime(), 0);
1812 });
1813 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_);
solenberg5b14b422015-10-01 04:10:31 -07001814 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_);
Taylor Brandstetter88532892016-08-01 14:17:27 -07001815 // Terminate channels before the fake clock is destroyed.
1816 EXPECT_TRUE(SendTerminate());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001817 }
1818
1819 void TestOnReadyToSend() {
1820 CreateChannels(RTCP, RTCP);
1821 TransportChannel* rtp = channel1_->transport_channel();
1822 TransportChannel* rtcp = channel1_->rtcp_transport_channel();
1823 EXPECT_FALSE(media_channel1_->ready_to_send());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001824
Taylor Brandstetter5d97a9a2016-06-10 14:17:27 -07001825 network_thread_->Invoke<void>(RTC_FROM_HERE,
1826 [rtp] { rtp->SignalReadyToSend(rtp); });
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001827 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001828 EXPECT_FALSE(media_channel1_->ready_to_send());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001829
Taylor Brandstetter5d97a9a2016-06-10 14:17:27 -07001830 network_thread_->Invoke<void>(RTC_FROM_HERE,
1831 [rtcp] { rtcp->SignalReadyToSend(rtcp); });
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001832 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001833 // MediaChannel::OnReadyToSend only be called when both rtp and rtcp
1834 // channel are ready to send.
1835 EXPECT_TRUE(media_channel1_->ready_to_send());
1836
1837 // rtp channel becomes not ready to send will be propagated to mediachannel
Taylor Brandstetterbad33bf2016-08-25 13:31:14 -07001838 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
1839 channel1_->SetTransportChannelReadyToSend(false, false);
1840 });
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001841 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001842 EXPECT_FALSE(media_channel1_->ready_to_send());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001843
Taylor Brandstetterbad33bf2016-08-25 13:31:14 -07001844 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
1845 channel1_->SetTransportChannelReadyToSend(false, true);
1846 });
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001847 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001848 EXPECT_TRUE(media_channel1_->ready_to_send());
1849
1850 // rtcp channel becomes not ready to send will be propagated to mediachannel
Taylor Brandstetterbad33bf2016-08-25 13:31:14 -07001851 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
1852 channel1_->SetTransportChannelReadyToSend(true, false);
1853 });
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001854 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001855 EXPECT_FALSE(media_channel1_->ready_to_send());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001856
Taylor Brandstetterbad33bf2016-08-25 13:31:14 -07001857 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
1858 channel1_->SetTransportChannelReadyToSend(true, true);
1859 });
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001860 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001861 EXPECT_TRUE(media_channel1_->ready_to_send());
1862 }
1863
1864 void TestOnReadyToSendWithRtcpMux() {
1865 CreateChannels(RTCP, RTCP);
1866 typename T::Content content;
1867 CreateContent(0, kPcmuCodec, kH264Codec, &content);
1868 // Both sides agree on mux. Should no longer be a separate RTCP channel.
1869 content.set_rtcp_mux(true);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +00001870 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL));
1871 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001872 EXPECT_TRUE(channel1_->rtcp_transport_channel() == NULL);
1873 TransportChannel* rtp = channel1_->transport_channel();
1874 EXPECT_FALSE(media_channel1_->ready_to_send());
1875 // In the case of rtcp mux, the SignalReadyToSend() from rtp channel
1876 // should trigger the MediaChannel's OnReadyToSend.
Taylor Brandstetter5d97a9a2016-06-10 14:17:27 -07001877 network_thread_->Invoke<void>(RTC_FROM_HERE,
1878 [rtp] { rtp->SignalReadyToSend(rtp); });
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001879 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001880 EXPECT_TRUE(media_channel1_->ready_to_send());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001881
Taylor Brandstetterbad33bf2016-08-25 13:31:14 -07001882 network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
1883 channel1_->SetTransportChannelReadyToSend(false, false);
1884 });
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001885 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001886 EXPECT_FALSE(media_channel1_->ready_to_send());
1887 }
1888
skvladdc1c62c2016-03-16 19:07:43 -07001889 bool SetRemoteContentWithBitrateLimit(int remote_limit) {
1890 typename T::Content content;
1891 CreateContent(0, kPcmuCodec, kH264Codec, &content);
1892 content.set_bandwidth(remote_limit);
1893 return channel1_->SetRemoteContent(&content, CA_OFFER, NULL);
1894 }
1895
1896 webrtc::RtpParameters BitrateLimitedParameters(int limit) {
1897 webrtc::RtpParameters parameters;
1898 webrtc::RtpEncodingParameters encoding;
1899 encoding.max_bitrate_bps = limit;
1900 parameters.encodings.push_back(encoding);
1901 return parameters;
1902 }
1903
1904 void VerifyMaxBitrate(const webrtc::RtpParameters& parameters,
1905 int expected_bitrate) {
1906 EXPECT_EQ(1UL, parameters.encodings.size());
1907 EXPECT_EQ(expected_bitrate, parameters.encodings[0].max_bitrate_bps);
1908 }
1909
1910 void DefaultMaxBitrateIsUnlimited() {
1911 CreateChannels(0, 0);
1912 EXPECT_TRUE(
1913 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL));
1914 EXPECT_EQ(media_channel1_->max_bps(), -1);
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -07001915 VerifyMaxBitrate(media_channel1_->GetRtpSendParameters(kSsrc1), -1);
skvladdc1c62c2016-03-16 19:07:43 -07001916 }
1917
1918 void CanChangeMaxBitrate() {
1919 CreateChannels(0, 0);
1920 EXPECT_TRUE(
1921 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL));
1922
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -07001923 EXPECT_TRUE(channel1_->SetRtpSendParameters(
1924 kSsrc1, BitrateLimitedParameters(1000)));
1925 VerifyMaxBitrate(channel1_->GetRtpSendParameters(kSsrc1), 1000);
1926 VerifyMaxBitrate(media_channel1_->GetRtpSendParameters(kSsrc1), 1000);
skvladdc1c62c2016-03-16 19:07:43 -07001927 EXPECT_EQ(-1, media_channel1_->max_bps());
1928
1929 EXPECT_TRUE(
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -07001930 channel1_->SetRtpSendParameters(kSsrc1, BitrateLimitedParameters(-1)));
1931 VerifyMaxBitrate(channel1_->GetRtpSendParameters(kSsrc1), -1);
1932 VerifyMaxBitrate(media_channel1_->GetRtpSendParameters(kSsrc1), -1);
skvladdc1c62c2016-03-16 19:07:43 -07001933 EXPECT_EQ(-1, media_channel1_->max_bps());
1934 }
1935
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001936 protected:
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001937 void WaitForThreads() { WaitForThreads(rtc::ArrayView<rtc::Thread*>()); }
1938 static void ProcessThreadQueue(rtc::Thread* thread) {
1939 RTC_DCHECK(thread->IsCurrent());
1940 while (!thread->empty()) {
1941 thread->ProcessMessages(0);
1942 }
1943 }
1944 void WaitForThreads(rtc::ArrayView<rtc::Thread*> threads) {
1945 // |threads| and current thread post packets to network thread.
1946 for (rtc::Thread* thread : threads) {
Taylor Brandstetter5d97a9a2016-06-10 14:17:27 -07001947 thread->Invoke<void>(RTC_FROM_HERE,
1948 [thread] { ProcessThreadQueue(thread); });
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001949 }
1950 ProcessThreadQueue(rtc::Thread::Current());
1951 // Network thread move them around and post back to worker = current thread.
1952 if (!network_thread_->IsCurrent()) {
1953 network_thread_->Invoke<void>(
Taylor Brandstetter5d97a9a2016-06-10 14:17:27 -07001954 RTC_FROM_HERE, [this] { ProcessThreadQueue(network_thread_); });
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001955 }
1956 // Worker thread = current Thread process received messages.
1957 ProcessThreadQueue(rtc::Thread::Current());
1958 }
Peter Boström34fbfff2015-09-24 19:20:30 +02001959 // TODO(pbos): Remove playout from all media channels and let renderers mute
1960 // themselves.
1961 const bool verify_playout_;
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001962 std::unique_ptr<rtc::Thread> network_thread_keeper_;
1963 rtc::Thread* network_thread_;
1964 std::unique_ptr<cricket::FakeTransportController> transport_controller1_;
1965 std::unique_ptr<cricket::FakeTransportController> transport_controller2_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001966 cricket::FakeMediaEngine media_engine_;
1967 // The media channels are owned by the voice channel objects below.
1968 typename T::MediaChannel* media_channel1_;
1969 typename T::MediaChannel* media_channel2_;
kwiberg31022942016-03-11 14:18:21 -08001970 std::unique_ptr<typename T::Channel> channel1_;
1971 std::unique_ptr<typename T::Channel> channel2_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001972 typename T::Content local_media_content1_;
1973 typename T::Content local_media_content2_;
1974 typename T::Content remote_media_content1_;
1975 typename T::Content remote_media_content2_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001976 // The RTP and RTCP packets to send in the tests.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001977 rtc::Buffer rtp_packet_;
1978 rtc::Buffer rtcp_packet_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001979 int media_info_callbacks1_;
1980 int media_info_callbacks2_;
Honghai Zhangcc411c02016-03-29 17:27:21 -07001981 cricket::CandidatePairInterface* last_selected_candidate_pair_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001982};
1983
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001984template<>
1985void ChannelTest<VoiceTraits>::CreateContent(
1986 int flags,
1987 const cricket::AudioCodec& audio_codec,
1988 const cricket::VideoCodec& video_codec,
1989 cricket::AudioContentDescription* audio) {
1990 audio->AddCodec(audio_codec);
1991 audio->set_rtcp_mux((flags & RTCP_MUX) != 0);
1992 if (flags & SECURE) {
1993 audio->AddCrypto(cricket::CryptoParams(
Guo-wei Shieh456696a2015-09-30 21:48:54 -07001994 1, rtc::CS_AES_CM_128_HMAC_SHA1_32,
1995 "inline:" + rtc::CreateRandomString(40), std::string()));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001996 }
1997}
1998
1999template<>
2000void ChannelTest<VoiceTraits>::CopyContent(
2001 const cricket::AudioContentDescription& source,
2002 cricket::AudioContentDescription* audio) {
2003 *audio = source;
2004}
2005
2006template<>
2007bool ChannelTest<VoiceTraits>::CodecMatches(const cricket::AudioCodec& c1,
2008 const cricket::AudioCodec& c2) {
2009 return c1.name == c2.name && c1.clockrate == c2.clockrate &&
2010 c1.bitrate == c2.bitrate && c1.channels == c2.channels;
2011}
2012
Peter Boström0c4e06b2015-10-07 12:23:21 +02002013template <>
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002014void ChannelTest<VoiceTraits>::AddLegacyStreamInContent(
Peter Boström0c4e06b2015-10-07 12:23:21 +02002015 uint32_t ssrc,
2016 int flags,
2017 cricket::AudioContentDescription* audio) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002018 audio->AddLegacyStream(ssrc);
2019}
2020
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002021class VoiceChannelSingleThreadTest : public ChannelTest<VoiceTraits> {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002022 public:
solenberg1dd98f32015-09-10 01:57:14 -07002023 typedef ChannelTest<VoiceTraits> Base;
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002024 VoiceChannelSingleThreadTest()
2025 : Base(true, kPcmuFrame, kRtcpReport, NetworkIsWorker::Yes) {}
2026};
2027
2028class VoiceChannelDoubleThreadTest : public ChannelTest<VoiceTraits> {
2029 public:
2030 typedef ChannelTest<VoiceTraits> Base;
2031 VoiceChannelDoubleThreadTest()
2032 : Base(true, kPcmuFrame, kRtcpReport, NetworkIsWorker::No) {}
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002033};
2034
2035// override to add NULL parameter
deadbeefcbecd352015-09-23 11:50:27 -07002036template <>
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002037cricket::VideoChannel* ChannelTest<VideoTraits>::CreateChannel(
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002038 rtc::Thread* worker_thread,
2039 rtc::Thread* network_thread,
deadbeefcbecd352015-09-23 11:50:27 -07002040 cricket::MediaEngineInterface* engine,
2041 cricket::FakeVideoMediaChannel* ch,
2042 cricket::TransportController* transport_controller,
jbauchcb560652016-08-04 05:20:32 -07002043 int flags) {
deadbeef7af91dd2016-12-13 11:29:11 -08002044 cricket::VideoChannel* channel = new cricket::VideoChannel(
2045 worker_thread, network_thread, ch, transport_controller,
2046 cricket::CN_VIDEO, (flags & RTCP) != 0, (flags & SECURE) != 0);
jbauchcb560652016-08-04 05:20:32 -07002047 rtc::CryptoOptions crypto_options;
2048 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0;
2049 channel->SetCryptoOptions(crypto_options);
skvlad6c87a672016-05-17 17:49:52 -07002050 if (!channel->Init_w(nullptr)) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002051 delete channel;
2052 channel = NULL;
2053 }
2054 return channel;
2055}
2056
2057// override to add 0 parameter
2058template<>
2059bool ChannelTest<VideoTraits>::AddStream1(int id) {
2060 return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id));
2061}
2062
2063template<>
2064void ChannelTest<VideoTraits>::CreateContent(
2065 int flags,
2066 const cricket::AudioCodec& audio_codec,
2067 const cricket::VideoCodec& video_codec,
2068 cricket::VideoContentDescription* video) {
2069 video->AddCodec(video_codec);
2070 video->set_rtcp_mux((flags & RTCP_MUX) != 0);
2071 if (flags & SECURE) {
2072 video->AddCrypto(cricket::CryptoParams(
Guo-wei Shieh456696a2015-09-30 21:48:54 -07002073 1, rtc::CS_AES_CM_128_HMAC_SHA1_80,
2074 "inline:" + rtc::CreateRandomString(40), std::string()));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002075 }
2076}
2077
2078template<>
2079void ChannelTest<VideoTraits>::CopyContent(
2080 const cricket::VideoContentDescription& source,
2081 cricket::VideoContentDescription* video) {
2082 *video = source;
2083}
2084
2085template<>
2086bool ChannelTest<VideoTraits>::CodecMatches(const cricket::VideoCodec& c1,
2087 const cricket::VideoCodec& c2) {
perkj26752742016-10-24 01:21:16 -07002088 return c1.name == c2.name;
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002089}
2090
Peter Boström0c4e06b2015-10-07 12:23:21 +02002091template <>
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002092void ChannelTest<VideoTraits>::AddLegacyStreamInContent(
Peter Boström0c4e06b2015-10-07 12:23:21 +02002093 uint32_t ssrc,
2094 int flags,
2095 cricket::VideoContentDescription* video) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002096 video->AddLegacyStream(ssrc);
2097}
2098
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002099class VideoChannelSingleThreadTest : public ChannelTest<VideoTraits> {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002100 public:
solenberg1dd98f32015-09-10 01:57:14 -07002101 typedef ChannelTest<VideoTraits> Base;
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002102 VideoChannelSingleThreadTest()
2103 : Base(false, kH264Packet, kRtcpReport, NetworkIsWorker::Yes) {}
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002104};
2105
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002106class VideoChannelDoubleThreadTest : public ChannelTest<VideoTraits> {
2107 public:
2108 typedef ChannelTest<VideoTraits> Base;
2109 VideoChannelDoubleThreadTest()
2110 : Base(false, kH264Packet, kRtcpReport, NetworkIsWorker::No) {}
2111};
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002112
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002113// VoiceChannelSingleThreadTest
2114TEST_F(VoiceChannelSingleThreadTest, TestInit) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002115 Base::TestInit();
2116 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
2117 EXPECT_TRUE(media_channel1_->dtmf_info_queue().empty());
2118}
2119
Danil Chapovalovdae07ba2016-05-14 01:43:50 +02002120TEST_F(VoiceChannelSingleThreadTest, TestDeinit) {
2121 Base::TestDeinit();
2122}
2123
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002124TEST_F(VoiceChannelSingleThreadTest, TestSetContents) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002125 Base::TestSetContents();
2126}
2127
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002128TEST_F(VoiceChannelSingleThreadTest, TestSetContentsNullOffer) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002129 Base::TestSetContentsNullOffer();
2130}
2131
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002132TEST_F(VoiceChannelSingleThreadTest, TestSetContentsRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002133 Base::TestSetContentsRtcpMux();
2134}
2135
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002136TEST_F(VoiceChannelSingleThreadTest, TestSetContentsRtcpMuxWithPrAnswer) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002137 Base::TestSetContentsRtcpMux();
2138}
2139
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002140TEST_F(VoiceChannelSingleThreadTest, TestSetRemoteContentUpdate) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002141 Base::TestSetRemoteContentUpdate();
2142}
2143
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002144TEST_F(VoiceChannelSingleThreadTest, TestStreams) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002145 Base::TestStreams();
2146}
2147
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002148TEST_F(VoiceChannelSingleThreadTest, TestUpdateStreamsInLocalContent) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002149 Base::TestUpdateStreamsInLocalContent();
2150}
2151
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002152TEST_F(VoiceChannelSingleThreadTest, TestUpdateRemoteStreamsInContent) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002153 Base::TestUpdateStreamsInRemoteContent();
2154}
2155
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002156TEST_F(VoiceChannelSingleThreadTest, TestChangeStreamParamsInContent) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002157 Base::TestChangeStreamParamsInContent();
2158}
2159
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002160TEST_F(VoiceChannelSingleThreadTest, TestPlayoutAndSendingStates) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002161 Base::TestPlayoutAndSendingStates();
2162}
2163
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002164TEST_F(VoiceChannelSingleThreadTest, TestMuteStream) {
solenberg1dd98f32015-09-10 01:57:14 -07002165 CreateChannels(0, 0);
2166 // Test that we can Mute the default channel even though the sending SSRC
2167 // is unknown.
2168 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
solenberg1dd98f32015-09-10 01:57:14 -07002169 EXPECT_TRUE(channel1_->SetAudioSend(0, false, nullptr, nullptr));
solenbergdfc8f4f2015-10-01 02:31:10 -07002170 EXPECT_TRUE(media_channel1_->IsStreamMuted(0));
2171 EXPECT_TRUE(channel1_->SetAudioSend(0, true, nullptr, nullptr));
solenberg1dd98f32015-09-10 01:57:14 -07002172 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
2173
2174 // Test that we can not mute an unknown SSRC.
solenbergdfc8f4f2015-10-01 02:31:10 -07002175 EXPECT_FALSE(channel1_->SetAudioSend(kSsrc1, false, nullptr, nullptr));
solenberg1dd98f32015-09-10 01:57:14 -07002176
2177 SendInitiate();
2178 // After the local session description has been set, we can mute a stream
2179 // with its SSRC.
solenberg1dd98f32015-09-10 01:57:14 -07002180 EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, false, nullptr, nullptr));
solenbergdfc8f4f2015-10-01 02:31:10 -07002181 EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1));
2182 EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, true, nullptr, nullptr));
solenberg1dd98f32015-09-10 01:57:14 -07002183 EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002184}
2185
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002186TEST_F(VoiceChannelSingleThreadTest, TestMediaContentDirection) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002187 Base::TestMediaContentDirection();
2188}
2189
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002190TEST_F(VoiceChannelSingleThreadTest, TestNetworkRouteChanges) {
Honghai Zhangcc411c02016-03-29 17:27:21 -07002191 Base::TestNetworkRouteChanges();
2192}
2193
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002194TEST_F(VoiceChannelSingleThreadTest, TestCallSetup) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002195 Base::TestCallSetup();
2196}
2197
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002198TEST_F(VoiceChannelSingleThreadTest, TestCallTeardownRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002199 Base::TestCallTeardownRtcpMux();
2200}
2201
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002202TEST_F(VoiceChannelSingleThreadTest, SendRtpToRtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002203 Base::SendRtpToRtp();
2204}
2205
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002206TEST_F(VoiceChannelSingleThreadTest, SendNoRtcpToNoRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002207 Base::SendNoRtcpToNoRtcp();
2208}
2209
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002210TEST_F(VoiceChannelSingleThreadTest, SendNoRtcpToRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002211 Base::SendNoRtcpToRtcp();
2212}
2213
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002214TEST_F(VoiceChannelSingleThreadTest, SendRtcpToNoRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002215 Base::SendRtcpToNoRtcp();
2216}
2217
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002218TEST_F(VoiceChannelSingleThreadTest, SendRtcpToRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002219 Base::SendRtcpToRtcp();
2220}
2221
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002222TEST_F(VoiceChannelSingleThreadTest, SendRtcpMuxToRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002223 Base::SendRtcpMuxToRtcp();
2224}
2225
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002226TEST_F(VoiceChannelSingleThreadTest, SendRtcpMuxToRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002227 Base::SendRtcpMuxToRtcpMux();
2228}
2229
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002230TEST_F(VoiceChannelSingleThreadTest, SendRequireRtcpMuxToRtcpMux) {
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07002231 Base::SendRequireRtcpMuxToRtcpMux();
2232}
2233
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002234TEST_F(VoiceChannelSingleThreadTest, SendRtcpMuxToRequireRtcpMux) {
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07002235 Base::SendRtcpMuxToRequireRtcpMux();
2236}
2237
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002238TEST_F(VoiceChannelSingleThreadTest, SendRequireRtcpMuxToRequireRtcpMux) {
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07002239 Base::SendRequireRtcpMuxToRequireRtcpMux();
2240}
2241
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002242TEST_F(VoiceChannelSingleThreadTest, SendRequireRtcpMuxToNoRtcpMux) {
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07002243 Base::SendRequireRtcpMuxToNoRtcpMux();
2244}
2245
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002246TEST_F(VoiceChannelSingleThreadTest, SendEarlyRtcpMuxToRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002247 Base::SendEarlyRtcpMuxToRtcp();
2248}
2249
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002250TEST_F(VoiceChannelSingleThreadTest, SendEarlyRtcpMuxToRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002251 Base::SendEarlyRtcpMuxToRtcpMux();
2252}
2253
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002254TEST_F(VoiceChannelSingleThreadTest, SendSrtpToSrtpRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002255 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX);
2256}
2257
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002258TEST_F(VoiceChannelSingleThreadTest, SendSrtpToRtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002259 Base::SendSrtpToSrtp();
2260}
2261
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002262TEST_F(VoiceChannelSingleThreadTest, SendSrtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002263 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX);
2264}
2265
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002266TEST_F(VoiceChannelSingleThreadTest, SendDtlsSrtpToSrtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002267 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2268 Base::SendSrtpToSrtp(DTLS, 0);
2269}
2270
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002271TEST_F(VoiceChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002272 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2273 Base::SendSrtpToSrtp(DTLS, DTLS);
2274}
2275
jbauchcb560652016-08-04 05:20:32 -07002276TEST_F(VoiceChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtpGcmBoth) {
2277 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2278 Base::SendSrtpToSrtp(DTLS | GCM_CIPHER, DTLS | GCM_CIPHER);
2279}
2280
2281TEST_F(VoiceChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtpGcmOne) {
2282 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2283 Base::SendSrtpToSrtp(DTLS | GCM_CIPHER, DTLS);
2284}
2285
2286TEST_F(VoiceChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtpGcmTwo) {
2287 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2288 Base::SendSrtpToSrtp(DTLS, DTLS | GCM_CIPHER);
2289}
2290
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002291TEST_F(VoiceChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002292 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2293 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX);
2294}
2295
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002296TEST_F(VoiceChannelSingleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002297 Base::SendEarlyMediaUsingRtcpMuxSrtp();
2298}
2299
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002300TEST_F(VoiceChannelSingleThreadTest, SendRtpToRtpOnThread) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002301 Base::SendRtpToRtpOnThread();
2302}
2303
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002304TEST_F(VoiceChannelSingleThreadTest, SendSrtpToSrtpOnThread) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002305 Base::SendSrtpToSrtpOnThread();
2306}
2307
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002308TEST_F(VoiceChannelSingleThreadTest, SendWithWritabilityLoss) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002309 Base::SendWithWritabilityLoss();
2310}
2311
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002312TEST_F(VoiceChannelSingleThreadTest, TestMediaMonitor) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002313 Base::TestMediaMonitor();
2314}
2315
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002316// Test that InsertDtmf properly forwards to the media channel.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002317TEST_F(VoiceChannelSingleThreadTest, TestInsertDtmf) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002318 CreateChannels(0, 0);
2319 EXPECT_TRUE(SendInitiate());
2320 EXPECT_TRUE(SendAccept());
2321 EXPECT_EQ(0U, media_channel1_->dtmf_info_queue().size());
2322
solenberg1d63dd02015-12-02 12:35:09 -08002323 EXPECT_TRUE(channel1_->InsertDtmf(1, 3, 100));
2324 EXPECT_TRUE(channel1_->InsertDtmf(2, 5, 110));
2325 EXPECT_TRUE(channel1_->InsertDtmf(3, 7, 120));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002326
henrike@webrtc.org9de257d2013-07-17 14:42:53 +00002327 ASSERT_EQ(3U, media_channel1_->dtmf_info_queue().size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002328 EXPECT_TRUE(CompareDtmfInfo(media_channel1_->dtmf_info_queue()[0],
solenberg1d63dd02015-12-02 12:35:09 -08002329 1, 3, 100));
henrike@webrtc.org9de257d2013-07-17 14:42:53 +00002330 EXPECT_TRUE(CompareDtmfInfo(media_channel1_->dtmf_info_queue()[1],
solenberg1d63dd02015-12-02 12:35:09 -08002331 2, 5, 110));
henrike@webrtc.org9de257d2013-07-17 14:42:53 +00002332 EXPECT_TRUE(CompareDtmfInfo(media_channel1_->dtmf_info_queue()[2],
solenberg1d63dd02015-12-02 12:35:09 -08002333 3, 7, 120));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002334}
2335
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002336TEST_F(VoiceChannelSingleThreadTest, TestSetContentFailure) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002337 Base::TestSetContentFailure();
2338}
2339
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002340TEST_F(VoiceChannelSingleThreadTest, TestSendTwoOffers) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002341 Base::TestSendTwoOffers();
2342}
2343
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002344TEST_F(VoiceChannelSingleThreadTest, TestReceiveTwoOffers) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002345 Base::TestReceiveTwoOffers();
2346}
2347
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002348TEST_F(VoiceChannelSingleThreadTest, TestSendPrAnswer) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002349 Base::TestSendPrAnswer();
2350}
2351
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002352TEST_F(VoiceChannelSingleThreadTest, TestReceivePrAnswer) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002353 Base::TestReceivePrAnswer();
2354}
2355
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002356TEST_F(VoiceChannelSingleThreadTest, TestFlushRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002357 Base::TestFlushRtcp();
2358}
2359
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002360TEST_F(VoiceChannelSingleThreadTest, TestSrtpError) {
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00002361 Base::TestSrtpError(kAudioPts[0]);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002362}
2363
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002364TEST_F(VoiceChannelSingleThreadTest, TestOnReadyToSend) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002365 Base::TestOnReadyToSend();
2366}
2367
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002368TEST_F(VoiceChannelSingleThreadTest, TestOnReadyToSendWithRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002369 Base::TestOnReadyToSendWithRtcpMux();
2370}
2371
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002372// Test that we can scale the output volume properly for 1:1 calls.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002373TEST_F(VoiceChannelSingleThreadTest, TestScaleVolume1to1Call) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002374 CreateChannels(RTCP, RTCP);
2375 EXPECT_TRUE(SendInitiate());
2376 EXPECT_TRUE(SendAccept());
solenberg4bac9c52015-10-09 02:32:53 -07002377 double volume;
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002378
solenberg4bac9c52015-10-09 02:32:53 -07002379 // Default is (1.0).
2380 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2381 EXPECT_DOUBLE_EQ(1.0, volume);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002382 // invalid ssrc.
solenberg4bac9c52015-10-09 02:32:53 -07002383 EXPECT_FALSE(media_channel1_->GetOutputVolume(3, &volume));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002384
solenberg4bac9c52015-10-09 02:32:53 -07002385 // Set scale to (1.5).
2386 EXPECT_TRUE(channel1_->SetOutputVolume(0, 1.5));
2387 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2388 EXPECT_DOUBLE_EQ(1.5, volume);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002389
solenberg4bac9c52015-10-09 02:32:53 -07002390 // Set scale to (0).
2391 EXPECT_TRUE(channel1_->SetOutputVolume(0, 0.0));
2392 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2393 EXPECT_DOUBLE_EQ(0.0, volume);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002394}
2395
2396// Test that we can scale the output volume properly for multiway calls.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002397TEST_F(VoiceChannelSingleThreadTest, TestScaleVolumeMultiwayCall) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002398 CreateChannels(RTCP, RTCP);
2399 EXPECT_TRUE(SendInitiate());
2400 EXPECT_TRUE(SendAccept());
2401 EXPECT_TRUE(AddStream1(1));
2402 EXPECT_TRUE(AddStream1(2));
2403
solenberg4bac9c52015-10-09 02:32:53 -07002404 double volume;
2405 // Default is (1.0).
2406 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2407 EXPECT_DOUBLE_EQ(1.0, volume);
2408 EXPECT_TRUE(media_channel1_->GetOutputVolume(1, &volume));
2409 EXPECT_DOUBLE_EQ(1.0, volume);
2410 EXPECT_TRUE(media_channel1_->GetOutputVolume(2, &volume));
2411 EXPECT_DOUBLE_EQ(1.0, volume);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002412 // invalid ssrc.
solenberg4bac9c52015-10-09 02:32:53 -07002413 EXPECT_FALSE(media_channel1_->GetOutputVolume(3, &volume));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002414
solenberg4bac9c52015-10-09 02:32:53 -07002415 // Set scale to (1.5) for ssrc = 1.
2416 EXPECT_TRUE(channel1_->SetOutputVolume(1, 1.5));
2417 EXPECT_TRUE(media_channel1_->GetOutputVolume(1, &volume));
2418 EXPECT_DOUBLE_EQ(1.5, volume);
2419 EXPECT_TRUE(media_channel1_->GetOutputVolume(2, &volume));
2420 EXPECT_DOUBLE_EQ(1.0, volume);
2421 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2422 EXPECT_DOUBLE_EQ(1.0, volume);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002423
solenberg4bac9c52015-10-09 02:32:53 -07002424 // Set scale to (0) for all ssrcs.
2425 EXPECT_TRUE(channel1_->SetOutputVolume(0, 0.0));
2426 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2427 EXPECT_DOUBLE_EQ(0.0, volume);
2428 EXPECT_TRUE(media_channel1_->GetOutputVolume(1, &volume));
2429 EXPECT_DOUBLE_EQ(0.0, volume);
2430 EXPECT_TRUE(media_channel1_->GetOutputVolume(2, &volume));
2431 EXPECT_DOUBLE_EQ(0.0, volume);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002432}
2433
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002434TEST_F(VoiceChannelSingleThreadTest, SendBundleToBundle) {
tfarina5237aaf2015-11-10 23:44:30 -08002435 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, false);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002436}
2437
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002438TEST_F(VoiceChannelSingleThreadTest, SendBundleToBundleSecure) {
tfarina5237aaf2015-11-10 23:44:30 -08002439 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, true);
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00002440}
2441
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002442TEST_F(VoiceChannelSingleThreadTest, SendBundleToBundleWithRtcpMux) {
tfarina5237aaf2015-11-10 23:44:30 -08002443 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, false);
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00002444}
2445
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002446TEST_F(VoiceChannelSingleThreadTest, SendBundleToBundleWithRtcpMuxSecure) {
tfarina5237aaf2015-11-10 23:44:30 -08002447 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, true);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002448}
2449
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002450TEST_F(VoiceChannelSingleThreadTest, DefaultMaxBitrateIsUnlimited) {
skvlade0d46372016-04-07 22:59:22 -07002451 Base::DefaultMaxBitrateIsUnlimited();
skvladdc1c62c2016-03-16 19:07:43 -07002452}
2453
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002454TEST_F(VoiceChannelSingleThreadTest, CanChangeMaxBitrate) {
skvlade0d46372016-04-07 22:59:22 -07002455 Base::CanChangeMaxBitrate();
skvladdc1c62c2016-03-16 19:07:43 -07002456}
2457
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002458// VoiceChannelDoubleThreadTest
2459TEST_F(VoiceChannelDoubleThreadTest, TestInit) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002460 Base::TestInit();
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002461 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
2462 EXPECT_TRUE(media_channel1_->dtmf_info_queue().empty());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002463}
2464
Danil Chapovalovdae07ba2016-05-14 01:43:50 +02002465TEST_F(VoiceChannelDoubleThreadTest, TestDeinit) {
2466 Base::TestDeinit();
2467}
2468
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002469TEST_F(VoiceChannelDoubleThreadTest, TestSetContents) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002470 Base::TestSetContents();
2471}
2472
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002473TEST_F(VoiceChannelDoubleThreadTest, TestSetContentsNullOffer) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002474 Base::TestSetContentsNullOffer();
2475}
2476
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002477TEST_F(VoiceChannelDoubleThreadTest, TestSetContentsRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002478 Base::TestSetContentsRtcpMux();
2479}
2480
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002481TEST_F(VoiceChannelDoubleThreadTest, TestSetContentsRtcpMuxWithPrAnswer) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002482 Base::TestSetContentsRtcpMux();
2483}
2484
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002485TEST_F(VoiceChannelDoubleThreadTest, TestSetRemoteContentUpdate) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002486 Base::TestSetRemoteContentUpdate();
2487}
2488
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002489TEST_F(VoiceChannelDoubleThreadTest, TestStreams) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002490 Base::TestStreams();
2491}
2492
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002493TEST_F(VoiceChannelDoubleThreadTest, TestUpdateStreamsInLocalContent) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002494 Base::TestUpdateStreamsInLocalContent();
2495}
2496
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002497TEST_F(VoiceChannelDoubleThreadTest, TestUpdateRemoteStreamsInContent) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002498 Base::TestUpdateStreamsInRemoteContent();
2499}
2500
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002501TEST_F(VoiceChannelDoubleThreadTest, TestChangeStreamParamsInContent) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002502 Base::TestChangeStreamParamsInContent();
2503}
2504
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002505TEST_F(VoiceChannelDoubleThreadTest, TestPlayoutAndSendingStates) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002506 Base::TestPlayoutAndSendingStates();
2507}
2508
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002509TEST_F(VoiceChannelDoubleThreadTest, TestMuteStream) {
2510 CreateChannels(0, 0);
2511 // Test that we can Mute the default channel even though the sending SSRC
2512 // is unknown.
2513 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
2514 EXPECT_TRUE(channel1_->SetAudioSend(0, false, nullptr, nullptr));
2515 EXPECT_TRUE(media_channel1_->IsStreamMuted(0));
2516 EXPECT_TRUE(channel1_->SetAudioSend(0, true, nullptr, nullptr));
2517 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
2518
2519 // Test that we can not mute an unknown SSRC.
2520 EXPECT_FALSE(channel1_->SetAudioSend(kSsrc1, false, nullptr, nullptr));
2521
2522 SendInitiate();
2523 // After the local session description has been set, we can mute a stream
2524 // with its SSRC.
2525 EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, false, nullptr, nullptr));
2526 EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1));
2527 EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, true, nullptr, nullptr));
2528 EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1));
2529}
2530
2531TEST_F(VoiceChannelDoubleThreadTest, TestMediaContentDirection) {
2532 Base::TestMediaContentDirection();
2533}
2534
2535TEST_F(VoiceChannelDoubleThreadTest, TestNetworkRouteChanges) {
2536 Base::TestNetworkRouteChanges();
2537}
2538
2539TEST_F(VoiceChannelDoubleThreadTest, TestCallSetup) {
2540 Base::TestCallSetup();
2541}
2542
2543TEST_F(VoiceChannelDoubleThreadTest, TestCallTeardownRtcpMux) {
2544 Base::TestCallTeardownRtcpMux();
2545}
2546
2547TEST_F(VoiceChannelDoubleThreadTest, SendRtpToRtp) {
2548 Base::SendRtpToRtp();
2549}
2550
2551TEST_F(VoiceChannelDoubleThreadTest, SendNoRtcpToNoRtcp) {
2552 Base::SendNoRtcpToNoRtcp();
2553}
2554
2555TEST_F(VoiceChannelDoubleThreadTest, SendNoRtcpToRtcp) {
2556 Base::SendNoRtcpToRtcp();
2557}
2558
2559TEST_F(VoiceChannelDoubleThreadTest, SendRtcpToNoRtcp) {
2560 Base::SendRtcpToNoRtcp();
2561}
2562
2563TEST_F(VoiceChannelDoubleThreadTest, SendRtcpToRtcp) {
2564 Base::SendRtcpToRtcp();
2565}
2566
2567TEST_F(VoiceChannelDoubleThreadTest, SendRtcpMuxToRtcp) {
2568 Base::SendRtcpMuxToRtcp();
2569}
2570
2571TEST_F(VoiceChannelDoubleThreadTest, SendRtcpMuxToRtcpMux) {
2572 Base::SendRtcpMuxToRtcpMux();
2573}
2574
2575TEST_F(VoiceChannelDoubleThreadTest, SendRequireRtcpMuxToRtcpMux) {
2576 Base::SendRequireRtcpMuxToRtcpMux();
2577}
2578
2579TEST_F(VoiceChannelDoubleThreadTest, SendRtcpMuxToRequireRtcpMux) {
2580 Base::SendRtcpMuxToRequireRtcpMux();
2581}
2582
2583TEST_F(VoiceChannelDoubleThreadTest, SendRequireRtcpMuxToRequireRtcpMux) {
2584 Base::SendRequireRtcpMuxToRequireRtcpMux();
2585}
2586
2587TEST_F(VoiceChannelDoubleThreadTest, SendRequireRtcpMuxToNoRtcpMux) {
2588 Base::SendRequireRtcpMuxToNoRtcpMux();
2589}
2590
2591TEST_F(VoiceChannelDoubleThreadTest, SendEarlyRtcpMuxToRtcp) {
2592 Base::SendEarlyRtcpMuxToRtcp();
2593}
2594
2595TEST_F(VoiceChannelDoubleThreadTest, SendEarlyRtcpMuxToRtcpMux) {
2596 Base::SendEarlyRtcpMuxToRtcpMux();
2597}
2598
2599TEST_F(VoiceChannelDoubleThreadTest, SendSrtpToSrtpRtcpMux) {
2600 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX);
2601}
2602
2603TEST_F(VoiceChannelDoubleThreadTest, SendSrtpToRtp) {
2604 Base::SendSrtpToSrtp();
2605}
2606
2607TEST_F(VoiceChannelDoubleThreadTest, SendSrtcpMux) {
2608 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX);
2609}
2610
2611TEST_F(VoiceChannelDoubleThreadTest, SendDtlsSrtpToSrtp) {
2612 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2613 Base::SendSrtpToSrtp(DTLS, 0);
2614}
2615
2616TEST_F(VoiceChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtp) {
2617 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2618 Base::SendSrtpToSrtp(DTLS, DTLS);
2619}
2620
jbauchcb560652016-08-04 05:20:32 -07002621TEST_F(VoiceChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtpGcmBoth) {
2622 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2623 Base::SendSrtpToSrtp(DTLS | GCM_CIPHER, DTLS | GCM_CIPHER);
2624}
2625
2626TEST_F(VoiceChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtpGcmOne) {
2627 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2628 Base::SendSrtpToSrtp(DTLS | GCM_CIPHER, DTLS);
2629}
2630
2631TEST_F(VoiceChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtpGcmTwo) {
2632 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2633 Base::SendSrtpToSrtp(DTLS, DTLS | GCM_CIPHER);
2634}
2635
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002636TEST_F(VoiceChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) {
2637 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2638 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX);
2639}
2640
2641TEST_F(VoiceChannelDoubleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) {
2642 Base::SendEarlyMediaUsingRtcpMuxSrtp();
2643}
2644
2645TEST_F(VoiceChannelDoubleThreadTest, SendRtpToRtpOnThread) {
2646 Base::SendRtpToRtpOnThread();
2647}
2648
2649TEST_F(VoiceChannelDoubleThreadTest, SendSrtpToSrtpOnThread) {
2650 Base::SendSrtpToSrtpOnThread();
2651}
2652
2653TEST_F(VoiceChannelDoubleThreadTest, SendWithWritabilityLoss) {
2654 Base::SendWithWritabilityLoss();
2655}
2656
2657TEST_F(VoiceChannelDoubleThreadTest, TestMediaMonitor) {
2658 Base::TestMediaMonitor();
2659}
2660
2661// Test that InsertDtmf properly forwards to the media channel.
2662TEST_F(VoiceChannelDoubleThreadTest, TestInsertDtmf) {
2663 CreateChannels(0, 0);
2664 EXPECT_TRUE(SendInitiate());
2665 EXPECT_TRUE(SendAccept());
2666 EXPECT_EQ(0U, media_channel1_->dtmf_info_queue().size());
2667
2668 EXPECT_TRUE(channel1_->InsertDtmf(1, 3, 100));
2669 EXPECT_TRUE(channel1_->InsertDtmf(2, 5, 110));
2670 EXPECT_TRUE(channel1_->InsertDtmf(3, 7, 120));
2671
2672 ASSERT_EQ(3U, media_channel1_->dtmf_info_queue().size());
2673 EXPECT_TRUE(
2674 CompareDtmfInfo(media_channel1_->dtmf_info_queue()[0], 1, 3, 100));
2675 EXPECT_TRUE(
2676 CompareDtmfInfo(media_channel1_->dtmf_info_queue()[1], 2, 5, 110));
2677 EXPECT_TRUE(
2678 CompareDtmfInfo(media_channel1_->dtmf_info_queue()[2], 3, 7, 120));
2679}
2680
2681TEST_F(VoiceChannelDoubleThreadTest, TestSetContentFailure) {
2682 Base::TestSetContentFailure();
2683}
2684
2685TEST_F(VoiceChannelDoubleThreadTest, TestSendTwoOffers) {
2686 Base::TestSendTwoOffers();
2687}
2688
2689TEST_F(VoiceChannelDoubleThreadTest, TestReceiveTwoOffers) {
2690 Base::TestReceiveTwoOffers();
2691}
2692
2693TEST_F(VoiceChannelDoubleThreadTest, TestSendPrAnswer) {
2694 Base::TestSendPrAnswer();
2695}
2696
2697TEST_F(VoiceChannelDoubleThreadTest, TestReceivePrAnswer) {
2698 Base::TestReceivePrAnswer();
2699}
2700
2701TEST_F(VoiceChannelDoubleThreadTest, TestFlushRtcp) {
2702 Base::TestFlushRtcp();
2703}
2704
2705TEST_F(VoiceChannelDoubleThreadTest, TestSrtpError) {
2706 Base::TestSrtpError(kAudioPts[0]);
2707}
2708
2709TEST_F(VoiceChannelDoubleThreadTest, TestOnReadyToSend) {
2710 Base::TestOnReadyToSend();
2711}
2712
2713TEST_F(VoiceChannelDoubleThreadTest, TestOnReadyToSendWithRtcpMux) {
2714 Base::TestOnReadyToSendWithRtcpMux();
2715}
2716
2717// Test that we can scale the output volume properly for 1:1 calls.
2718TEST_F(VoiceChannelDoubleThreadTest, TestScaleVolume1to1Call) {
2719 CreateChannels(RTCP, RTCP);
2720 EXPECT_TRUE(SendInitiate());
2721 EXPECT_TRUE(SendAccept());
2722 double volume;
2723
2724 // Default is (1.0).
2725 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2726 EXPECT_DOUBLE_EQ(1.0, volume);
2727 // invalid ssrc.
2728 EXPECT_FALSE(media_channel1_->GetOutputVolume(3, &volume));
2729
2730 // Set scale to (1.5).
2731 EXPECT_TRUE(channel1_->SetOutputVolume(0, 1.5));
2732 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2733 EXPECT_DOUBLE_EQ(1.5, volume);
2734
2735 // Set scale to (0).
2736 EXPECT_TRUE(channel1_->SetOutputVolume(0, 0.0));
2737 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2738 EXPECT_DOUBLE_EQ(0.0, volume);
2739}
2740
2741// Test that we can scale the output volume properly for multiway calls.
2742TEST_F(VoiceChannelDoubleThreadTest, TestScaleVolumeMultiwayCall) {
2743 CreateChannels(RTCP, RTCP);
2744 EXPECT_TRUE(SendInitiate());
2745 EXPECT_TRUE(SendAccept());
2746 EXPECT_TRUE(AddStream1(1));
2747 EXPECT_TRUE(AddStream1(2));
2748
2749 double volume;
2750 // Default is (1.0).
2751 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2752 EXPECT_DOUBLE_EQ(1.0, volume);
2753 EXPECT_TRUE(media_channel1_->GetOutputVolume(1, &volume));
2754 EXPECT_DOUBLE_EQ(1.0, volume);
2755 EXPECT_TRUE(media_channel1_->GetOutputVolume(2, &volume));
2756 EXPECT_DOUBLE_EQ(1.0, volume);
2757 // invalid ssrc.
2758 EXPECT_FALSE(media_channel1_->GetOutputVolume(3, &volume));
2759
2760 // Set scale to (1.5) for ssrc = 1.
2761 EXPECT_TRUE(channel1_->SetOutputVolume(1, 1.5));
2762 EXPECT_TRUE(media_channel1_->GetOutputVolume(1, &volume));
2763 EXPECT_DOUBLE_EQ(1.5, volume);
2764 EXPECT_TRUE(media_channel1_->GetOutputVolume(2, &volume));
2765 EXPECT_DOUBLE_EQ(1.0, volume);
2766 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2767 EXPECT_DOUBLE_EQ(1.0, volume);
2768
2769 // Set scale to (0) for all ssrcs.
2770 EXPECT_TRUE(channel1_->SetOutputVolume(0, 0.0));
2771 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2772 EXPECT_DOUBLE_EQ(0.0, volume);
2773 EXPECT_TRUE(media_channel1_->GetOutputVolume(1, &volume));
2774 EXPECT_DOUBLE_EQ(0.0, volume);
2775 EXPECT_TRUE(media_channel1_->GetOutputVolume(2, &volume));
2776 EXPECT_DOUBLE_EQ(0.0, volume);
2777}
2778
2779TEST_F(VoiceChannelDoubleThreadTest, SendBundleToBundle) {
2780 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, false);
2781}
2782
2783TEST_F(VoiceChannelDoubleThreadTest, SendBundleToBundleSecure) {
2784 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, true);
2785}
2786
2787TEST_F(VoiceChannelDoubleThreadTest, SendBundleToBundleWithRtcpMux) {
2788 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, false);
2789}
2790
2791TEST_F(VoiceChannelDoubleThreadTest, SendBundleToBundleWithRtcpMuxSecure) {
2792 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, true);
2793}
2794
2795TEST_F(VoiceChannelDoubleThreadTest, DefaultMaxBitrateIsUnlimited) {
2796 Base::DefaultMaxBitrateIsUnlimited();
2797}
2798
2799TEST_F(VoiceChannelDoubleThreadTest, CanChangeMaxBitrate) {
2800 Base::CanChangeMaxBitrate();
2801}
2802
2803// VideoChannelSingleThreadTest
2804TEST_F(VideoChannelSingleThreadTest, TestInit) {
2805 Base::TestInit();
2806}
2807
Danil Chapovalovdae07ba2016-05-14 01:43:50 +02002808TEST_F(VideoChannelSingleThreadTest, TestDeinit) {
2809 Base::TestDeinit();
2810}
2811
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002812TEST_F(VideoChannelSingleThreadTest, TestSetContents) {
2813 Base::TestSetContents();
2814}
2815
2816TEST_F(VideoChannelSingleThreadTest, TestSetContentsNullOffer) {
2817 Base::TestSetContentsNullOffer();
2818}
2819
2820TEST_F(VideoChannelSingleThreadTest, TestSetContentsRtcpMux) {
2821 Base::TestSetContentsRtcpMux();
2822}
2823
2824TEST_F(VideoChannelSingleThreadTest, TestSetContentsRtcpMuxWithPrAnswer) {
2825 Base::TestSetContentsRtcpMux();
2826}
2827
2828TEST_F(VideoChannelSingleThreadTest, TestSetRemoteContentUpdate) {
2829 Base::TestSetRemoteContentUpdate();
2830}
2831
2832TEST_F(VideoChannelSingleThreadTest, TestStreams) {
2833 Base::TestStreams();
2834}
2835
2836TEST_F(VideoChannelSingleThreadTest, TestUpdateStreamsInLocalContent) {
2837 Base::TestUpdateStreamsInLocalContent();
2838}
2839
2840TEST_F(VideoChannelSingleThreadTest, TestUpdateRemoteStreamsInContent) {
2841 Base::TestUpdateStreamsInRemoteContent();
2842}
2843
2844TEST_F(VideoChannelSingleThreadTest, TestChangeStreamParamsInContent) {
2845 Base::TestChangeStreamParamsInContent();
2846}
2847
2848TEST_F(VideoChannelSingleThreadTest, TestPlayoutAndSendingStates) {
2849 Base::TestPlayoutAndSendingStates();
2850}
2851
2852TEST_F(VideoChannelSingleThreadTest, TestMuteStream) {
solenberg1dd98f32015-09-10 01:57:14 -07002853 CreateChannels(0, 0);
2854 // Test that we can Mute the default channel even though the sending SSRC
2855 // is unknown.
2856 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
deadbeef5a4a75a2016-06-02 16:23:38 -07002857 EXPECT_TRUE(channel1_->SetVideoSend(0, false, nullptr, nullptr));
solenbergdfc8f4f2015-10-01 02:31:10 -07002858 EXPECT_TRUE(media_channel1_->IsStreamMuted(0));
deadbeef5a4a75a2016-06-02 16:23:38 -07002859 EXPECT_TRUE(channel1_->SetVideoSend(0, true, nullptr, nullptr));
solenberg1dd98f32015-09-10 01:57:14 -07002860 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
2861 // Test that we can not mute an unknown SSRC.
deadbeef5a4a75a2016-06-02 16:23:38 -07002862 EXPECT_FALSE(channel1_->SetVideoSend(kSsrc1, false, nullptr, nullptr));
solenberg1dd98f32015-09-10 01:57:14 -07002863 SendInitiate();
2864 // After the local session description has been set, we can mute a stream
2865 // with its SSRC.
deadbeef5a4a75a2016-06-02 16:23:38 -07002866 EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, false, nullptr, nullptr));
solenbergdfc8f4f2015-10-01 02:31:10 -07002867 EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1));
deadbeef5a4a75a2016-06-02 16:23:38 -07002868 EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, true, nullptr, nullptr));
solenberg1dd98f32015-09-10 01:57:14 -07002869 EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002870}
2871
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002872TEST_F(VideoChannelSingleThreadTest, TestMediaContentDirection) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002873 Base::TestMediaContentDirection();
2874}
2875
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002876TEST_F(VideoChannelSingleThreadTest, TestNetworkRouteChanges) {
Honghai Zhangcc411c02016-03-29 17:27:21 -07002877 Base::TestNetworkRouteChanges();
2878}
2879
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002880TEST_F(VideoChannelSingleThreadTest, TestCallSetup) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002881 Base::TestCallSetup();
2882}
2883
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002884TEST_F(VideoChannelSingleThreadTest, TestCallTeardownRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002885 Base::TestCallTeardownRtcpMux();
2886}
2887
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002888TEST_F(VideoChannelSingleThreadTest, SendRtpToRtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002889 Base::SendRtpToRtp();
2890}
2891
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002892TEST_F(VideoChannelSingleThreadTest, SendNoRtcpToNoRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002893 Base::SendNoRtcpToNoRtcp();
2894}
2895
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002896TEST_F(VideoChannelSingleThreadTest, SendNoRtcpToRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002897 Base::SendNoRtcpToRtcp();
2898}
2899
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002900TEST_F(VideoChannelSingleThreadTest, SendRtcpToNoRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002901 Base::SendRtcpToNoRtcp();
2902}
2903
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002904TEST_F(VideoChannelSingleThreadTest, SendRtcpToRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002905 Base::SendRtcpToRtcp();
2906}
2907
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002908TEST_F(VideoChannelSingleThreadTest, SendRtcpMuxToRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002909 Base::SendRtcpMuxToRtcp();
2910}
2911
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002912TEST_F(VideoChannelSingleThreadTest, SendRtcpMuxToRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002913 Base::SendRtcpMuxToRtcpMux();
2914}
2915
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002916TEST_F(VideoChannelSingleThreadTest, SendRequireRtcpMuxToRtcpMux) {
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07002917 Base::SendRequireRtcpMuxToRtcpMux();
2918}
2919
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002920TEST_F(VideoChannelSingleThreadTest, SendRtcpMuxToRequireRtcpMux) {
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07002921 Base::SendRtcpMuxToRequireRtcpMux();
2922}
2923
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002924TEST_F(VideoChannelSingleThreadTest, SendRequireRtcpMuxToRequireRtcpMux) {
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07002925 Base::SendRequireRtcpMuxToRequireRtcpMux();
2926}
2927
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002928TEST_F(VideoChannelSingleThreadTest, SendRequireRtcpMuxToNoRtcpMux) {
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07002929 Base::SendRequireRtcpMuxToNoRtcpMux();
2930}
2931
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002932TEST_F(VideoChannelSingleThreadTest, SendEarlyRtcpMuxToRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002933 Base::SendEarlyRtcpMuxToRtcp();
2934}
2935
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002936TEST_F(VideoChannelSingleThreadTest, SendEarlyRtcpMuxToRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002937 Base::SendEarlyRtcpMuxToRtcpMux();
2938}
2939
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002940TEST_F(VideoChannelSingleThreadTest, SendSrtpToSrtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002941 Base::SendSrtpToSrtp();
2942}
2943
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002944TEST_F(VideoChannelSingleThreadTest, SendSrtpToRtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002945 Base::SendSrtpToSrtp();
2946}
2947
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002948TEST_F(VideoChannelSingleThreadTest, SendDtlsSrtpToSrtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002949 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2950 Base::SendSrtpToSrtp(DTLS, 0);
2951}
2952
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002953TEST_F(VideoChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002954 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2955 Base::SendSrtpToSrtp(DTLS, DTLS);
2956}
2957
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002958TEST_F(VideoChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002959 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2960 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX);
2961}
2962
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002963TEST_F(VideoChannelSingleThreadTest, SendSrtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002964 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX);
2965}
2966
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002967TEST_F(VideoChannelSingleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002968 Base::SendEarlyMediaUsingRtcpMuxSrtp();
2969}
2970
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002971TEST_F(VideoChannelSingleThreadTest, SendRtpToRtpOnThread) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002972 Base::SendRtpToRtpOnThread();
2973}
2974
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002975TEST_F(VideoChannelSingleThreadTest, SendSrtpToSrtpOnThread) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002976 Base::SendSrtpToSrtpOnThread();
2977}
2978
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002979TEST_F(VideoChannelSingleThreadTest, SendWithWritabilityLoss) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002980 Base::SendWithWritabilityLoss();
2981}
2982
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002983TEST_F(VideoChannelSingleThreadTest, TestMediaMonitor) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002984 Base::TestMediaMonitor();
2985}
2986
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002987TEST_F(VideoChannelSingleThreadTest, TestSetContentFailure) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002988 Base::TestSetContentFailure();
2989}
2990
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002991TEST_F(VideoChannelSingleThreadTest, TestSendTwoOffers) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002992 Base::TestSendTwoOffers();
2993}
2994
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002995TEST_F(VideoChannelSingleThreadTest, TestReceiveTwoOffers) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002996 Base::TestReceiveTwoOffers();
2997}
2998
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002999TEST_F(VideoChannelSingleThreadTest, TestSendPrAnswer) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003000 Base::TestSendPrAnswer();
3001}
3002
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003003TEST_F(VideoChannelSingleThreadTest, TestReceivePrAnswer) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003004 Base::TestReceivePrAnswer();
3005}
3006
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003007TEST_F(VideoChannelSingleThreadTest, TestFlushRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003008 Base::TestFlushRtcp();
3009}
3010
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003011TEST_F(VideoChannelSingleThreadTest, SendBundleToBundle) {
tfarina5237aaf2015-11-10 23:44:30 -08003012 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, false);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003013}
3014
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003015TEST_F(VideoChannelSingleThreadTest, SendBundleToBundleSecure) {
tfarina5237aaf2015-11-10 23:44:30 -08003016 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, true);
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00003017}
3018
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003019TEST_F(VideoChannelSingleThreadTest, SendBundleToBundleWithRtcpMux) {
tfarina5237aaf2015-11-10 23:44:30 -08003020 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, false);
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00003021}
3022
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003023TEST_F(VideoChannelSingleThreadTest, SendBundleToBundleWithRtcpMuxSecure) {
tfarina5237aaf2015-11-10 23:44:30 -08003024 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, true);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003025}
3026
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003027TEST_F(VideoChannelSingleThreadTest, TestSrtpError) {
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00003028 Base::TestSrtpError(kVideoPts[0]);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003029}
3030
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003031TEST_F(VideoChannelSingleThreadTest, TestOnReadyToSend) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003032 Base::TestOnReadyToSend();
3033}
3034
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003035TEST_F(VideoChannelSingleThreadTest, TestOnReadyToSendWithRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003036 Base::TestOnReadyToSendWithRtcpMux();
3037}
3038
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003039TEST_F(VideoChannelSingleThreadTest, DefaultMaxBitrateIsUnlimited) {
skvladdc1c62c2016-03-16 19:07:43 -07003040 Base::DefaultMaxBitrateIsUnlimited();
3041}
3042
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003043TEST_F(VideoChannelSingleThreadTest, CanChangeMaxBitrate) {
skvladdc1c62c2016-03-16 19:07:43 -07003044 Base::CanChangeMaxBitrate();
3045}
3046
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003047// VideoChannelDoubleThreadTest
3048TEST_F(VideoChannelDoubleThreadTest, TestInit) {
3049 Base::TestInit();
3050}
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003051
Danil Chapovalovdae07ba2016-05-14 01:43:50 +02003052TEST_F(VideoChannelDoubleThreadTest, TestDeinit) {
3053 Base::TestDeinit();
3054}
3055
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003056TEST_F(VideoChannelDoubleThreadTest, TestSetContents) {
3057 Base::TestSetContents();
3058}
3059
3060TEST_F(VideoChannelDoubleThreadTest, TestSetContentsNullOffer) {
3061 Base::TestSetContentsNullOffer();
3062}
3063
3064TEST_F(VideoChannelDoubleThreadTest, TestSetContentsRtcpMux) {
3065 Base::TestSetContentsRtcpMux();
3066}
3067
3068TEST_F(VideoChannelDoubleThreadTest, TestSetContentsRtcpMuxWithPrAnswer) {
3069 Base::TestSetContentsRtcpMux();
3070}
3071
3072TEST_F(VideoChannelDoubleThreadTest, TestSetRemoteContentUpdate) {
3073 Base::TestSetRemoteContentUpdate();
3074}
3075
3076TEST_F(VideoChannelDoubleThreadTest, TestStreams) {
3077 Base::TestStreams();
3078}
3079
3080TEST_F(VideoChannelDoubleThreadTest, TestUpdateStreamsInLocalContent) {
3081 Base::TestUpdateStreamsInLocalContent();
3082}
3083
3084TEST_F(VideoChannelDoubleThreadTest, TestUpdateRemoteStreamsInContent) {
3085 Base::TestUpdateStreamsInRemoteContent();
3086}
3087
3088TEST_F(VideoChannelDoubleThreadTest, TestChangeStreamParamsInContent) {
3089 Base::TestChangeStreamParamsInContent();
3090}
3091
3092TEST_F(VideoChannelDoubleThreadTest, TestPlayoutAndSendingStates) {
3093 Base::TestPlayoutAndSendingStates();
3094}
3095
3096TEST_F(VideoChannelDoubleThreadTest, TestMuteStream) {
3097 CreateChannels(0, 0);
3098 // Test that we can Mute the default channel even though the sending SSRC
3099 // is unknown.
3100 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
deadbeef5a4a75a2016-06-02 16:23:38 -07003101 EXPECT_TRUE(channel1_->SetVideoSend(0, false, nullptr, nullptr));
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003102 EXPECT_TRUE(media_channel1_->IsStreamMuted(0));
deadbeef5a4a75a2016-06-02 16:23:38 -07003103 EXPECT_TRUE(channel1_->SetVideoSend(0, true, nullptr, nullptr));
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003104 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
3105 // Test that we can not mute an unknown SSRC.
deadbeef5a4a75a2016-06-02 16:23:38 -07003106 EXPECT_FALSE(channel1_->SetVideoSend(kSsrc1, false, nullptr, nullptr));
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003107 SendInitiate();
3108 // After the local session description has been set, we can mute a stream
3109 // with its SSRC.
deadbeef5a4a75a2016-06-02 16:23:38 -07003110 EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, false, nullptr, nullptr));
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003111 EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1));
deadbeef5a4a75a2016-06-02 16:23:38 -07003112 EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, true, nullptr, nullptr));
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003113 EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1));
3114}
3115
3116TEST_F(VideoChannelDoubleThreadTest, TestMediaContentDirection) {
3117 Base::TestMediaContentDirection();
3118}
3119
3120TEST_F(VideoChannelDoubleThreadTest, TestNetworkRouteChanges) {
3121 Base::TestNetworkRouteChanges();
3122}
3123
3124TEST_F(VideoChannelDoubleThreadTest, TestCallSetup) {
3125 Base::TestCallSetup();
3126}
3127
3128TEST_F(VideoChannelDoubleThreadTest, TestCallTeardownRtcpMux) {
3129 Base::TestCallTeardownRtcpMux();
3130}
3131
3132TEST_F(VideoChannelDoubleThreadTest, SendRtpToRtp) {
3133 Base::SendRtpToRtp();
3134}
3135
3136TEST_F(VideoChannelDoubleThreadTest, SendNoRtcpToNoRtcp) {
3137 Base::SendNoRtcpToNoRtcp();
3138}
3139
3140TEST_F(VideoChannelDoubleThreadTest, SendNoRtcpToRtcp) {
3141 Base::SendNoRtcpToRtcp();
3142}
3143
3144TEST_F(VideoChannelDoubleThreadTest, SendRtcpToNoRtcp) {
3145 Base::SendRtcpToNoRtcp();
3146}
3147
3148TEST_F(VideoChannelDoubleThreadTest, SendRtcpToRtcp) {
3149 Base::SendRtcpToRtcp();
3150}
3151
3152TEST_F(VideoChannelDoubleThreadTest, SendRtcpMuxToRtcp) {
3153 Base::SendRtcpMuxToRtcp();
3154}
3155
3156TEST_F(VideoChannelDoubleThreadTest, SendRtcpMuxToRtcpMux) {
3157 Base::SendRtcpMuxToRtcpMux();
3158}
3159
3160TEST_F(VideoChannelDoubleThreadTest, SendRequireRtcpMuxToRtcpMux) {
3161 Base::SendRequireRtcpMuxToRtcpMux();
3162}
3163
3164TEST_F(VideoChannelDoubleThreadTest, SendRtcpMuxToRequireRtcpMux) {
3165 Base::SendRtcpMuxToRequireRtcpMux();
3166}
3167
3168TEST_F(VideoChannelDoubleThreadTest, SendRequireRtcpMuxToRequireRtcpMux) {
3169 Base::SendRequireRtcpMuxToRequireRtcpMux();
3170}
3171
3172TEST_F(VideoChannelDoubleThreadTest, SendRequireRtcpMuxToNoRtcpMux) {
3173 Base::SendRequireRtcpMuxToNoRtcpMux();
3174}
3175
3176TEST_F(VideoChannelDoubleThreadTest, SendEarlyRtcpMuxToRtcp) {
3177 Base::SendEarlyRtcpMuxToRtcp();
3178}
3179
3180TEST_F(VideoChannelDoubleThreadTest, SendEarlyRtcpMuxToRtcpMux) {
3181 Base::SendEarlyRtcpMuxToRtcpMux();
3182}
3183
3184TEST_F(VideoChannelDoubleThreadTest, SendSrtpToSrtp) {
3185 Base::SendSrtpToSrtp();
3186}
3187
3188TEST_F(VideoChannelDoubleThreadTest, SendSrtpToRtp) {
3189 Base::SendSrtpToSrtp();
3190}
3191
3192TEST_F(VideoChannelDoubleThreadTest, SendDtlsSrtpToSrtp) {
3193 MAYBE_SKIP_TEST(HaveDtlsSrtp);
3194 Base::SendSrtpToSrtp(DTLS, 0);
3195}
3196
3197TEST_F(VideoChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtp) {
3198 MAYBE_SKIP_TEST(HaveDtlsSrtp);
3199 Base::SendSrtpToSrtp(DTLS, DTLS);
3200}
3201
3202TEST_F(VideoChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) {
3203 MAYBE_SKIP_TEST(HaveDtlsSrtp);
3204 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX);
3205}
3206
3207TEST_F(VideoChannelDoubleThreadTest, SendSrtcpMux) {
3208 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX);
3209}
3210
3211TEST_F(VideoChannelDoubleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) {
3212 Base::SendEarlyMediaUsingRtcpMuxSrtp();
3213}
3214
3215TEST_F(VideoChannelDoubleThreadTest, SendRtpToRtpOnThread) {
3216 Base::SendRtpToRtpOnThread();
3217}
3218
3219TEST_F(VideoChannelDoubleThreadTest, SendSrtpToSrtpOnThread) {
3220 Base::SendSrtpToSrtpOnThread();
3221}
3222
3223TEST_F(VideoChannelDoubleThreadTest, SendWithWritabilityLoss) {
3224 Base::SendWithWritabilityLoss();
3225}
3226
3227TEST_F(VideoChannelDoubleThreadTest, TestMediaMonitor) {
3228 Base::TestMediaMonitor();
3229}
3230
3231TEST_F(VideoChannelDoubleThreadTest, TestSetContentFailure) {
3232 Base::TestSetContentFailure();
3233}
3234
3235TEST_F(VideoChannelDoubleThreadTest, TestSendTwoOffers) {
3236 Base::TestSendTwoOffers();
3237}
3238
3239TEST_F(VideoChannelDoubleThreadTest, TestReceiveTwoOffers) {
3240 Base::TestReceiveTwoOffers();
3241}
3242
3243TEST_F(VideoChannelDoubleThreadTest, TestSendPrAnswer) {
3244 Base::TestSendPrAnswer();
3245}
3246
3247TEST_F(VideoChannelDoubleThreadTest, TestReceivePrAnswer) {
3248 Base::TestReceivePrAnswer();
3249}
3250
3251TEST_F(VideoChannelDoubleThreadTest, TestFlushRtcp) {
3252 Base::TestFlushRtcp();
3253}
3254
3255TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundle) {
3256 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, false);
3257}
3258
3259TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundleSecure) {
3260 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, true);
3261}
3262
3263TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundleWithRtcpMux) {
3264 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, false);
3265}
3266
3267TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundleWithRtcpMuxSecure) {
3268 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, true);
3269}
3270
3271TEST_F(VideoChannelDoubleThreadTest, TestSrtpError) {
3272 Base::TestSrtpError(kVideoPts[0]);
3273}
3274
3275TEST_F(VideoChannelDoubleThreadTest, TestOnReadyToSend) {
3276 Base::TestOnReadyToSend();
3277}
3278
3279TEST_F(VideoChannelDoubleThreadTest, TestOnReadyToSendWithRtcpMux) {
3280 Base::TestOnReadyToSendWithRtcpMux();
3281}
3282
3283TEST_F(VideoChannelDoubleThreadTest, DefaultMaxBitrateIsUnlimited) {
3284 Base::DefaultMaxBitrateIsUnlimited();
3285}
3286
3287TEST_F(VideoChannelDoubleThreadTest, CanChangeMaxBitrate) {
3288 Base::CanChangeMaxBitrate();
3289}
3290
deadbeefc0dad892017-01-04 20:28:21 -08003291// DataChannelSingleThreadTest
3292class DataChannelSingleThreadTest : public ChannelTest<DataTraits> {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003293 public:
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003294 typedef ChannelTest<DataTraits> Base;
deadbeefc0dad892017-01-04 20:28:21 -08003295 DataChannelSingleThreadTest()
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003296 : Base(true, kDataPacket, kRtcpReport, NetworkIsWorker::Yes) {}
3297};
3298
deadbeefc0dad892017-01-04 20:28:21 -08003299// DataChannelDoubleThreadTest
3300class DataChannelDoubleThreadTest : public ChannelTest<DataTraits> {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003301 public:
3302 typedef ChannelTest<DataTraits> Base;
deadbeefc0dad892017-01-04 20:28:21 -08003303 DataChannelDoubleThreadTest()
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003304 : Base(true, kDataPacket, kRtcpReport, NetworkIsWorker::No) {}
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003305};
3306
3307// Override to avoid engine channel parameter.
deadbeefcbecd352015-09-23 11:50:27 -07003308template <>
deadbeefc0dad892017-01-04 20:28:21 -08003309cricket::DataChannel* ChannelTest<DataTraits>::CreateChannel(
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003310 rtc::Thread* worker_thread,
3311 rtc::Thread* network_thread,
deadbeefcbecd352015-09-23 11:50:27 -07003312 cricket::MediaEngineInterface* engine,
3313 cricket::FakeDataMediaChannel* ch,
3314 cricket::TransportController* transport_controller,
jbauchcb560652016-08-04 05:20:32 -07003315 int flags) {
deadbeefc0dad892017-01-04 20:28:21 -08003316 cricket::DataChannel* channel = new cricket::DataChannel(
deadbeef7af91dd2016-12-13 11:29:11 -08003317 worker_thread, network_thread, ch, transport_controller, cricket::CN_DATA,
3318 (flags & RTCP) != 0, (flags & SECURE) != 0);
jbauchcb560652016-08-04 05:20:32 -07003319 rtc::CryptoOptions crypto_options;
3320 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0;
3321 channel->SetCryptoOptions(crypto_options);
skvlad6c87a672016-05-17 17:49:52 -07003322 if (!channel->Init_w(nullptr)) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003323 delete channel;
3324 channel = NULL;
3325 }
3326 return channel;
3327}
3328
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003329template <>
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003330void ChannelTest<DataTraits>::CreateContent(
3331 int flags,
3332 const cricket::AudioCodec& audio_codec,
3333 const cricket::VideoCodec& video_codec,
3334 cricket::DataContentDescription* data) {
3335 data->AddCodec(kGoogleDataCodec);
3336 data->set_rtcp_mux((flags & RTCP_MUX) != 0);
3337 if (flags & SECURE) {
3338 data->AddCrypto(cricket::CryptoParams(
Guo-wei Shieh456696a2015-09-30 21:48:54 -07003339 1, rtc::CS_AES_CM_128_HMAC_SHA1_32,
3340 "inline:" + rtc::CreateRandomString(40), std::string()));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003341 }
3342}
3343
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003344template <>
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003345void ChannelTest<DataTraits>::CopyContent(
3346 const cricket::DataContentDescription& source,
3347 cricket::DataContentDescription* data) {
3348 *data = source;
3349}
3350
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003351template <>
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003352bool ChannelTest<DataTraits>::CodecMatches(const cricket::DataCodec& c1,
3353 const cricket::DataCodec& c2) {
3354 return c1.name == c2.name;
3355}
3356
Peter Boström0c4e06b2015-10-07 12:23:21 +02003357template <>
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003358void ChannelTest<DataTraits>::AddLegacyStreamInContent(
Peter Boström0c4e06b2015-10-07 12:23:21 +02003359 uint32_t ssrc,
3360 int flags,
3361 cricket::DataContentDescription* data) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003362 data->AddLegacyStream(ssrc);
3363}
3364
deadbeefc0dad892017-01-04 20:28:21 -08003365TEST_F(DataChannelSingleThreadTest, TestInit) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003366 Base::TestInit();
3367 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
3368}
3369
deadbeefc0dad892017-01-04 20:28:21 -08003370TEST_F(DataChannelSingleThreadTest, TestDeinit) {
Danil Chapovalovdae07ba2016-05-14 01:43:50 +02003371 Base::TestDeinit();
3372}
3373
deadbeefc0dad892017-01-04 20:28:21 -08003374TEST_F(DataChannelSingleThreadTest, TestSetContents) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003375 Base::TestSetContents();
3376}
3377
deadbeefc0dad892017-01-04 20:28:21 -08003378TEST_F(DataChannelSingleThreadTest, TestSetContentsNullOffer) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003379 Base::TestSetContentsNullOffer();
3380}
3381
deadbeefc0dad892017-01-04 20:28:21 -08003382TEST_F(DataChannelSingleThreadTest, TestSetContentsRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003383 Base::TestSetContentsRtcpMux();
3384}
3385
deadbeefc0dad892017-01-04 20:28:21 -08003386TEST_F(DataChannelSingleThreadTest, TestSetRemoteContentUpdate) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003387 Base::TestSetRemoteContentUpdate();
3388}
3389
deadbeefc0dad892017-01-04 20:28:21 -08003390TEST_F(DataChannelSingleThreadTest, TestStreams) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003391 Base::TestStreams();
3392}
3393
deadbeefc0dad892017-01-04 20:28:21 -08003394TEST_F(DataChannelSingleThreadTest, TestUpdateStreamsInLocalContent) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003395 Base::TestUpdateStreamsInLocalContent();
3396}
3397
deadbeefc0dad892017-01-04 20:28:21 -08003398TEST_F(DataChannelSingleThreadTest, TestUpdateRemoteStreamsInContent) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003399 Base::TestUpdateStreamsInRemoteContent();
3400}
3401
deadbeefc0dad892017-01-04 20:28:21 -08003402TEST_F(DataChannelSingleThreadTest, TestChangeStreamParamsInContent) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003403 Base::TestChangeStreamParamsInContent();
3404}
3405
deadbeefc0dad892017-01-04 20:28:21 -08003406TEST_F(DataChannelSingleThreadTest, TestPlayoutAndSendingStates) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003407 Base::TestPlayoutAndSendingStates();
3408}
3409
deadbeefc0dad892017-01-04 20:28:21 -08003410TEST_F(DataChannelSingleThreadTest, TestMediaContentDirection) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003411 Base::TestMediaContentDirection();
3412}
3413
deadbeefc0dad892017-01-04 20:28:21 -08003414TEST_F(DataChannelSingleThreadTest, TestCallSetup) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003415 Base::TestCallSetup();
3416}
3417
deadbeefc0dad892017-01-04 20:28:21 -08003418TEST_F(DataChannelSingleThreadTest, TestCallTeardownRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003419 Base::TestCallTeardownRtcpMux();
3420}
3421
deadbeefc0dad892017-01-04 20:28:21 -08003422TEST_F(DataChannelSingleThreadTest, TestOnReadyToSend) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003423 Base::TestOnReadyToSend();
3424}
3425
deadbeefc0dad892017-01-04 20:28:21 -08003426TEST_F(DataChannelSingleThreadTest, TestOnReadyToSendWithRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003427 Base::TestOnReadyToSendWithRtcpMux();
3428}
3429
deadbeefc0dad892017-01-04 20:28:21 -08003430TEST_F(DataChannelSingleThreadTest, SendRtpToRtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003431 Base::SendRtpToRtp();
3432}
3433
deadbeefc0dad892017-01-04 20:28:21 -08003434TEST_F(DataChannelSingleThreadTest, SendNoRtcpToNoRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003435 Base::SendNoRtcpToNoRtcp();
3436}
3437
deadbeefc0dad892017-01-04 20:28:21 -08003438TEST_F(DataChannelSingleThreadTest, SendNoRtcpToRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003439 Base::SendNoRtcpToRtcp();
3440}
3441
deadbeefc0dad892017-01-04 20:28:21 -08003442TEST_F(DataChannelSingleThreadTest, SendRtcpToNoRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003443 Base::SendRtcpToNoRtcp();
3444}
3445
deadbeefc0dad892017-01-04 20:28:21 -08003446TEST_F(DataChannelSingleThreadTest, SendRtcpToRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003447 Base::SendRtcpToRtcp();
3448}
3449
deadbeefc0dad892017-01-04 20:28:21 -08003450TEST_F(DataChannelSingleThreadTest, SendRtcpMuxToRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003451 Base::SendRtcpMuxToRtcp();
3452}
3453
deadbeefc0dad892017-01-04 20:28:21 -08003454TEST_F(DataChannelSingleThreadTest, SendRtcpMuxToRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003455 Base::SendRtcpMuxToRtcpMux();
3456}
3457
deadbeefc0dad892017-01-04 20:28:21 -08003458TEST_F(DataChannelSingleThreadTest, SendEarlyRtcpMuxToRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003459 Base::SendEarlyRtcpMuxToRtcp();
3460}
3461
deadbeefc0dad892017-01-04 20:28:21 -08003462TEST_F(DataChannelSingleThreadTest, SendEarlyRtcpMuxToRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003463 Base::SendEarlyRtcpMuxToRtcpMux();
3464}
3465
deadbeefc0dad892017-01-04 20:28:21 -08003466TEST_F(DataChannelSingleThreadTest, SendSrtpToSrtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003467 Base::SendSrtpToSrtp();
3468}
3469
deadbeefc0dad892017-01-04 20:28:21 -08003470TEST_F(DataChannelSingleThreadTest, SendSrtpToRtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003471 Base::SendSrtpToSrtp();
3472}
3473
deadbeefc0dad892017-01-04 20:28:21 -08003474TEST_F(DataChannelSingleThreadTest, SendSrtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003475 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX);
3476}
3477
deadbeefc0dad892017-01-04 20:28:21 -08003478TEST_F(DataChannelSingleThreadTest, SendRtpToRtpOnThread) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003479 Base::SendRtpToRtpOnThread();
3480}
3481
deadbeefc0dad892017-01-04 20:28:21 -08003482TEST_F(DataChannelSingleThreadTest, SendSrtpToSrtpOnThread) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003483 Base::SendSrtpToSrtpOnThread();
3484}
3485
deadbeefc0dad892017-01-04 20:28:21 -08003486TEST_F(DataChannelSingleThreadTest, SendWithWritabilityLoss) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003487 Base::SendWithWritabilityLoss();
3488}
3489
deadbeefc0dad892017-01-04 20:28:21 -08003490TEST_F(DataChannelSingleThreadTest, TestMediaMonitor) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003491 Base::TestMediaMonitor();
3492}
3493
deadbeefc0dad892017-01-04 20:28:21 -08003494TEST_F(DataChannelSingleThreadTest, TestSendData) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003495 CreateChannels(0, 0);
3496 EXPECT_TRUE(SendInitiate());
3497 EXPECT_TRUE(SendAccept());
3498
3499 cricket::SendDataParams params;
3500 params.ssrc = 42;
3501 unsigned char data[] = {'f', 'o', 'o'};
3502 rtc::CopyOnWriteBuffer payload(data, 3);
3503 cricket::SendDataResult result;
3504 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result));
3505 EXPECT_EQ(params.ssrc, media_channel1_->last_sent_data_params().ssrc);
3506 EXPECT_EQ("foo", media_channel1_->last_sent_data());
3507}
3508
deadbeefc0dad892017-01-04 20:28:21 -08003509TEST_F(DataChannelDoubleThreadTest, TestInit) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003510 Base::TestInit();
3511 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
3512}
3513
deadbeefc0dad892017-01-04 20:28:21 -08003514TEST_F(DataChannelDoubleThreadTest, TestDeinit) {
Danil Chapovalovdae07ba2016-05-14 01:43:50 +02003515 Base::TestDeinit();
3516}
3517
deadbeefc0dad892017-01-04 20:28:21 -08003518TEST_F(DataChannelDoubleThreadTest, TestSetContents) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003519 Base::TestSetContents();
3520}
3521
deadbeefc0dad892017-01-04 20:28:21 -08003522TEST_F(DataChannelDoubleThreadTest, TestSetContentsNullOffer) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003523 Base::TestSetContentsNullOffer();
3524}
3525
deadbeefc0dad892017-01-04 20:28:21 -08003526TEST_F(DataChannelDoubleThreadTest, TestSetContentsRtcpMux) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003527 Base::TestSetContentsRtcpMux();
3528}
3529
deadbeefc0dad892017-01-04 20:28:21 -08003530TEST_F(DataChannelDoubleThreadTest, TestSetRemoteContentUpdate) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003531 Base::TestSetRemoteContentUpdate();
3532}
3533
deadbeefc0dad892017-01-04 20:28:21 -08003534TEST_F(DataChannelDoubleThreadTest, TestStreams) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003535 Base::TestStreams();
3536}
3537
deadbeefc0dad892017-01-04 20:28:21 -08003538TEST_F(DataChannelDoubleThreadTest, TestUpdateStreamsInLocalContent) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003539 Base::TestUpdateStreamsInLocalContent();
3540}
3541
deadbeefc0dad892017-01-04 20:28:21 -08003542TEST_F(DataChannelDoubleThreadTest, TestUpdateRemoteStreamsInContent) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003543 Base::TestUpdateStreamsInRemoteContent();
3544}
3545
deadbeefc0dad892017-01-04 20:28:21 -08003546TEST_F(DataChannelDoubleThreadTest, TestChangeStreamParamsInContent) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003547 Base::TestChangeStreamParamsInContent();
3548}
3549
deadbeefc0dad892017-01-04 20:28:21 -08003550TEST_F(DataChannelDoubleThreadTest, TestPlayoutAndSendingStates) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003551 Base::TestPlayoutAndSendingStates();
3552}
3553
deadbeefc0dad892017-01-04 20:28:21 -08003554TEST_F(DataChannelDoubleThreadTest, TestMediaContentDirection) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003555 Base::TestMediaContentDirection();
3556}
3557
deadbeefc0dad892017-01-04 20:28:21 -08003558TEST_F(DataChannelDoubleThreadTest, TestCallSetup) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003559 Base::TestCallSetup();
3560}
3561
deadbeefc0dad892017-01-04 20:28:21 -08003562TEST_F(DataChannelDoubleThreadTest, TestCallTeardownRtcpMux) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003563 Base::TestCallTeardownRtcpMux();
3564}
3565
deadbeefc0dad892017-01-04 20:28:21 -08003566TEST_F(DataChannelDoubleThreadTest, TestOnReadyToSend) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003567 Base::TestOnReadyToSend();
3568}
3569
deadbeefc0dad892017-01-04 20:28:21 -08003570TEST_F(DataChannelDoubleThreadTest, TestOnReadyToSendWithRtcpMux) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003571 Base::TestOnReadyToSendWithRtcpMux();
3572}
3573
deadbeefc0dad892017-01-04 20:28:21 -08003574TEST_F(DataChannelDoubleThreadTest, SendRtpToRtp) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003575 Base::SendRtpToRtp();
3576}
3577
deadbeefc0dad892017-01-04 20:28:21 -08003578TEST_F(DataChannelDoubleThreadTest, SendNoRtcpToNoRtcp) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003579 Base::SendNoRtcpToNoRtcp();
3580}
3581
deadbeefc0dad892017-01-04 20:28:21 -08003582TEST_F(DataChannelDoubleThreadTest, SendNoRtcpToRtcp) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003583 Base::SendNoRtcpToRtcp();
3584}
3585
deadbeefc0dad892017-01-04 20:28:21 -08003586TEST_F(DataChannelDoubleThreadTest, SendRtcpToNoRtcp) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003587 Base::SendRtcpToNoRtcp();
3588}
3589
deadbeefc0dad892017-01-04 20:28:21 -08003590TEST_F(DataChannelDoubleThreadTest, SendRtcpToRtcp) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003591 Base::SendRtcpToRtcp();
3592}
3593
deadbeefc0dad892017-01-04 20:28:21 -08003594TEST_F(DataChannelDoubleThreadTest, SendRtcpMuxToRtcp) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003595 Base::SendRtcpMuxToRtcp();
3596}
3597
deadbeefc0dad892017-01-04 20:28:21 -08003598TEST_F(DataChannelDoubleThreadTest, SendRtcpMuxToRtcpMux) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003599 Base::SendRtcpMuxToRtcpMux();
3600}
3601
deadbeefc0dad892017-01-04 20:28:21 -08003602TEST_F(DataChannelDoubleThreadTest, SendEarlyRtcpMuxToRtcp) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003603 Base::SendEarlyRtcpMuxToRtcp();
3604}
3605
deadbeefc0dad892017-01-04 20:28:21 -08003606TEST_F(DataChannelDoubleThreadTest, SendEarlyRtcpMuxToRtcpMux) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003607 Base::SendEarlyRtcpMuxToRtcpMux();
3608}
3609
deadbeefc0dad892017-01-04 20:28:21 -08003610TEST_F(DataChannelDoubleThreadTest, SendSrtpToSrtp) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003611 Base::SendSrtpToSrtp();
3612}
3613
deadbeefc0dad892017-01-04 20:28:21 -08003614TEST_F(DataChannelDoubleThreadTest, SendSrtpToRtp) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003615 Base::SendSrtpToSrtp();
3616}
3617
deadbeefc0dad892017-01-04 20:28:21 -08003618TEST_F(DataChannelDoubleThreadTest, SendSrtcpMux) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003619 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX);
3620}
3621
deadbeefc0dad892017-01-04 20:28:21 -08003622TEST_F(DataChannelDoubleThreadTest, SendRtpToRtpOnThread) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003623 Base::SendRtpToRtpOnThread();
3624}
3625
deadbeefc0dad892017-01-04 20:28:21 -08003626TEST_F(DataChannelDoubleThreadTest, SendSrtpToSrtpOnThread) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003627 Base::SendSrtpToSrtpOnThread();
3628}
3629
deadbeefc0dad892017-01-04 20:28:21 -08003630TEST_F(DataChannelDoubleThreadTest, SendWithWritabilityLoss) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003631 Base::SendWithWritabilityLoss();
3632}
3633
deadbeefc0dad892017-01-04 20:28:21 -08003634TEST_F(DataChannelDoubleThreadTest, TestMediaMonitor) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003635 Base::TestMediaMonitor();
3636}
3637
deadbeefc0dad892017-01-04 20:28:21 -08003638TEST_F(DataChannelDoubleThreadTest, TestSendData) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003639 CreateChannels(0, 0);
3640 EXPECT_TRUE(SendInitiate());
3641 EXPECT_TRUE(SendAccept());
3642
3643 cricket::SendDataParams params;
3644 params.ssrc = 42;
3645 unsigned char data[] = {
3646 'f', 'o', 'o'
3647 };
jbaucheec21bd2016-03-20 06:15:43 -07003648 rtc::CopyOnWriteBuffer payload(data, 3);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003649 cricket::SendDataResult result;
3650 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result));
3651 EXPECT_EQ(params.ssrc,
3652 media_channel1_->last_sent_data_params().ssrc);
3653 EXPECT_EQ("foo", media_channel1_->last_sent_data());
3654}
3655
3656// TODO(pthatcher): TestSetReceiver?