blob: d15748ffbb878c3ace52f849862c1072d5397cfc [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"
buildbot@webrtc.org65b98d12014-08-07 22:09:08 +000015#include "webrtc/base/gunit.h"
buildbot@webrtc.org65b98d12014-08-07 22:09:08 +000016#include "webrtc/base/logging.h"
kjellandera96e2d72016-02-04 23:52:28 -080017#include "webrtc/media/base/fakemediaengine.h"
18#include "webrtc/media/base/fakertp.h"
kjellandera96e2d72016-02-04 23:52:28 -080019#include "webrtc/media/base/mediachannel.h"
kjellandera96e2d72016-02-04 23:52:28 -080020#include "webrtc/media/base/testutils.h"
Tommif888bb52015-12-12 01:37:01 +010021#include "webrtc/p2p/base/faketransportcontroller.h"
kjellander@webrtc.org9b8df252016-02-12 06:47:59 +010022#include "webrtc/pc/channel.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000023
24#define MAYBE_SKIP_TEST(feature) \
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000025 if (!(rtc::SSLStreamAdapter::feature())) { \
henrike@webrtc.org28e20752013-07-10 00:45:36 +000026 LOG(LS_INFO) << "Feature disabled... skipping"; \
27 return; \
28 }
29
30using cricket::CA_OFFER;
31using cricket::CA_PRANSWER;
32using cricket::CA_ANSWER;
33using cricket::CA_UPDATE;
34using cricket::FakeVoiceMediaChannel;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000035using cricket::ScreencastId;
36using cricket::StreamParams;
37using cricket::TransportChannel;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000038
Danil Chapovalov33b01f22016-05-11 19:55:27 +020039namespace {
40const cricket::AudioCodec kPcmuCodec(0, "PCMU", 64000, 8000, 1);
41const cricket::AudioCodec kPcmaCodec(8, "PCMA", 64000, 8000, 1);
42const cricket::AudioCodec kIsacCodec(103, "ISAC", 40000, 16000, 1);
43const cricket::VideoCodec kH264Codec(97, "H264", 640, 400, 30);
44const cricket::VideoCodec kH264SvcCodec(99, "H264-SVC", 320, 200, 15);
45const cricket::DataCodec kGoogleDataCodec(101, "google-data");
46const uint32_t kSsrc1 = 0x1111;
47const uint32_t kSsrc2 = 0x2222;
48const uint32_t kSsrc3 = 0x3333;
49const int kAudioPts[] = {0, 8};
50const int kVideoPts[] = {97, 99};
51enum class NetworkIsWorker { Yes, No };
52} // namespace
henrike@webrtc.org28e20752013-07-10 00:45:36 +000053
deadbeefcbecd352015-09-23 11:50:27 -070054template <class ChannelT,
55 class MediaChannelT,
56 class ContentT,
57 class CodecT,
58 class MediaInfoT,
59 class OptionsT>
henrike@webrtc.org28e20752013-07-10 00:45:36 +000060class Traits {
61 public:
62 typedef ChannelT Channel;
63 typedef MediaChannelT MediaChannel;
64 typedef ContentT Content;
65 typedef CodecT Codec;
66 typedef MediaInfoT MediaInfo;
Fredrik Solenbergb071a192015-09-17 16:42:56 +020067 typedef OptionsT Options;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000068};
69
henrike@webrtc.org28e20752013-07-10 00:45:36 +000070class VoiceTraits : public Traits<cricket::VoiceChannel,
71 cricket::FakeVoiceMediaChannel,
72 cricket::AudioContentDescription,
73 cricket::AudioCodec,
Fredrik Solenbergb071a192015-09-17 16:42:56 +020074 cricket::VoiceMediaInfo,
deadbeefcbecd352015-09-23 11:50:27 -070075 cricket::AudioOptions> {};
henrike@webrtc.org28e20752013-07-10 00:45:36 +000076
77class VideoTraits : public Traits<cricket::VideoChannel,
78 cricket::FakeVideoMediaChannel,
79 cricket::VideoContentDescription,
80 cricket::VideoCodec,
Fredrik Solenbergb071a192015-09-17 16:42:56 +020081 cricket::VideoMediaInfo,
deadbeefcbecd352015-09-23 11:50:27 -070082 cricket::VideoOptions> {};
henrike@webrtc.org28e20752013-07-10 00:45:36 +000083
84class DataTraits : public Traits<cricket::DataChannel,
85 cricket::FakeDataMediaChannel,
86 cricket::DataContentDescription,
87 cricket::DataCodec,
Fredrik Solenbergb071a192015-09-17 16:42:56 +020088 cricket::DataMediaInfo,
deadbeefcbecd352015-09-23 11:50:27 -070089 cricket::DataOptions> {};
henrike@webrtc.org28e20752013-07-10 00:45:36 +000090
Danil Chapovalov33b01f22016-05-11 19:55:27 +020091// Base class for Voice/Video/DataChannel tests
henrike@webrtc.org28e20752013-07-10 00:45:36 +000092template<class T>
93class ChannelTest : public testing::Test, public sigslot::has_slots<> {
94 public:
95 enum Flags { RTCP = 0x1, RTCP_MUX = 0x2, SECURE = 0x4, SSRC_MUX = 0x8,
96 DTLS = 0x10 };
97
Peter Boström34fbfff2015-09-24 19:20:30 +020098 ChannelTest(bool verify_playout,
Danil Chapovalov33b01f22016-05-11 19:55:27 +020099 rtc::ArrayView<const uint8_t> rtp_data,
100 rtc::ArrayView<const uint8_t> rtcp_data,
101 NetworkIsWorker network_is_worker)
Peter Boström34fbfff2015-09-24 19:20:30 +0200102 : verify_playout_(verify_playout),
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000103 media_channel1_(NULL),
104 media_channel2_(NULL),
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200105 rtp_packet_(rtp_data.data(), rtp_data.size()),
106 rtcp_packet_(rtcp_data.data(), rtcp_data.size()),
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000107 media_info_callbacks1_(),
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200108 media_info_callbacks2_() {
109 if (network_is_worker == NetworkIsWorker::Yes) {
110 network_thread_ = rtc::Thread::Current();
111 } else {
112 network_thread_keeper_ = rtc::Thread::Create();
113 network_thread_keeper_->SetName("Network", nullptr);
114 network_thread_keeper_->Start();
115 network_thread_ = network_thread_keeper_.get();
116 }
117 transport_controller1_.reset(new cricket::FakeTransportController(
118 network_thread_, cricket::ICEROLE_CONTROLLING));
119 transport_controller2_.reset(new cricket::FakeTransportController(
120 network_thread_, cricket::ICEROLE_CONTROLLED));
121 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000122
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000123 void CreateChannels(int flags1, int flags2) {
Fredrik Solenbergb071a192015-09-17 16:42:56 +0200124 CreateChannels(new typename T::MediaChannel(NULL, typename T::Options()),
125 new typename T::MediaChannel(NULL, typename T::Options()),
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200126 flags1, flags2);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000127 }
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200128 void CreateChannels(typename T::MediaChannel* ch1,
129 typename T::MediaChannel* ch2,
130 int flags1,
131 int flags2) {
132 rtc::Thread* worker_thread = rtc::Thread::Current();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000133 media_channel1_ = ch1;
134 media_channel2_ = ch2;
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200135 channel1_.reset(
136 CreateChannel(worker_thread, network_thread_, &media_engine_, ch1,
137 transport_controller1_.get(), (flags1 & RTCP) != 0));
138 channel2_.reset(
139 CreateChannel(worker_thread, network_thread_, &media_engine_, ch2,
140 transport_controller2_.get(), (flags2 & RTCP) != 0));
141 channel1_->SignalMediaMonitor.connect(this,
142 &ChannelTest<T>::OnMediaMonitor1);
143 channel2_->SignalMediaMonitor.connect(this,
144 &ChannelTest<T>::OnMediaMonitor2);
mallinath@webrtc.org19f27e62013-10-13 17:18:27 +0000145 if ((flags1 & DTLS) && (flags2 & DTLS)) {
146 flags1 = (flags1 & ~SECURE);
147 flags2 = (flags2 & ~SECURE);
148 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000149 CreateContent(flags1, kPcmuCodec, kH264Codec,
150 &local_media_content1_);
151 CreateContent(flags2, kPcmuCodec, kH264Codec,
152 &local_media_content2_);
153 CopyContent(local_media_content1_, &remote_media_content1_);
154 CopyContent(local_media_content2_, &remote_media_content2_);
155
156 if (flags1 & DTLS) {
Torbjorn Granlundb6d4ec42015-08-17 14:08:59 +0200157 // Confirmed to work with KT_RSA and KT_ECDSA.
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200158 transport_controller1_->SetLocalCertificate(
jbauch555604a2016-04-26 03:13:22 -0700159 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>(
kwiberg0eb15ed2015-12-17 03:04:15 -0800160 rtc::SSLIdentity::Generate("session1", rtc::KT_DEFAULT))));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000161 }
162 if (flags2 & DTLS) {
Torbjorn Granlundb6d4ec42015-08-17 14:08:59 +0200163 // Confirmed to work with KT_RSA and KT_ECDSA.
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200164 transport_controller2_->SetLocalCertificate(
jbauch555604a2016-04-26 03:13:22 -0700165 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>(
kwiberg0eb15ed2015-12-17 03:04:15 -0800166 rtc::SSLIdentity::Generate("session2", rtc::KT_DEFAULT))));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000167 }
168
169 // Add stream information (SSRC) to the local content but not to the remote
170 // content. This means that we per default know the SSRC of what we send but
171 // not what we receive.
172 AddLegacyStreamInContent(kSsrc1, flags1, &local_media_content1_);
173 AddLegacyStreamInContent(kSsrc2, flags2, &local_media_content2_);
174
175 // If SSRC_MUX is used we also need to know the SSRC of the incoming stream.
176 if (flags1 & SSRC_MUX) {
177 AddLegacyStreamInContent(kSsrc1, flags1, &remote_media_content1_);
178 }
179 if (flags2 & SSRC_MUX) {
180 AddLegacyStreamInContent(kSsrc2, flags2, &remote_media_content2_);
181 }
182 }
deadbeefcbecd352015-09-23 11:50:27 -0700183 typename T::Channel* CreateChannel(
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200184 rtc::Thread* worker_thread,
185 rtc::Thread* network_thread,
deadbeefcbecd352015-09-23 11:50:27 -0700186 cricket::MediaEngineInterface* engine,
187 typename T::MediaChannel* ch,
188 cricket::TransportController* transport_controller,
189 bool rtcp) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200190 typename T::Channel* channel =
191 new typename T::Channel(worker_thread, network_thread, engine, ch,
192 transport_controller, cricket::CN_AUDIO, rtcp);
193 if (!channel->Init_w()) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000194 delete channel;
195 channel = NULL;
196 }
197 return channel;
198 }
199
200 bool SendInitiate() {
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000201 bool result = channel1_->SetLocalContent(&local_media_content1_,
202 CA_OFFER, NULL);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000203 if (result) {
204 channel1_->Enable(true);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000205 result = channel2_->SetRemoteContent(&remote_media_content1_,
206 CA_OFFER, NULL);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000207 if (result) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200208 transport_controller1_->Connect(transport_controller2_.get());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000209
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000210 result = channel2_->SetLocalContent(&local_media_content2_,
211 CA_ANSWER, NULL);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000212 }
213 }
214 return result;
215 }
216
217 bool SendAccept() {
218 channel2_->Enable(true);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000219 return channel1_->SetRemoteContent(&remote_media_content2_,
220 CA_ANSWER, NULL);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000221 }
222
223 bool SendOffer() {
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000224 bool result = channel1_->SetLocalContent(&local_media_content1_,
225 CA_OFFER, NULL);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000226 if (result) {
227 channel1_->Enable(true);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000228 result = channel2_->SetRemoteContent(&remote_media_content1_,
229 CA_OFFER, NULL);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000230 }
231 return result;
232 }
233
234 bool SendProvisionalAnswer() {
235 bool result = channel2_->SetLocalContent(&local_media_content2_,
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000236 CA_PRANSWER, NULL);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000237 if (result) {
238 channel2_->Enable(true);
239 result = channel1_->SetRemoteContent(&remote_media_content2_,
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000240 CA_PRANSWER, NULL);
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200241 transport_controller1_->Connect(transport_controller2_.get());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000242 }
243 return result;
244 }
245
246 bool SendFinalAnswer() {
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000247 bool result = channel2_->SetLocalContent(&local_media_content2_,
248 CA_ANSWER, NULL);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000249 if (result)
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000250 result = channel1_->SetRemoteContent(&remote_media_content2_,
251 CA_ANSWER, NULL);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000252 return result;
253 }
254
255 bool SendTerminate() {
256 channel1_.reset();
257 channel2_.reset();
258 return true;
259 }
260
261 bool AddStream1(int id) {
262 return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id));
263 }
264 bool RemoveStream1(int id) {
265 return channel1_->RemoveRecvStream(id);
266 }
267
268 cricket::FakeTransport* GetTransport1() {
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200269 std::string name = channel1_->content_name();
270 return network_thread_->Invoke<cricket::FakeTransport*>(
Danil Chapovalov7f216b72016-05-12 09:20:31 +0200271 [this, name] { return transport_controller1_->GetTransport_n(name); });
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000272 }
273 cricket::FakeTransport* GetTransport2() {
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200274 std::string name = channel2_->content_name();
275 return network_thread_->Invoke<cricket::FakeTransport*>(
Danil Chapovalov7f216b72016-05-12 09:20:31 +0200276 [this, name] { return transport_controller2_->GetTransport_n(name); });
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000277 }
278
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200279 void SendRtp1() {
280 media_channel1_->SendRtp(rtp_packet_.data(), rtp_packet_.size(),
281 rtc::PacketOptions());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000282 }
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200283 void SendRtp2() {
284 media_channel2_->SendRtp(rtp_packet_.data(), rtp_packet_.size(),
285 rtc::PacketOptions());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000286 }
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200287 void SendRtcp1() {
288 media_channel1_->SendRtcp(rtcp_packet_.data(), rtcp_packet_.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000289 }
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200290 void SendRtcp2() {
291 media_channel2_->SendRtcp(rtcp_packet_.data(), rtcp_packet_.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000292 }
293 // Methods to send custom data.
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200294 void SendCustomRtp1(uint32_t ssrc, int sequence_number, int pl_type = -1) {
295 rtc::Buffer data = CreateRtpData(ssrc, sequence_number, pl_type);
296 media_channel1_->SendRtp(data.data(), data.size(), rtc::PacketOptions());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000297 }
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200298 void SendCustomRtp2(uint32_t ssrc, int sequence_number, int pl_type = -1) {
299 rtc::Buffer data = CreateRtpData(ssrc, sequence_number, pl_type);
300 media_channel2_->SendRtp(data.data(), data.size(), rtc::PacketOptions());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000301 }
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200302 void SendCustomRtcp1(uint32_t ssrc) {
303 rtc::Buffer data = CreateRtcpData(ssrc);
304 media_channel1_->SendRtcp(data.data(), data.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000305 }
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200306 void SendCustomRtcp2(uint32_t ssrc) {
307 rtc::Buffer data = CreateRtcpData(ssrc);
308 media_channel2_->SendRtcp(data.data(), data.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000309 }
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200310
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000311 bool CheckRtp1() {
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200312 return media_channel1_->CheckRtp(rtp_packet_.data(), rtp_packet_.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000313 }
314 bool CheckRtp2() {
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200315 return media_channel2_->CheckRtp(rtp_packet_.data(), rtp_packet_.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000316 }
317 bool CheckRtcp1() {
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200318 return media_channel1_->CheckRtcp(rtcp_packet_.data(), rtcp_packet_.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000319 }
320 bool CheckRtcp2() {
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200321 return media_channel2_->CheckRtcp(rtcp_packet_.data(), rtcp_packet_.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000322 }
323 // Methods to check custom data.
Peter Boström0c4e06b2015-10-07 12:23:21 +0200324 bool CheckCustomRtp1(uint32_t ssrc, int sequence_number, int pl_type = -1) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200325 rtc::Buffer data = CreateRtpData(ssrc, sequence_number, pl_type);
326 return media_channel1_->CheckRtp(data.data(), data.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000327 }
Peter Boström0c4e06b2015-10-07 12:23:21 +0200328 bool CheckCustomRtp2(uint32_t ssrc, int sequence_number, int pl_type = -1) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200329 rtc::Buffer data = CreateRtpData(ssrc, sequence_number, pl_type);
330 return media_channel2_->CheckRtp(data.data(), data.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000331 }
Peter Boström0c4e06b2015-10-07 12:23:21 +0200332 bool CheckCustomRtcp1(uint32_t ssrc) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200333 rtc::Buffer data = CreateRtcpData(ssrc);
334 return media_channel1_->CheckRtcp(data.data(), data.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000335 }
Peter Boström0c4e06b2015-10-07 12:23:21 +0200336 bool CheckCustomRtcp2(uint32_t ssrc) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200337 rtc::Buffer data = CreateRtcpData(ssrc);
338 return media_channel2_->CheckRtcp(data.data(), data.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000339 }
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200340 rtc::Buffer CreateRtpData(uint32_t ssrc, int sequence_number, int pl_type) {
341 rtc::Buffer data(rtp_packet_.data(), rtp_packet_.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000342 // Set SSRC in the rtp packet copy.
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200343 rtc::SetBE32(data.data() + 8, ssrc);
344 rtc::SetBE16(data.data() + 2, sequence_number);
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +0000345 if (pl_type >= 0) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200346 rtc::Set8(data.data(), 1, static_cast<uint8_t>(pl_type));
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +0000347 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000348 return data;
349 }
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200350 rtc::Buffer CreateRtcpData(uint32_t ssrc) {
351 rtc::Buffer data(rtcp_packet_.data(), rtcp_packet_.size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000352 // Set SSRC in the rtcp packet copy.
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200353 rtc::SetBE32(data.data() + 4, ssrc);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000354 return data;
355 }
356
357 bool CheckNoRtp1() {
358 return media_channel1_->CheckNoRtp();
359 }
360 bool CheckNoRtp2() {
361 return media_channel2_->CheckNoRtp();
362 }
363 bool CheckNoRtcp1() {
364 return media_channel1_->CheckNoRtcp();
365 }
366 bool CheckNoRtcp2() {
367 return media_channel2_->CheckNoRtcp();
368 }
369
370 void CreateContent(int flags,
371 const cricket::AudioCodec& audio_codec,
372 const cricket::VideoCodec& video_codec,
373 typename T::Content* content) {
374 // overridden in specialized classes
375 }
376 void CopyContent(const typename T::Content& source,
377 typename T::Content* content) {
378 // overridden in specialized classes
379 }
380
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000381 // Creates a cricket::SessionDescription with one MediaContent and one stream.
382 // kPcmuCodec is used as audio codec and kH264Codec is used as video codec.
Peter Boström0c4e06b2015-10-07 12:23:21 +0200383 cricket::SessionDescription* CreateSessionDescriptionWithStream(
384 uint32_t ssrc) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000385 typename T::Content content;
386 cricket::SessionDescription* sdesc = new cricket::SessionDescription();
387 CreateContent(SECURE, kPcmuCodec, kH264Codec, &content);
388 AddLegacyStreamInContent(ssrc, 0, &content);
389 sdesc->AddContent("DUMMY_CONTENT_NAME",
390 cricket::NS_JINGLE_RTP, content.Copy());
391 return sdesc;
392 }
393
ossu292d6582016-03-17 02:31:13 -0700394 // Will manage the lifetime of a CallThread, making sure it's
395 // destroyed before this object goes out of scope.
396 class ScopedCallThread {
397 public:
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200398 template <class FunctorT>
399 ScopedCallThread(const FunctorT& functor)
400 : thread_(rtc::Thread::Create()),
401 task_(new rtc::FunctorMessageHandler<void, FunctorT>(functor)) {
ossu292d6582016-03-17 02:31:13 -0700402 thread_->Start();
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200403 thread_->Post(task_.get());
ossu292d6582016-03-17 02:31:13 -0700404 }
405
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200406 ~ScopedCallThread() { thread_->Stop(); }
ossu292d6582016-03-17 02:31:13 -0700407
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200408 rtc::Thread* thread() { return thread_.get(); }
ossu292d6582016-03-17 02:31:13 -0700409
410 private:
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200411 std::unique_ptr<rtc::Thread> thread_;
412 std::unique_ptr<rtc::MessageHandler> task_;
ossu292d6582016-03-17 02:31:13 -0700413 };
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000414
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000415 bool CodecMatches(const typename T::Codec& c1, const typename T::Codec& c2) {
416 return false; // overridden in specialized classes
417 }
418
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200419 void OnMediaMonitor1(typename T::Channel* channel,
420 const typename T::MediaInfo& info) {
421 RTC_DCHECK_EQ(channel, channel1_.get());
422 media_info_callbacks1_++;
423 }
424 void OnMediaMonitor2(typename T::Channel* channel,
425 const typename T::MediaInfo& info) {
426 RTC_DCHECK_EQ(channel, channel2_.get());
427 media_info_callbacks2_++;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000428 }
429
Honghai Zhangcc411c02016-03-29 17:27:21 -0700430 cricket::CandidatePairInterface* last_selected_candidate_pair() {
431 return last_selected_candidate_pair_;
432 }
433
Peter Boström0c4e06b2015-10-07 12:23:21 +0200434 void AddLegacyStreamInContent(uint32_t ssrc,
435 int flags,
436 typename T::Content* content) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000437 // Base implementation.
438 }
439
440 // Tests that can be used by derived classes.
441
442 // Basic sanity check.
443 void TestInit() {
444 CreateChannels(0, 0);
445 EXPECT_FALSE(channel1_->secure());
446 EXPECT_FALSE(media_channel1_->sending());
Peter Boström34fbfff2015-09-24 19:20:30 +0200447 if (verify_playout_) {
448 EXPECT_FALSE(media_channel1_->playout());
449 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000450 EXPECT_TRUE(media_channel1_->codecs().empty());
451 EXPECT_TRUE(media_channel1_->recv_streams().empty());
452 EXPECT_TRUE(media_channel1_->rtp_packets().empty());
453 EXPECT_TRUE(media_channel1_->rtcp_packets().empty());
454 }
455
456 // Test that SetLocalContent and SetRemoteContent properly configure
457 // the codecs.
458 void TestSetContents() {
459 CreateChannels(0, 0);
460 typename T::Content content;
461 CreateContent(0, kPcmuCodec, kH264Codec, &content);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000462 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000463 EXPECT_EQ(0U, media_channel1_->codecs().size());
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000464 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000465 ASSERT_EQ(1U, media_channel1_->codecs().size());
466 EXPECT_TRUE(CodecMatches(content.codecs()[0],
467 media_channel1_->codecs()[0]));
468 }
469
470 // Test that SetLocalContent and SetRemoteContent properly deals
471 // with an empty offer.
472 void TestSetContentsNullOffer() {
473 CreateChannels(0, 0);
474 typename T::Content content;
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000475 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000476 CreateContent(0, kPcmuCodec, kH264Codec, &content);
477 EXPECT_EQ(0U, media_channel1_->codecs().size());
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000478 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000479 ASSERT_EQ(1U, media_channel1_->codecs().size());
480 EXPECT_TRUE(CodecMatches(content.codecs()[0],
481 media_channel1_->codecs()[0]));
482 }
483
484 // Test that SetLocalContent and SetRemoteContent properly set RTCP
485 // mux.
486 void TestSetContentsRtcpMux() {
487 CreateChannels(RTCP, RTCP);
488 EXPECT_TRUE(channel1_->rtcp_transport_channel() != NULL);
489 EXPECT_TRUE(channel2_->rtcp_transport_channel() != NULL);
490 typename T::Content content;
491 CreateContent(0, kPcmuCodec, kH264Codec, &content);
492 // Both sides agree on mux. Should no longer be a separate RTCP channel.
493 content.set_rtcp_mux(true);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000494 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL));
495 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000496 EXPECT_TRUE(channel1_->rtcp_transport_channel() == NULL);
497 // Only initiator supports mux. Should still have a separate RTCP channel.
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000498 EXPECT_TRUE(channel2_->SetLocalContent(&content, CA_OFFER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000499 content.set_rtcp_mux(false);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000500 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_ANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000501 EXPECT_TRUE(channel2_->rtcp_transport_channel() != NULL);
502 }
503
504 // Test that SetLocalContent and SetRemoteContent properly set RTCP
505 // mux when a provisional answer is received.
506 void TestSetContentsRtcpMuxWithPrAnswer() {
507 CreateChannels(RTCP, RTCP);
508 EXPECT_TRUE(channel1_->rtcp_transport_channel() != NULL);
509 EXPECT_TRUE(channel2_->rtcp_transport_channel() != NULL);
510 typename T::Content content;
511 CreateContent(0, kPcmuCodec, kH264Codec, &content);
512 content.set_rtcp_mux(true);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000513 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL));
514 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_PRANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000515 EXPECT_TRUE(channel1_->rtcp_transport_channel() != NULL);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000516 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000517 // Both sides agree on mux. Should no longer be a separate RTCP channel.
518 EXPECT_TRUE(channel1_->rtcp_transport_channel() == NULL);
519 // Only initiator supports mux. Should still have a separate RTCP channel.
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000520 EXPECT_TRUE(channel2_->SetLocalContent(&content, CA_OFFER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000521 content.set_rtcp_mux(false);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000522 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_PRANSWER, NULL));
523 EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_ANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000524 EXPECT_TRUE(channel2_->rtcp_transport_channel() != NULL);
525 }
526
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000527 // Test that SetRemoteContent properly deals with a content update.
528 void TestSetRemoteContentUpdate() {
529 CreateChannels(0, 0);
530 typename T::Content content;
531 CreateContent(RTCP | RTCP_MUX | SECURE,
532 kPcmuCodec, kH264Codec,
533 &content);
534 EXPECT_EQ(0U, media_channel1_->codecs().size());
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000535 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL));
536 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000537 ASSERT_EQ(1U, media_channel1_->codecs().size());
538 EXPECT_TRUE(CodecMatches(content.codecs()[0],
539 media_channel1_->codecs()[0]));
540 // Now update with other codecs.
541 typename T::Content update_content;
542 update_content.set_partial(true);
543 CreateContent(0, kIsacCodec, kH264SvcCodec,
544 &update_content);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000545 EXPECT_TRUE(channel1_->SetRemoteContent(&update_content, CA_UPDATE, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000546 ASSERT_EQ(1U, media_channel1_->codecs().size());
547 EXPECT_TRUE(CodecMatches(update_content.codecs()[0],
548 media_channel1_->codecs()[0]));
549 // Now update without any codecs. This is ignored.
550 typename T::Content empty_content;
551 empty_content.set_partial(true);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000552 EXPECT_TRUE(channel1_->SetRemoteContent(&empty_content, CA_UPDATE, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000553 ASSERT_EQ(1U, media_channel1_->codecs().size());
554 EXPECT_TRUE(CodecMatches(update_content.codecs()[0],
555 media_channel1_->codecs()[0]));
556 }
557
558 // Test that Add/RemoveStream properly forward to the media channel.
559 void TestStreams() {
560 CreateChannels(0, 0);
561 EXPECT_TRUE(AddStream1(1));
562 EXPECT_TRUE(AddStream1(2));
563 EXPECT_EQ(2U, media_channel1_->recv_streams().size());
564 EXPECT_TRUE(RemoveStream1(2));
565 EXPECT_EQ(1U, media_channel1_->recv_streams().size());
566 EXPECT_TRUE(RemoveStream1(1));
567 EXPECT_EQ(0U, media_channel1_->recv_streams().size());
568 }
569
570 // Test that SetLocalContent properly handles adding and removing StreamParams
571 // to the local content description.
572 // This test uses the CA_UPDATE action that don't require a full
573 // MediaContentDescription to do an update.
574 void TestUpdateStreamsInLocalContent() {
575 cricket::StreamParams stream1;
576 stream1.groupid = "group1";
577 stream1.id = "stream1";
578 stream1.ssrcs.push_back(kSsrc1);
579 stream1.cname = "stream1_cname";
580
581 cricket::StreamParams stream2;
582 stream2.groupid = "group2";
583 stream2.id = "stream2";
584 stream2.ssrcs.push_back(kSsrc2);
585 stream2.cname = "stream2_cname";
586
587 cricket::StreamParams stream3;
588 stream3.groupid = "group3";
589 stream3.id = "stream3";
590 stream3.ssrcs.push_back(kSsrc3);
591 stream3.cname = "stream3_cname";
592
593 CreateChannels(0, 0);
594 typename T::Content content1;
595 CreateContent(0, kPcmuCodec, kH264Codec, &content1);
596 content1.AddStream(stream1);
597 EXPECT_EQ(0u, media_channel1_->send_streams().size());
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000598 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000599
600 ASSERT_EQ(1u, media_channel1_->send_streams().size());
601 EXPECT_EQ(stream1, media_channel1_->send_streams()[0]);
602
603 // Update the local streams by adding another sending stream.
604 // Use a partial updated session description.
605 typename T::Content content2;
606 content2.AddStream(stream2);
607 content2.AddStream(stream3);
608 content2.set_partial(true);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000609 EXPECT_TRUE(channel1_->SetLocalContent(&content2, CA_UPDATE, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000610 ASSERT_EQ(3u, media_channel1_->send_streams().size());
611 EXPECT_EQ(stream1, media_channel1_->send_streams()[0]);
612 EXPECT_EQ(stream2, media_channel1_->send_streams()[1]);
613 EXPECT_EQ(stream3, media_channel1_->send_streams()[2]);
614
615 // Update the local streams by removing the first sending stream.
616 // This is done by removing all SSRCS for this particular stream.
617 typename T::Content content3;
618 stream1.ssrcs.clear();
619 content3.AddStream(stream1);
620 content3.set_partial(true);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000621 EXPECT_TRUE(channel1_->SetLocalContent(&content3, CA_UPDATE, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000622 ASSERT_EQ(2u, media_channel1_->send_streams().size());
623 EXPECT_EQ(stream2, media_channel1_->send_streams()[0]);
624 EXPECT_EQ(stream3, media_channel1_->send_streams()[1]);
625
626 // Update the local streams with a stream that does not change.
627 // THe update is ignored.
628 typename T::Content content4;
629 content4.AddStream(stream2);
630 content4.set_partial(true);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000631 EXPECT_TRUE(channel1_->SetLocalContent(&content4, CA_UPDATE, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000632 ASSERT_EQ(2u, media_channel1_->send_streams().size());
633 EXPECT_EQ(stream2, media_channel1_->send_streams()[0]);
634 EXPECT_EQ(stream3, media_channel1_->send_streams()[1]);
635 }
636
637 // Test that SetRemoteContent properly handles adding and removing
638 // StreamParams to the remote content description.
639 // This test uses the CA_UPDATE action that don't require a full
640 // MediaContentDescription to do an update.
641 void TestUpdateStreamsInRemoteContent() {
642 cricket::StreamParams stream1;
643 stream1.id = "Stream1";
644 stream1.groupid = "1";
645 stream1.ssrcs.push_back(kSsrc1);
646 stream1.cname = "stream1_cname";
647
648 cricket::StreamParams stream2;
649 stream2.id = "Stream2";
650 stream2.groupid = "2";
651 stream2.ssrcs.push_back(kSsrc2);
652 stream2.cname = "stream2_cname";
653
654 cricket::StreamParams stream3;
655 stream3.id = "Stream3";
656 stream3.groupid = "3";
657 stream3.ssrcs.push_back(kSsrc3);
658 stream3.cname = "stream3_cname";
659
660 CreateChannels(0, 0);
661 typename T::Content content1;
662 CreateContent(0, kPcmuCodec, kH264Codec, &content1);
663 content1.AddStream(stream1);
664 EXPECT_EQ(0u, media_channel1_->recv_streams().size());
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000665 EXPECT_TRUE(channel1_->SetRemoteContent(&content1, CA_OFFER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000666
667 ASSERT_EQ(1u, media_channel1_->codecs().size());
668 ASSERT_EQ(1u, media_channel1_->recv_streams().size());
669 EXPECT_EQ(stream1, media_channel1_->recv_streams()[0]);
670
671 // Update the remote streams by adding another sending stream.
672 // Use a partial updated session description.
673 typename T::Content content2;
674 content2.AddStream(stream2);
675 content2.AddStream(stream3);
676 content2.set_partial(true);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000677 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_UPDATE, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000678 ASSERT_EQ(3u, media_channel1_->recv_streams().size());
679 EXPECT_EQ(stream1, media_channel1_->recv_streams()[0]);
680 EXPECT_EQ(stream2, media_channel1_->recv_streams()[1]);
681 EXPECT_EQ(stream3, media_channel1_->recv_streams()[2]);
682
683 // Update the remote streams by removing the first stream.
684 // This is done by removing all SSRCS for this particular stream.
685 typename T::Content content3;
686 stream1.ssrcs.clear();
687 content3.AddStream(stream1);
688 content3.set_partial(true);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000689 EXPECT_TRUE(channel1_->SetRemoteContent(&content3, CA_UPDATE, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000690 ASSERT_EQ(2u, media_channel1_->recv_streams().size());
691 EXPECT_EQ(stream2, media_channel1_->recv_streams()[0]);
692 EXPECT_EQ(stream3, media_channel1_->recv_streams()[1]);
693
694 // Update the remote streams with a stream that does not change.
695 // The update is ignored.
696 typename T::Content content4;
697 content4.AddStream(stream2);
698 content4.set_partial(true);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000699 EXPECT_TRUE(channel1_->SetRemoteContent(&content4, CA_UPDATE, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000700 ASSERT_EQ(2u, media_channel1_->recv_streams().size());
701 EXPECT_EQ(stream2, media_channel1_->recv_streams()[0]);
702 EXPECT_EQ(stream3, media_channel1_->recv_streams()[1]);
703 }
704
705 // Test that SetLocalContent and SetRemoteContent properly
706 // handles adding and removing StreamParams when the action is a full
707 // CA_OFFER / CA_ANSWER.
708 void TestChangeStreamParamsInContent() {
709 cricket::StreamParams stream1;
710 stream1.groupid = "group1";
711 stream1.id = "stream1";
712 stream1.ssrcs.push_back(kSsrc1);
713 stream1.cname = "stream1_cname";
714
715 cricket::StreamParams stream2;
716 stream2.groupid = "group1";
717 stream2.id = "stream2";
718 stream2.ssrcs.push_back(kSsrc2);
719 stream2.cname = "stream2_cname";
720
721 // Setup a call where channel 1 send |stream1| to channel 2.
722 CreateChannels(0, 0);
723 typename T::Content content1;
724 CreateContent(0, kPcmuCodec, kH264Codec, &content1);
725 content1.AddStream(stream1);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000726 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000727 EXPECT_TRUE(channel1_->Enable(true));
728 EXPECT_EQ(1u, media_channel1_->send_streams().size());
729
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000730 EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000731 EXPECT_EQ(1u, media_channel2_->recv_streams().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200732 transport_controller1_->Connect(transport_controller2_.get());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000733
734 // Channel 2 do not send anything.
735 typename T::Content content2;
736 CreateContent(0, kPcmuCodec, kH264Codec, &content2);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000737 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_ANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000738 EXPECT_EQ(0u, media_channel1_->recv_streams().size());
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000739 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_ANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000740 EXPECT_TRUE(channel2_->Enable(true));
741 EXPECT_EQ(0u, media_channel2_->send_streams().size());
742
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200743 SendCustomRtp1(kSsrc1, 0);
744 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000745 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, 0));
746
747 // Let channel 2 update the content by sending |stream2| and enable SRTP.
748 typename T::Content content3;
749 CreateContent(SECURE, kPcmuCodec, kH264Codec, &content3);
750 content3.AddStream(stream2);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000751 EXPECT_TRUE(channel2_->SetLocalContent(&content3, CA_OFFER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000752 ASSERT_EQ(1u, media_channel2_->send_streams().size());
753 EXPECT_EQ(stream2, media_channel2_->send_streams()[0]);
754
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000755 EXPECT_TRUE(channel1_->SetRemoteContent(&content3, CA_OFFER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000756 ASSERT_EQ(1u, media_channel1_->recv_streams().size());
757 EXPECT_EQ(stream2, media_channel1_->recv_streams()[0]);
758
759 // Channel 1 replies but stop sending stream1.
760 typename T::Content content4;
761 CreateContent(SECURE, kPcmuCodec, kH264Codec, &content4);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000762 EXPECT_TRUE(channel1_->SetLocalContent(&content4, CA_ANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000763 EXPECT_EQ(0u, media_channel1_->send_streams().size());
764
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000765 EXPECT_TRUE(channel2_->SetRemoteContent(&content4, CA_ANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000766 EXPECT_EQ(0u, media_channel2_->recv_streams().size());
767
768 EXPECT_TRUE(channel1_->secure());
769 EXPECT_TRUE(channel2_->secure());
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200770 SendCustomRtp2(kSsrc2, 0);
771 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000772 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, 0));
773 }
774
775 // Test that we only start playout and sending at the right times.
776 void TestPlayoutAndSendingStates() {
777 CreateChannels(0, 0);
Peter Boström34fbfff2015-09-24 19:20:30 +0200778 if (verify_playout_) {
779 EXPECT_FALSE(media_channel1_->playout());
780 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000781 EXPECT_FALSE(media_channel1_->sending());
Peter Boström34fbfff2015-09-24 19:20:30 +0200782 if (verify_playout_) {
783 EXPECT_FALSE(media_channel2_->playout());
784 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000785 EXPECT_FALSE(media_channel2_->sending());
786 EXPECT_TRUE(channel1_->Enable(true));
Peter Boström34fbfff2015-09-24 19:20:30 +0200787 if (verify_playout_) {
788 EXPECT_FALSE(media_channel1_->playout());
789 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000790 EXPECT_FALSE(media_channel1_->sending());
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000791 EXPECT_TRUE(channel1_->SetLocalContent(&local_media_content1_,
792 CA_OFFER, NULL));
Peter Boström34fbfff2015-09-24 19:20:30 +0200793 if (verify_playout_) {
794 EXPECT_TRUE(media_channel1_->playout());
795 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000796 EXPECT_FALSE(media_channel1_->sending());
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000797 EXPECT_TRUE(channel2_->SetRemoteContent(&local_media_content1_,
798 CA_OFFER, NULL));
Peter Boström34fbfff2015-09-24 19:20:30 +0200799 if (verify_playout_) {
800 EXPECT_FALSE(media_channel2_->playout());
801 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000802 EXPECT_FALSE(media_channel2_->sending());
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000803 EXPECT_TRUE(channel2_->SetLocalContent(&local_media_content2_,
804 CA_ANSWER, NULL));
Peter Boström34fbfff2015-09-24 19:20:30 +0200805 if (verify_playout_) {
806 EXPECT_FALSE(media_channel2_->playout());
807 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000808 EXPECT_FALSE(media_channel2_->sending());
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200809 transport_controller1_->Connect(transport_controller2_.get());
Peter Boström34fbfff2015-09-24 19:20:30 +0200810 if (verify_playout_) {
811 EXPECT_TRUE(media_channel1_->playout());
812 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000813 EXPECT_FALSE(media_channel1_->sending());
Peter Boström34fbfff2015-09-24 19:20:30 +0200814 if (verify_playout_) {
815 EXPECT_FALSE(media_channel2_->playout());
816 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000817 EXPECT_FALSE(media_channel2_->sending());
818 EXPECT_TRUE(channel2_->Enable(true));
Peter Boström34fbfff2015-09-24 19:20:30 +0200819 if (verify_playout_) {
820 EXPECT_TRUE(media_channel2_->playout());
821 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000822 EXPECT_TRUE(media_channel2_->sending());
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000823 EXPECT_TRUE(channel1_->SetRemoteContent(&local_media_content2_,
824 CA_ANSWER, NULL));
Peter Boström34fbfff2015-09-24 19:20:30 +0200825 if (verify_playout_) {
826 EXPECT_TRUE(media_channel1_->playout());
827 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000828 EXPECT_TRUE(media_channel1_->sending());
829 }
830
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000831 // Test that changing the MediaContentDirection in the local and remote
832 // session description start playout and sending at the right time.
833 void TestMediaContentDirection() {
834 CreateChannels(0, 0);
835 typename T::Content content1;
836 CreateContent(0, kPcmuCodec, kH264Codec, &content1);
837 typename T::Content content2;
838 CreateContent(0, kPcmuCodec, kH264Codec, &content2);
839 // Set |content2| to be InActive.
840 content2.set_direction(cricket::MD_INACTIVE);
841
842 EXPECT_TRUE(channel1_->Enable(true));
843 EXPECT_TRUE(channel2_->Enable(true));
Peter Boström34fbfff2015-09-24 19:20:30 +0200844 if (verify_playout_) {
845 EXPECT_FALSE(media_channel1_->playout());
846 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000847 EXPECT_FALSE(media_channel1_->sending());
Peter Boström34fbfff2015-09-24 19:20:30 +0200848 if (verify_playout_) {
849 EXPECT_FALSE(media_channel2_->playout());
850 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000851 EXPECT_FALSE(media_channel2_->sending());
852
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000853 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL));
854 EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, NULL));
855 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_PRANSWER, NULL));
856 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_PRANSWER, NULL));
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200857 transport_controller1_->Connect(transport_controller2_.get());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000858
Peter Boström34fbfff2015-09-24 19:20:30 +0200859 if (verify_playout_) {
860 EXPECT_TRUE(media_channel1_->playout());
861 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000862 EXPECT_FALSE(media_channel1_->sending()); // remote InActive
Peter Boström34fbfff2015-09-24 19:20:30 +0200863 if (verify_playout_) {
864 EXPECT_FALSE(media_channel2_->playout()); // local InActive
865 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000866 EXPECT_FALSE(media_channel2_->sending()); // local InActive
867
868 // Update |content2| to be RecvOnly.
869 content2.set_direction(cricket::MD_RECVONLY);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000870 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_PRANSWER, NULL));
871 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_PRANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000872
Peter Boström34fbfff2015-09-24 19:20:30 +0200873 if (verify_playout_) {
874 EXPECT_TRUE(media_channel1_->playout());
875 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000876 EXPECT_TRUE(media_channel1_->sending());
Peter Boström34fbfff2015-09-24 19:20:30 +0200877 if (verify_playout_) {
878 EXPECT_TRUE(media_channel2_->playout()); // local RecvOnly
879 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000880 EXPECT_FALSE(media_channel2_->sending()); // local RecvOnly
881
882 // Update |content2| to be SendRecv.
883 content2.set_direction(cricket::MD_SENDRECV);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000884 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_ANSWER, NULL));
885 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_ANSWER, NULL));
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_TRUE(media_channel1_->sending());
Peter Boström34fbfff2015-09-24 19:20:30 +0200891 if (verify_playout_) {
892 EXPECT_TRUE(media_channel2_->playout());
893 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000894 EXPECT_TRUE(media_channel2_->sending());
895 }
896
Honghai Zhangcc411c02016-03-29 17:27:21 -0700897 // Tests that when the transport channel signals a candidate pair change
898 // event, the media channel will receive a call on the network route change.
899 void TestNetworkRouteChanges() {
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200900 constexpr uint16_t kLocalNetId = 1;
901 constexpr uint16_t kRemoteNetId = 2;
902 constexpr int kLastPacketId = 100;
903
Honghai Zhangcc411c02016-03-29 17:27:21 -0700904 CreateChannels(0, 0);
905
906 cricket::TransportChannel* transport_channel1 =
907 channel1_->transport_channel();
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200908 ASSERT_TRUE(transport_channel1);
Honghai Zhangcc411c02016-03-29 17:27:21 -0700909 typename T::MediaChannel* media_channel1 =
910 static_cast<typename T::MediaChannel*>(channel1_->media_channel());
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200911 ASSERT_TRUE(media_channel1);
Honghai Zhangcc411c02016-03-29 17:27:21 -0700912
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200913 media_channel1->set_num_network_route_changes(0);
914 network_thread_->Invoke<void>([transport_channel1] {
915 // The transport channel becomes disconnected.
916 transport_channel1->SignalSelectedCandidatePairChanged(transport_channel1,
917 nullptr, -1);
918 });
919 WaitForThreads();
920 EXPECT_EQ(1, media_channel1->num_network_route_changes());
Honghai Zhangcc411c02016-03-29 17:27:21 -0700921 EXPECT_FALSE(media_channel1->last_network_route().connected);
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200922 media_channel1->set_num_network_route_changes(0);
Honghai Zhangcc411c02016-03-29 17:27:21 -0700923
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200924 network_thread_->Invoke<void>([this, transport_channel1, media_channel1,
925 kLocalNetId, kRemoteNetId, kLastPacketId] {
926 // The transport channel becomes connected.
927 rtc::SocketAddress local_address("192.168.1.1", 1000 /* port number */);
928 rtc::SocketAddress remote_address("192.168.1.2", 2000 /* port number */);
929 std::unique_ptr<cricket::CandidatePairInterface> candidate_pair(
930 transport_controller1_->CreateFakeCandidatePair(
931 local_address, kLocalNetId, remote_address, kRemoteNetId));
932 transport_channel1->SignalSelectedCandidatePairChanged(
933 transport_channel1, candidate_pair.get(), kLastPacketId);
934 });
935 WaitForThreads();
936 EXPECT_EQ(1, media_channel1->num_network_route_changes());
937 rtc::NetworkRoute expected_network_route(kLocalNetId, kRemoteNetId,
938 kLastPacketId);
Honghai Zhangcc411c02016-03-29 17:27:21 -0700939 EXPECT_EQ(expected_network_route, media_channel1->last_network_route());
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200940 EXPECT_EQ(kLastPacketId,
Honghai Zhang52dce732016-03-31 12:37:31 -0700941 media_channel1->last_network_route().last_sent_packet_id);
Honghai Zhangcc411c02016-03-29 17:27:21 -0700942 }
943
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000944 // Test setting up a call.
945 void TestCallSetup() {
946 CreateChannels(0, 0);
947 EXPECT_FALSE(channel1_->secure());
948 EXPECT_TRUE(SendInitiate());
Peter Boström34fbfff2015-09-24 19:20:30 +0200949 if (verify_playout_) {
950 EXPECT_TRUE(media_channel1_->playout());
951 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000952 EXPECT_FALSE(media_channel1_->sending());
953 EXPECT_TRUE(SendAccept());
954 EXPECT_FALSE(channel1_->secure());
955 EXPECT_TRUE(media_channel1_->sending());
956 EXPECT_EQ(1U, media_channel1_->codecs().size());
Peter Boström34fbfff2015-09-24 19:20:30 +0200957 if (verify_playout_) {
958 EXPECT_TRUE(media_channel2_->playout());
959 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000960 EXPECT_TRUE(media_channel2_->sending());
961 EXPECT_EQ(1U, media_channel2_->codecs().size());
962 }
963
964 // Test that we don't crash if packets are sent during call teardown
965 // when RTCP mux is enabled. This is a regression test against a specific
966 // race condition that would only occur when a RTCP packet was sent during
967 // teardown of a channel on which RTCP mux was enabled.
968 void TestCallTeardownRtcpMux() {
969 class LastWordMediaChannel : public T::MediaChannel {
970 public:
Fredrik Solenbergb071a192015-09-17 16:42:56 +0200971 LastWordMediaChannel() : T::MediaChannel(NULL, typename T::Options()) {}
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000972 ~LastWordMediaChannel() {
stefanc1aeaf02015-10-15 07:26:07 -0700973 T::MediaChannel::SendRtp(kPcmuFrame, sizeof(kPcmuFrame),
974 rtc::PacketOptions());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000975 T::MediaChannel::SendRtcp(kRtcpReport, sizeof(kRtcpReport));
976 }
977 };
978 CreateChannels(new LastWordMediaChannel(), new LastWordMediaChannel(),
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200979 RTCP | RTCP_MUX, RTCP | RTCP_MUX);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000980 EXPECT_TRUE(SendInitiate());
981 EXPECT_TRUE(SendAccept());
982 EXPECT_TRUE(SendTerminate());
983 }
984
985 // Send voice RTP data to the other side and ensure it gets there.
986 void SendRtpToRtp() {
987 CreateChannels(0, 0);
988 EXPECT_TRUE(SendInitiate());
989 EXPECT_TRUE(SendAccept());
deadbeefcbecd352015-09-23 11:50:27 -0700990 ASSERT_TRUE(GetTransport1());
991 ASSERT_TRUE(GetTransport2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000992 EXPECT_EQ(1U, GetTransport1()->channels().size());
993 EXPECT_EQ(1U, GetTransport2()->channels().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +0200994 SendRtp1();
995 SendRtp2();
996 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000997 EXPECT_TRUE(CheckRtp1());
998 EXPECT_TRUE(CheckRtp2());
999 EXPECT_TRUE(CheckNoRtp1());
1000 EXPECT_TRUE(CheckNoRtp2());
1001 }
1002
1003 // Check that RTCP is not transmitted if both sides don't support RTCP.
1004 void SendNoRtcpToNoRtcp() {
1005 CreateChannels(0, 0);
1006 EXPECT_TRUE(SendInitiate());
1007 EXPECT_TRUE(SendAccept());
deadbeefcbecd352015-09-23 11:50:27 -07001008 ASSERT_TRUE(GetTransport1());
1009 ASSERT_TRUE(GetTransport2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001010 EXPECT_EQ(1U, GetTransport1()->channels().size());
1011 EXPECT_EQ(1U, GetTransport2()->channels().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001012 SendRtcp1();
1013 SendRtcp2();
1014 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001015 EXPECT_TRUE(CheckNoRtcp1());
1016 EXPECT_TRUE(CheckNoRtcp2());
1017 }
1018
1019 // Check that RTCP is not transmitted if the callee doesn't support RTCP.
1020 void SendNoRtcpToRtcp() {
1021 CreateChannels(0, RTCP);
1022 EXPECT_TRUE(SendInitiate());
1023 EXPECT_TRUE(SendAccept());
deadbeefcbecd352015-09-23 11:50:27 -07001024 ASSERT_TRUE(GetTransport1());
1025 ASSERT_TRUE(GetTransport2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001026 EXPECT_EQ(1U, GetTransport1()->channels().size());
1027 EXPECT_EQ(2U, GetTransport2()->channels().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001028 SendRtcp1();
1029 SendRtcp2();
1030 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001031 EXPECT_TRUE(CheckNoRtcp1());
1032 EXPECT_TRUE(CheckNoRtcp2());
1033 }
1034
1035 // Check that RTCP is not transmitted if the caller doesn't support RTCP.
1036 void SendRtcpToNoRtcp() {
1037 CreateChannels(RTCP, 0);
1038 EXPECT_TRUE(SendInitiate());
1039 EXPECT_TRUE(SendAccept());
deadbeefcbecd352015-09-23 11:50:27 -07001040 ASSERT_TRUE(GetTransport1());
1041 ASSERT_TRUE(GetTransport2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001042 EXPECT_EQ(2U, GetTransport1()->channels().size());
1043 EXPECT_EQ(1U, GetTransport2()->channels().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001044 SendRtcp1();
1045 SendRtcp2();
1046 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001047 EXPECT_TRUE(CheckNoRtcp1());
1048 EXPECT_TRUE(CheckNoRtcp2());
1049 }
1050
1051 // Check that RTCP is transmitted if both sides support RTCP.
1052 void SendRtcpToRtcp() {
1053 CreateChannels(RTCP, RTCP);
1054 EXPECT_TRUE(SendInitiate());
1055 EXPECT_TRUE(SendAccept());
deadbeefcbecd352015-09-23 11:50:27 -07001056 ASSERT_TRUE(GetTransport1());
1057 ASSERT_TRUE(GetTransport2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001058 EXPECT_EQ(2U, GetTransport1()->channels().size());
1059 EXPECT_EQ(2U, GetTransport2()->channels().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001060 SendRtcp1();
1061 SendRtcp2();
1062 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001063 EXPECT_TRUE(CheckRtcp1());
1064 EXPECT_TRUE(CheckRtcp2());
1065 EXPECT_TRUE(CheckNoRtcp1());
1066 EXPECT_TRUE(CheckNoRtcp2());
1067 }
1068
1069 // Check that RTCP is transmitted if only the initiator supports mux.
1070 void SendRtcpMuxToRtcp() {
1071 CreateChannels(RTCP | RTCP_MUX, RTCP);
1072 EXPECT_TRUE(SendInitiate());
1073 EXPECT_TRUE(SendAccept());
deadbeefcbecd352015-09-23 11:50:27 -07001074 ASSERT_TRUE(GetTransport1());
1075 ASSERT_TRUE(GetTransport2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001076 EXPECT_EQ(2U, GetTransport1()->channels().size());
1077 EXPECT_EQ(2U, GetTransport2()->channels().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001078 SendRtcp1();
1079 SendRtcp2();
1080 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001081 EXPECT_TRUE(CheckRtcp1());
1082 EXPECT_TRUE(CheckRtcp2());
1083 EXPECT_TRUE(CheckNoRtcp1());
1084 EXPECT_TRUE(CheckNoRtcp2());
1085 }
1086
1087 // Check that RTP and RTCP are transmitted ok when both sides support mux.
1088 void SendRtcpMuxToRtcpMux() {
1089 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
1090 EXPECT_TRUE(SendInitiate());
deadbeefcbecd352015-09-23 11:50:27 -07001091 ASSERT_TRUE(GetTransport1());
1092 ASSERT_TRUE(GetTransport2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001093 EXPECT_EQ(2U, GetTransport1()->channels().size());
1094 EXPECT_EQ(1U, GetTransport2()->channels().size());
1095 EXPECT_TRUE(SendAccept());
1096 EXPECT_EQ(1U, GetTransport1()->channels().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001097 SendRtp1();
1098 SendRtp2();
1099 SendRtcp1();
1100 SendRtcp2();
1101 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001102 EXPECT_TRUE(CheckRtp1());
1103 EXPECT_TRUE(CheckRtp2());
1104 EXPECT_TRUE(CheckNoRtp1());
1105 EXPECT_TRUE(CheckNoRtp2());
1106 EXPECT_TRUE(CheckRtcp1());
1107 EXPECT_TRUE(CheckRtcp2());
1108 EXPECT_TRUE(CheckNoRtcp1());
1109 EXPECT_TRUE(CheckNoRtcp2());
1110 }
1111
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07001112 // Check that RTP and RTCP are transmitted ok when both sides
1113 // support mux and one the offerer requires mux.
1114 void SendRequireRtcpMuxToRtcpMux() {
1115 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
1116 channel1_->ActivateRtcpMux();
1117 EXPECT_TRUE(SendInitiate());
deadbeefcbecd352015-09-23 11:50:27 -07001118 ASSERT_TRUE(GetTransport1());
1119 ASSERT_TRUE(GetTransport2());
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07001120 EXPECT_EQ(1U, GetTransport1()->channels().size());
1121 EXPECT_EQ(1U, GetTransport2()->channels().size());
1122 EXPECT_TRUE(SendAccept());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001123 SendRtp1();
1124 SendRtp2();
1125 SendRtcp1();
1126 SendRtcp2();
1127 WaitForThreads();
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07001128 EXPECT_TRUE(CheckRtp1());
1129 EXPECT_TRUE(CheckRtp2());
1130 EXPECT_TRUE(CheckNoRtp1());
1131 EXPECT_TRUE(CheckNoRtp2());
1132 EXPECT_TRUE(CheckRtcp1());
1133 EXPECT_TRUE(CheckRtcp2());
1134 EXPECT_TRUE(CheckNoRtcp1());
1135 EXPECT_TRUE(CheckNoRtcp2());
1136 }
1137
1138 // Check that RTP and RTCP are transmitted ok when both sides
1139 // support mux and one the answerer requires rtcp mux.
1140 void SendRtcpMuxToRequireRtcpMux() {
1141 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
1142 channel2_->ActivateRtcpMux();
1143 EXPECT_TRUE(SendInitiate());
deadbeefcbecd352015-09-23 11:50:27 -07001144 ASSERT_TRUE(GetTransport1());
1145 ASSERT_TRUE(GetTransport2());
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07001146 EXPECT_EQ(2U, GetTransport1()->channels().size());
1147 EXPECT_EQ(1U, GetTransport2()->channels().size());
1148 EXPECT_TRUE(SendAccept());
1149 EXPECT_EQ(1U, GetTransport1()->channels().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001150 SendRtp1();
1151 SendRtp2();
1152 SendRtcp1();
1153 SendRtcp2();
1154 WaitForThreads();
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07001155 EXPECT_TRUE(CheckRtp1());
1156 EXPECT_TRUE(CheckRtp2());
1157 EXPECT_TRUE(CheckNoRtp1());
1158 EXPECT_TRUE(CheckNoRtp2());
1159 EXPECT_TRUE(CheckRtcp1());
1160 EXPECT_TRUE(CheckRtcp2());
1161 EXPECT_TRUE(CheckNoRtcp1());
1162 EXPECT_TRUE(CheckNoRtcp2());
1163 }
1164
1165 // Check that RTP and RTCP are transmitted ok when both sides
1166 // require mux.
1167 void SendRequireRtcpMuxToRequireRtcpMux() {
1168 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
1169 channel1_->ActivateRtcpMux();
1170 channel2_->ActivateRtcpMux();
1171 EXPECT_TRUE(SendInitiate());
deadbeefcbecd352015-09-23 11:50:27 -07001172 ASSERT_TRUE(GetTransport1());
1173 ASSERT_TRUE(GetTransport2());
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07001174 EXPECT_EQ(1U, GetTransport1()->channels().size());
1175 EXPECT_EQ(1U, GetTransport2()->channels().size());
1176 EXPECT_TRUE(SendAccept());
1177 EXPECT_EQ(1U, GetTransport1()->channels().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001178 SendRtp1();
1179 SendRtp2();
1180 SendRtcp1();
1181 SendRtcp2();
1182 WaitForThreads();
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07001183 EXPECT_TRUE(CheckRtp1());
1184 EXPECT_TRUE(CheckRtp2());
1185 EXPECT_TRUE(CheckNoRtp1());
1186 EXPECT_TRUE(CheckNoRtp2());
1187 EXPECT_TRUE(CheckRtcp1());
1188 EXPECT_TRUE(CheckRtcp2());
1189 EXPECT_TRUE(CheckNoRtcp1());
1190 EXPECT_TRUE(CheckNoRtcp2());
1191 }
1192
1193 // Check that SendAccept fails if the answerer doesn't support mux
1194 // and the offerer requires it.
1195 void SendRequireRtcpMuxToNoRtcpMux() {
1196 CreateChannels(RTCP | RTCP_MUX, RTCP);
1197 channel1_->ActivateRtcpMux();
1198 EXPECT_TRUE(SendInitiate());
deadbeefcbecd352015-09-23 11:50:27 -07001199 ASSERT_TRUE(GetTransport1());
1200 ASSERT_TRUE(GetTransport2());
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07001201 EXPECT_EQ(1U, GetTransport1()->channels().size());
1202 EXPECT_EQ(2U, GetTransport2()->channels().size());
1203 EXPECT_FALSE(SendAccept());
1204 }
1205
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001206 // Check that RTCP data sent by the initiator before the accept is not muxed.
1207 void SendEarlyRtcpMuxToRtcp() {
1208 CreateChannels(RTCP | RTCP_MUX, RTCP);
1209 EXPECT_TRUE(SendInitiate());
deadbeefcbecd352015-09-23 11:50:27 -07001210 ASSERT_TRUE(GetTransport1());
1211 ASSERT_TRUE(GetTransport2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001212 EXPECT_EQ(2U, GetTransport1()->channels().size());
1213 EXPECT_EQ(2U, GetTransport2()->channels().size());
1214
1215 // RTCP can be sent before the call is accepted, if the transport is ready.
1216 // It should not be muxed though, as the remote side doesn't support mux.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001217 SendRtcp1();
1218 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001219 EXPECT_TRUE(CheckNoRtp2());
1220 EXPECT_TRUE(CheckRtcp2());
1221
1222 // Send RTCP packet from callee and verify that it is received.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001223 SendRtcp2();
1224 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001225 EXPECT_TRUE(CheckNoRtp1());
1226 EXPECT_TRUE(CheckRtcp1());
1227
1228 // Complete call setup and ensure everything is still OK.
1229 EXPECT_TRUE(SendAccept());
1230 EXPECT_EQ(2U, GetTransport1()->channels().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001231 SendRtcp1();
1232 SendRtcp2();
1233 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001234 EXPECT_TRUE(CheckRtcp2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001235 EXPECT_TRUE(CheckRtcp1());
1236 }
1237
1238
1239 // Check that RTCP data is not muxed until both sides have enabled muxing,
1240 // but that we properly demux before we get the accept message, since there
1241 // is a race between RTP data and the jingle accept.
1242 void SendEarlyRtcpMuxToRtcpMux() {
1243 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
1244 EXPECT_TRUE(SendInitiate());
deadbeefcbecd352015-09-23 11:50:27 -07001245 ASSERT_TRUE(GetTransport1());
1246 ASSERT_TRUE(GetTransport2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001247 EXPECT_EQ(2U, GetTransport1()->channels().size());
1248 EXPECT_EQ(1U, GetTransport2()->channels().size());
1249
1250 // RTCP can't be sent yet, since the RTCP transport isn't writable, and
1251 // we haven't yet received the accept that says we should mux.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001252 SendRtcp1();
1253 WaitForThreads();
1254 EXPECT_TRUE(CheckNoRtcp2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001255
1256 // Send muxed RTCP packet from callee and verify that it is received.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001257 SendRtcp2();
1258 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001259 EXPECT_TRUE(CheckNoRtp1());
1260 EXPECT_TRUE(CheckRtcp1());
1261
1262 // Complete call setup and ensure everything is still OK.
1263 EXPECT_TRUE(SendAccept());
1264 EXPECT_EQ(1U, GetTransport1()->channels().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001265 SendRtcp1();
1266 SendRtcp2();
1267 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001268 EXPECT_TRUE(CheckRtcp2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001269 EXPECT_TRUE(CheckRtcp1());
1270 }
1271
1272 // Test that we properly send SRTP with RTCP in both directions.
1273 // You can pass in DTLS and/or RTCP_MUX as flags.
1274 void SendSrtpToSrtp(int flags1_in = 0, int flags2_in = 0) {
1275 ASSERT((flags1_in & ~(RTCP_MUX | DTLS)) == 0);
1276 ASSERT((flags2_in & ~(RTCP_MUX | DTLS)) == 0);
1277
1278 int flags1 = RTCP | SECURE | flags1_in;
1279 int flags2 = RTCP | SECURE | flags2_in;
1280 bool dtls1 = !!(flags1_in & DTLS);
1281 bool dtls2 = !!(flags2_in & DTLS);
1282 CreateChannels(flags1, flags2);
1283 EXPECT_FALSE(channel1_->secure());
1284 EXPECT_FALSE(channel2_->secure());
1285 EXPECT_TRUE(SendInitiate());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001286 WaitForThreads();
1287 EXPECT_TRUE(channel1_->writable());
1288 EXPECT_TRUE(channel2_->writable());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001289 EXPECT_TRUE(SendAccept());
1290 EXPECT_TRUE(channel1_->secure());
1291 EXPECT_TRUE(channel2_->secure());
1292 EXPECT_EQ(dtls1 && dtls2, channel1_->secure_dtls());
1293 EXPECT_EQ(dtls1 && dtls2, channel2_->secure_dtls());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001294 SendRtp1();
1295 SendRtp2();
1296 SendRtcp1();
1297 SendRtcp2();
1298 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001299 EXPECT_TRUE(CheckRtp1());
1300 EXPECT_TRUE(CheckRtp2());
1301 EXPECT_TRUE(CheckNoRtp1());
1302 EXPECT_TRUE(CheckNoRtp2());
1303 EXPECT_TRUE(CheckRtcp1());
1304 EXPECT_TRUE(CheckRtcp2());
1305 EXPECT_TRUE(CheckNoRtcp1());
1306 EXPECT_TRUE(CheckNoRtcp2());
1307 }
1308
1309 // Test that we properly handling SRTP negotiating down to RTP.
1310 void SendSrtpToRtp() {
1311 CreateChannels(RTCP | SECURE, RTCP);
1312 EXPECT_FALSE(channel1_->secure());
1313 EXPECT_FALSE(channel2_->secure());
1314 EXPECT_TRUE(SendInitiate());
1315 EXPECT_TRUE(SendAccept());
1316 EXPECT_FALSE(channel1_->secure());
1317 EXPECT_FALSE(channel2_->secure());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001318 SendRtp1();
1319 SendRtp2();
1320 SendRtcp1();
1321 SendRtcp2();
1322 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001323 EXPECT_TRUE(CheckRtp1());
1324 EXPECT_TRUE(CheckRtp2());
1325 EXPECT_TRUE(CheckNoRtp1());
1326 EXPECT_TRUE(CheckNoRtp2());
1327 EXPECT_TRUE(CheckRtcp1());
1328 EXPECT_TRUE(CheckRtcp2());
1329 EXPECT_TRUE(CheckNoRtcp1());
1330 EXPECT_TRUE(CheckNoRtcp2());
1331 }
1332
1333 // Test that we can send and receive early media when a provisional answer is
1334 // sent and received. The test uses SRTP, RTCP mux and SSRC mux.
1335 void SendEarlyMediaUsingRtcpMuxSrtp() {
1336 int sequence_number1_1 = 0, sequence_number2_2 = 0;
1337
1338 CreateChannels(SSRC_MUX | RTCP | RTCP_MUX | SECURE,
1339 SSRC_MUX | RTCP | RTCP_MUX | SECURE);
1340 EXPECT_TRUE(SendOffer());
1341 EXPECT_TRUE(SendProvisionalAnswer());
1342 EXPECT_TRUE(channel1_->secure());
1343 EXPECT_TRUE(channel2_->secure());
deadbeefcbecd352015-09-23 11:50:27 -07001344 ASSERT_TRUE(GetTransport1());
1345 ASSERT_TRUE(GetTransport2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001346 EXPECT_EQ(2U, GetTransport1()->channels().size());
1347 EXPECT_EQ(2U, GetTransport2()->channels().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001348 WaitForThreads(); // Wait for 'sending' flag go through network thread.
1349 SendCustomRtcp1(kSsrc1);
1350 SendCustomRtp1(kSsrc1, ++sequence_number1_1);
1351 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001352 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001353 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1));
1354
1355 // Send packets from callee and verify that it is received.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001356 SendCustomRtcp2(kSsrc2);
1357 SendCustomRtp2(kSsrc2, ++sequence_number2_2);
1358 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001359 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001360 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2));
1361
1362 // Complete call setup and ensure everything is still OK.
1363 EXPECT_TRUE(SendFinalAnswer());
1364 EXPECT_EQ(1U, GetTransport1()->channels().size());
1365 EXPECT_EQ(1U, GetTransport2()->channels().size());
1366 EXPECT_TRUE(channel1_->secure());
1367 EXPECT_TRUE(channel2_->secure());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001368 SendCustomRtcp1(kSsrc1);
1369 SendCustomRtp1(kSsrc1, ++sequence_number1_1);
1370 SendCustomRtcp2(kSsrc2);
1371 SendCustomRtp2(kSsrc2, ++sequence_number2_2);
1372 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001373 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001374 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001375 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001376 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2));
1377 }
1378
1379 // Test that we properly send RTP without SRTP from a thread.
1380 void SendRtpToRtpOnThread() {
buildbot@webrtc.org6bfd6192014-05-15 16:15:59 +00001381 CreateChannels(RTCP, RTCP);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001382 EXPECT_TRUE(SendInitiate());
1383 EXPECT_TRUE(SendAccept());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001384 ScopedCallThread send_rtp1([this] { SendRtp1(); });
1385 ScopedCallThread send_rtp2([this] { SendRtp2(); });
1386 ScopedCallThread send_rtcp1([this] { SendRtcp1(); });
1387 ScopedCallThread send_rtcp2([this] { SendRtcp2(); });
1388 rtc::Thread* involved_threads[] = {send_rtp1.thread(), send_rtp2.thread(),
1389 send_rtcp1.thread(),
1390 send_rtcp2.thread()};
1391 WaitForThreads(involved_threads);
1392 EXPECT_TRUE(CheckRtp1());
1393 EXPECT_TRUE(CheckRtp2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001394 EXPECT_TRUE(CheckNoRtp1());
1395 EXPECT_TRUE(CheckNoRtp2());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001396 EXPECT_TRUE(CheckRtcp1());
1397 EXPECT_TRUE(CheckRtcp2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001398 EXPECT_TRUE(CheckNoRtcp1());
1399 EXPECT_TRUE(CheckNoRtcp2());
1400 }
1401
1402 // Test that we properly send SRTP with RTCP from a thread.
1403 void SendSrtpToSrtpOnThread() {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001404 CreateChannels(RTCP | SECURE, RTCP | SECURE);
1405 EXPECT_TRUE(SendInitiate());
1406 EXPECT_TRUE(SendAccept());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001407 ScopedCallThread send_rtp1([this] { SendRtp1(); });
1408 ScopedCallThread send_rtp2([this] { SendRtp2(); });
1409 ScopedCallThread send_rtcp1([this] { SendRtcp1(); });
1410 ScopedCallThread send_rtcp2([this] { SendRtcp2(); });
1411 rtc::Thread* involved_threads[] = {send_rtp1.thread(), send_rtp2.thread(),
1412 send_rtcp1.thread(),
1413 send_rtcp2.thread()};
1414 WaitForThreads(involved_threads);
1415 EXPECT_TRUE(CheckRtp1());
1416 EXPECT_TRUE(CheckRtp2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001417 EXPECT_TRUE(CheckNoRtp1());
1418 EXPECT_TRUE(CheckNoRtp2());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001419 EXPECT_TRUE(CheckRtcp1());
1420 EXPECT_TRUE(CheckRtcp2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001421 EXPECT_TRUE(CheckNoRtcp1());
1422 EXPECT_TRUE(CheckNoRtcp2());
1423 }
1424
1425 // Test that the mediachannel retains its sending state after the transport
1426 // becomes non-writable.
1427 void SendWithWritabilityLoss() {
1428 CreateChannels(0, 0);
1429 EXPECT_TRUE(SendInitiate());
1430 EXPECT_TRUE(SendAccept());
deadbeefcbecd352015-09-23 11:50:27 -07001431 ASSERT_TRUE(GetTransport1());
1432 ASSERT_TRUE(GetTransport2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001433 EXPECT_EQ(1U, GetTransport1()->channels().size());
1434 EXPECT_EQ(1U, GetTransport2()->channels().size());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001435 SendRtp1();
1436 SendRtp2();
1437 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001438 EXPECT_TRUE(CheckRtp1());
1439 EXPECT_TRUE(CheckRtp2());
1440 EXPECT_TRUE(CheckNoRtp1());
1441 EXPECT_TRUE(CheckNoRtp2());
1442
wu@webrtc.org97077a32013-10-25 21:18:33 +00001443 // Lose writability, which should fail.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001444 network_thread_->Invoke<void>(
1445 [this] { GetTransport1()->SetWritable(false); });
1446 SendRtp1();
1447 SendRtp2();
1448 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001449 EXPECT_TRUE(CheckRtp1());
1450 EXPECT_TRUE(CheckNoRtp2());
1451
1452 // Regain writability
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001453 network_thread_->Invoke<void>(
1454 [this] { GetTransport1()->SetWritable(true); });
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001455 EXPECT_TRUE(media_channel1_->sending());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001456 SendRtp1();
1457 SendRtp2();
1458 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001459 EXPECT_TRUE(CheckRtp1());
1460 EXPECT_TRUE(CheckRtp2());
1461 EXPECT_TRUE(CheckNoRtp1());
1462 EXPECT_TRUE(CheckNoRtp2());
1463
1464 // Lose writability completely
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001465 network_thread_->Invoke<void>(
1466 [this] { GetTransport1()->SetDestination(NULL); });
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001467 EXPECT_TRUE(media_channel1_->sending());
1468
wu@webrtc.org97077a32013-10-25 21:18:33 +00001469 // Should fail also.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001470 SendRtp1();
1471 SendRtp2();
1472 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001473 EXPECT_TRUE(CheckRtp1());
1474 EXPECT_TRUE(CheckNoRtp2());
1475
1476 // Gain writability back
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001477 network_thread_->Invoke<void>(
1478 [this] { GetTransport1()->SetDestination(GetTransport2()); });
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001479 EXPECT_TRUE(media_channel1_->sending());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001480 SendRtp1();
1481 SendRtp2();
1482 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001483 EXPECT_TRUE(CheckRtp1());
1484 EXPECT_TRUE(CheckRtp2());
1485 EXPECT_TRUE(CheckNoRtp1());
1486 EXPECT_TRUE(CheckNoRtp2());
1487 }
1488
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00001489 void SendBundleToBundle(
1490 const int* pl_types, int len, bool rtcp_mux, bool secure) {
1491 ASSERT_EQ(2, len);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001492 int sequence_number1_1 = 0, sequence_number2_2 = 0;
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00001493 // Only pl_type1 was added to the bundle filter for both |channel1_|
1494 // and |channel2_|.
1495 int pl_type1 = pl_types[0];
1496 int pl_type2 = pl_types[1];
1497 int flags = SSRC_MUX | RTCP;
1498 if (secure) flags |= SECURE;
Peter Boström0c4e06b2015-10-07 12:23:21 +02001499 uint32_t expected_channels = 2U;
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00001500 if (rtcp_mux) {
1501 flags |= RTCP_MUX;
1502 expected_channels = 1U;
1503 }
1504 CreateChannels(flags, flags);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001505 EXPECT_TRUE(SendInitiate());
deadbeefcbecd352015-09-23 11:50:27 -07001506 ASSERT_TRUE(GetTransport1());
1507 ASSERT_TRUE(GetTransport2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001508 EXPECT_EQ(2U, GetTransport1()->channels().size());
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00001509 EXPECT_EQ(expected_channels, GetTransport2()->channels().size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001510 EXPECT_TRUE(SendAccept());
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00001511 EXPECT_EQ(expected_channels, GetTransport1()->channels().size());
1512 EXPECT_EQ(expected_channels, GetTransport2()->channels().size());
1513 EXPECT_TRUE(channel1_->bundle_filter()->FindPayloadType(pl_type1));
1514 EXPECT_TRUE(channel2_->bundle_filter()->FindPayloadType(pl_type1));
1515 EXPECT_FALSE(channel1_->bundle_filter()->FindPayloadType(pl_type2));
1516 EXPECT_FALSE(channel2_->bundle_filter()->FindPayloadType(pl_type2));
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00001517
1518 // Both channels can receive pl_type1 only.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001519 SendCustomRtp1(kSsrc1, ++sequence_number1_1, pl_type1);
1520 SendCustomRtp2(kSsrc2, ++sequence_number2_2, pl_type1);
1521 WaitForThreads();
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00001522 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1, pl_type1));
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00001523 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2, pl_type1));
1524 EXPECT_TRUE(CheckNoRtp1());
1525 EXPECT_TRUE(CheckNoRtp2());
1526
1527 // RTCP test
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001528 SendCustomRtp1(kSsrc1, ++sequence_number1_1, pl_type2);
1529 SendCustomRtp2(kSsrc2, ++sequence_number2_2, pl_type2);
1530 WaitForThreads();
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00001531 EXPECT_FALSE(CheckCustomRtp2(kSsrc1, sequence_number1_1, pl_type2));
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00001532 EXPECT_FALSE(CheckCustomRtp1(kSsrc2, sequence_number2_2, pl_type2));
1533
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001534 SendCustomRtcp1(kSsrc1);
1535 SendCustomRtcp2(kSsrc2);
1536 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001537 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2));
1538 EXPECT_TRUE(CheckNoRtcp1());
1539 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1));
1540 EXPECT_TRUE(CheckNoRtcp2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001541
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001542 SendCustomRtcp1(kSsrc2);
1543 SendCustomRtcp2(kSsrc1);
1544 WaitForThreads();
pbos482b12e2015-11-16 10:19:58 -08001545 // Bundle filter shouldn't filter out any RTCP.
1546 EXPECT_TRUE(CheckCustomRtcp1(kSsrc1));
1547 EXPECT_TRUE(CheckCustomRtcp2(kSsrc2));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001548 }
1549
1550 // Test that the media monitor can be run and gives timely callbacks.
1551 void TestMediaMonitor() {
1552 static const int kTimeout = 500;
1553 CreateChannels(0, 0);
1554 EXPECT_TRUE(SendInitiate());
1555 EXPECT_TRUE(SendAccept());
1556 channel1_->StartMediaMonitor(100);
1557 channel2_->StartMediaMonitor(100);
1558 // Ensure we get callbacks and stop.
1559 EXPECT_TRUE_WAIT(media_info_callbacks1_ > 0, kTimeout);
1560 EXPECT_TRUE_WAIT(media_info_callbacks2_ > 0, kTimeout);
1561 channel1_->StopMediaMonitor();
1562 channel2_->StopMediaMonitor();
1563 // Ensure a restart of a stopped monitor works.
1564 channel1_->StartMediaMonitor(100);
1565 EXPECT_TRUE_WAIT(media_info_callbacks1_ > 0, kTimeout);
1566 channel1_->StopMediaMonitor();
1567 // Ensure stopping a stopped monitor is OK.
1568 channel1_->StopMediaMonitor();
1569 }
1570
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001571 void TestSetContentFailure() {
1572 CreateChannels(0, 0);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001573
Peter Thatchera6d24442015-07-09 21:26:36 -07001574 auto sdesc = cricket::SessionDescription();
1575 sdesc.AddContent(cricket::CN_AUDIO, cricket::NS_JINGLE_RTP,
1576 new cricket::AudioContentDescription());
1577 sdesc.AddContent(cricket::CN_VIDEO, cricket::NS_JINGLE_RTP,
1578 new cricket::VideoContentDescription());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001579
Peter Thatchera6d24442015-07-09 21:26:36 -07001580 std::string err;
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001581 media_channel1_->set_fail_set_recv_codecs(true);
Peter Thatchera6d24442015-07-09 21:26:36 -07001582 EXPECT_FALSE(channel1_->PushdownLocalDescription(
1583 &sdesc, cricket::CA_OFFER, &err));
1584 EXPECT_FALSE(channel1_->PushdownLocalDescription(
1585 &sdesc, cricket::CA_ANSWER, &err));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001586
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001587 media_channel1_->set_fail_set_send_codecs(true);
Peter Thatchera6d24442015-07-09 21:26:36 -07001588 EXPECT_FALSE(channel1_->PushdownRemoteDescription(
1589 &sdesc, cricket::CA_OFFER, &err));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001590 media_channel1_->set_fail_set_send_codecs(true);
Peter Thatchera6d24442015-07-09 21:26:36 -07001591 EXPECT_FALSE(channel1_->PushdownRemoteDescription(
1592 &sdesc, cricket::CA_ANSWER, &err));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001593 }
1594
1595 void TestSendTwoOffers() {
1596 CreateChannels(0, 0);
1597
Peter Thatchera6d24442015-07-09 21:26:36 -07001598 std::string err;
kwiberg31022942016-03-11 14:18:21 -08001599 std::unique_ptr<cricket::SessionDescription> sdesc1(
Peter Thatchera6d24442015-07-09 21:26:36 -07001600 CreateSessionDescriptionWithStream(1));
1601 EXPECT_TRUE(channel1_->PushdownLocalDescription(
1602 sdesc1.get(), cricket::CA_OFFER, &err));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001603 EXPECT_TRUE(media_channel1_->HasSendStream(1));
1604
kwiberg31022942016-03-11 14:18:21 -08001605 std::unique_ptr<cricket::SessionDescription> sdesc2(
Peter Thatchera6d24442015-07-09 21:26:36 -07001606 CreateSessionDescriptionWithStream(2));
1607 EXPECT_TRUE(channel1_->PushdownLocalDescription(
1608 sdesc2.get(), cricket::CA_OFFER, &err));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001609 EXPECT_FALSE(media_channel1_->HasSendStream(1));
1610 EXPECT_TRUE(media_channel1_->HasSendStream(2));
1611 }
1612
1613 void TestReceiveTwoOffers() {
1614 CreateChannels(0, 0);
1615
Peter Thatchera6d24442015-07-09 21:26:36 -07001616 std::string err;
kwiberg31022942016-03-11 14:18:21 -08001617 std::unique_ptr<cricket::SessionDescription> sdesc1(
Peter Thatchera6d24442015-07-09 21:26:36 -07001618 CreateSessionDescriptionWithStream(1));
1619 EXPECT_TRUE(channel1_->PushdownRemoteDescription(
1620 sdesc1.get(), cricket::CA_OFFER, &err));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001621 EXPECT_TRUE(media_channel1_->HasRecvStream(1));
1622
kwiberg31022942016-03-11 14:18:21 -08001623 std::unique_ptr<cricket::SessionDescription> sdesc2(
Peter Thatchera6d24442015-07-09 21:26:36 -07001624 CreateSessionDescriptionWithStream(2));
1625 EXPECT_TRUE(channel1_->PushdownRemoteDescription(
1626 sdesc2.get(), cricket::CA_OFFER, &err));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001627 EXPECT_FALSE(media_channel1_->HasRecvStream(1));
1628 EXPECT_TRUE(media_channel1_->HasRecvStream(2));
1629 }
1630
1631 void TestSendPrAnswer() {
1632 CreateChannels(0, 0);
1633
Peter Thatchera6d24442015-07-09 21:26:36 -07001634 std::string err;
1635 // Receive offer
kwiberg31022942016-03-11 14:18:21 -08001636 std::unique_ptr<cricket::SessionDescription> sdesc1(
Peter Thatchera6d24442015-07-09 21:26:36 -07001637 CreateSessionDescriptionWithStream(1));
1638 EXPECT_TRUE(channel1_->PushdownRemoteDescription(
1639 sdesc1.get(), cricket::CA_OFFER, &err));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001640 EXPECT_TRUE(media_channel1_->HasRecvStream(1));
1641
Peter Thatchera6d24442015-07-09 21:26:36 -07001642 // Send PR answer
kwiberg31022942016-03-11 14:18:21 -08001643 std::unique_ptr<cricket::SessionDescription> sdesc2(
Peter Thatchera6d24442015-07-09 21:26:36 -07001644 CreateSessionDescriptionWithStream(2));
1645 EXPECT_TRUE(channel1_->PushdownLocalDescription(
1646 sdesc2.get(), cricket::CA_PRANSWER, &err));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001647 EXPECT_TRUE(media_channel1_->HasRecvStream(1));
1648 EXPECT_TRUE(media_channel1_->HasSendStream(2));
1649
Peter Thatchera6d24442015-07-09 21:26:36 -07001650 // Send answer
kwiberg31022942016-03-11 14:18:21 -08001651 std::unique_ptr<cricket::SessionDescription> sdesc3(
Peter Thatchera6d24442015-07-09 21:26:36 -07001652 CreateSessionDescriptionWithStream(3));
1653 EXPECT_TRUE(channel1_->PushdownLocalDescription(
1654 sdesc3.get(), cricket::CA_ANSWER, &err));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001655 EXPECT_TRUE(media_channel1_->HasRecvStream(1));
1656 EXPECT_FALSE(media_channel1_->HasSendStream(2));
1657 EXPECT_TRUE(media_channel1_->HasSendStream(3));
1658 }
1659
1660 void TestReceivePrAnswer() {
1661 CreateChannels(0, 0);
1662
Peter Thatchera6d24442015-07-09 21:26:36 -07001663 std::string err;
1664 // Send offer
kwiberg31022942016-03-11 14:18:21 -08001665 std::unique_ptr<cricket::SessionDescription> sdesc1(
Peter Thatchera6d24442015-07-09 21:26:36 -07001666 CreateSessionDescriptionWithStream(1));
1667 EXPECT_TRUE(channel1_->PushdownLocalDescription(
1668 sdesc1.get(), cricket::CA_OFFER, &err));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001669 EXPECT_TRUE(media_channel1_->HasSendStream(1));
1670
Peter Thatchera6d24442015-07-09 21:26:36 -07001671 // Receive PR answer
kwiberg31022942016-03-11 14:18:21 -08001672 std::unique_ptr<cricket::SessionDescription> sdesc2(
Peter Thatchera6d24442015-07-09 21:26:36 -07001673 CreateSessionDescriptionWithStream(2));
1674 EXPECT_TRUE(channel1_->PushdownRemoteDescription(
1675 sdesc2.get(), cricket::CA_PRANSWER, &err));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001676 EXPECT_TRUE(media_channel1_->HasSendStream(1));
1677 EXPECT_TRUE(media_channel1_->HasRecvStream(2));
1678
Peter Thatchera6d24442015-07-09 21:26:36 -07001679 // Receive answer
kwiberg31022942016-03-11 14:18:21 -08001680 std::unique_ptr<cricket::SessionDescription> sdesc3(
Peter Thatchera6d24442015-07-09 21:26:36 -07001681 CreateSessionDescriptionWithStream(3));
1682 EXPECT_TRUE(channel1_->PushdownRemoteDescription(
1683 sdesc3.get(), cricket::CA_ANSWER, &err));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001684 EXPECT_TRUE(media_channel1_->HasSendStream(1));
1685 EXPECT_FALSE(media_channel1_->HasRecvStream(2));
1686 EXPECT_TRUE(media_channel1_->HasRecvStream(3));
1687 }
1688
1689 void TestFlushRtcp() {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001690 CreateChannels(RTCP, RTCP);
1691 EXPECT_TRUE(SendInitiate());
1692 EXPECT_TRUE(SendAccept());
deadbeefcbecd352015-09-23 11:50:27 -07001693 ASSERT_TRUE(GetTransport1());
1694 ASSERT_TRUE(GetTransport2());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001695 EXPECT_EQ(2U, GetTransport1()->channels().size());
1696 EXPECT_EQ(2U, GetTransport2()->channels().size());
1697
1698 // Send RTCP1 from a different thread.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001699 ScopedCallThread send_rtcp([this] { SendRtcp1(); });
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001700 // The sending message is only posted. channel2_ should be empty.
1701 EXPECT_TRUE(CheckNoRtcp2());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001702 rtc::Thread* wait_for[] = {send_rtcp.thread()};
1703 WaitForThreads(wait_for); // Ensure rtcp was posted
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001704
1705 // When channel1_ is deleted, the RTCP packet should be sent out to
1706 // channel2_.
1707 channel1_.reset();
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001708 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001709 EXPECT_TRUE(CheckRtcp2());
1710 }
1711
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00001712 void TestSrtpError(int pl_type) {
solenberg5b14b422015-10-01 04:10:31 -07001713 struct SrtpErrorHandler : public sigslot::has_slots<> {
1714 SrtpErrorHandler() :
1715 mode_(cricket::SrtpFilter::UNPROTECT),
1716 error_(cricket::SrtpFilter::ERROR_NONE) {}
1717 void OnSrtpError(uint32 ssrc, cricket::SrtpFilter::Mode mode,
1718 cricket::SrtpFilter::Error error) {
1719 mode_ = mode;
1720 error_ = error;
1721 }
1722 cricket::SrtpFilter::Mode mode_;
1723 cricket::SrtpFilter::Error error_;
1724 } error_handler;
1725
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00001726 // For Audio, only pl_type 0 is added to the bundle filter.
1727 // For Video, only pl_type 97 is added to the bundle filter.
1728 // So we need to pass in pl_type so that the packet can pass through
1729 // the bundle filter before it can be processed by the srtp filter.
1730 // The packet is not a valid srtp packet because it is too short.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001731 static unsigned const char kBadPacket[] = {
1732 0x84, static_cast<unsigned char>(pl_type),
1733 0x00, 0x01,
1734 0x00, 0x00,
1735 0x00, 0x00,
1736 0x00, 0x00,
1737 0x00, 0x01};
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001738 CreateChannels(RTCP | SECURE, RTCP | SECURE);
1739 EXPECT_FALSE(channel1_->secure());
1740 EXPECT_FALSE(channel2_->secure());
1741 EXPECT_TRUE(SendInitiate());
1742 EXPECT_TRUE(SendAccept());
1743 EXPECT_TRUE(channel1_->secure());
1744 EXPECT_TRUE(channel2_->secure());
solenberg5629a1d2015-10-01 08:45:57 -07001745 channel2_->srtp_filter()->set_signal_silent_time(250);
solenberg5b14b422015-10-01 04:10:31 -07001746 channel2_->srtp_filter()->SignalSrtpError.connect(
1747 &error_handler, &SrtpErrorHandler::OnSrtpError);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001748
1749 // Testing failures in sending packets.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001750 media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket),
1751 rtc::PacketOptions());
1752 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001753 // The first failure will trigger an error.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001754 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_);
solenberg5b14b422015-10-01 04:10:31 -07001755 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_);
1756 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE;
solenberg5629a1d2015-10-01 08:45:57 -07001757 error_handler.mode_ = cricket::SrtpFilter::UNPROTECT;
1758 // The next 250 ms failures will not trigger an error.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001759 media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket),
1760 rtc::PacketOptions());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001761 // Wait for a while to ensure no message comes in.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001762 WaitForThreads();
solenberg5629a1d2015-10-01 08:45:57 -07001763 rtc::Thread::Current()->ProcessMessages(200);
solenberg5b14b422015-10-01 04:10:31 -07001764 EXPECT_EQ(cricket::SrtpFilter::ERROR_NONE, error_handler.error_);
solenberg5629a1d2015-10-01 08:45:57 -07001765 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_);
1766 // Wait for a little more - the error will be triggered again.
1767 rtc::Thread::Current()->ProcessMessages(200);
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001768 media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket),
1769 rtc::PacketOptions());
1770 WaitForThreads();
1771 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_);
solenberg5b14b422015-10-01 04:10:31 -07001772 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001773
1774 // Testing failures in receiving packets.
solenberg5b14b422015-10-01 04:10:31 -07001775 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE;
solenberg5629a1d2015-10-01 08:45:57 -07001776 error_handler.mode_ = cricket::SrtpFilter::UNPROTECT;
solenberg5b14b422015-10-01 04:10:31 -07001777
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001778 network_thread_->Invoke<void>([this] {
1779 cricket::TransportChannel* transport_channel =
1780 channel2_->transport_channel();
1781 transport_channel->SignalReadPacket(
1782 transport_channel, reinterpret_cast<const char*>(kBadPacket),
1783 sizeof(kBadPacket), rtc::PacketTime(), 0);
1784 });
1785 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_);
solenberg5b14b422015-10-01 04:10:31 -07001786 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001787 }
1788
1789 void TestOnReadyToSend() {
1790 CreateChannels(RTCP, RTCP);
1791 TransportChannel* rtp = channel1_->transport_channel();
1792 TransportChannel* rtcp = channel1_->rtcp_transport_channel();
1793 EXPECT_FALSE(media_channel1_->ready_to_send());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001794
1795 network_thread_->Invoke<void>([rtp] { rtp->SignalReadyToSend(rtp); });
1796 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001797 EXPECT_FALSE(media_channel1_->ready_to_send());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001798
1799 network_thread_->Invoke<void>([rtcp] { rtcp->SignalReadyToSend(rtcp); });
1800 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001801 // MediaChannel::OnReadyToSend only be called when both rtp and rtcp
1802 // channel are ready to send.
1803 EXPECT_TRUE(media_channel1_->ready_to_send());
1804
1805 // rtp channel becomes not ready to send will be propagated to mediachannel
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001806 network_thread_->Invoke<void>(
1807 [this] { channel1_->SetReadyToSend(false, false); });
1808 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001809 EXPECT_FALSE(media_channel1_->ready_to_send());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001810
1811 network_thread_->Invoke<void>(
1812 [this] { channel1_->SetReadyToSend(false, true); });
1813 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001814 EXPECT_TRUE(media_channel1_->ready_to_send());
1815
1816 // rtcp channel becomes not ready to send will be propagated to mediachannel
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001817 network_thread_->Invoke<void>(
1818 [this] { channel1_->SetReadyToSend(true, false); });
1819 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001820 EXPECT_FALSE(media_channel1_->ready_to_send());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001821
1822 network_thread_->Invoke<void>(
1823 [this] { channel1_->SetReadyToSend(true, true); });
1824 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001825 EXPECT_TRUE(media_channel1_->ready_to_send());
1826 }
1827
1828 void TestOnReadyToSendWithRtcpMux() {
1829 CreateChannels(RTCP, RTCP);
1830 typename T::Content content;
1831 CreateContent(0, kPcmuCodec, kH264Codec, &content);
1832 // Both sides agree on mux. Should no longer be a separate RTCP channel.
1833 content.set_rtcp_mux(true);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +00001834 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL));
1835 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001836 EXPECT_TRUE(channel1_->rtcp_transport_channel() == NULL);
1837 TransportChannel* rtp = channel1_->transport_channel();
1838 EXPECT_FALSE(media_channel1_->ready_to_send());
1839 // In the case of rtcp mux, the SignalReadyToSend() from rtp channel
1840 // should trigger the MediaChannel's OnReadyToSend.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001841 network_thread_->Invoke<void>([rtp] { rtp->SignalReadyToSend(rtp); });
1842 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001843 EXPECT_TRUE(media_channel1_->ready_to_send());
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001844
1845 network_thread_->Invoke<void>(
1846 [this] { channel1_->SetReadyToSend(false, false); });
1847 WaitForThreads();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001848 EXPECT_FALSE(media_channel1_->ready_to_send());
1849 }
1850
skvladdc1c62c2016-03-16 19:07:43 -07001851 bool SetRemoteContentWithBitrateLimit(int remote_limit) {
1852 typename T::Content content;
1853 CreateContent(0, kPcmuCodec, kH264Codec, &content);
1854 content.set_bandwidth(remote_limit);
1855 return channel1_->SetRemoteContent(&content, CA_OFFER, NULL);
1856 }
1857
1858 webrtc::RtpParameters BitrateLimitedParameters(int limit) {
1859 webrtc::RtpParameters parameters;
1860 webrtc::RtpEncodingParameters encoding;
1861 encoding.max_bitrate_bps = limit;
1862 parameters.encodings.push_back(encoding);
1863 return parameters;
1864 }
1865
1866 void VerifyMaxBitrate(const webrtc::RtpParameters& parameters,
1867 int expected_bitrate) {
1868 EXPECT_EQ(1UL, parameters.encodings.size());
1869 EXPECT_EQ(expected_bitrate, parameters.encodings[0].max_bitrate_bps);
1870 }
1871
1872 void DefaultMaxBitrateIsUnlimited() {
1873 CreateChannels(0, 0);
1874 EXPECT_TRUE(
1875 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL));
1876 EXPECT_EQ(media_channel1_->max_bps(), -1);
1877 VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), -1);
1878 }
1879
1880 void CanChangeMaxBitrate() {
1881 CreateChannels(0, 0);
1882 EXPECT_TRUE(
1883 channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL));
1884
1885 EXPECT_TRUE(
1886 channel1_->SetRtpParameters(kSsrc1, BitrateLimitedParameters(1000)));
1887 VerifyMaxBitrate(channel1_->GetRtpParameters(kSsrc1), 1000);
1888 VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), 1000);
1889 EXPECT_EQ(-1, media_channel1_->max_bps());
1890
1891 EXPECT_TRUE(
1892 channel1_->SetRtpParameters(kSsrc1, BitrateLimitedParameters(-1)));
1893 VerifyMaxBitrate(channel1_->GetRtpParameters(kSsrc1), -1);
1894 VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), -1);
1895 EXPECT_EQ(-1, media_channel1_->max_bps());
1896 }
1897
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001898 protected:
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001899 void WaitForThreads() { WaitForThreads(rtc::ArrayView<rtc::Thread*>()); }
1900 static void ProcessThreadQueue(rtc::Thread* thread) {
1901 RTC_DCHECK(thread->IsCurrent());
1902 while (!thread->empty()) {
1903 thread->ProcessMessages(0);
1904 }
1905 }
1906 void WaitForThreads(rtc::ArrayView<rtc::Thread*> threads) {
1907 // |threads| and current thread post packets to network thread.
1908 for (rtc::Thread* thread : threads) {
1909 thread->Invoke<void>([thread] { ProcessThreadQueue(thread); });
1910 }
1911 ProcessThreadQueue(rtc::Thread::Current());
1912 // Network thread move them around and post back to worker = current thread.
1913 if (!network_thread_->IsCurrent()) {
1914 network_thread_->Invoke<void>(
1915 [this] { ProcessThreadQueue(network_thread_); });
1916 }
1917 // Worker thread = current Thread process received messages.
1918 ProcessThreadQueue(rtc::Thread::Current());
1919 }
Peter Boström34fbfff2015-09-24 19:20:30 +02001920 // TODO(pbos): Remove playout from all media channels and let renderers mute
1921 // themselves.
1922 const bool verify_playout_;
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001923 std::unique_ptr<rtc::Thread> network_thread_keeper_;
1924 rtc::Thread* network_thread_;
1925 std::unique_ptr<cricket::FakeTransportController> transport_controller1_;
1926 std::unique_ptr<cricket::FakeTransportController> transport_controller2_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001927 cricket::FakeMediaEngine media_engine_;
1928 // The media channels are owned by the voice channel objects below.
1929 typename T::MediaChannel* media_channel1_;
1930 typename T::MediaChannel* media_channel2_;
kwiberg31022942016-03-11 14:18:21 -08001931 std::unique_ptr<typename T::Channel> channel1_;
1932 std::unique_ptr<typename T::Channel> channel2_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001933 typename T::Content local_media_content1_;
1934 typename T::Content local_media_content2_;
1935 typename T::Content remote_media_content1_;
1936 typename T::Content remote_media_content2_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001937 // The RTP and RTCP packets to send in the tests.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001938 rtc::Buffer rtp_packet_;
1939 rtc::Buffer rtcp_packet_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001940 int media_info_callbacks1_;
1941 int media_info_callbacks2_;
Honghai Zhangcc411c02016-03-29 17:27:21 -07001942 cricket::CandidatePairInterface* last_selected_candidate_pair_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001943};
1944
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001945template<>
1946void ChannelTest<VoiceTraits>::CreateContent(
1947 int flags,
1948 const cricket::AudioCodec& audio_codec,
1949 const cricket::VideoCodec& video_codec,
1950 cricket::AudioContentDescription* audio) {
1951 audio->AddCodec(audio_codec);
1952 audio->set_rtcp_mux((flags & RTCP_MUX) != 0);
1953 if (flags & SECURE) {
1954 audio->AddCrypto(cricket::CryptoParams(
Guo-wei Shieh456696a2015-09-30 21:48:54 -07001955 1, rtc::CS_AES_CM_128_HMAC_SHA1_32,
1956 "inline:" + rtc::CreateRandomString(40), std::string()));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001957 }
1958}
1959
1960template<>
1961void ChannelTest<VoiceTraits>::CopyContent(
1962 const cricket::AudioContentDescription& source,
1963 cricket::AudioContentDescription* audio) {
1964 *audio = source;
1965}
1966
1967template<>
1968bool ChannelTest<VoiceTraits>::CodecMatches(const cricket::AudioCodec& c1,
1969 const cricket::AudioCodec& c2) {
1970 return c1.name == c2.name && c1.clockrate == c2.clockrate &&
1971 c1.bitrate == c2.bitrate && c1.channels == c2.channels;
1972}
1973
Peter Boström0c4e06b2015-10-07 12:23:21 +02001974template <>
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001975void ChannelTest<VoiceTraits>::AddLegacyStreamInContent(
Peter Boström0c4e06b2015-10-07 12:23:21 +02001976 uint32_t ssrc,
1977 int flags,
1978 cricket::AudioContentDescription* audio) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001979 audio->AddLegacyStream(ssrc);
1980}
1981
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001982class VoiceChannelSingleThreadTest : public ChannelTest<VoiceTraits> {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001983 public:
solenberg1dd98f32015-09-10 01:57:14 -07001984 typedef ChannelTest<VoiceTraits> Base;
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001985 VoiceChannelSingleThreadTest()
1986 : Base(true, kPcmuFrame, kRtcpReport, NetworkIsWorker::Yes) {}
1987};
1988
1989class VoiceChannelDoubleThreadTest : public ChannelTest<VoiceTraits> {
1990 public:
1991 typedef ChannelTest<VoiceTraits> Base;
1992 VoiceChannelDoubleThreadTest()
1993 : Base(true, kPcmuFrame, kRtcpReport, NetworkIsWorker::No) {}
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001994};
1995
1996// override to add NULL parameter
deadbeefcbecd352015-09-23 11:50:27 -07001997template <>
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001998cricket::VideoChannel* ChannelTest<VideoTraits>::CreateChannel(
Danil Chapovalov33b01f22016-05-11 19:55:27 +02001999 rtc::Thread* worker_thread,
2000 rtc::Thread* network_thread,
deadbeefcbecd352015-09-23 11:50:27 -07002001 cricket::MediaEngineInterface* engine,
2002 cricket::FakeVideoMediaChannel* ch,
2003 cricket::TransportController* transport_controller,
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002004 bool rtcp) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002005 cricket::VideoChannel* channel =
2006 new cricket::VideoChannel(worker_thread, network_thread, ch,
2007 transport_controller, cricket::CN_VIDEO, rtcp);
2008 if (!channel->Init_w()) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002009 delete channel;
2010 channel = NULL;
2011 }
2012 return channel;
2013}
2014
2015// override to add 0 parameter
2016template<>
2017bool ChannelTest<VideoTraits>::AddStream1(int id) {
2018 return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id));
2019}
2020
2021template<>
2022void ChannelTest<VideoTraits>::CreateContent(
2023 int flags,
2024 const cricket::AudioCodec& audio_codec,
2025 const cricket::VideoCodec& video_codec,
2026 cricket::VideoContentDescription* video) {
2027 video->AddCodec(video_codec);
2028 video->set_rtcp_mux((flags & RTCP_MUX) != 0);
2029 if (flags & SECURE) {
2030 video->AddCrypto(cricket::CryptoParams(
Guo-wei Shieh456696a2015-09-30 21:48:54 -07002031 1, rtc::CS_AES_CM_128_HMAC_SHA1_80,
2032 "inline:" + rtc::CreateRandomString(40), std::string()));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002033 }
2034}
2035
2036template<>
2037void ChannelTest<VideoTraits>::CopyContent(
2038 const cricket::VideoContentDescription& source,
2039 cricket::VideoContentDescription* video) {
2040 *video = source;
2041}
2042
2043template<>
2044bool ChannelTest<VideoTraits>::CodecMatches(const cricket::VideoCodec& c1,
2045 const cricket::VideoCodec& c2) {
2046 return c1.name == c2.name && c1.width == c2.width && c1.height == c2.height &&
2047 c1.framerate == c2.framerate;
2048}
2049
Peter Boström0c4e06b2015-10-07 12:23:21 +02002050template <>
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002051void ChannelTest<VideoTraits>::AddLegacyStreamInContent(
Peter Boström0c4e06b2015-10-07 12:23:21 +02002052 uint32_t ssrc,
2053 int flags,
2054 cricket::VideoContentDescription* video) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002055 video->AddLegacyStream(ssrc);
2056}
2057
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002058class VideoChannelSingleThreadTest : public ChannelTest<VideoTraits> {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002059 public:
solenberg1dd98f32015-09-10 01:57:14 -07002060 typedef ChannelTest<VideoTraits> Base;
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002061 VideoChannelSingleThreadTest()
2062 : Base(false, kH264Packet, kRtcpReport, NetworkIsWorker::Yes) {}
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002063};
2064
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002065class VideoChannelDoubleThreadTest : public ChannelTest<VideoTraits> {
2066 public:
2067 typedef ChannelTest<VideoTraits> Base;
2068 VideoChannelDoubleThreadTest()
2069 : Base(false, kH264Packet, kRtcpReport, NetworkIsWorker::No) {}
2070};
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002071
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002072// VoiceChannelSingleThreadTest
2073TEST_F(VoiceChannelSingleThreadTest, TestInit) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002074 Base::TestInit();
2075 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
2076 EXPECT_TRUE(media_channel1_->dtmf_info_queue().empty());
2077}
2078
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002079TEST_F(VoiceChannelSingleThreadTest, TestSetContents) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002080 Base::TestSetContents();
2081}
2082
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002083TEST_F(VoiceChannelSingleThreadTest, TestSetContentsNullOffer) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002084 Base::TestSetContentsNullOffer();
2085}
2086
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002087TEST_F(VoiceChannelSingleThreadTest, TestSetContentsRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002088 Base::TestSetContentsRtcpMux();
2089}
2090
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002091TEST_F(VoiceChannelSingleThreadTest, TestSetContentsRtcpMuxWithPrAnswer) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002092 Base::TestSetContentsRtcpMux();
2093}
2094
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002095TEST_F(VoiceChannelSingleThreadTest, TestSetRemoteContentUpdate) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002096 Base::TestSetRemoteContentUpdate();
2097}
2098
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002099TEST_F(VoiceChannelSingleThreadTest, TestStreams) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002100 Base::TestStreams();
2101}
2102
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002103TEST_F(VoiceChannelSingleThreadTest, TestUpdateStreamsInLocalContent) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002104 Base::TestUpdateStreamsInLocalContent();
2105}
2106
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002107TEST_F(VoiceChannelSingleThreadTest, TestUpdateRemoteStreamsInContent) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002108 Base::TestUpdateStreamsInRemoteContent();
2109}
2110
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002111TEST_F(VoiceChannelSingleThreadTest, TestChangeStreamParamsInContent) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002112 Base::TestChangeStreamParamsInContent();
2113}
2114
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002115TEST_F(VoiceChannelSingleThreadTest, TestPlayoutAndSendingStates) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002116 Base::TestPlayoutAndSendingStates();
2117}
2118
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002119TEST_F(VoiceChannelSingleThreadTest, TestMuteStream) {
solenberg1dd98f32015-09-10 01:57:14 -07002120 CreateChannels(0, 0);
2121 // Test that we can Mute the default channel even though the sending SSRC
2122 // is unknown.
2123 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
solenberg1dd98f32015-09-10 01:57:14 -07002124 EXPECT_TRUE(channel1_->SetAudioSend(0, false, nullptr, nullptr));
solenbergdfc8f4f2015-10-01 02:31:10 -07002125 EXPECT_TRUE(media_channel1_->IsStreamMuted(0));
2126 EXPECT_TRUE(channel1_->SetAudioSend(0, true, nullptr, nullptr));
solenberg1dd98f32015-09-10 01:57:14 -07002127 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
2128
2129 // Test that we can not mute an unknown SSRC.
solenbergdfc8f4f2015-10-01 02:31:10 -07002130 EXPECT_FALSE(channel1_->SetAudioSend(kSsrc1, false, nullptr, nullptr));
solenberg1dd98f32015-09-10 01:57:14 -07002131
2132 SendInitiate();
2133 // After the local session description has been set, we can mute a stream
2134 // with its SSRC.
solenberg1dd98f32015-09-10 01:57:14 -07002135 EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, false, nullptr, nullptr));
solenbergdfc8f4f2015-10-01 02:31:10 -07002136 EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1));
2137 EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, true, nullptr, nullptr));
solenberg1dd98f32015-09-10 01:57:14 -07002138 EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002139}
2140
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002141TEST_F(VoiceChannelSingleThreadTest, TestMediaContentDirection) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002142 Base::TestMediaContentDirection();
2143}
2144
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002145TEST_F(VoiceChannelSingleThreadTest, TestNetworkRouteChanges) {
Honghai Zhangcc411c02016-03-29 17:27:21 -07002146 Base::TestNetworkRouteChanges();
2147}
2148
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002149TEST_F(VoiceChannelSingleThreadTest, TestCallSetup) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002150 Base::TestCallSetup();
2151}
2152
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002153TEST_F(VoiceChannelSingleThreadTest, TestCallTeardownRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002154 Base::TestCallTeardownRtcpMux();
2155}
2156
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002157TEST_F(VoiceChannelSingleThreadTest, SendRtpToRtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002158 Base::SendRtpToRtp();
2159}
2160
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002161TEST_F(VoiceChannelSingleThreadTest, SendNoRtcpToNoRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002162 Base::SendNoRtcpToNoRtcp();
2163}
2164
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002165TEST_F(VoiceChannelSingleThreadTest, SendNoRtcpToRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002166 Base::SendNoRtcpToRtcp();
2167}
2168
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002169TEST_F(VoiceChannelSingleThreadTest, SendRtcpToNoRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002170 Base::SendRtcpToNoRtcp();
2171}
2172
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002173TEST_F(VoiceChannelSingleThreadTest, SendRtcpToRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002174 Base::SendRtcpToRtcp();
2175}
2176
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002177TEST_F(VoiceChannelSingleThreadTest, SendRtcpMuxToRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002178 Base::SendRtcpMuxToRtcp();
2179}
2180
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002181TEST_F(VoiceChannelSingleThreadTest, SendRtcpMuxToRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002182 Base::SendRtcpMuxToRtcpMux();
2183}
2184
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002185TEST_F(VoiceChannelSingleThreadTest, SendRequireRtcpMuxToRtcpMux) {
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07002186 Base::SendRequireRtcpMuxToRtcpMux();
2187}
2188
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002189TEST_F(VoiceChannelSingleThreadTest, SendRtcpMuxToRequireRtcpMux) {
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07002190 Base::SendRtcpMuxToRequireRtcpMux();
2191}
2192
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002193TEST_F(VoiceChannelSingleThreadTest, SendRequireRtcpMuxToRequireRtcpMux) {
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07002194 Base::SendRequireRtcpMuxToRequireRtcpMux();
2195}
2196
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002197TEST_F(VoiceChannelSingleThreadTest, SendRequireRtcpMuxToNoRtcpMux) {
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07002198 Base::SendRequireRtcpMuxToNoRtcpMux();
2199}
2200
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002201TEST_F(VoiceChannelSingleThreadTest, SendEarlyRtcpMuxToRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002202 Base::SendEarlyRtcpMuxToRtcp();
2203}
2204
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002205TEST_F(VoiceChannelSingleThreadTest, SendEarlyRtcpMuxToRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002206 Base::SendEarlyRtcpMuxToRtcpMux();
2207}
2208
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002209TEST_F(VoiceChannelSingleThreadTest, SendSrtpToSrtpRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002210 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX);
2211}
2212
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002213TEST_F(VoiceChannelSingleThreadTest, SendSrtpToRtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002214 Base::SendSrtpToSrtp();
2215}
2216
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002217TEST_F(VoiceChannelSingleThreadTest, SendSrtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002218 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX);
2219}
2220
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002221TEST_F(VoiceChannelSingleThreadTest, SendDtlsSrtpToSrtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002222 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2223 Base::SendSrtpToSrtp(DTLS, 0);
2224}
2225
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002226TEST_F(VoiceChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002227 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2228 Base::SendSrtpToSrtp(DTLS, DTLS);
2229}
2230
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002231TEST_F(VoiceChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002232 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2233 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX);
2234}
2235
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002236TEST_F(VoiceChannelSingleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002237 Base::SendEarlyMediaUsingRtcpMuxSrtp();
2238}
2239
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002240TEST_F(VoiceChannelSingleThreadTest, SendRtpToRtpOnThread) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002241 Base::SendRtpToRtpOnThread();
2242}
2243
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002244TEST_F(VoiceChannelSingleThreadTest, SendSrtpToSrtpOnThread) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002245 Base::SendSrtpToSrtpOnThread();
2246}
2247
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002248TEST_F(VoiceChannelSingleThreadTest, SendWithWritabilityLoss) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002249 Base::SendWithWritabilityLoss();
2250}
2251
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002252TEST_F(VoiceChannelSingleThreadTest, TestMediaMonitor) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002253 Base::TestMediaMonitor();
2254}
2255
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002256// Test that InsertDtmf properly forwards to the media channel.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002257TEST_F(VoiceChannelSingleThreadTest, TestInsertDtmf) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002258 CreateChannels(0, 0);
2259 EXPECT_TRUE(SendInitiate());
2260 EXPECT_TRUE(SendAccept());
2261 EXPECT_EQ(0U, media_channel1_->dtmf_info_queue().size());
2262
solenberg1d63dd02015-12-02 12:35:09 -08002263 EXPECT_TRUE(channel1_->InsertDtmf(1, 3, 100));
2264 EXPECT_TRUE(channel1_->InsertDtmf(2, 5, 110));
2265 EXPECT_TRUE(channel1_->InsertDtmf(3, 7, 120));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002266
henrike@webrtc.org9de257d2013-07-17 14:42:53 +00002267 ASSERT_EQ(3U, media_channel1_->dtmf_info_queue().size());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002268 EXPECT_TRUE(CompareDtmfInfo(media_channel1_->dtmf_info_queue()[0],
solenberg1d63dd02015-12-02 12:35:09 -08002269 1, 3, 100));
henrike@webrtc.org9de257d2013-07-17 14:42:53 +00002270 EXPECT_TRUE(CompareDtmfInfo(media_channel1_->dtmf_info_queue()[1],
solenberg1d63dd02015-12-02 12:35:09 -08002271 2, 5, 110));
henrike@webrtc.org9de257d2013-07-17 14:42:53 +00002272 EXPECT_TRUE(CompareDtmfInfo(media_channel1_->dtmf_info_queue()[2],
solenberg1d63dd02015-12-02 12:35:09 -08002273 3, 7, 120));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002274}
2275
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002276TEST_F(VoiceChannelSingleThreadTest, TestSetContentFailure) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002277 Base::TestSetContentFailure();
2278}
2279
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002280TEST_F(VoiceChannelSingleThreadTest, TestSendTwoOffers) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002281 Base::TestSendTwoOffers();
2282}
2283
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002284TEST_F(VoiceChannelSingleThreadTest, TestReceiveTwoOffers) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002285 Base::TestReceiveTwoOffers();
2286}
2287
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002288TEST_F(VoiceChannelSingleThreadTest, TestSendPrAnswer) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002289 Base::TestSendPrAnswer();
2290}
2291
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002292TEST_F(VoiceChannelSingleThreadTest, TestReceivePrAnswer) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002293 Base::TestReceivePrAnswer();
2294}
2295
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002296TEST_F(VoiceChannelSingleThreadTest, TestFlushRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002297 Base::TestFlushRtcp();
2298}
2299
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002300TEST_F(VoiceChannelSingleThreadTest, TestSrtpError) {
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00002301 Base::TestSrtpError(kAudioPts[0]);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002302}
2303
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002304TEST_F(VoiceChannelSingleThreadTest, TestOnReadyToSend) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002305 Base::TestOnReadyToSend();
2306}
2307
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002308TEST_F(VoiceChannelSingleThreadTest, TestOnReadyToSendWithRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002309 Base::TestOnReadyToSendWithRtcpMux();
2310}
2311
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002312// Test that we can scale the output volume properly for 1:1 calls.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002313TEST_F(VoiceChannelSingleThreadTest, TestScaleVolume1to1Call) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002314 CreateChannels(RTCP, RTCP);
2315 EXPECT_TRUE(SendInitiate());
2316 EXPECT_TRUE(SendAccept());
solenberg4bac9c52015-10-09 02:32:53 -07002317 double volume;
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002318
solenberg4bac9c52015-10-09 02:32:53 -07002319 // Default is (1.0).
2320 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2321 EXPECT_DOUBLE_EQ(1.0, volume);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002322 // invalid ssrc.
solenberg4bac9c52015-10-09 02:32:53 -07002323 EXPECT_FALSE(media_channel1_->GetOutputVolume(3, &volume));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002324
solenberg4bac9c52015-10-09 02:32:53 -07002325 // Set scale to (1.5).
2326 EXPECT_TRUE(channel1_->SetOutputVolume(0, 1.5));
2327 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2328 EXPECT_DOUBLE_EQ(1.5, volume);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002329
solenberg4bac9c52015-10-09 02:32:53 -07002330 // Set scale to (0).
2331 EXPECT_TRUE(channel1_->SetOutputVolume(0, 0.0));
2332 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2333 EXPECT_DOUBLE_EQ(0.0, volume);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002334}
2335
2336// Test that we can scale the output volume properly for multiway calls.
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002337TEST_F(VoiceChannelSingleThreadTest, TestScaleVolumeMultiwayCall) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002338 CreateChannels(RTCP, RTCP);
2339 EXPECT_TRUE(SendInitiate());
2340 EXPECT_TRUE(SendAccept());
2341 EXPECT_TRUE(AddStream1(1));
2342 EXPECT_TRUE(AddStream1(2));
2343
solenberg4bac9c52015-10-09 02:32:53 -07002344 double volume;
2345 // Default is (1.0).
2346 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2347 EXPECT_DOUBLE_EQ(1.0, volume);
2348 EXPECT_TRUE(media_channel1_->GetOutputVolume(1, &volume));
2349 EXPECT_DOUBLE_EQ(1.0, volume);
2350 EXPECT_TRUE(media_channel1_->GetOutputVolume(2, &volume));
2351 EXPECT_DOUBLE_EQ(1.0, volume);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002352 // invalid ssrc.
solenberg4bac9c52015-10-09 02:32:53 -07002353 EXPECT_FALSE(media_channel1_->GetOutputVolume(3, &volume));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002354
solenberg4bac9c52015-10-09 02:32:53 -07002355 // Set scale to (1.5) for ssrc = 1.
2356 EXPECT_TRUE(channel1_->SetOutputVolume(1, 1.5));
2357 EXPECT_TRUE(media_channel1_->GetOutputVolume(1, &volume));
2358 EXPECT_DOUBLE_EQ(1.5, volume);
2359 EXPECT_TRUE(media_channel1_->GetOutputVolume(2, &volume));
2360 EXPECT_DOUBLE_EQ(1.0, volume);
2361 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2362 EXPECT_DOUBLE_EQ(1.0, volume);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002363
solenberg4bac9c52015-10-09 02:32:53 -07002364 // Set scale to (0) for all ssrcs.
2365 EXPECT_TRUE(channel1_->SetOutputVolume(0, 0.0));
2366 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2367 EXPECT_DOUBLE_EQ(0.0, volume);
2368 EXPECT_TRUE(media_channel1_->GetOutputVolume(1, &volume));
2369 EXPECT_DOUBLE_EQ(0.0, volume);
2370 EXPECT_TRUE(media_channel1_->GetOutputVolume(2, &volume));
2371 EXPECT_DOUBLE_EQ(0.0, volume);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002372}
2373
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002374TEST_F(VoiceChannelSingleThreadTest, SendBundleToBundle) {
tfarina5237aaf2015-11-10 23:44:30 -08002375 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, false);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002376}
2377
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002378TEST_F(VoiceChannelSingleThreadTest, SendBundleToBundleSecure) {
tfarina5237aaf2015-11-10 23:44:30 -08002379 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, true);
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00002380}
2381
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002382TEST_F(VoiceChannelSingleThreadTest, SendBundleToBundleWithRtcpMux) {
tfarina5237aaf2015-11-10 23:44:30 -08002383 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, false);
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00002384}
2385
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002386TEST_F(VoiceChannelSingleThreadTest, SendBundleToBundleWithRtcpMuxSecure) {
tfarina5237aaf2015-11-10 23:44:30 -08002387 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, true);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002388}
2389
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002390TEST_F(VoiceChannelSingleThreadTest, DefaultMaxBitrateIsUnlimited) {
skvlade0d46372016-04-07 22:59:22 -07002391 Base::DefaultMaxBitrateIsUnlimited();
skvladdc1c62c2016-03-16 19:07:43 -07002392}
2393
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002394TEST_F(VoiceChannelSingleThreadTest, CanChangeMaxBitrate) {
skvlade0d46372016-04-07 22:59:22 -07002395 Base::CanChangeMaxBitrate();
skvladdc1c62c2016-03-16 19:07:43 -07002396}
2397
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002398// VoiceChannelDoubleThreadTest
2399TEST_F(VoiceChannelDoubleThreadTest, TestInit) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002400 Base::TestInit();
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002401 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
2402 EXPECT_TRUE(media_channel1_->dtmf_info_queue().empty());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002403}
2404
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002405TEST_F(VoiceChannelDoubleThreadTest, TestSetContents) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002406 Base::TestSetContents();
2407}
2408
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002409TEST_F(VoiceChannelDoubleThreadTest, TestSetContentsNullOffer) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002410 Base::TestSetContentsNullOffer();
2411}
2412
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002413TEST_F(VoiceChannelDoubleThreadTest, TestSetContentsRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002414 Base::TestSetContentsRtcpMux();
2415}
2416
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002417TEST_F(VoiceChannelDoubleThreadTest, TestSetContentsRtcpMuxWithPrAnswer) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002418 Base::TestSetContentsRtcpMux();
2419}
2420
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002421TEST_F(VoiceChannelDoubleThreadTest, TestSetRemoteContentUpdate) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002422 Base::TestSetRemoteContentUpdate();
2423}
2424
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002425TEST_F(VoiceChannelDoubleThreadTest, TestStreams) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002426 Base::TestStreams();
2427}
2428
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002429TEST_F(VoiceChannelDoubleThreadTest, TestUpdateStreamsInLocalContent) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002430 Base::TestUpdateStreamsInLocalContent();
2431}
2432
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002433TEST_F(VoiceChannelDoubleThreadTest, TestUpdateRemoteStreamsInContent) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002434 Base::TestUpdateStreamsInRemoteContent();
2435}
2436
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002437TEST_F(VoiceChannelDoubleThreadTest, TestChangeStreamParamsInContent) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002438 Base::TestChangeStreamParamsInContent();
2439}
2440
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002441TEST_F(VoiceChannelDoubleThreadTest, TestPlayoutAndSendingStates) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002442 Base::TestPlayoutAndSendingStates();
2443}
2444
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002445TEST_F(VoiceChannelDoubleThreadTest, TestMuteStream) {
2446 CreateChannels(0, 0);
2447 // Test that we can Mute the default channel even though the sending SSRC
2448 // is unknown.
2449 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
2450 EXPECT_TRUE(channel1_->SetAudioSend(0, false, nullptr, nullptr));
2451 EXPECT_TRUE(media_channel1_->IsStreamMuted(0));
2452 EXPECT_TRUE(channel1_->SetAudioSend(0, true, nullptr, nullptr));
2453 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
2454
2455 // Test that we can not mute an unknown SSRC.
2456 EXPECT_FALSE(channel1_->SetAudioSend(kSsrc1, false, nullptr, nullptr));
2457
2458 SendInitiate();
2459 // After the local session description has been set, we can mute a stream
2460 // with its SSRC.
2461 EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, false, nullptr, nullptr));
2462 EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1));
2463 EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, true, nullptr, nullptr));
2464 EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1));
2465}
2466
2467TEST_F(VoiceChannelDoubleThreadTest, TestMediaContentDirection) {
2468 Base::TestMediaContentDirection();
2469}
2470
2471TEST_F(VoiceChannelDoubleThreadTest, TestNetworkRouteChanges) {
2472 Base::TestNetworkRouteChanges();
2473}
2474
2475TEST_F(VoiceChannelDoubleThreadTest, TestCallSetup) {
2476 Base::TestCallSetup();
2477}
2478
2479TEST_F(VoiceChannelDoubleThreadTest, TestCallTeardownRtcpMux) {
2480 Base::TestCallTeardownRtcpMux();
2481}
2482
2483TEST_F(VoiceChannelDoubleThreadTest, SendRtpToRtp) {
2484 Base::SendRtpToRtp();
2485}
2486
2487TEST_F(VoiceChannelDoubleThreadTest, SendNoRtcpToNoRtcp) {
2488 Base::SendNoRtcpToNoRtcp();
2489}
2490
2491TEST_F(VoiceChannelDoubleThreadTest, SendNoRtcpToRtcp) {
2492 Base::SendNoRtcpToRtcp();
2493}
2494
2495TEST_F(VoiceChannelDoubleThreadTest, SendRtcpToNoRtcp) {
2496 Base::SendRtcpToNoRtcp();
2497}
2498
2499TEST_F(VoiceChannelDoubleThreadTest, SendRtcpToRtcp) {
2500 Base::SendRtcpToRtcp();
2501}
2502
2503TEST_F(VoiceChannelDoubleThreadTest, SendRtcpMuxToRtcp) {
2504 Base::SendRtcpMuxToRtcp();
2505}
2506
2507TEST_F(VoiceChannelDoubleThreadTest, SendRtcpMuxToRtcpMux) {
2508 Base::SendRtcpMuxToRtcpMux();
2509}
2510
2511TEST_F(VoiceChannelDoubleThreadTest, SendRequireRtcpMuxToRtcpMux) {
2512 Base::SendRequireRtcpMuxToRtcpMux();
2513}
2514
2515TEST_F(VoiceChannelDoubleThreadTest, SendRtcpMuxToRequireRtcpMux) {
2516 Base::SendRtcpMuxToRequireRtcpMux();
2517}
2518
2519TEST_F(VoiceChannelDoubleThreadTest, SendRequireRtcpMuxToRequireRtcpMux) {
2520 Base::SendRequireRtcpMuxToRequireRtcpMux();
2521}
2522
2523TEST_F(VoiceChannelDoubleThreadTest, SendRequireRtcpMuxToNoRtcpMux) {
2524 Base::SendRequireRtcpMuxToNoRtcpMux();
2525}
2526
2527TEST_F(VoiceChannelDoubleThreadTest, SendEarlyRtcpMuxToRtcp) {
2528 Base::SendEarlyRtcpMuxToRtcp();
2529}
2530
2531TEST_F(VoiceChannelDoubleThreadTest, SendEarlyRtcpMuxToRtcpMux) {
2532 Base::SendEarlyRtcpMuxToRtcpMux();
2533}
2534
2535TEST_F(VoiceChannelDoubleThreadTest, SendSrtpToSrtpRtcpMux) {
2536 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX);
2537}
2538
2539TEST_F(VoiceChannelDoubleThreadTest, SendSrtpToRtp) {
2540 Base::SendSrtpToSrtp();
2541}
2542
2543TEST_F(VoiceChannelDoubleThreadTest, SendSrtcpMux) {
2544 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX);
2545}
2546
2547TEST_F(VoiceChannelDoubleThreadTest, SendDtlsSrtpToSrtp) {
2548 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2549 Base::SendSrtpToSrtp(DTLS, 0);
2550}
2551
2552TEST_F(VoiceChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtp) {
2553 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2554 Base::SendSrtpToSrtp(DTLS, DTLS);
2555}
2556
2557TEST_F(VoiceChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) {
2558 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2559 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX);
2560}
2561
2562TEST_F(VoiceChannelDoubleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) {
2563 Base::SendEarlyMediaUsingRtcpMuxSrtp();
2564}
2565
2566TEST_F(VoiceChannelDoubleThreadTest, SendRtpToRtpOnThread) {
2567 Base::SendRtpToRtpOnThread();
2568}
2569
2570TEST_F(VoiceChannelDoubleThreadTest, SendSrtpToSrtpOnThread) {
2571 Base::SendSrtpToSrtpOnThread();
2572}
2573
2574TEST_F(VoiceChannelDoubleThreadTest, SendWithWritabilityLoss) {
2575 Base::SendWithWritabilityLoss();
2576}
2577
2578TEST_F(VoiceChannelDoubleThreadTest, TestMediaMonitor) {
2579 Base::TestMediaMonitor();
2580}
2581
2582// Test that InsertDtmf properly forwards to the media channel.
2583TEST_F(VoiceChannelDoubleThreadTest, TestInsertDtmf) {
2584 CreateChannels(0, 0);
2585 EXPECT_TRUE(SendInitiate());
2586 EXPECT_TRUE(SendAccept());
2587 EXPECT_EQ(0U, media_channel1_->dtmf_info_queue().size());
2588
2589 EXPECT_TRUE(channel1_->InsertDtmf(1, 3, 100));
2590 EXPECT_TRUE(channel1_->InsertDtmf(2, 5, 110));
2591 EXPECT_TRUE(channel1_->InsertDtmf(3, 7, 120));
2592
2593 ASSERT_EQ(3U, media_channel1_->dtmf_info_queue().size());
2594 EXPECT_TRUE(
2595 CompareDtmfInfo(media_channel1_->dtmf_info_queue()[0], 1, 3, 100));
2596 EXPECT_TRUE(
2597 CompareDtmfInfo(media_channel1_->dtmf_info_queue()[1], 2, 5, 110));
2598 EXPECT_TRUE(
2599 CompareDtmfInfo(media_channel1_->dtmf_info_queue()[2], 3, 7, 120));
2600}
2601
2602TEST_F(VoiceChannelDoubleThreadTest, TestSetContentFailure) {
2603 Base::TestSetContentFailure();
2604}
2605
2606TEST_F(VoiceChannelDoubleThreadTest, TestSendTwoOffers) {
2607 Base::TestSendTwoOffers();
2608}
2609
2610TEST_F(VoiceChannelDoubleThreadTest, TestReceiveTwoOffers) {
2611 Base::TestReceiveTwoOffers();
2612}
2613
2614TEST_F(VoiceChannelDoubleThreadTest, TestSendPrAnswer) {
2615 Base::TestSendPrAnswer();
2616}
2617
2618TEST_F(VoiceChannelDoubleThreadTest, TestReceivePrAnswer) {
2619 Base::TestReceivePrAnswer();
2620}
2621
2622TEST_F(VoiceChannelDoubleThreadTest, TestFlushRtcp) {
2623 Base::TestFlushRtcp();
2624}
2625
2626TEST_F(VoiceChannelDoubleThreadTest, TestSrtpError) {
2627 Base::TestSrtpError(kAudioPts[0]);
2628}
2629
2630TEST_F(VoiceChannelDoubleThreadTest, TestOnReadyToSend) {
2631 Base::TestOnReadyToSend();
2632}
2633
2634TEST_F(VoiceChannelDoubleThreadTest, TestOnReadyToSendWithRtcpMux) {
2635 Base::TestOnReadyToSendWithRtcpMux();
2636}
2637
2638// Test that we can scale the output volume properly for 1:1 calls.
2639TEST_F(VoiceChannelDoubleThreadTest, TestScaleVolume1to1Call) {
2640 CreateChannels(RTCP, RTCP);
2641 EXPECT_TRUE(SendInitiate());
2642 EXPECT_TRUE(SendAccept());
2643 double volume;
2644
2645 // Default is (1.0).
2646 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2647 EXPECT_DOUBLE_EQ(1.0, volume);
2648 // invalid ssrc.
2649 EXPECT_FALSE(media_channel1_->GetOutputVolume(3, &volume));
2650
2651 // Set scale to (1.5).
2652 EXPECT_TRUE(channel1_->SetOutputVolume(0, 1.5));
2653 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2654 EXPECT_DOUBLE_EQ(1.5, volume);
2655
2656 // Set scale to (0).
2657 EXPECT_TRUE(channel1_->SetOutputVolume(0, 0.0));
2658 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2659 EXPECT_DOUBLE_EQ(0.0, volume);
2660}
2661
2662// Test that we can scale the output volume properly for multiway calls.
2663TEST_F(VoiceChannelDoubleThreadTest, TestScaleVolumeMultiwayCall) {
2664 CreateChannels(RTCP, RTCP);
2665 EXPECT_TRUE(SendInitiate());
2666 EXPECT_TRUE(SendAccept());
2667 EXPECT_TRUE(AddStream1(1));
2668 EXPECT_TRUE(AddStream1(2));
2669
2670 double volume;
2671 // Default is (1.0).
2672 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2673 EXPECT_DOUBLE_EQ(1.0, volume);
2674 EXPECT_TRUE(media_channel1_->GetOutputVolume(1, &volume));
2675 EXPECT_DOUBLE_EQ(1.0, volume);
2676 EXPECT_TRUE(media_channel1_->GetOutputVolume(2, &volume));
2677 EXPECT_DOUBLE_EQ(1.0, volume);
2678 // invalid ssrc.
2679 EXPECT_FALSE(media_channel1_->GetOutputVolume(3, &volume));
2680
2681 // Set scale to (1.5) for ssrc = 1.
2682 EXPECT_TRUE(channel1_->SetOutputVolume(1, 1.5));
2683 EXPECT_TRUE(media_channel1_->GetOutputVolume(1, &volume));
2684 EXPECT_DOUBLE_EQ(1.5, volume);
2685 EXPECT_TRUE(media_channel1_->GetOutputVolume(2, &volume));
2686 EXPECT_DOUBLE_EQ(1.0, volume);
2687 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2688 EXPECT_DOUBLE_EQ(1.0, volume);
2689
2690 // Set scale to (0) for all ssrcs.
2691 EXPECT_TRUE(channel1_->SetOutputVolume(0, 0.0));
2692 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2693 EXPECT_DOUBLE_EQ(0.0, volume);
2694 EXPECT_TRUE(media_channel1_->GetOutputVolume(1, &volume));
2695 EXPECT_DOUBLE_EQ(0.0, volume);
2696 EXPECT_TRUE(media_channel1_->GetOutputVolume(2, &volume));
2697 EXPECT_DOUBLE_EQ(0.0, volume);
2698}
2699
2700TEST_F(VoiceChannelDoubleThreadTest, SendBundleToBundle) {
2701 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, false);
2702}
2703
2704TEST_F(VoiceChannelDoubleThreadTest, SendBundleToBundleSecure) {
2705 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, true);
2706}
2707
2708TEST_F(VoiceChannelDoubleThreadTest, SendBundleToBundleWithRtcpMux) {
2709 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, false);
2710}
2711
2712TEST_F(VoiceChannelDoubleThreadTest, SendBundleToBundleWithRtcpMuxSecure) {
2713 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, true);
2714}
2715
2716TEST_F(VoiceChannelDoubleThreadTest, DefaultMaxBitrateIsUnlimited) {
2717 Base::DefaultMaxBitrateIsUnlimited();
2718}
2719
2720TEST_F(VoiceChannelDoubleThreadTest, CanChangeMaxBitrate) {
2721 Base::CanChangeMaxBitrate();
2722}
2723
2724// VideoChannelSingleThreadTest
2725TEST_F(VideoChannelSingleThreadTest, TestInit) {
2726 Base::TestInit();
2727}
2728
2729TEST_F(VideoChannelSingleThreadTest, TestSetContents) {
2730 Base::TestSetContents();
2731}
2732
2733TEST_F(VideoChannelSingleThreadTest, TestSetContentsNullOffer) {
2734 Base::TestSetContentsNullOffer();
2735}
2736
2737TEST_F(VideoChannelSingleThreadTest, TestSetContentsRtcpMux) {
2738 Base::TestSetContentsRtcpMux();
2739}
2740
2741TEST_F(VideoChannelSingleThreadTest, TestSetContentsRtcpMuxWithPrAnswer) {
2742 Base::TestSetContentsRtcpMux();
2743}
2744
2745TEST_F(VideoChannelSingleThreadTest, TestSetRemoteContentUpdate) {
2746 Base::TestSetRemoteContentUpdate();
2747}
2748
2749TEST_F(VideoChannelSingleThreadTest, TestStreams) {
2750 Base::TestStreams();
2751}
2752
2753TEST_F(VideoChannelSingleThreadTest, TestUpdateStreamsInLocalContent) {
2754 Base::TestUpdateStreamsInLocalContent();
2755}
2756
2757TEST_F(VideoChannelSingleThreadTest, TestUpdateRemoteStreamsInContent) {
2758 Base::TestUpdateStreamsInRemoteContent();
2759}
2760
2761TEST_F(VideoChannelSingleThreadTest, TestChangeStreamParamsInContent) {
2762 Base::TestChangeStreamParamsInContent();
2763}
2764
2765TEST_F(VideoChannelSingleThreadTest, TestPlayoutAndSendingStates) {
2766 Base::TestPlayoutAndSendingStates();
2767}
2768
2769TEST_F(VideoChannelSingleThreadTest, TestMuteStream) {
solenberg1dd98f32015-09-10 01:57:14 -07002770 CreateChannels(0, 0);
2771 // Test that we can Mute the default channel even though the sending SSRC
2772 // is unknown.
2773 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
solenberg1dd98f32015-09-10 01:57:14 -07002774 EXPECT_TRUE(channel1_->SetVideoSend(0, false, nullptr));
solenbergdfc8f4f2015-10-01 02:31:10 -07002775 EXPECT_TRUE(media_channel1_->IsStreamMuted(0));
2776 EXPECT_TRUE(channel1_->SetVideoSend(0, true, nullptr));
solenberg1dd98f32015-09-10 01:57:14 -07002777 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
2778 // Test that we can not mute an unknown SSRC.
solenbergdfc8f4f2015-10-01 02:31:10 -07002779 EXPECT_FALSE(channel1_->SetVideoSend(kSsrc1, false, nullptr));
solenberg1dd98f32015-09-10 01:57:14 -07002780 SendInitiate();
2781 // After the local session description has been set, we can mute a stream
2782 // with its SSRC.
solenberg1dd98f32015-09-10 01:57:14 -07002783 EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, false, nullptr));
solenbergdfc8f4f2015-10-01 02:31:10 -07002784 EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1));
2785 EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, true, nullptr));
solenberg1dd98f32015-09-10 01:57:14 -07002786 EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002787}
2788
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002789TEST_F(VideoChannelSingleThreadTest, TestMediaContentDirection) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002790 Base::TestMediaContentDirection();
2791}
2792
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002793TEST_F(VideoChannelSingleThreadTest, TestNetworkRouteChanges) {
Honghai Zhangcc411c02016-03-29 17:27:21 -07002794 Base::TestNetworkRouteChanges();
2795}
2796
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002797TEST_F(VideoChannelSingleThreadTest, TestCallSetup) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002798 Base::TestCallSetup();
2799}
2800
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002801TEST_F(VideoChannelSingleThreadTest, TestCallTeardownRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002802 Base::TestCallTeardownRtcpMux();
2803}
2804
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002805TEST_F(VideoChannelSingleThreadTest, SendRtpToRtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002806 Base::SendRtpToRtp();
2807}
2808
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002809TEST_F(VideoChannelSingleThreadTest, SendNoRtcpToNoRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002810 Base::SendNoRtcpToNoRtcp();
2811}
2812
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002813TEST_F(VideoChannelSingleThreadTest, SendNoRtcpToRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002814 Base::SendNoRtcpToRtcp();
2815}
2816
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002817TEST_F(VideoChannelSingleThreadTest, SendRtcpToNoRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002818 Base::SendRtcpToNoRtcp();
2819}
2820
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002821TEST_F(VideoChannelSingleThreadTest, SendRtcpToRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002822 Base::SendRtcpToRtcp();
2823}
2824
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002825TEST_F(VideoChannelSingleThreadTest, SendRtcpMuxToRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002826 Base::SendRtcpMuxToRtcp();
2827}
2828
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002829TEST_F(VideoChannelSingleThreadTest, SendRtcpMuxToRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002830 Base::SendRtcpMuxToRtcpMux();
2831}
2832
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002833TEST_F(VideoChannelSingleThreadTest, SendRequireRtcpMuxToRtcpMux) {
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07002834 Base::SendRequireRtcpMuxToRtcpMux();
2835}
2836
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002837TEST_F(VideoChannelSingleThreadTest, SendRtcpMuxToRequireRtcpMux) {
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07002838 Base::SendRtcpMuxToRequireRtcpMux();
2839}
2840
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002841TEST_F(VideoChannelSingleThreadTest, SendRequireRtcpMuxToRequireRtcpMux) {
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07002842 Base::SendRequireRtcpMuxToRequireRtcpMux();
2843}
2844
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002845TEST_F(VideoChannelSingleThreadTest, SendRequireRtcpMuxToNoRtcpMux) {
Peter Thatcheraf55ccc2015-05-21 07:48:41 -07002846 Base::SendRequireRtcpMuxToNoRtcpMux();
2847}
2848
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002849TEST_F(VideoChannelSingleThreadTest, SendEarlyRtcpMuxToRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002850 Base::SendEarlyRtcpMuxToRtcp();
2851}
2852
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002853TEST_F(VideoChannelSingleThreadTest, SendEarlyRtcpMuxToRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002854 Base::SendEarlyRtcpMuxToRtcpMux();
2855}
2856
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002857TEST_F(VideoChannelSingleThreadTest, SendSrtpToSrtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002858 Base::SendSrtpToSrtp();
2859}
2860
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002861TEST_F(VideoChannelSingleThreadTest, SendSrtpToRtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002862 Base::SendSrtpToSrtp();
2863}
2864
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002865TEST_F(VideoChannelSingleThreadTest, SendDtlsSrtpToSrtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002866 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2867 Base::SendSrtpToSrtp(DTLS, 0);
2868}
2869
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002870TEST_F(VideoChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002871 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2872 Base::SendSrtpToSrtp(DTLS, DTLS);
2873}
2874
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002875TEST_F(VideoChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002876 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2877 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX);
2878}
2879
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002880TEST_F(VideoChannelSingleThreadTest, SendSrtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002881 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX);
2882}
2883
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002884TEST_F(VideoChannelSingleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002885 Base::SendEarlyMediaUsingRtcpMuxSrtp();
2886}
2887
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002888TEST_F(VideoChannelSingleThreadTest, SendRtpToRtpOnThread) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002889 Base::SendRtpToRtpOnThread();
2890}
2891
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002892TEST_F(VideoChannelSingleThreadTest, SendSrtpToSrtpOnThread) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002893 Base::SendSrtpToSrtpOnThread();
2894}
2895
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002896TEST_F(VideoChannelSingleThreadTest, SendWithWritabilityLoss) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002897 Base::SendWithWritabilityLoss();
2898}
2899
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002900TEST_F(VideoChannelSingleThreadTest, TestMediaMonitor) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002901 Base::TestMediaMonitor();
2902}
2903
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002904TEST_F(VideoChannelSingleThreadTest, TestSetContentFailure) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002905 Base::TestSetContentFailure();
2906}
2907
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002908TEST_F(VideoChannelSingleThreadTest, TestSendTwoOffers) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002909 Base::TestSendTwoOffers();
2910}
2911
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002912TEST_F(VideoChannelSingleThreadTest, TestReceiveTwoOffers) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002913 Base::TestReceiveTwoOffers();
2914}
2915
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002916TEST_F(VideoChannelSingleThreadTest, TestSendPrAnswer) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002917 Base::TestSendPrAnswer();
2918}
2919
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002920TEST_F(VideoChannelSingleThreadTest, TestReceivePrAnswer) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002921 Base::TestReceivePrAnswer();
2922}
2923
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002924TEST_F(VideoChannelSingleThreadTest, TestFlushRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002925 Base::TestFlushRtcp();
2926}
2927
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002928TEST_F(VideoChannelSingleThreadTest, SendBundleToBundle) {
tfarina5237aaf2015-11-10 23:44:30 -08002929 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, false);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002930}
2931
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002932TEST_F(VideoChannelSingleThreadTest, SendBundleToBundleSecure) {
tfarina5237aaf2015-11-10 23:44:30 -08002933 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, true);
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00002934}
2935
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002936TEST_F(VideoChannelSingleThreadTest, SendBundleToBundleWithRtcpMux) {
tfarina5237aaf2015-11-10 23:44:30 -08002937 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, false);
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00002938}
2939
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002940TEST_F(VideoChannelSingleThreadTest, SendBundleToBundleWithRtcpMuxSecure) {
tfarina5237aaf2015-11-10 23:44:30 -08002941 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, true);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002942}
2943
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002944TEST_F(VideoChannelSingleThreadTest, TestSrtpError) {
buildbot@webrtc.org5ee0f052014-05-05 20:18:08 +00002945 Base::TestSrtpError(kVideoPts[0]);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002946}
2947
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002948TEST_F(VideoChannelSingleThreadTest, TestOnReadyToSend) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002949 Base::TestOnReadyToSend();
2950}
2951
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002952TEST_F(VideoChannelSingleThreadTest, TestOnReadyToSendWithRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002953 Base::TestOnReadyToSendWithRtcpMux();
2954}
2955
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002956TEST_F(VideoChannelSingleThreadTest, DefaultMaxBitrateIsUnlimited) {
skvladdc1c62c2016-03-16 19:07:43 -07002957 Base::DefaultMaxBitrateIsUnlimited();
2958}
2959
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002960TEST_F(VideoChannelSingleThreadTest, CanChangeMaxBitrate) {
skvladdc1c62c2016-03-16 19:07:43 -07002961 Base::CanChangeMaxBitrate();
2962}
2963
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002964// VideoChannelDoubleThreadTest
2965TEST_F(VideoChannelDoubleThreadTest, TestInit) {
2966 Base::TestInit();
2967}
henrike@webrtc.org28e20752013-07-10 00:45:36 +00002968
Danil Chapovalov33b01f22016-05-11 19:55:27 +02002969TEST_F(VideoChannelDoubleThreadTest, TestSetContents) {
2970 Base::TestSetContents();
2971}
2972
2973TEST_F(VideoChannelDoubleThreadTest, TestSetContentsNullOffer) {
2974 Base::TestSetContentsNullOffer();
2975}
2976
2977TEST_F(VideoChannelDoubleThreadTest, TestSetContentsRtcpMux) {
2978 Base::TestSetContentsRtcpMux();
2979}
2980
2981TEST_F(VideoChannelDoubleThreadTest, TestSetContentsRtcpMuxWithPrAnswer) {
2982 Base::TestSetContentsRtcpMux();
2983}
2984
2985TEST_F(VideoChannelDoubleThreadTest, TestSetRemoteContentUpdate) {
2986 Base::TestSetRemoteContentUpdate();
2987}
2988
2989TEST_F(VideoChannelDoubleThreadTest, TestStreams) {
2990 Base::TestStreams();
2991}
2992
2993TEST_F(VideoChannelDoubleThreadTest, TestUpdateStreamsInLocalContent) {
2994 Base::TestUpdateStreamsInLocalContent();
2995}
2996
2997TEST_F(VideoChannelDoubleThreadTest, TestUpdateRemoteStreamsInContent) {
2998 Base::TestUpdateStreamsInRemoteContent();
2999}
3000
3001TEST_F(VideoChannelDoubleThreadTest, TestChangeStreamParamsInContent) {
3002 Base::TestChangeStreamParamsInContent();
3003}
3004
3005TEST_F(VideoChannelDoubleThreadTest, TestPlayoutAndSendingStates) {
3006 Base::TestPlayoutAndSendingStates();
3007}
3008
3009TEST_F(VideoChannelDoubleThreadTest, TestMuteStream) {
3010 CreateChannels(0, 0);
3011 // Test that we can Mute the default channel even though the sending SSRC
3012 // is unknown.
3013 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
3014 EXPECT_TRUE(channel1_->SetVideoSend(0, false, nullptr));
3015 EXPECT_TRUE(media_channel1_->IsStreamMuted(0));
3016 EXPECT_TRUE(channel1_->SetVideoSend(0, true, nullptr));
3017 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
3018 // Test that we can not mute an unknown SSRC.
3019 EXPECT_FALSE(channel1_->SetVideoSend(kSsrc1, false, nullptr));
3020 SendInitiate();
3021 // After the local session description has been set, we can mute a stream
3022 // with its SSRC.
3023 EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, false, nullptr));
3024 EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1));
3025 EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, true, nullptr));
3026 EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1));
3027}
3028
3029TEST_F(VideoChannelDoubleThreadTest, TestMediaContentDirection) {
3030 Base::TestMediaContentDirection();
3031}
3032
3033TEST_F(VideoChannelDoubleThreadTest, TestNetworkRouteChanges) {
3034 Base::TestNetworkRouteChanges();
3035}
3036
3037TEST_F(VideoChannelDoubleThreadTest, TestCallSetup) {
3038 Base::TestCallSetup();
3039}
3040
3041TEST_F(VideoChannelDoubleThreadTest, TestCallTeardownRtcpMux) {
3042 Base::TestCallTeardownRtcpMux();
3043}
3044
3045TEST_F(VideoChannelDoubleThreadTest, SendRtpToRtp) {
3046 Base::SendRtpToRtp();
3047}
3048
3049TEST_F(VideoChannelDoubleThreadTest, SendNoRtcpToNoRtcp) {
3050 Base::SendNoRtcpToNoRtcp();
3051}
3052
3053TEST_F(VideoChannelDoubleThreadTest, SendNoRtcpToRtcp) {
3054 Base::SendNoRtcpToRtcp();
3055}
3056
3057TEST_F(VideoChannelDoubleThreadTest, SendRtcpToNoRtcp) {
3058 Base::SendRtcpToNoRtcp();
3059}
3060
3061TEST_F(VideoChannelDoubleThreadTest, SendRtcpToRtcp) {
3062 Base::SendRtcpToRtcp();
3063}
3064
3065TEST_F(VideoChannelDoubleThreadTest, SendRtcpMuxToRtcp) {
3066 Base::SendRtcpMuxToRtcp();
3067}
3068
3069TEST_F(VideoChannelDoubleThreadTest, SendRtcpMuxToRtcpMux) {
3070 Base::SendRtcpMuxToRtcpMux();
3071}
3072
3073TEST_F(VideoChannelDoubleThreadTest, SendRequireRtcpMuxToRtcpMux) {
3074 Base::SendRequireRtcpMuxToRtcpMux();
3075}
3076
3077TEST_F(VideoChannelDoubleThreadTest, SendRtcpMuxToRequireRtcpMux) {
3078 Base::SendRtcpMuxToRequireRtcpMux();
3079}
3080
3081TEST_F(VideoChannelDoubleThreadTest, SendRequireRtcpMuxToRequireRtcpMux) {
3082 Base::SendRequireRtcpMuxToRequireRtcpMux();
3083}
3084
3085TEST_F(VideoChannelDoubleThreadTest, SendRequireRtcpMuxToNoRtcpMux) {
3086 Base::SendRequireRtcpMuxToNoRtcpMux();
3087}
3088
3089TEST_F(VideoChannelDoubleThreadTest, SendEarlyRtcpMuxToRtcp) {
3090 Base::SendEarlyRtcpMuxToRtcp();
3091}
3092
3093TEST_F(VideoChannelDoubleThreadTest, SendEarlyRtcpMuxToRtcpMux) {
3094 Base::SendEarlyRtcpMuxToRtcpMux();
3095}
3096
3097TEST_F(VideoChannelDoubleThreadTest, SendSrtpToSrtp) {
3098 Base::SendSrtpToSrtp();
3099}
3100
3101TEST_F(VideoChannelDoubleThreadTest, SendSrtpToRtp) {
3102 Base::SendSrtpToSrtp();
3103}
3104
3105TEST_F(VideoChannelDoubleThreadTest, SendDtlsSrtpToSrtp) {
3106 MAYBE_SKIP_TEST(HaveDtlsSrtp);
3107 Base::SendSrtpToSrtp(DTLS, 0);
3108}
3109
3110TEST_F(VideoChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtp) {
3111 MAYBE_SKIP_TEST(HaveDtlsSrtp);
3112 Base::SendSrtpToSrtp(DTLS, DTLS);
3113}
3114
3115TEST_F(VideoChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) {
3116 MAYBE_SKIP_TEST(HaveDtlsSrtp);
3117 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX);
3118}
3119
3120TEST_F(VideoChannelDoubleThreadTest, SendSrtcpMux) {
3121 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX);
3122}
3123
3124TEST_F(VideoChannelDoubleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) {
3125 Base::SendEarlyMediaUsingRtcpMuxSrtp();
3126}
3127
3128TEST_F(VideoChannelDoubleThreadTest, SendRtpToRtpOnThread) {
3129 Base::SendRtpToRtpOnThread();
3130}
3131
3132TEST_F(VideoChannelDoubleThreadTest, SendSrtpToSrtpOnThread) {
3133 Base::SendSrtpToSrtpOnThread();
3134}
3135
3136TEST_F(VideoChannelDoubleThreadTest, SendWithWritabilityLoss) {
3137 Base::SendWithWritabilityLoss();
3138}
3139
3140TEST_F(VideoChannelDoubleThreadTest, TestMediaMonitor) {
3141 Base::TestMediaMonitor();
3142}
3143
3144TEST_F(VideoChannelDoubleThreadTest, TestSetContentFailure) {
3145 Base::TestSetContentFailure();
3146}
3147
3148TEST_F(VideoChannelDoubleThreadTest, TestSendTwoOffers) {
3149 Base::TestSendTwoOffers();
3150}
3151
3152TEST_F(VideoChannelDoubleThreadTest, TestReceiveTwoOffers) {
3153 Base::TestReceiveTwoOffers();
3154}
3155
3156TEST_F(VideoChannelDoubleThreadTest, TestSendPrAnswer) {
3157 Base::TestSendPrAnswer();
3158}
3159
3160TEST_F(VideoChannelDoubleThreadTest, TestReceivePrAnswer) {
3161 Base::TestReceivePrAnswer();
3162}
3163
3164TEST_F(VideoChannelDoubleThreadTest, TestFlushRtcp) {
3165 Base::TestFlushRtcp();
3166}
3167
3168TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundle) {
3169 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, false);
3170}
3171
3172TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundleSecure) {
3173 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, true);
3174}
3175
3176TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundleWithRtcpMux) {
3177 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, false);
3178}
3179
3180TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundleWithRtcpMuxSecure) {
3181 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, true);
3182}
3183
3184TEST_F(VideoChannelDoubleThreadTest, TestSrtpError) {
3185 Base::TestSrtpError(kVideoPts[0]);
3186}
3187
3188TEST_F(VideoChannelDoubleThreadTest, TestOnReadyToSend) {
3189 Base::TestOnReadyToSend();
3190}
3191
3192TEST_F(VideoChannelDoubleThreadTest, TestOnReadyToSendWithRtcpMux) {
3193 Base::TestOnReadyToSendWithRtcpMux();
3194}
3195
3196TEST_F(VideoChannelDoubleThreadTest, DefaultMaxBitrateIsUnlimited) {
3197 Base::DefaultMaxBitrateIsUnlimited();
3198}
3199
3200TEST_F(VideoChannelDoubleThreadTest, CanChangeMaxBitrate) {
3201 Base::CanChangeMaxBitrate();
3202}
3203
3204// DataChannelSingleThreadTest
3205class DataChannelSingleThreadTest : public ChannelTest<DataTraits> {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003206 public:
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003207 typedef ChannelTest<DataTraits> Base;
3208 DataChannelSingleThreadTest()
3209 : Base(true, kDataPacket, kRtcpReport, NetworkIsWorker::Yes) {}
3210};
3211
3212// DataChannelDoubleThreadTest
3213class DataChannelDoubleThreadTest : public ChannelTest<DataTraits> {
3214 public:
3215 typedef ChannelTest<DataTraits> Base;
3216 DataChannelDoubleThreadTest()
3217 : Base(true, kDataPacket, kRtcpReport, NetworkIsWorker::No) {}
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003218};
3219
3220// Override to avoid engine channel parameter.
deadbeefcbecd352015-09-23 11:50:27 -07003221template <>
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003222cricket::DataChannel* ChannelTest<DataTraits>::CreateChannel(
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003223 rtc::Thread* worker_thread,
3224 rtc::Thread* network_thread,
deadbeefcbecd352015-09-23 11:50:27 -07003225 cricket::MediaEngineInterface* engine,
3226 cricket::FakeDataMediaChannel* ch,
3227 cricket::TransportController* transport_controller,
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003228 bool rtcp) {
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003229 cricket::DataChannel* channel =
3230 new cricket::DataChannel(worker_thread, network_thread, ch,
3231 transport_controller, cricket::CN_DATA, rtcp);
3232 if (!channel->Init_w()) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003233 delete channel;
3234 channel = NULL;
3235 }
3236 return channel;
3237}
3238
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003239template <>
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003240void ChannelTest<DataTraits>::CreateContent(
3241 int flags,
3242 const cricket::AudioCodec& audio_codec,
3243 const cricket::VideoCodec& video_codec,
3244 cricket::DataContentDescription* data) {
3245 data->AddCodec(kGoogleDataCodec);
3246 data->set_rtcp_mux((flags & RTCP_MUX) != 0);
3247 if (flags & SECURE) {
3248 data->AddCrypto(cricket::CryptoParams(
Guo-wei Shieh456696a2015-09-30 21:48:54 -07003249 1, rtc::CS_AES_CM_128_HMAC_SHA1_32,
3250 "inline:" + rtc::CreateRandomString(40), std::string()));
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003251 }
3252}
3253
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003254template <>
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003255void ChannelTest<DataTraits>::CopyContent(
3256 const cricket::DataContentDescription& source,
3257 cricket::DataContentDescription* data) {
3258 *data = source;
3259}
3260
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003261template <>
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003262bool ChannelTest<DataTraits>::CodecMatches(const cricket::DataCodec& c1,
3263 const cricket::DataCodec& c2) {
3264 return c1.name == c2.name;
3265}
3266
Peter Boström0c4e06b2015-10-07 12:23:21 +02003267template <>
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003268void ChannelTest<DataTraits>::AddLegacyStreamInContent(
Peter Boström0c4e06b2015-10-07 12:23:21 +02003269 uint32_t ssrc,
3270 int flags,
3271 cricket::DataContentDescription* data) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003272 data->AddLegacyStream(ssrc);
3273}
3274
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003275TEST_F(DataChannelSingleThreadTest, TestInit) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003276 Base::TestInit();
3277 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
3278}
3279
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003280TEST_F(DataChannelSingleThreadTest, TestSetContents) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003281 Base::TestSetContents();
3282}
3283
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003284TEST_F(DataChannelSingleThreadTest, TestSetContentsNullOffer) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003285 Base::TestSetContentsNullOffer();
3286}
3287
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003288TEST_F(DataChannelSingleThreadTest, TestSetContentsRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003289 Base::TestSetContentsRtcpMux();
3290}
3291
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003292TEST_F(DataChannelSingleThreadTest, TestSetRemoteContentUpdate) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003293 Base::TestSetRemoteContentUpdate();
3294}
3295
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003296TEST_F(DataChannelSingleThreadTest, TestStreams) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003297 Base::TestStreams();
3298}
3299
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003300TEST_F(DataChannelSingleThreadTest, TestUpdateStreamsInLocalContent) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003301 Base::TestUpdateStreamsInLocalContent();
3302}
3303
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003304TEST_F(DataChannelSingleThreadTest, TestUpdateRemoteStreamsInContent) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003305 Base::TestUpdateStreamsInRemoteContent();
3306}
3307
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003308TEST_F(DataChannelSingleThreadTest, TestChangeStreamParamsInContent) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003309 Base::TestChangeStreamParamsInContent();
3310}
3311
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003312TEST_F(DataChannelSingleThreadTest, TestPlayoutAndSendingStates) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003313 Base::TestPlayoutAndSendingStates();
3314}
3315
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003316TEST_F(DataChannelSingleThreadTest, TestMediaContentDirection) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003317 Base::TestMediaContentDirection();
3318}
3319
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003320TEST_F(DataChannelSingleThreadTest, TestCallSetup) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003321 Base::TestCallSetup();
3322}
3323
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003324TEST_F(DataChannelSingleThreadTest, TestCallTeardownRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003325 Base::TestCallTeardownRtcpMux();
3326}
3327
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003328TEST_F(DataChannelSingleThreadTest, TestOnReadyToSend) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003329 Base::TestOnReadyToSend();
3330}
3331
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003332TEST_F(DataChannelSingleThreadTest, TestOnReadyToSendWithRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003333 Base::TestOnReadyToSendWithRtcpMux();
3334}
3335
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003336TEST_F(DataChannelSingleThreadTest, SendRtpToRtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003337 Base::SendRtpToRtp();
3338}
3339
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003340TEST_F(DataChannelSingleThreadTest, SendNoRtcpToNoRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003341 Base::SendNoRtcpToNoRtcp();
3342}
3343
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003344TEST_F(DataChannelSingleThreadTest, SendNoRtcpToRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003345 Base::SendNoRtcpToRtcp();
3346}
3347
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003348TEST_F(DataChannelSingleThreadTest, SendRtcpToNoRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003349 Base::SendRtcpToNoRtcp();
3350}
3351
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003352TEST_F(DataChannelSingleThreadTest, SendRtcpToRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003353 Base::SendRtcpToRtcp();
3354}
3355
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003356TEST_F(DataChannelSingleThreadTest, SendRtcpMuxToRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003357 Base::SendRtcpMuxToRtcp();
3358}
3359
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003360TEST_F(DataChannelSingleThreadTest, SendRtcpMuxToRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003361 Base::SendRtcpMuxToRtcpMux();
3362}
3363
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003364TEST_F(DataChannelSingleThreadTest, SendEarlyRtcpMuxToRtcp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003365 Base::SendEarlyRtcpMuxToRtcp();
3366}
3367
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003368TEST_F(DataChannelSingleThreadTest, SendEarlyRtcpMuxToRtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003369 Base::SendEarlyRtcpMuxToRtcpMux();
3370}
3371
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003372TEST_F(DataChannelSingleThreadTest, SendSrtpToSrtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003373 Base::SendSrtpToSrtp();
3374}
3375
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003376TEST_F(DataChannelSingleThreadTest, SendSrtpToRtp) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003377 Base::SendSrtpToSrtp();
3378}
3379
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003380TEST_F(DataChannelSingleThreadTest, SendSrtcpMux) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003381 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX);
3382}
3383
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003384TEST_F(DataChannelSingleThreadTest, SendRtpToRtpOnThread) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003385 Base::SendRtpToRtpOnThread();
3386}
3387
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003388TEST_F(DataChannelSingleThreadTest, SendSrtpToSrtpOnThread) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003389 Base::SendSrtpToSrtpOnThread();
3390}
3391
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003392TEST_F(DataChannelSingleThreadTest, SendWithWritabilityLoss) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003393 Base::SendWithWritabilityLoss();
3394}
3395
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003396TEST_F(DataChannelSingleThreadTest, TestMediaMonitor) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003397 Base::TestMediaMonitor();
3398}
3399
Danil Chapovalov33b01f22016-05-11 19:55:27 +02003400TEST_F(DataChannelSingleThreadTest, TestSendData) {
3401 CreateChannels(0, 0);
3402 EXPECT_TRUE(SendInitiate());
3403 EXPECT_TRUE(SendAccept());
3404
3405 cricket::SendDataParams params;
3406 params.ssrc = 42;
3407 unsigned char data[] = {'f', 'o', 'o'};
3408 rtc::CopyOnWriteBuffer payload(data, 3);
3409 cricket::SendDataResult result;
3410 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result));
3411 EXPECT_EQ(params.ssrc, media_channel1_->last_sent_data_params().ssrc);
3412 EXPECT_EQ("foo", media_channel1_->last_sent_data());
3413}
3414
3415TEST_F(DataChannelDoubleThreadTest, TestInit) {
3416 Base::TestInit();
3417 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
3418}
3419
3420TEST_F(DataChannelDoubleThreadTest, TestSetContents) {
3421 Base::TestSetContents();
3422}
3423
3424TEST_F(DataChannelDoubleThreadTest, TestSetContentsNullOffer) {
3425 Base::TestSetContentsNullOffer();
3426}
3427
3428TEST_F(DataChannelDoubleThreadTest, TestSetContentsRtcpMux) {
3429 Base::TestSetContentsRtcpMux();
3430}
3431
3432TEST_F(DataChannelDoubleThreadTest, TestSetRemoteContentUpdate) {
3433 Base::TestSetRemoteContentUpdate();
3434}
3435
3436TEST_F(DataChannelDoubleThreadTest, TestStreams) {
3437 Base::TestStreams();
3438}
3439
3440TEST_F(DataChannelDoubleThreadTest, TestUpdateStreamsInLocalContent) {
3441 Base::TestUpdateStreamsInLocalContent();
3442}
3443
3444TEST_F(DataChannelDoubleThreadTest, TestUpdateRemoteStreamsInContent) {
3445 Base::TestUpdateStreamsInRemoteContent();
3446}
3447
3448TEST_F(DataChannelDoubleThreadTest, TestChangeStreamParamsInContent) {
3449 Base::TestChangeStreamParamsInContent();
3450}
3451
3452TEST_F(DataChannelDoubleThreadTest, TestPlayoutAndSendingStates) {
3453 Base::TestPlayoutAndSendingStates();
3454}
3455
3456TEST_F(DataChannelDoubleThreadTest, TestMediaContentDirection) {
3457 Base::TestMediaContentDirection();
3458}
3459
3460TEST_F(DataChannelDoubleThreadTest, TestCallSetup) {
3461 Base::TestCallSetup();
3462}
3463
3464TEST_F(DataChannelDoubleThreadTest, TestCallTeardownRtcpMux) {
3465 Base::TestCallTeardownRtcpMux();
3466}
3467
3468TEST_F(DataChannelDoubleThreadTest, TestOnReadyToSend) {
3469 Base::TestOnReadyToSend();
3470}
3471
3472TEST_F(DataChannelDoubleThreadTest, TestOnReadyToSendWithRtcpMux) {
3473 Base::TestOnReadyToSendWithRtcpMux();
3474}
3475
3476TEST_F(DataChannelDoubleThreadTest, SendRtpToRtp) {
3477 Base::SendRtpToRtp();
3478}
3479
3480TEST_F(DataChannelDoubleThreadTest, SendNoRtcpToNoRtcp) {
3481 Base::SendNoRtcpToNoRtcp();
3482}
3483
3484TEST_F(DataChannelDoubleThreadTest, SendNoRtcpToRtcp) {
3485 Base::SendNoRtcpToRtcp();
3486}
3487
3488TEST_F(DataChannelDoubleThreadTest, SendRtcpToNoRtcp) {
3489 Base::SendRtcpToNoRtcp();
3490}
3491
3492TEST_F(DataChannelDoubleThreadTest, SendRtcpToRtcp) {
3493 Base::SendRtcpToRtcp();
3494}
3495
3496TEST_F(DataChannelDoubleThreadTest, SendRtcpMuxToRtcp) {
3497 Base::SendRtcpMuxToRtcp();
3498}
3499
3500TEST_F(DataChannelDoubleThreadTest, SendRtcpMuxToRtcpMux) {
3501 Base::SendRtcpMuxToRtcpMux();
3502}
3503
3504TEST_F(DataChannelDoubleThreadTest, SendEarlyRtcpMuxToRtcp) {
3505 Base::SendEarlyRtcpMuxToRtcp();
3506}
3507
3508TEST_F(DataChannelDoubleThreadTest, SendEarlyRtcpMuxToRtcpMux) {
3509 Base::SendEarlyRtcpMuxToRtcpMux();
3510}
3511
3512TEST_F(DataChannelDoubleThreadTest, SendSrtpToSrtp) {
3513 Base::SendSrtpToSrtp();
3514}
3515
3516TEST_F(DataChannelDoubleThreadTest, SendSrtpToRtp) {
3517 Base::SendSrtpToSrtp();
3518}
3519
3520TEST_F(DataChannelDoubleThreadTest, SendSrtcpMux) {
3521 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX);
3522}
3523
3524TEST_F(DataChannelDoubleThreadTest, SendRtpToRtpOnThread) {
3525 Base::SendRtpToRtpOnThread();
3526}
3527
3528TEST_F(DataChannelDoubleThreadTest, SendSrtpToSrtpOnThread) {
3529 Base::SendSrtpToSrtpOnThread();
3530}
3531
3532TEST_F(DataChannelDoubleThreadTest, SendWithWritabilityLoss) {
3533 Base::SendWithWritabilityLoss();
3534}
3535
3536TEST_F(DataChannelDoubleThreadTest, TestMediaMonitor) {
3537 Base::TestMediaMonitor();
3538}
3539
3540TEST_F(DataChannelDoubleThreadTest, TestSendData) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003541 CreateChannels(0, 0);
3542 EXPECT_TRUE(SendInitiate());
3543 EXPECT_TRUE(SendAccept());
3544
3545 cricket::SendDataParams params;
3546 params.ssrc = 42;
3547 unsigned char data[] = {
3548 'f', 'o', 'o'
3549 };
jbaucheec21bd2016-03-20 06:15:43 -07003550 rtc::CopyOnWriteBuffer payload(data, 3);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003551 cricket::SendDataResult result;
3552 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result));
3553 EXPECT_EQ(params.ssrc,
3554 media_channel1_->last_sent_data_params().ssrc);
3555 EXPECT_EQ("foo", media_channel1_->last_sent_data());
3556}
3557
3558// TODO(pthatcher): TestSetReceiver?