1 /*
2 * Copyright 2009 The WebRTC project authors. All Rights Reserved.
3 *
4 * 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.
9 */
10
11 #include "pc/channel.h"
12
13 #include <stddef.h>
14
15 #include <cstdint>
16 #include <string>
17 #include <type_traits>
18
19 #include "absl/functional/any_invocable.h"
20 #include "api/array_view.h"
21 #include "api/audio_options.h"
22 #include "api/rtp_parameters.h"
23 #include "api/task_queue/pending_task_safety_flag.h"
24 #include "media/base/codec.h"
25 #include "media/base/fake_media_engine.h"
26 #include "media/base/fake_rtp.h"
27 #include "media/base/media_channel.h"
28 #include "media/base/media_constants.h"
29 #include "media/base/rid_description.h"
30 #include "p2p/base/candidate_pair_interface.h"
31 #include "p2p/base/dtls_transport_internal.h"
32 #include "p2p/base/fake_dtls_transport.h"
33 #include "p2p/base/fake_packet_transport.h"
34 #include "p2p/base/ice_transport_internal.h"
35 #include "p2p/base/p2p_constants.h"
36 #include "p2p/base/packet_transport_internal.h"
37 #include "pc/dtls_srtp_transport.h"
38 #include "pc/jsep_transport.h"
39 #include "pc/rtp_transport.h"
40 #include "rtc_base/arraysize.h"
41 #include "rtc_base/buffer.h"
42 #include "rtc_base/byte_order.h"
43 #include "rtc_base/checks.h"
44 #include "rtc_base/rtc_certificate.h"
45 #include "rtc_base/ssl_identity.h"
46 #include "rtc_base/task_queue_for_test.h"
47 #include "test/gmock.h"
48 #include "test/gtest.h"
49 #include "test/scoped_key_value_config.h"
50
51 using cricket::DtlsTransportInternal;
52 using cricket::FakeVoiceMediaChannel;
53 using cricket::RidDescription;
54 using cricket::RidDirection;
55 using cricket::StreamParams;
56 using webrtc::RtpTransceiverDirection;
57 using webrtc::SdpType;
58
59 namespace {
60 const cricket::AudioCodec kPcmuCodec(0, "PCMU", 64000, 8000, 1);
61 const cricket::AudioCodec kPcmaCodec(8, "PCMA", 64000, 8000, 1);
62 const cricket::AudioCodec kIsacCodec(103, "ISAC", 40000, 16000, 1);
63 const cricket::VideoCodec kH264Codec(97, "H264");
64 const cricket::VideoCodec kH264SvcCodec(99, "H264-SVC");
65 const uint32_t kSsrc1 = 0x1111;
66 const uint32_t kSsrc2 = 0x2222;
67 const uint32_t kSsrc3 = 0x3333;
68 const uint32_t kSsrc4 = 0x4444;
69 const int kAudioPts[] = {0, 8};
70 const int kVideoPts[] = {97, 99};
71 enum class NetworkIsWorker { Yes, No };
72
73 } // namespace
74
75 template <class ChannelT,
76 class MediaChannelT,
77 class ContentT,
78 class CodecT,
79 class MediaInfoT,
80 class OptionsT>
81 class Traits {
82 public:
83 typedef ChannelT Channel;
84 typedef MediaChannelT MediaChannel;
85 typedef ContentT Content;
86 typedef CodecT Codec;
87 typedef MediaInfoT MediaInfo;
88 typedef OptionsT Options;
89 };
90
91 class VoiceTraits : public Traits<cricket::VoiceChannel,
92 cricket::FakeVoiceMediaChannel,
93 cricket::AudioContentDescription,
94 cricket::AudioCodec,
95 cricket::VoiceMediaInfo,
96 cricket::AudioOptions> {};
97
98 class VideoTraits : public Traits<cricket::VideoChannel,
99 cricket::FakeVideoMediaChannel,
100 cricket::VideoContentDescription,
101 cricket::VideoCodec,
102 cricket::VideoMediaInfo,
103 cricket::VideoOptions> {};
104
105 // Base class for Voice/Video tests
106 template <class T>
107 class ChannelTest : public ::testing::Test, public sigslot::has_slots<> {
108 public:
109 enum Flags {
110 RTCP_MUX = 0x1,
111 SSRC_MUX = 0x8,
112 DTLS = 0x10,
113 // Use BaseChannel with PacketTransportInternal rather than
114 // DtlsTransportInternal.
115 RAW_PACKET_TRANSPORT = 0x20,
116 };
117
ChannelTest(bool verify_playout,rtc::ArrayView<const uint8_t> rtp_data,rtc::ArrayView<const uint8_t> rtcp_data,NetworkIsWorker network_is_worker)118 ChannelTest(bool verify_playout,
119 rtc::ArrayView<const uint8_t> rtp_data,
120 rtc::ArrayView<const uint8_t> rtcp_data,
121 NetworkIsWorker network_is_worker)
122 : verify_playout_(verify_playout),
123 rtp_packet_(rtp_data.data(), rtp_data.size()),
124 rtcp_packet_(rtcp_data.data(), rtcp_data.size()) {
125 if (network_is_worker == NetworkIsWorker::Yes) {
126 network_thread_ = rtc::Thread::Current();
127 } else {
128 network_thread_keeper_ = rtc::Thread::Create();
129 network_thread_keeper_->SetName("Network", nullptr);
130 network_thread_ = network_thread_keeper_.get();
131 }
132 RTC_DCHECK(network_thread_);
133 }
134
~ChannelTest()135 ~ChannelTest() {
136 if (network_thread_) {
137 SendTask(network_thread_, [this]() {
138 network_thread_safety_->SetNotAlive();
139 DeinitChannels();
140 });
141 }
142 }
143
CreateChannels(int flags1,int flags2)144 void CreateChannels(int flags1, int flags2) {
145 CreateChannels(std::make_unique<typename T::MediaChannel>(
146 nullptr, typename T::Options(), network_thread_),
147 std::make_unique<typename T::MediaChannel>(
148 nullptr, typename T::Options(), network_thread_),
149 flags1, flags2);
150 }
CreateChannels(std::unique_ptr<typename T::MediaChannel> ch1,std::unique_ptr<typename T::MediaChannel> ch2,int flags1,int flags2)151 void CreateChannels(std::unique_ptr<typename T::MediaChannel> ch1,
152 std::unique_ptr<typename T::MediaChannel> ch2,
153 int flags1,
154 int flags2) {
155 RTC_DCHECK(!channel1_);
156 RTC_DCHECK(!channel2_);
157
158 // Network thread is started in CreateChannels, to allow the test to
159 // configure a fake clock before any threads are spawned and attempt to
160 // access the time.
161 if (network_thread_keeper_) {
162 network_thread_keeper_->Start();
163 }
164
165 // Make sure if using raw packet transports, they're used for both
166 // channels.
167 RTC_DCHECK_EQ(flags1 & RAW_PACKET_TRANSPORT, flags2 & RAW_PACKET_TRANSPORT);
168 rtc::Thread* worker_thread = rtc::Thread::Current();
169 // Based on flags, create fake DTLS or raw packet transports.
170 if (flags1 & RAW_PACKET_TRANSPORT) {
171 fake_rtp_packet_transport1_.reset(
172 new rtc::FakePacketTransport("channel1_rtp"));
173 if (!(flags1 & RTCP_MUX)) {
174 fake_rtcp_packet_transport1_.reset(
175 new rtc::FakePacketTransport("channel1_rtcp"));
176 }
177 } else {
178 // Confirmed to work with KT_RSA and KT_ECDSA.
179 fake_rtp_dtls_transport1_.reset(new cricket::FakeDtlsTransport(
180 "channel1", cricket::ICE_CANDIDATE_COMPONENT_RTP, network_thread_));
181 if (!(flags1 & RTCP_MUX)) {
182 fake_rtcp_dtls_transport1_.reset(new cricket::FakeDtlsTransport(
183 "channel1", cricket::ICE_CANDIDATE_COMPONENT_RTCP,
184 network_thread_));
185 }
186 if (flags1 & DTLS) {
187 auto cert1 = rtc::RTCCertificate::Create(
188 rtc::SSLIdentity::Create("session1", rtc::KT_DEFAULT));
189 fake_rtp_dtls_transport1_->SetLocalCertificate(cert1);
190 if (fake_rtcp_dtls_transport1_) {
191 fake_rtcp_dtls_transport1_->SetLocalCertificate(cert1);
192 }
193 }
194 }
195 // Based on flags, create fake DTLS or raw packet transports.
196 if (flags2 & RAW_PACKET_TRANSPORT) {
197 fake_rtp_packet_transport2_.reset(
198 new rtc::FakePacketTransport("channel2_rtp"));
199 if (!(flags2 & RTCP_MUX)) {
200 fake_rtcp_packet_transport2_.reset(
201 new rtc::FakePacketTransport("channel2_rtcp"));
202 }
203 } else {
204 // Confirmed to work with KT_RSA and KT_ECDSA.
205 fake_rtp_dtls_transport2_.reset(new cricket::FakeDtlsTransport(
206 "channel2", cricket::ICE_CANDIDATE_COMPONENT_RTP, network_thread_));
207 if (!(flags2 & RTCP_MUX)) {
208 fake_rtcp_dtls_transport2_.reset(new cricket::FakeDtlsTransport(
209 "channel2", cricket::ICE_CANDIDATE_COMPONENT_RTCP,
210 network_thread_));
211 }
212 if (flags2 & DTLS) {
213 auto cert2 = rtc::RTCCertificate::Create(
214 rtc::SSLIdentity::Create("session2", rtc::KT_DEFAULT));
215 fake_rtp_dtls_transport2_->SetLocalCertificate(cert2);
216 if (fake_rtcp_dtls_transport2_) {
217 fake_rtcp_dtls_transport2_->SetLocalCertificate(cert2);
218 }
219 }
220 }
221 rtp_transport1_ = CreateRtpTransportBasedOnFlags(
222 fake_rtp_packet_transport1_.get(), fake_rtcp_packet_transport1_.get(),
223 fake_rtp_dtls_transport1_.get(), fake_rtcp_dtls_transport1_.get(),
224 flags1);
225 rtp_transport2_ = CreateRtpTransportBasedOnFlags(
226 fake_rtp_packet_transport2_.get(), fake_rtcp_packet_transport2_.get(),
227 fake_rtp_dtls_transport2_.get(), fake_rtcp_dtls_transport2_.get(),
228 flags2);
229
230 channel1_ = CreateChannel(worker_thread, network_thread_, std::move(ch1),
231 rtp_transport1_.get(), flags1);
232 channel2_ = CreateChannel(worker_thread, network_thread_, std::move(ch2),
233 rtp_transport2_.get(), flags2);
234 CreateContent(flags1, kPcmuCodec, kH264Codec, &local_media_content1_);
235 CreateContent(flags2, kPcmuCodec, kH264Codec, &local_media_content2_);
236 CopyContent(local_media_content1_, &remote_media_content1_);
237 CopyContent(local_media_content2_, &remote_media_content2_);
238
239 // Add stream information (SSRC) to the local content but not to the remote
240 // content. This means that we per default know the SSRC of what we send but
241 // not what we receive.
242 AddLegacyStreamInContent(kSsrc1, flags1, &local_media_content1_);
243 AddLegacyStreamInContent(kSsrc2, flags2, &local_media_content2_);
244
245 // If SSRC_MUX is used we also need to know the SSRC of the incoming stream.
246 if (flags1 & SSRC_MUX) {
247 AddLegacyStreamInContent(kSsrc1, flags1, &remote_media_content1_);
248 }
249 if (flags2 & SSRC_MUX) {
250 AddLegacyStreamInContent(kSsrc2, flags2, &remote_media_content2_);
251 }
252 }
253 std::unique_ptr<typename T::Channel> CreateChannel(
254 rtc::Thread* worker_thread,
255 rtc::Thread* network_thread,
256 std::unique_ptr<typename T::MediaChannel> ch,
257 webrtc::RtpTransportInternal* rtp_transport,
258 int flags);
259
CreateRtpTransportBasedOnFlags(rtc::PacketTransportInternal * rtp_packet_transport,rtc::PacketTransportInternal * rtcp_packet_transport,DtlsTransportInternal * rtp_dtls_transport,DtlsTransportInternal * rtcp_dtls_transport,int flags)260 std::unique_ptr<webrtc::RtpTransportInternal> CreateRtpTransportBasedOnFlags(
261 rtc::PacketTransportInternal* rtp_packet_transport,
262 rtc::PacketTransportInternal* rtcp_packet_transport,
263 DtlsTransportInternal* rtp_dtls_transport,
264 DtlsTransportInternal* rtcp_dtls_transport,
265 int flags) {
266 if (flags & RTCP_MUX) {
267 rtcp_packet_transport = nullptr;
268 rtcp_dtls_transport = nullptr;
269 }
270
271 if (flags & DTLS) {
272 return CreateDtlsSrtpTransport(rtp_dtls_transport, rtcp_dtls_transport);
273 } else {
274 if (flags & RAW_PACKET_TRANSPORT) {
275 return CreateUnencryptedTransport(rtp_packet_transport,
276 rtcp_packet_transport);
277 } else {
278 return CreateUnencryptedTransport(rtp_dtls_transport,
279 rtcp_dtls_transport);
280 }
281 }
282 }
283
284 // Unininitializes the channels on the network thread.
DeinitChannels()285 void DeinitChannels() {
286 if (!channel1_ && !channel2_)
287 return;
288 SendTask(network_thread_, [this]() {
289 if (channel1_) {
290 RTC_DCHECK_RUN_ON(channel1_->network_thread());
291 channel1_->SetRtpTransport(nullptr);
292 }
293 if (channel2_) {
294 RTC_DCHECK_RUN_ON(channel2_->network_thread());
295 channel2_->SetRtpTransport(nullptr);
296 }
297 });
298 }
299
CreateUnencryptedTransport(rtc::PacketTransportInternal * rtp_packet_transport,rtc::PacketTransportInternal * rtcp_packet_transport)300 std::unique_ptr<webrtc::RtpTransport> CreateUnencryptedTransport(
301 rtc::PacketTransportInternal* rtp_packet_transport,
302 rtc::PacketTransportInternal* rtcp_packet_transport) {
303 auto rtp_transport = std::make_unique<webrtc::RtpTransport>(
304 rtcp_packet_transport == nullptr);
305
306 SendTask(network_thread_,
307 [&rtp_transport, rtp_packet_transport, rtcp_packet_transport] {
308 rtp_transport->SetRtpPacketTransport(rtp_packet_transport);
309 if (rtcp_packet_transport) {
310 rtp_transport->SetRtcpPacketTransport(rtcp_packet_transport);
311 }
312 });
313 return rtp_transport;
314 }
315
CreateDtlsSrtpTransport(cricket::DtlsTransportInternal * rtp_dtls_transport,cricket::DtlsTransportInternal * rtcp_dtls_transport)316 std::unique_ptr<webrtc::DtlsSrtpTransport> CreateDtlsSrtpTransport(
317 cricket::DtlsTransportInternal* rtp_dtls_transport,
318 cricket::DtlsTransportInternal* rtcp_dtls_transport) {
319 auto dtls_srtp_transport = std::make_unique<webrtc::DtlsSrtpTransport>(
320 rtcp_dtls_transport == nullptr, field_trials_);
321
322 SendTask(network_thread_,
323 [&dtls_srtp_transport, rtp_dtls_transport, rtcp_dtls_transport] {
324 dtls_srtp_transport->SetDtlsTransports(rtp_dtls_transport,
325 rtcp_dtls_transport);
326 });
327 return dtls_srtp_transport;
328 }
329
ConnectFakeTransports()330 void ConnectFakeTransports() {
331 SendTask(network_thread_, [this] {
332 bool asymmetric = false;
333 // Depending on test flags, could be using DTLS or raw packet transport.
334 if (fake_rtp_dtls_transport1_ && fake_rtp_dtls_transport2_) {
335 fake_rtp_dtls_transport1_->SetDestination(
336 fake_rtp_dtls_transport2_.get(), asymmetric);
337 }
338 if (fake_rtcp_dtls_transport1_ && fake_rtcp_dtls_transport2_) {
339 fake_rtcp_dtls_transport1_->SetDestination(
340 fake_rtcp_dtls_transport2_.get(), asymmetric);
341 }
342 if (fake_rtp_packet_transport1_ && fake_rtp_packet_transport2_) {
343 fake_rtp_packet_transport1_->SetDestination(
344 fake_rtp_packet_transport2_.get(), asymmetric);
345 }
346 if (fake_rtcp_packet_transport1_ && fake_rtcp_packet_transport2_) {
347 fake_rtcp_packet_transport1_->SetDestination(
348 fake_rtcp_packet_transport2_.get(), asymmetric);
349 }
350 });
351 // The transport becoming writable will asynchronously update the send state
352 // on the worker thread; since this test uses the main thread as the worker
353 // thread, we must process the message queue for this to occur.
354 WaitForThreads();
355 }
356
SendInitiate()357 bool SendInitiate() {
358 std::string err;
359 bool result = channel1_->SetLocalContent(&local_media_content1_,
360 SdpType::kOffer, err);
361 if (result) {
362 channel1_->Enable(true);
363 FlushCurrentThread();
364 result = channel2_->SetRemoteContent(&remote_media_content1_,
365 SdpType::kOffer, err);
366 if (result) {
367 ConnectFakeTransports();
368 result = channel2_->SetLocalContent(&local_media_content2_,
369 SdpType::kAnswer, err);
370 }
371 }
372 return result;
373 }
374
SendAccept()375 bool SendAccept() {
376 channel2_->Enable(true);
377 FlushCurrentThread();
378 std::string err;
379 return channel1_->SetRemoteContent(&remote_media_content2_,
380 SdpType::kAnswer, err);
381 }
382
SendOffer()383 bool SendOffer() {
384 std::string err;
385 bool result = channel1_->SetLocalContent(&local_media_content1_,
386 SdpType::kOffer, err);
387 if (result) {
388 channel1_->Enable(true);
389 result = channel2_->SetRemoteContent(&remote_media_content1_,
390 SdpType::kOffer, err);
391 }
392 return result;
393 }
394
SendProvisionalAnswer()395 bool SendProvisionalAnswer() {
396 std::string err;
397 bool result = channel2_->SetLocalContent(&local_media_content2_,
398 SdpType::kPrAnswer, err);
399 if (result) {
400 channel2_->Enable(true);
401 result = channel1_->SetRemoteContent(&remote_media_content2_,
402 SdpType::kPrAnswer, err);
403 ConnectFakeTransports();
404 }
405 return result;
406 }
407
SendFinalAnswer()408 bool SendFinalAnswer() {
409 std::string err;
410 bool result = channel2_->SetLocalContent(&local_media_content2_,
411 SdpType::kAnswer, err);
412 if (result) {
413 result = channel1_->SetRemoteContent(&remote_media_content2_,
414 SdpType::kAnswer, err);
415 }
416 return result;
417 }
418
SendRtp(typename T::MediaChannel * media_channel,rtc::Buffer data)419 void SendRtp(typename T::MediaChannel* media_channel, rtc::Buffer data) {
420 network_thread_->PostTask(webrtc::SafeTask(
421 network_thread_safety_, [media_channel, data = std::move(data)]() {
422 media_channel->SendRtp(data.data(), data.size(),
423 rtc::PacketOptions());
424 }));
425 }
426
SendRtp1()427 void SendRtp1() {
428 SendRtp1(rtc::Buffer(rtp_packet_.data(), rtp_packet_.size()));
429 }
430
SendRtp1(rtc::Buffer data)431 void SendRtp1(rtc::Buffer data) {
432 SendRtp(media_channel1(), std::move(data));
433 }
434
SendRtp2()435 void SendRtp2() {
436 SendRtp2(rtc::Buffer(rtp_packet_.data(), rtp_packet_.size()));
437 }
438
SendRtp2(rtc::Buffer data)439 void SendRtp2(rtc::Buffer data) {
440 SendRtp(media_channel2(), std::move(data));
441 }
442
443 // Methods to send custom data.
SendCustomRtp1(uint32_t ssrc,int sequence_number,int pl_type=-1)444 void SendCustomRtp1(uint32_t ssrc, int sequence_number, int pl_type = -1) {
445 SendRtp1(CreateRtpData(ssrc, sequence_number, pl_type));
446 }
SendCustomRtp2(uint32_t ssrc,int sequence_number,int pl_type=-1)447 void SendCustomRtp2(uint32_t ssrc, int sequence_number, int pl_type = -1) {
448 SendRtp2(CreateRtpData(ssrc, sequence_number, pl_type));
449 }
450
CheckRtp1()451 bool CheckRtp1() {
452 return media_channel1()->CheckRtp(rtp_packet_.data(), rtp_packet_.size());
453 }
CheckRtp2()454 bool CheckRtp2() {
455 return media_channel2()->CheckRtp(rtp_packet_.data(), rtp_packet_.size());
456 }
457 // Methods to check custom data.
CheckCustomRtp1(uint32_t ssrc,int sequence_number,int pl_type=-1)458 bool CheckCustomRtp1(uint32_t ssrc, int sequence_number, int pl_type = -1) {
459 rtc::Buffer data = CreateRtpData(ssrc, sequence_number, pl_type);
460 return media_channel1()->CheckRtp(data.data(), data.size());
461 }
CheckCustomRtp2(uint32_t ssrc,int sequence_number,int pl_type=-1)462 bool CheckCustomRtp2(uint32_t ssrc, int sequence_number, int pl_type = -1) {
463 rtc::Buffer data = CreateRtpData(ssrc, sequence_number, pl_type);
464 return media_channel2()->CheckRtp(data.data(), data.size());
465 }
CreateRtpData(uint32_t ssrc,int sequence_number,int pl_type)466 rtc::Buffer CreateRtpData(uint32_t ssrc, int sequence_number, int pl_type) {
467 rtc::Buffer data(rtp_packet_.data(), rtp_packet_.size());
468 // Set SSRC in the rtp packet copy.
469 rtc::SetBE32(data.data() + 8, ssrc);
470 rtc::SetBE16(data.data() + 2, sequence_number);
471 if (pl_type >= 0) {
472 rtc::Set8(data.data(), 1, static_cast<uint8_t>(pl_type));
473 }
474 return data;
475 }
476
CheckNoRtp1()477 bool CheckNoRtp1() { return media_channel1()->CheckNoRtp(); }
CheckNoRtp2()478 bool CheckNoRtp2() { return media_channel2()->CheckNoRtp(); }
479
CreateContent(int flags,const cricket::AudioCodec & audio_codec,const cricket::VideoCodec & video_codec,typename T::Content * content)480 void CreateContent(int flags,
481 const cricket::AudioCodec& audio_codec,
482 const cricket::VideoCodec& video_codec,
483 typename T::Content* content) {
484 // overridden in specialized classes
485 }
CopyContent(const typename T::Content & source,typename T::Content * content)486 void CopyContent(const typename T::Content& source,
487 typename T::Content* content) {
488 // overridden in specialized classes
489 }
490
491 // Creates a MediaContent with one stream.
492 // kPcmuCodec is used as audio codec and kH264Codec is used as video codec.
CreateMediaContentWithStream(uint32_t ssrc)493 typename T::Content* CreateMediaContentWithStream(uint32_t ssrc) {
494 typename T::Content* content = new typename T::Content();
495 CreateContent(0, kPcmuCodec, kH264Codec, content);
496 AddLegacyStreamInContent(ssrc, 0, content);
497 return content;
498 }
499
500 // Will manage the lifetime of a CallThread, making sure it's
501 // destroyed before this object goes out of scope.
502 class ScopedCallThread {
503 public:
ScopedCallThread(absl::AnyInvocable<void ()&&> functor)504 explicit ScopedCallThread(absl::AnyInvocable<void() &&> functor)
505 : thread_(rtc::Thread::Create()) {
506 thread_->Start();
507 thread_->PostTask(std::move(functor));
508 }
509
~ScopedCallThread()510 ~ScopedCallThread() { thread_->Stop(); }
511
thread()512 rtc::Thread* thread() { return thread_.get(); }
513
514 private:
515 std::unique_ptr<rtc::Thread> thread_;
516 };
517
CodecMatches(const typename T::Codec & c1,const typename T::Codec & c2)518 bool CodecMatches(const typename T::Codec& c1, const typename T::Codec& c2) {
519 return false; // overridden in specialized classes
520 }
521
last_selected_candidate_pair()522 cricket::CandidatePairInterface* last_selected_candidate_pair() {
523 return last_selected_candidate_pair_;
524 }
525
AddLegacyStreamInContent(uint32_t ssrc,int flags,typename T::Content * content)526 void AddLegacyStreamInContent(uint32_t ssrc,
527 int flags,
528 typename T::Content* content) {
529 // Base implementation.
530 }
531
532 // Utility method that calls BaseChannel::srtp_active() on the network thread
533 // and returns the result. The `srtp_active()` state is maintained on the
534 // network thread, which callers need to factor in.
IsSrtpActive(std::unique_ptr<typename T::Channel> & channel)535 bool IsSrtpActive(std::unique_ptr<typename T::Channel>& channel) {
536 RTC_DCHECK(channel.get());
537 bool result;
538 SendTask(network_thread_, [&] { result = channel->srtp_active(); });
539 return result;
540 }
541
542 // Returns true iff the transport is set for a channel and rtcp_mux_enabled()
543 // returns true.
IsRtcpMuxEnabled(std::unique_ptr<typename T::Channel> & channel)544 bool IsRtcpMuxEnabled(std::unique_ptr<typename T::Channel>& channel) {
545 RTC_DCHECK(channel.get());
546 bool result;
547 SendTask(network_thread_, [&] {
548 result = channel->rtp_transport() &&
549 channel->rtp_transport()->rtcp_mux_enabled();
550 });
551 return result;
552 }
553
554 // Tests that can be used by derived classes.
555
556 // Basic sanity check.
TestInit()557 void TestInit() {
558 CreateChannels(0, 0);
559 EXPECT_FALSE(IsSrtpActive(channel1_));
560 EXPECT_FALSE(media_channel1()->sending());
561 if (verify_playout_) {
562 EXPECT_FALSE(media_channel1()->playout());
563 }
564 EXPECT_TRUE(media_channel1()->codecs().empty());
565 EXPECT_TRUE(media_channel1()->recv_streams().empty());
566 EXPECT_TRUE(media_channel1()->rtp_packets().empty());
567 }
568
569 // Test that SetLocalContent and SetRemoteContent properly configure
570 // the codecs.
TestSetContents()571 void TestSetContents() {
572 CreateChannels(0, 0);
573 typename T::Content content;
574 CreateContent(0, kPcmuCodec, kH264Codec, &content);
575 std::string err;
576 EXPECT_TRUE(channel1_->SetLocalContent(&content, SdpType::kOffer, err));
577 EXPECT_EQ(0U, media_channel1()->codecs().size());
578 EXPECT_TRUE(channel1_->SetRemoteContent(&content, SdpType::kAnswer, err));
579 ASSERT_EQ(1U, media_channel1()->codecs().size());
580 EXPECT_TRUE(
581 CodecMatches(content.codecs()[0], media_channel1()->codecs()[0]));
582 }
583
584 // Test that SetLocalContent and SetRemoteContent properly configure
585 // extmap-allow-mixed.
TestSetContentsExtmapAllowMixedCaller(bool offer,bool answer)586 void TestSetContentsExtmapAllowMixedCaller(bool offer, bool answer) {
587 // For a caller, SetLocalContent() is called first with an offer and next
588 // SetRemoteContent() is called with the answer.
589 CreateChannels(0, 0);
590 typename T::Content content;
591 CreateContent(0, kPcmuCodec, kH264Codec, &content);
592 auto offer_enum = offer ? (T::Content::kSession) : (T::Content::kNo);
593 auto answer_enum = answer ? (T::Content::kSession) : (T::Content::kNo);
594 content.set_extmap_allow_mixed_enum(offer_enum);
595 std::string err;
596 EXPECT_TRUE(channel1_->SetLocalContent(&content, SdpType::kOffer, err));
597 content.set_extmap_allow_mixed_enum(answer_enum);
598 EXPECT_TRUE(channel1_->SetRemoteContent(&content, SdpType::kAnswer, err));
599 EXPECT_EQ(answer, media_channel1()->ExtmapAllowMixed());
600 }
TestSetContentsExtmapAllowMixedCallee(bool offer,bool answer)601 void TestSetContentsExtmapAllowMixedCallee(bool offer, bool answer) {
602 // For a callee, SetRemoteContent() is called first with an offer and next
603 // SetLocalContent() is called with the answer.
604 CreateChannels(0, 0);
605 typename T::Content content;
606 CreateContent(0, kPcmuCodec, kH264Codec, &content);
607 auto offer_enum = offer ? (T::Content::kSession) : (T::Content::kNo);
608 auto answer_enum = answer ? (T::Content::kSession) : (T::Content::kNo);
609 content.set_extmap_allow_mixed_enum(offer_enum);
610 std::string err;
611 EXPECT_TRUE(channel1_->SetRemoteContent(&content, SdpType::kOffer, err));
612 content.set_extmap_allow_mixed_enum(answer_enum);
613 EXPECT_TRUE(channel1_->SetLocalContent(&content, SdpType::kAnswer, err));
614 EXPECT_EQ(answer, media_channel1()->ExtmapAllowMixed());
615 }
616
617 // Test that SetLocalContent and SetRemoteContent properly deals
618 // with an empty offer.
TestSetContentsNullOffer()619 void TestSetContentsNullOffer() {
620 CreateChannels(0, 0);
621 typename T::Content content;
622 std::string err;
623 EXPECT_TRUE(channel1_->SetLocalContent(&content, SdpType::kOffer, err));
624 CreateContent(0, kPcmuCodec, kH264Codec, &content);
625 EXPECT_EQ(0U, media_channel1()->codecs().size());
626 EXPECT_TRUE(channel1_->SetRemoteContent(&content, SdpType::kAnswer, err));
627 ASSERT_EQ(1U, media_channel1()->codecs().size());
628 EXPECT_TRUE(
629 CodecMatches(content.codecs()[0], media_channel1()->codecs()[0]));
630 }
631
632 // Test that SetLocalContent and SetRemoteContent properly set RTCP
633 // mux.
TestSetContentsRtcpMux()634 void TestSetContentsRtcpMux() {
635 CreateChannels(0, 0);
636 typename T::Content content;
637 CreateContent(0, kPcmuCodec, kH264Codec, &content);
638 // Both sides agree on mux. Should no longer be a separate RTCP channel.
639 content.set_rtcp_mux(true);
640 std::string err;
641 EXPECT_TRUE(channel1_->SetLocalContent(&content, SdpType::kOffer, err));
642 EXPECT_TRUE(channel1_->SetRemoteContent(&content, SdpType::kAnswer, err));
643 // Only initiator supports mux. Should still have a separate RTCP channel.
644 EXPECT_TRUE(channel2_->SetLocalContent(&content, SdpType::kOffer, err));
645 content.set_rtcp_mux(false);
646 EXPECT_TRUE(channel2_->SetRemoteContent(&content, SdpType::kAnswer, err));
647 }
648
649 // Test that SetLocalContent and SetRemoteContent properly
650 // handles adding and removing StreamParams when the action is a full
651 // SdpType::kOffer / SdpType::kAnswer.
TestChangeStreamParamsInContent()652 void TestChangeStreamParamsInContent() {
653 cricket::StreamParams stream1;
654 stream1.id = "stream1";
655 stream1.ssrcs.push_back(kSsrc1);
656 stream1.cname = "stream1_cname";
657
658 cricket::StreamParams stream2;
659 stream2.id = "stream2";
660 stream2.ssrcs.push_back(kSsrc2);
661 stream2.cname = "stream2_cname";
662
663 // Setup a call where channel 1 send `stream1` to channel 2.
664 CreateChannels(0, 0);
665 typename T::Content content1;
666 CreateContent(0, kPcmuCodec, kH264Codec, &content1);
667 content1.AddStream(stream1);
668 std::string err;
669 EXPECT_TRUE(channel1_->SetLocalContent(&content1, SdpType::kOffer, err));
670 channel1_->Enable(true);
671 EXPECT_EQ(1u, media_channel1()->send_streams().size());
672
673 EXPECT_TRUE(channel2_->SetRemoteContent(&content1, SdpType::kOffer, err));
674 EXPECT_EQ(1u, media_channel2()->recv_streams().size());
675 ConnectFakeTransports();
676
677 // Channel 2 do not send anything.
678 typename T::Content content2;
679 CreateContent(0, kPcmuCodec, kH264Codec, &content2);
680 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, SdpType::kAnswer, err));
681 EXPECT_EQ(0u, media_channel1()->recv_streams().size());
682 EXPECT_TRUE(channel2_->SetLocalContent(&content2, SdpType::kAnswer, err));
683 channel2_->Enable(true);
684 EXPECT_EQ(0u, media_channel2()->send_streams().size());
685
686 SendCustomRtp1(kSsrc1, 0);
687 WaitForThreads();
688 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, 0));
689
690 // Let channel 2 update the content by sending `stream2` and enable SRTP.
691 typename T::Content content3;
692 CreateContent(0, kPcmuCodec, kH264Codec, &content3);
693 content3.AddStream(stream2);
694 EXPECT_TRUE(channel2_->SetLocalContent(&content3, SdpType::kOffer, err));
695 ASSERT_EQ(1u, media_channel2()->send_streams().size());
696 EXPECT_EQ(stream2, media_channel2()->send_streams()[0]);
697
698 EXPECT_TRUE(channel1_->SetRemoteContent(&content3, SdpType::kOffer, err));
699 ASSERT_EQ(1u, media_channel1()->recv_streams().size());
700 EXPECT_EQ(stream2, media_channel1()->recv_streams()[0]);
701
702 // Channel 1 replies but stop sending stream1.
703 typename T::Content content4;
704 CreateContent(0, kPcmuCodec, kH264Codec, &content4);
705 EXPECT_TRUE(channel1_->SetLocalContent(&content4, SdpType::kAnswer, err));
706 EXPECT_EQ(0u, media_channel1()->send_streams().size());
707
708 EXPECT_TRUE(channel2_->SetRemoteContent(&content4, SdpType::kAnswer, err));
709 EXPECT_EQ(0u, media_channel2()->recv_streams().size());
710
711 SendCustomRtp2(kSsrc2, 0);
712 WaitForThreads();
713 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, 0));
714 }
715
716 // Test that we only start playout and sending at the right times.
TestPlayoutAndSendingStates()717 void TestPlayoutAndSendingStates() {
718 CreateChannels(0, 0);
719 if (verify_playout_) {
720 EXPECT_FALSE(media_channel1()->playout());
721 }
722 EXPECT_FALSE(media_channel1()->sending());
723 if (verify_playout_) {
724 EXPECT_FALSE(media_channel2()->playout());
725 }
726 EXPECT_FALSE(media_channel2()->sending());
727 channel1_->Enable(true);
728 FlushCurrentThread();
729 if (verify_playout_) {
730 EXPECT_FALSE(media_channel1()->playout());
731 }
732 EXPECT_FALSE(media_channel1()->sending());
733 std::string err;
734 EXPECT_TRUE(channel1_->SetLocalContent(&local_media_content1_,
735 SdpType::kOffer, err));
736 if (verify_playout_) {
737 EXPECT_TRUE(media_channel1()->playout());
738 }
739 EXPECT_FALSE(media_channel1()->sending());
740 EXPECT_TRUE(channel2_->SetRemoteContent(&local_media_content1_,
741 SdpType::kOffer, err));
742 if (verify_playout_) {
743 EXPECT_FALSE(media_channel2()->playout());
744 }
745 EXPECT_FALSE(media_channel2()->sending());
746 EXPECT_TRUE(channel2_->SetLocalContent(&local_media_content2_,
747 SdpType::kAnswer, err));
748 if (verify_playout_) {
749 EXPECT_FALSE(media_channel2()->playout());
750 }
751 EXPECT_FALSE(media_channel2()->sending());
752 ConnectFakeTransports();
753 if (verify_playout_) {
754 EXPECT_TRUE(media_channel1()->playout());
755 }
756 EXPECT_FALSE(media_channel1()->sending());
757 if (verify_playout_) {
758 EXPECT_FALSE(media_channel2()->playout());
759 }
760 EXPECT_FALSE(media_channel2()->sending());
761 channel2_->Enable(true);
762 FlushCurrentThread();
763 if (verify_playout_) {
764 EXPECT_TRUE(media_channel2()->playout());
765 }
766 EXPECT_TRUE(media_channel2()->sending());
767 EXPECT_TRUE(channel1_->SetRemoteContent(&local_media_content2_,
768 SdpType::kAnswer, err));
769 if (verify_playout_) {
770 EXPECT_TRUE(media_channel1()->playout());
771 }
772 EXPECT_TRUE(media_channel1()->sending());
773 }
774
775 // Test that changing the MediaContentDirection in the local and remote
776 // session description start playout and sending at the right time.
TestMediaContentDirection()777 void TestMediaContentDirection() {
778 CreateChannels(0, 0);
779 typename T::Content content1;
780 CreateContent(0, kPcmuCodec, kH264Codec, &content1);
781 typename T::Content content2;
782 CreateContent(0, kPcmuCodec, kH264Codec, &content2);
783 // Set `content2` to be InActive.
784 content2.set_direction(RtpTransceiverDirection::kInactive);
785
786 channel1_->Enable(true);
787 channel2_->Enable(true);
788 FlushCurrentThread();
789 if (verify_playout_) {
790 EXPECT_FALSE(media_channel1()->playout());
791 }
792 EXPECT_FALSE(media_channel1()->sending());
793 if (verify_playout_) {
794 EXPECT_FALSE(media_channel2()->playout());
795 }
796 EXPECT_FALSE(media_channel2()->sending());
797
798 std::string err;
799 EXPECT_TRUE(channel1_->SetLocalContent(&content1, SdpType::kOffer, err));
800 EXPECT_TRUE(channel2_->SetRemoteContent(&content1, SdpType::kOffer, err));
801 EXPECT_TRUE(channel2_->SetLocalContent(&content2, SdpType::kPrAnswer, err));
802 EXPECT_TRUE(
803 channel1_->SetRemoteContent(&content2, SdpType::kPrAnswer, err));
804 ConnectFakeTransports();
805
806 if (verify_playout_) {
807 EXPECT_TRUE(media_channel1()->playout());
808 }
809 EXPECT_FALSE(media_channel1()->sending()); // remote InActive
810 if (verify_playout_) {
811 EXPECT_FALSE(media_channel2()->playout()); // local InActive
812 }
813 EXPECT_FALSE(media_channel2()->sending()); // local InActive
814
815 // Update `content2` to be RecvOnly.
816 content2.set_direction(RtpTransceiverDirection::kRecvOnly);
817 EXPECT_TRUE(channel2_->SetLocalContent(&content2, SdpType::kPrAnswer, err));
818 EXPECT_TRUE(
819 channel1_->SetRemoteContent(&content2, SdpType::kPrAnswer, err));
820
821 if (verify_playout_) {
822 EXPECT_TRUE(media_channel1()->playout());
823 }
824 EXPECT_TRUE(media_channel1()->sending());
825 if (verify_playout_) {
826 EXPECT_TRUE(media_channel2()->playout()); // local RecvOnly
827 }
828 EXPECT_FALSE(media_channel2()->sending()); // local RecvOnly
829
830 // Update `content2` to be SendRecv.
831 content2.set_direction(RtpTransceiverDirection::kSendRecv);
832 EXPECT_TRUE(channel2_->SetLocalContent(&content2, SdpType::kAnswer, err));
833 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, SdpType::kAnswer, err));
834
835 if (verify_playout_) {
836 EXPECT_TRUE(media_channel1()->playout());
837 }
838 EXPECT_TRUE(media_channel1()->sending());
839 if (verify_playout_) {
840 EXPECT_TRUE(media_channel2()->playout());
841 }
842 EXPECT_TRUE(media_channel2()->sending());
843 }
844
845 // Tests that when the transport channel signals a candidate pair change
846 // event, the media channel will receive a call on the network route change.
TestNetworkRouteChanges()847 void TestNetworkRouteChanges() {
848 static constexpr uint16_t kLocalNetId = 1;
849 static constexpr uint16_t kRemoteNetId = 2;
850 static constexpr int kLastPacketId = 100;
851 // Ipv4(20) + UDP(8).
852 static constexpr int kTransportOverheadPerPacket = 28;
853 static constexpr int kSrtpOverheadPerPacket = 10;
854
855 CreateChannels(DTLS, DTLS);
856 SendInitiate();
857
858 typename T::MediaChannel* media_channel1 =
859 static_cast<typename T::MediaChannel*>(channel1_->media_channel());
860 ASSERT_TRUE(media_channel1);
861
862 // Need to wait for the threads before calling
863 // `set_num_network_route_changes` because the network route would be set
864 // when creating the channel.
865 WaitForThreads();
866 media_channel1->set_num_network_route_changes(0);
867 SendTask(network_thread_, [this] {
868 rtc::NetworkRoute network_route;
869 // The transport channel becomes disconnected.
870 fake_rtp_dtls_transport1_->ice_transport()->SignalNetworkRouteChanged(
871 absl::optional<rtc::NetworkRoute>(network_route));
872 });
873 WaitForThreads();
874 EXPECT_EQ(1, media_channel1->num_network_route_changes());
875 EXPECT_FALSE(media_channel1->last_network_route().connected);
876 media_channel1->set_num_network_route_changes(0);
877
878 SendTask(network_thread_, [this] {
879 rtc::NetworkRoute network_route;
880 network_route.connected = true;
881 network_route.local =
882 rtc::RouteEndpoint::CreateWithNetworkId(kLocalNetId);
883 network_route.remote =
884 rtc::RouteEndpoint::CreateWithNetworkId(kRemoteNetId);
885 network_route.last_sent_packet_id = kLastPacketId;
886 network_route.packet_overhead = kTransportOverheadPerPacket;
887 // The transport channel becomes connected.
888 fake_rtp_dtls_transport1_->ice_transport()->SignalNetworkRouteChanged(
889
890 absl::optional<rtc::NetworkRoute>(network_route));
891 });
892 WaitForThreads();
893 EXPECT_EQ(1, media_channel1->num_network_route_changes());
894 EXPECT_TRUE(media_channel1->last_network_route().connected);
895 EXPECT_EQ(kLocalNetId,
896 media_channel1->last_network_route().local.network_id());
897 EXPECT_EQ(kRemoteNetId,
898 media_channel1->last_network_route().remote.network_id());
899 EXPECT_EQ(kLastPacketId,
900 media_channel1->last_network_route().last_sent_packet_id);
901 EXPECT_EQ(kTransportOverheadPerPacket + kSrtpOverheadPerPacket,
902 media_channel1->transport_overhead_per_packet());
903 }
904
905 // Test setting up a call.
TestCallSetup()906 void TestCallSetup() {
907 CreateChannels(0, 0);
908 EXPECT_FALSE(IsSrtpActive(channel1_));
909 EXPECT_TRUE(SendInitiate());
910 if (verify_playout_) {
911 EXPECT_TRUE(media_channel1()->playout());
912 }
913 EXPECT_FALSE(media_channel1()->sending());
914 EXPECT_TRUE(SendAccept());
915 EXPECT_FALSE(IsSrtpActive(channel1_));
916 EXPECT_TRUE(media_channel1()->sending());
917 EXPECT_EQ(1U, media_channel1()->codecs().size());
918 if (verify_playout_) {
919 EXPECT_TRUE(media_channel2()->playout());
920 }
921 EXPECT_TRUE(media_channel2()->sending());
922 EXPECT_EQ(1U, media_channel2()->codecs().size());
923 }
924
925 // Send voice RTP data to the other side and ensure it gets there.
SendRtpToRtp()926 void SendRtpToRtp() {
927 CreateChannels(RTCP_MUX, RTCP_MUX);
928 EXPECT_TRUE(SendInitiate());
929 EXPECT_TRUE(SendAccept());
930 EXPECT_TRUE(IsRtcpMuxEnabled(channel1_));
931 EXPECT_TRUE(IsRtcpMuxEnabled(channel2_));
932 SendRtp1();
933 SendRtp2();
934 WaitForThreads();
935 EXPECT_TRUE(CheckRtp1());
936 EXPECT_TRUE(CheckRtp2());
937 EXPECT_TRUE(CheckNoRtp1());
938 EXPECT_TRUE(CheckNoRtp2());
939 }
940
TestDeinit()941 void TestDeinit() {
942 CreateChannels(0, 0);
943 EXPECT_TRUE(SendInitiate());
944 EXPECT_TRUE(SendAccept());
945 SendRtp1();
946 SendRtp2();
947
948 DeinitChannels();
949
950 // Do not wait, destroy channels.
951 channel1_.reset(nullptr);
952 channel2_.reset(nullptr);
953 }
954
SendDtlsSrtpToDtlsSrtp(int flags1,int flags2)955 void SendDtlsSrtpToDtlsSrtp(int flags1, int flags2) {
956 CreateChannels(flags1 | DTLS, flags2 | DTLS);
957 EXPECT_FALSE(IsSrtpActive(channel1_));
958 EXPECT_FALSE(IsSrtpActive(channel2_));
959 EXPECT_TRUE(SendInitiate());
960 WaitForThreads();
961 EXPECT_TRUE(SendAccept());
962 EXPECT_TRUE(IsSrtpActive(channel1_));
963 EXPECT_TRUE(IsSrtpActive(channel2_));
964 SendRtp1();
965 SendRtp2();
966 WaitForThreads();
967 EXPECT_TRUE(CheckRtp1());
968 EXPECT_TRUE(CheckRtp2());
969 EXPECT_TRUE(CheckNoRtp1());
970 EXPECT_TRUE(CheckNoRtp2());
971 }
972
973 // Test that we can send and receive early media when a provisional answer is
974 // sent and received. The test uses SRTP, RTCP mux and SSRC mux.
SendEarlyMediaUsingRtcpMuxSrtp()975 void SendEarlyMediaUsingRtcpMuxSrtp() {
976 int sequence_number1_1 = 0, sequence_number2_2 = 0;
977
978 CreateChannels(SSRC_MUX | RTCP_MUX | DTLS, SSRC_MUX | RTCP_MUX | DTLS);
979 EXPECT_TRUE(SendOffer());
980 EXPECT_TRUE(SendProvisionalAnswer());
981 EXPECT_TRUE(IsSrtpActive(channel1_));
982 EXPECT_TRUE(IsSrtpActive(channel2_));
983 EXPECT_TRUE(IsRtcpMuxEnabled(channel1_));
984 EXPECT_TRUE(IsRtcpMuxEnabled(channel2_));
985 WaitForThreads(); // Wait for 'sending' flag go through network thread.
986 SendCustomRtp1(kSsrc1, ++sequence_number1_1);
987 WaitForThreads();
988 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1));
989
990 // Send packets from callee and verify that it is received.
991 SendCustomRtp2(kSsrc2, ++sequence_number2_2);
992 WaitForThreads();
993 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2));
994
995 // Complete call setup and ensure everything is still OK.
996 EXPECT_TRUE(SendFinalAnswer());
997 EXPECT_TRUE(IsSrtpActive(channel1_));
998 EXPECT_TRUE(IsSrtpActive(channel2_));
999 SendCustomRtp1(kSsrc1, ++sequence_number1_1);
1000 SendCustomRtp2(kSsrc2, ++sequence_number2_2);
1001 WaitForThreads();
1002 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1));
1003 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2));
1004 }
1005
1006 // Test that we properly send RTP without SRTP from a thread.
SendRtpToRtpOnThread()1007 void SendRtpToRtpOnThread() {
1008 CreateChannels(0, 0);
1009 EXPECT_TRUE(SendInitiate());
1010 EXPECT_TRUE(SendAccept());
1011 ScopedCallThread send_rtp1([this] { SendRtp1(); });
1012 ScopedCallThread send_rtp2([this] { SendRtp2(); });
1013 rtc::Thread* involved_threads[] = {send_rtp1.thread(), send_rtp2.thread()};
1014 WaitForThreads(involved_threads);
1015 EXPECT_TRUE(CheckRtp1());
1016 EXPECT_TRUE(CheckRtp2());
1017 EXPECT_TRUE(CheckNoRtp1());
1018 EXPECT_TRUE(CheckNoRtp2());
1019 }
1020
1021 // Test that the mediachannel retains its sending state after the transport
1022 // becomes non-writable.
SendWithWritabilityLoss()1023 void SendWithWritabilityLoss() {
1024 CreateChannels(RTCP_MUX, RTCP_MUX);
1025 EXPECT_TRUE(SendInitiate());
1026 EXPECT_TRUE(SendAccept());
1027 EXPECT_TRUE(IsRtcpMuxEnabled(channel1_));
1028 EXPECT_TRUE(IsRtcpMuxEnabled(channel2_));
1029 SendRtp1();
1030 SendRtp2();
1031 WaitForThreads();
1032 EXPECT_TRUE(CheckRtp1());
1033 EXPECT_TRUE(CheckRtp2());
1034 EXPECT_TRUE(CheckNoRtp1());
1035 EXPECT_TRUE(CheckNoRtp2());
1036
1037 // Lose writability, which should fail.
1038 SendTask(network_thread_,
1039 [this] { fake_rtp_dtls_transport1_->SetWritable(false); });
1040 SendRtp1();
1041 SendRtp2();
1042 WaitForThreads();
1043 EXPECT_TRUE(CheckRtp1());
1044 EXPECT_TRUE(CheckNoRtp2());
1045
1046 // Regain writability
1047 SendTask(network_thread_,
1048 [this] { fake_rtp_dtls_transport1_->SetWritable(true); });
1049 EXPECT_TRUE(media_channel1()->sending());
1050 SendRtp1();
1051 SendRtp2();
1052 WaitForThreads();
1053 EXPECT_TRUE(CheckRtp1());
1054 EXPECT_TRUE(CheckRtp2());
1055 EXPECT_TRUE(CheckNoRtp1());
1056 EXPECT_TRUE(CheckNoRtp2());
1057
1058 // Lose writability completely
1059 SendTask(network_thread_, [this] {
1060 bool asymmetric = true;
1061 fake_rtp_dtls_transport1_->SetDestination(nullptr, asymmetric);
1062 });
1063 EXPECT_TRUE(media_channel1()->sending());
1064
1065 // Should fail also.
1066 SendRtp1();
1067 SendRtp2();
1068 WaitForThreads();
1069 EXPECT_TRUE(CheckRtp1());
1070 EXPECT_TRUE(CheckNoRtp2());
1071 EXPECT_TRUE(CheckNoRtp1());
1072
1073 // Gain writability back
1074 SendTask(network_thread_, [this] {
1075 bool asymmetric = true;
1076 fake_rtp_dtls_transport1_->SetDestination(fake_rtp_dtls_transport2_.get(),
1077 asymmetric);
1078 });
1079 EXPECT_TRUE(media_channel1()->sending());
1080 SendRtp1();
1081 SendRtp2();
1082 WaitForThreads();
1083 EXPECT_TRUE(CheckRtp1());
1084 EXPECT_TRUE(CheckRtp2());
1085 EXPECT_TRUE(CheckNoRtp1());
1086 EXPECT_TRUE(CheckNoRtp2());
1087 }
1088
SendBundleToBundle(const int * pl_types,int len,bool rtcp_mux,bool secure)1089 void SendBundleToBundle(const int* pl_types,
1090 int len,
1091 bool rtcp_mux,
1092 bool secure) {
1093 ASSERT_EQ(2, len);
1094 int sequence_number1_1 = 0, sequence_number2_2 = 0;
1095 // Only pl_type1 was added to the bundle filter for both `channel1_`
1096 // and `channel2_`.
1097 int pl_type1 = pl_types[0];
1098 int pl_type2 = pl_types[1];
1099 int flags = SSRC_MUX;
1100 if (secure)
1101 flags |= DTLS;
1102 if (rtcp_mux) {
1103 flags |= RTCP_MUX;
1104 }
1105 CreateChannels(flags, flags);
1106 EXPECT_TRUE(SendInitiate());
1107 EXPECT_TRUE(SendAccept());
1108
1109 // Both channels can receive pl_type1 only.
1110 SendCustomRtp1(kSsrc1, ++sequence_number1_1, pl_type1);
1111 SendCustomRtp2(kSsrc2, ++sequence_number2_2, pl_type1);
1112 WaitForThreads();
1113 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1, pl_type1));
1114 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2, pl_type1));
1115 EXPECT_TRUE(CheckNoRtp1());
1116 EXPECT_TRUE(CheckNoRtp2());
1117
1118 SendCustomRtp1(kSsrc3, ++sequence_number1_1, pl_type2);
1119 SendCustomRtp2(kSsrc4, ++sequence_number2_2, pl_type2);
1120 WaitForThreads();
1121 EXPECT_FALSE(CheckCustomRtp2(kSsrc3, sequence_number1_1, pl_type2));
1122 EXPECT_FALSE(CheckCustomRtp1(kSsrc4, sequence_number2_2, pl_type2));
1123 }
1124
TestSetContentFailure()1125 void TestSetContentFailure() {
1126 CreateChannels(0, 0);
1127
1128 std::string err;
1129 std::unique_ptr<typename T::Content> content(
1130 CreateMediaContentWithStream(1));
1131
1132 media_channel1()->set_fail_set_recv_codecs(true);
1133 EXPECT_FALSE(
1134 channel1_->SetLocalContent(content.get(), SdpType::kOffer, err));
1135 EXPECT_FALSE(
1136 channel1_->SetLocalContent(content.get(), SdpType::kAnswer, err));
1137
1138 media_channel1()->set_fail_set_send_codecs(true);
1139 EXPECT_FALSE(
1140 channel1_->SetRemoteContent(content.get(), SdpType::kOffer, err));
1141
1142 media_channel1()->set_fail_set_send_codecs(true);
1143 EXPECT_FALSE(
1144 channel1_->SetRemoteContent(content.get(), SdpType::kAnswer, err));
1145 }
1146
TestSendTwoOffers()1147 void TestSendTwoOffers() {
1148 CreateChannels(0, 0);
1149
1150 std::string err;
1151 std::unique_ptr<typename T::Content> content1(
1152 CreateMediaContentWithStream(1));
1153 EXPECT_TRUE(
1154 channel1_->SetLocalContent(content1.get(), SdpType::kOffer, err));
1155 EXPECT_TRUE(media_channel1()->HasSendStream(1));
1156
1157 std::unique_ptr<typename T::Content> content2(
1158 CreateMediaContentWithStream(2));
1159 EXPECT_TRUE(
1160 channel1_->SetLocalContent(content2.get(), SdpType::kOffer, err));
1161 EXPECT_FALSE(media_channel1()->HasSendStream(1));
1162 EXPECT_TRUE(media_channel1()->HasSendStream(2));
1163 }
1164
TestReceiveTwoOffers()1165 void TestReceiveTwoOffers() {
1166 CreateChannels(0, 0);
1167
1168 std::string err;
1169 std::unique_ptr<typename T::Content> content1(
1170 CreateMediaContentWithStream(1));
1171 EXPECT_TRUE(
1172 channel1_->SetRemoteContent(content1.get(), SdpType::kOffer, err));
1173 EXPECT_TRUE(media_channel1()->HasRecvStream(1));
1174
1175 std::unique_ptr<typename T::Content> content2(
1176 CreateMediaContentWithStream(2));
1177 EXPECT_TRUE(
1178 channel1_->SetRemoteContent(content2.get(), SdpType::kOffer, err));
1179 EXPECT_FALSE(media_channel1()->HasRecvStream(1));
1180 EXPECT_TRUE(media_channel1()->HasRecvStream(2));
1181 }
1182
TestSendPrAnswer()1183 void TestSendPrAnswer() {
1184 CreateChannels(0, 0);
1185
1186 std::string err;
1187 // Receive offer
1188 std::unique_ptr<typename T::Content> content1(
1189 CreateMediaContentWithStream(1));
1190 EXPECT_TRUE(
1191 channel1_->SetRemoteContent(content1.get(), SdpType::kOffer, err));
1192 EXPECT_TRUE(media_channel1()->HasRecvStream(1));
1193
1194 // Send PR answer
1195 std::unique_ptr<typename T::Content> content2(
1196 CreateMediaContentWithStream(2));
1197 EXPECT_TRUE(
1198 channel1_->SetLocalContent(content2.get(), SdpType::kPrAnswer, err));
1199 EXPECT_TRUE(media_channel1()->HasRecvStream(1));
1200 EXPECT_TRUE(media_channel1()->HasSendStream(2));
1201
1202 // Send answer
1203 std::unique_ptr<typename T::Content> content3(
1204 CreateMediaContentWithStream(3));
1205 EXPECT_TRUE(
1206 channel1_->SetLocalContent(content3.get(), SdpType::kAnswer, err));
1207 EXPECT_TRUE(media_channel1()->HasRecvStream(1));
1208 EXPECT_FALSE(media_channel1()->HasSendStream(2));
1209 EXPECT_TRUE(media_channel1()->HasSendStream(3));
1210 }
1211
TestReceivePrAnswer()1212 void TestReceivePrAnswer() {
1213 CreateChannels(0, 0);
1214
1215 std::string err;
1216 // Send offer
1217 std::unique_ptr<typename T::Content> content1(
1218 CreateMediaContentWithStream(1));
1219 EXPECT_TRUE(
1220 channel1_->SetLocalContent(content1.get(), SdpType::kOffer, err));
1221 EXPECT_TRUE(media_channel1()->HasSendStream(1));
1222
1223 // Receive PR answer
1224 std::unique_ptr<typename T::Content> content2(
1225 CreateMediaContentWithStream(2));
1226 EXPECT_TRUE(
1227 channel1_->SetRemoteContent(content2.get(), SdpType::kPrAnswer, err));
1228 EXPECT_TRUE(media_channel1()->HasSendStream(1));
1229 EXPECT_TRUE(media_channel1()->HasRecvStream(2));
1230
1231 // Receive answer
1232 std::unique_ptr<typename T::Content> content3(
1233 CreateMediaContentWithStream(3));
1234 EXPECT_TRUE(
1235 channel1_->SetRemoteContent(content3.get(), SdpType::kAnswer, err));
1236 EXPECT_TRUE(media_channel1()->HasSendStream(1));
1237 EXPECT_FALSE(media_channel1()->HasRecvStream(2));
1238 EXPECT_TRUE(media_channel1()->HasRecvStream(3));
1239 }
1240
TestOnTransportReadyToSend()1241 void TestOnTransportReadyToSend() {
1242 CreateChannels(0, 0);
1243 EXPECT_FALSE(media_channel1()->ready_to_send());
1244
1245 network_thread_->PostTask(
1246 [this] { channel1_->OnTransportReadyToSend(true); });
1247 WaitForThreads();
1248 EXPECT_TRUE(media_channel1()->ready_to_send());
1249
1250 network_thread_->PostTask(
1251 [this] { channel1_->OnTransportReadyToSend(false); });
1252 WaitForThreads();
1253 EXPECT_FALSE(media_channel1()->ready_to_send());
1254 }
1255
SetRemoteContentWithBitrateLimit(int remote_limit)1256 bool SetRemoteContentWithBitrateLimit(int remote_limit) {
1257 typename T::Content content;
1258 CreateContent(0, kPcmuCodec, kH264Codec, &content);
1259 content.set_bandwidth(remote_limit);
1260 return channel1_->SetRemoteContent(&content, SdpType::kOffer, NULL);
1261 }
1262
BitrateLimitedParameters(absl::optional<int> limit)1263 webrtc::RtpParameters BitrateLimitedParameters(absl::optional<int> limit) {
1264 webrtc::RtpParameters parameters;
1265 webrtc::RtpEncodingParameters encoding;
1266 encoding.max_bitrate_bps = limit;
1267 parameters.encodings.push_back(encoding);
1268 return parameters;
1269 }
1270
VerifyMaxBitrate(const webrtc::RtpParameters & parameters,absl::optional<int> expected_bitrate)1271 void VerifyMaxBitrate(const webrtc::RtpParameters& parameters,
1272 absl::optional<int> expected_bitrate) {
1273 EXPECT_EQ(1UL, parameters.encodings.size());
1274 EXPECT_EQ(expected_bitrate, parameters.encodings[0].max_bitrate_bps);
1275 }
1276
DefaultMaxBitrateIsUnlimited()1277 void DefaultMaxBitrateIsUnlimited() {
1278 CreateChannels(0, 0);
1279 std::string err;
1280 EXPECT_TRUE(channel1_->SetLocalContent(&local_media_content1_,
1281 SdpType::kOffer, err));
1282 EXPECT_EQ(media_channel1()->max_bps(), -1);
1283 VerifyMaxBitrate(media_channel1()->GetRtpSendParameters(kSsrc1),
1284 absl::nullopt);
1285 }
1286
1287 // Test that when a channel gets new RtpTransport with a call to
1288 // `SetRtpTransport`, the socket options from the old RtpTransport is merged
1289 // with the options on the new one.
1290
1291 // For example, audio and video may use separate socket options, but initially
1292 // be unbundled, then later become bundled. When this happens, their preferred
1293 // socket options should be merged to the underlying transport they share.
SocketOptionsMergedOnSetTransport()1294 void SocketOptionsMergedOnSetTransport() {
1295 constexpr int kSndBufSize = 4000;
1296 constexpr int kRcvBufSize = 8000;
1297
1298 CreateChannels(DTLS, DTLS);
1299
1300 new_rtp_transport_ = CreateDtlsSrtpTransport(
1301 fake_rtp_dtls_transport2_.get(), fake_rtcp_dtls_transport2_.get());
1302
1303 bool rcv_success, send_success;
1304 int rcv_buf, send_buf;
1305 SendTask(network_thread_, [&] {
1306 channel1_->SetOption(cricket::BaseChannel::ST_RTP,
1307 rtc::Socket::Option::OPT_SNDBUF, kSndBufSize);
1308 channel2_->SetOption(cricket::BaseChannel::ST_RTP,
1309 rtc::Socket::Option::OPT_RCVBUF, kRcvBufSize);
1310 channel1_->SetRtpTransport(new_rtp_transport_.get());
1311 send_success = fake_rtp_dtls_transport2_->GetOption(
1312 rtc::Socket::Option::OPT_SNDBUF, &send_buf);
1313 rcv_success = fake_rtp_dtls_transport2_->GetOption(
1314 rtc::Socket::Option::OPT_RCVBUF, &rcv_buf);
1315 });
1316
1317 ASSERT_TRUE(send_success);
1318 EXPECT_EQ(kSndBufSize, send_buf);
1319 ASSERT_TRUE(rcv_success);
1320 EXPECT_EQ(kRcvBufSize, rcv_buf);
1321 }
1322
CreateSimulcastContent(const std::vector<std::string> & rids,typename T::Content * content)1323 void CreateSimulcastContent(const std::vector<std::string>& rids,
1324 typename T::Content* content) {
1325 std::vector<RidDescription> rid_descriptions;
1326 for (const std::string& name : rids) {
1327 rid_descriptions.push_back(RidDescription(name, RidDirection::kSend));
1328 }
1329
1330 StreamParams stream;
1331 stream.set_rids(rid_descriptions);
1332 CreateContent(0, kPcmuCodec, kH264Codec, content);
1333 // This is for unified plan, so there can be only one StreamParams.
1334 content->mutable_streams().clear();
1335 content->AddStream(stream);
1336 }
1337
VerifySimulcastStreamParams(const StreamParams & expected,const typename T::Channel * channel)1338 void VerifySimulcastStreamParams(const StreamParams& expected,
1339 const typename T::Channel* channel) {
1340 const std::vector<StreamParams>& streams = channel->local_streams();
1341 ASSERT_EQ(1u, streams.size());
1342 const StreamParams& result = streams[0];
1343 EXPECT_EQ(expected.rids(), result.rids());
1344 EXPECT_TRUE(result.has_ssrcs());
1345 EXPECT_EQ(expected.rids().size() * 2, result.ssrcs.size());
1346 std::vector<uint32_t> primary_ssrcs;
1347 result.GetPrimarySsrcs(&primary_ssrcs);
1348 EXPECT_EQ(expected.rids().size(), primary_ssrcs.size());
1349 }
1350
TestUpdateLocalStreamsWithSimulcast()1351 void TestUpdateLocalStreamsWithSimulcast() {
1352 CreateChannels(0, 0);
1353 typename T::Content content1, content2, content3;
1354 CreateSimulcastContent({"f", "h", "q"}, &content1);
1355 std::string err;
1356 EXPECT_TRUE(channel1_->SetLocalContent(&content1, SdpType::kOffer, err));
1357 VerifySimulcastStreamParams(content1.streams()[0], channel1_.get());
1358 StreamParams stream1 = channel1_->local_streams()[0];
1359
1360 // Create a similar offer. SetLocalContent should not remove and add.
1361 CreateSimulcastContent({"f", "h", "q"}, &content2);
1362 EXPECT_TRUE(channel1_->SetLocalContent(&content2, SdpType::kOffer, err));
1363 VerifySimulcastStreamParams(content2.streams()[0], channel1_.get());
1364 StreamParams stream2 = channel1_->local_streams()[0];
1365 // Check that the streams are identical (SSRCs didn't change).
1366 EXPECT_EQ(stream1, stream2);
1367
1368 // Create third offer that has same RIDs in different order.
1369 CreateSimulcastContent({"f", "q", "h"}, &content3);
1370 EXPECT_TRUE(channel1_->SetLocalContent(&content3, SdpType::kOffer, err));
1371 VerifySimulcastStreamParams(content3.streams()[0], channel1_.get());
1372 }
1373
1374 protected:
WaitForThreads()1375 void WaitForThreads() { WaitForThreads(rtc::ArrayView<rtc::Thread*>()); }
ProcessThreadQueue(rtc::Thread * thread)1376 static void ProcessThreadQueue(rtc::Thread* thread) {
1377 RTC_DCHECK(thread->IsCurrent());
1378 while (!thread->empty()) {
1379 thread->ProcessMessages(0);
1380 }
1381 }
FlushCurrentThread()1382 static void FlushCurrentThread() {
1383 rtc::Thread::Current()->ProcessMessages(0);
1384 }
WaitForThreads(rtc::ArrayView<rtc::Thread * > threads)1385 void WaitForThreads(rtc::ArrayView<rtc::Thread*> threads) {
1386 // `threads` and current thread post packets to network thread.
1387 for (rtc::Thread* thread : threads) {
1388 SendTask(thread, [thread] { ProcessThreadQueue(thread); });
1389 }
1390 ProcessThreadQueue(rtc::Thread::Current());
1391 // Network thread move them around and post back to worker = current thread.
1392 if (!network_thread_->IsCurrent()) {
1393 SendTask(network_thread_,
1394 [this] { ProcessThreadQueue(network_thread_); });
1395 }
1396 // Worker thread = current Thread process received messages.
1397 ProcessThreadQueue(rtc::Thread::Current());
1398 }
1399
media_channel1()1400 typename T::MediaChannel* media_channel1() {
1401 RTC_DCHECK(channel1_);
1402 RTC_DCHECK(channel1_->media_channel());
1403 return static_cast<typename T::MediaChannel*>(channel1_->media_channel());
1404 }
1405
media_channel2()1406 typename T::MediaChannel* media_channel2() {
1407 RTC_DCHECK(channel2_);
1408 RTC_DCHECK(channel2_->media_channel());
1409 return static_cast<typename T::MediaChannel*>(channel2_->media_channel());
1410 }
1411
1412 rtc::AutoThread main_thread_;
1413 // TODO(pbos): Remove playout from all media channels and let renderers mute
1414 // themselves.
1415 const bool verify_playout_;
1416 rtc::scoped_refptr<webrtc::PendingTaskSafetyFlag> network_thread_safety_ =
1417 webrtc::PendingTaskSafetyFlag::CreateDetached();
1418 std::unique_ptr<rtc::Thread> network_thread_keeper_;
1419 rtc::Thread* network_thread_;
1420 std::unique_ptr<cricket::FakeDtlsTransport> fake_rtp_dtls_transport1_;
1421 std::unique_ptr<cricket::FakeDtlsTransport> fake_rtcp_dtls_transport1_;
1422 std::unique_ptr<cricket::FakeDtlsTransport> fake_rtp_dtls_transport2_;
1423 std::unique_ptr<cricket::FakeDtlsTransport> fake_rtcp_dtls_transport2_;
1424 std::unique_ptr<rtc::FakePacketTransport> fake_rtp_packet_transport1_;
1425 std::unique_ptr<rtc::FakePacketTransport> fake_rtcp_packet_transport1_;
1426 std::unique_ptr<rtc::FakePacketTransport> fake_rtp_packet_transport2_;
1427 std::unique_ptr<rtc::FakePacketTransport> fake_rtcp_packet_transport2_;
1428 std::unique_ptr<webrtc::RtpTransportInternal> rtp_transport1_;
1429 std::unique_ptr<webrtc::RtpTransportInternal> rtp_transport2_;
1430 std::unique_ptr<webrtc::RtpTransportInternal> new_rtp_transport_;
1431 cricket::FakeMediaEngine media_engine_;
1432 std::unique_ptr<typename T::Channel> channel1_;
1433 std::unique_ptr<typename T::Channel> channel2_;
1434 typename T::Content local_media_content1_;
1435 typename T::Content local_media_content2_;
1436 typename T::Content remote_media_content1_;
1437 typename T::Content remote_media_content2_;
1438 // The RTP and RTCP packets to send in the tests.
1439 rtc::Buffer rtp_packet_;
1440 rtc::Buffer rtcp_packet_;
1441 cricket::CandidatePairInterface* last_selected_candidate_pair_;
1442 rtc::UniqueRandomIdGenerator ssrc_generator_;
1443 webrtc::test::ScopedKeyValueConfig field_trials_;
1444 };
1445
1446 template <>
CreateChannel(rtc::Thread * worker_thread,rtc::Thread * network_thread,std::unique_ptr<cricket::FakeVoiceMediaChannel> ch,webrtc::RtpTransportInternal * rtp_transport,int flags)1447 std::unique_ptr<cricket::VoiceChannel> ChannelTest<VoiceTraits>::CreateChannel(
1448 rtc::Thread* worker_thread,
1449 rtc::Thread* network_thread,
1450 std::unique_ptr<cricket::FakeVoiceMediaChannel> ch,
1451 webrtc::RtpTransportInternal* rtp_transport,
1452 int flags) {
1453 rtc::Thread* signaling_thread = rtc::Thread::Current();
1454 auto channel = std::make_unique<cricket::VoiceChannel>(
1455 worker_thread, network_thread, signaling_thread, std::move(ch),
1456 cricket::CN_AUDIO, (flags & DTLS) != 0, webrtc::CryptoOptions(),
1457 &ssrc_generator_);
1458 SendTask(network_thread, [&]() {
1459 RTC_DCHECK_RUN_ON(channel->network_thread());
1460 channel->SetRtpTransport(rtp_transport);
1461 });
1462 return channel;
1463 }
1464
1465 template <>
CreateContent(int flags,const cricket::AudioCodec & audio_codec,const cricket::VideoCodec & video_codec,cricket::AudioContentDescription * audio)1466 void ChannelTest<VoiceTraits>::CreateContent(
1467 int flags,
1468 const cricket::AudioCodec& audio_codec,
1469 const cricket::VideoCodec& video_codec,
1470 cricket::AudioContentDescription* audio) {
1471 audio->AddCodec(audio_codec);
1472 audio->set_rtcp_mux((flags & RTCP_MUX) != 0);
1473 }
1474
1475 template <>
CopyContent(const cricket::AudioContentDescription & source,cricket::AudioContentDescription * audio)1476 void ChannelTest<VoiceTraits>::CopyContent(
1477 const cricket::AudioContentDescription& source,
1478 cricket::AudioContentDescription* audio) {
1479 *audio = source;
1480 }
1481
1482 template <>
CodecMatches(const cricket::AudioCodec & c1,const cricket::AudioCodec & c2)1483 bool ChannelTest<VoiceTraits>::CodecMatches(const cricket::AudioCodec& c1,
1484 const cricket::AudioCodec& c2) {
1485 return c1.name == c2.name && c1.clockrate == c2.clockrate &&
1486 c1.bitrate == c2.bitrate && c1.channels == c2.channels;
1487 }
1488
1489 template <>
AddLegacyStreamInContent(uint32_t ssrc,int flags,cricket::AudioContentDescription * audio)1490 void ChannelTest<VoiceTraits>::AddLegacyStreamInContent(
1491 uint32_t ssrc,
1492 int flags,
1493 cricket::AudioContentDescription* audio) {
1494 audio->AddLegacyStream(ssrc);
1495 }
1496
1497 class VoiceChannelSingleThreadTest : public ChannelTest<VoiceTraits> {
1498 public:
1499 typedef ChannelTest<VoiceTraits> Base;
VoiceChannelSingleThreadTest()1500 VoiceChannelSingleThreadTest()
1501 : Base(true, kPcmuFrame, kRtcpReport, NetworkIsWorker::Yes) {}
1502 };
1503
1504 class VoiceChannelDoubleThreadTest : public ChannelTest<VoiceTraits> {
1505 public:
1506 typedef ChannelTest<VoiceTraits> Base;
VoiceChannelDoubleThreadTest()1507 VoiceChannelDoubleThreadTest()
1508 : Base(true, kPcmuFrame, kRtcpReport, NetworkIsWorker::No) {}
1509 };
1510
1511 class VoiceChannelWithEncryptedRtpHeaderExtensionsSingleThreadTest
1512 : public ChannelTest<VoiceTraits> {
1513 public:
1514 typedef ChannelTest<VoiceTraits> Base;
VoiceChannelWithEncryptedRtpHeaderExtensionsSingleThreadTest()1515 VoiceChannelWithEncryptedRtpHeaderExtensionsSingleThreadTest()
1516 : Base(true,
1517 kPcmuFrameWithExtensions,
1518 kRtcpReport,
1519 NetworkIsWorker::Yes) {}
1520 };
1521
1522 class VoiceChannelWithEncryptedRtpHeaderExtensionsDoubleThreadTest
1523 : public ChannelTest<VoiceTraits> {
1524 public:
1525 typedef ChannelTest<VoiceTraits> Base;
VoiceChannelWithEncryptedRtpHeaderExtensionsDoubleThreadTest()1526 VoiceChannelWithEncryptedRtpHeaderExtensionsDoubleThreadTest()
1527 : Base(true, kPcmuFrameWithExtensions, kRtcpReport, NetworkIsWorker::No) {
1528 }
1529 };
1530
1531 // override to add NULL parameter
1532 template <>
CreateChannel(rtc::Thread * worker_thread,rtc::Thread * network_thread,std::unique_ptr<cricket::FakeVideoMediaChannel> ch,webrtc::RtpTransportInternal * rtp_transport,int flags)1533 std::unique_ptr<cricket::VideoChannel> ChannelTest<VideoTraits>::CreateChannel(
1534 rtc::Thread* worker_thread,
1535 rtc::Thread* network_thread,
1536 std::unique_ptr<cricket::FakeVideoMediaChannel> ch,
1537 webrtc::RtpTransportInternal* rtp_transport,
1538 int flags) {
1539 rtc::Thread* signaling_thread = rtc::Thread::Current();
1540 auto channel = std::make_unique<cricket::VideoChannel>(
1541 worker_thread, network_thread, signaling_thread, std::move(ch),
1542 cricket::CN_VIDEO, (flags & DTLS) != 0, webrtc::CryptoOptions(),
1543 &ssrc_generator_);
1544 SendTask(network_thread, [&]() {
1545 RTC_DCHECK_RUN_ON(channel->network_thread());
1546 channel->SetRtpTransport(rtp_transport);
1547 });
1548 return channel;
1549 }
1550
1551 template <>
CreateContent(int flags,const cricket::AudioCodec & audio_codec,const cricket::VideoCodec & video_codec,cricket::VideoContentDescription * video)1552 void ChannelTest<VideoTraits>::CreateContent(
1553 int flags,
1554 const cricket::AudioCodec& audio_codec,
1555 const cricket::VideoCodec& video_codec,
1556 cricket::VideoContentDescription* video) {
1557 video->AddCodec(video_codec);
1558 video->set_rtcp_mux((flags & RTCP_MUX) != 0);
1559 }
1560
1561 template <>
CopyContent(const cricket::VideoContentDescription & source,cricket::VideoContentDescription * video)1562 void ChannelTest<VideoTraits>::CopyContent(
1563 const cricket::VideoContentDescription& source,
1564 cricket::VideoContentDescription* video) {
1565 *video = source;
1566 }
1567
1568 template <>
CodecMatches(const cricket::VideoCodec & c1,const cricket::VideoCodec & c2)1569 bool ChannelTest<VideoTraits>::CodecMatches(const cricket::VideoCodec& c1,
1570 const cricket::VideoCodec& c2) {
1571 return c1.name == c2.name;
1572 }
1573
1574 template <>
AddLegacyStreamInContent(uint32_t ssrc,int flags,cricket::VideoContentDescription * video)1575 void ChannelTest<VideoTraits>::AddLegacyStreamInContent(
1576 uint32_t ssrc,
1577 int flags,
1578 cricket::VideoContentDescription* video) {
1579 video->AddLegacyStream(ssrc);
1580 }
1581
1582 class VideoChannelSingleThreadTest : public ChannelTest<VideoTraits> {
1583 public:
1584 typedef ChannelTest<VideoTraits> Base;
VideoChannelSingleThreadTest()1585 VideoChannelSingleThreadTest()
1586 : Base(false, kH264Packet, kRtcpReport, NetworkIsWorker::Yes) {}
1587 };
1588
1589 class VideoChannelDoubleThreadTest : public ChannelTest<VideoTraits> {
1590 public:
1591 typedef ChannelTest<VideoTraits> Base;
VideoChannelDoubleThreadTest()1592 VideoChannelDoubleThreadTest()
1593 : Base(false, kH264Packet, kRtcpReport, NetworkIsWorker::No) {}
1594 };
1595
TEST_F(VoiceChannelSingleThreadTest,TestInit)1596 TEST_F(VoiceChannelSingleThreadTest, TestInit) {
1597 Base::TestInit();
1598 EXPECT_FALSE(media_channel1()->IsStreamMuted(0));
1599 EXPECT_TRUE(media_channel1()->dtmf_info_queue().empty());
1600 }
1601
TEST_F(VoiceChannelSingleThreadTest,TestDeinit)1602 TEST_F(VoiceChannelSingleThreadTest, TestDeinit) {
1603 Base::TestDeinit();
1604 }
1605
TEST_F(VoiceChannelSingleThreadTest,TestSetContents)1606 TEST_F(VoiceChannelSingleThreadTest, TestSetContents) {
1607 Base::TestSetContents();
1608 }
1609
TEST_F(VoiceChannelSingleThreadTest,TestSetContentsExtmapAllowMixedAsCaller)1610 TEST_F(VoiceChannelSingleThreadTest, TestSetContentsExtmapAllowMixedAsCaller) {
1611 Base::TestSetContentsExtmapAllowMixedCaller(/*offer=*/true, /*answer=*/true);
1612 }
1613
TEST_F(VoiceChannelSingleThreadTest,TestSetContentsExtmapAllowMixedNotSupportedAsCaller)1614 TEST_F(VoiceChannelSingleThreadTest,
1615 TestSetContentsExtmapAllowMixedNotSupportedAsCaller) {
1616 Base::TestSetContentsExtmapAllowMixedCaller(/*offer=*/true, /*answer=*/false);
1617 }
1618
TEST_F(VoiceChannelSingleThreadTest,TestSetContentsExtmapAllowMixedAsCallee)1619 TEST_F(VoiceChannelSingleThreadTest, TestSetContentsExtmapAllowMixedAsCallee) {
1620 Base::TestSetContentsExtmapAllowMixedCallee(/*offer=*/true, /*answer=*/true);
1621 }
1622
TEST_F(VoiceChannelSingleThreadTest,TestSetContentsExtmapAllowMixedNotSupportedAsCallee)1623 TEST_F(VoiceChannelSingleThreadTest,
1624 TestSetContentsExtmapAllowMixedNotSupportedAsCallee) {
1625 Base::TestSetContentsExtmapAllowMixedCallee(/*offer=*/true, /*answer=*/false);
1626 }
1627
TEST_F(VoiceChannelSingleThreadTest,TestSetContentsNullOffer)1628 TEST_F(VoiceChannelSingleThreadTest, TestSetContentsNullOffer) {
1629 Base::TestSetContentsNullOffer();
1630 }
1631
TEST_F(VoiceChannelSingleThreadTest,TestSetContentsRtcpMux)1632 TEST_F(VoiceChannelSingleThreadTest, TestSetContentsRtcpMux) {
1633 Base::TestSetContentsRtcpMux();
1634 }
1635
TEST_F(VoiceChannelSingleThreadTest,TestSetContentsRtcpMuxWithPrAnswer)1636 TEST_F(VoiceChannelSingleThreadTest, TestSetContentsRtcpMuxWithPrAnswer) {
1637 Base::TestSetContentsRtcpMux();
1638 }
1639
TEST_F(VoiceChannelSingleThreadTest,TestChangeStreamParamsInContent)1640 TEST_F(VoiceChannelSingleThreadTest, TestChangeStreamParamsInContent) {
1641 Base::TestChangeStreamParamsInContent();
1642 }
1643
TEST_F(VoiceChannelSingleThreadTest,TestPlayoutAndSendingStates)1644 TEST_F(VoiceChannelSingleThreadTest, TestPlayoutAndSendingStates) {
1645 Base::TestPlayoutAndSendingStates();
1646 }
1647
TEST_F(VoiceChannelSingleThreadTest,TestMediaContentDirection)1648 TEST_F(VoiceChannelSingleThreadTest, TestMediaContentDirection) {
1649 Base::TestMediaContentDirection();
1650 }
1651
TEST_F(VoiceChannelSingleThreadTest,TestNetworkRouteChanges)1652 TEST_F(VoiceChannelSingleThreadTest, TestNetworkRouteChanges) {
1653 Base::TestNetworkRouteChanges();
1654 }
1655
TEST_F(VoiceChannelSingleThreadTest,TestCallSetup)1656 TEST_F(VoiceChannelSingleThreadTest, TestCallSetup) {
1657 Base::TestCallSetup();
1658 }
1659
TEST_F(VoiceChannelSingleThreadTest,SendRtpToRtp)1660 TEST_F(VoiceChannelSingleThreadTest, SendRtpToRtp) {
1661 Base::SendRtpToRtp();
1662 }
1663
TEST_F(VoiceChannelSingleThreadTest,SendDtlsSrtpToDtlsSrtp)1664 TEST_F(VoiceChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtp) {
1665 Base::SendDtlsSrtpToDtlsSrtp(0, 0);
1666 }
1667
TEST_F(VoiceChannelSingleThreadTest,SendDtlsSrtpToDtlsSrtpRtcpMux)1668 TEST_F(VoiceChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) {
1669 Base::SendDtlsSrtpToDtlsSrtp(RTCP_MUX, RTCP_MUX);
1670 }
1671
TEST_F(VoiceChannelSingleThreadTest,SendEarlyMediaUsingRtcpMuxSrtp)1672 TEST_F(VoiceChannelSingleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) {
1673 Base::SendEarlyMediaUsingRtcpMuxSrtp();
1674 }
1675
TEST_F(VoiceChannelSingleThreadTest,SendRtpToRtpOnThread)1676 TEST_F(VoiceChannelSingleThreadTest, SendRtpToRtpOnThread) {
1677 Base::SendRtpToRtpOnThread();
1678 }
1679
TEST_F(VoiceChannelSingleThreadTest,SendWithWritabilityLoss)1680 TEST_F(VoiceChannelSingleThreadTest, SendWithWritabilityLoss) {
1681 Base::SendWithWritabilityLoss();
1682 }
1683
TEST_F(VoiceChannelSingleThreadTest,TestSetContentFailure)1684 TEST_F(VoiceChannelSingleThreadTest, TestSetContentFailure) {
1685 Base::TestSetContentFailure();
1686 }
1687
TEST_F(VoiceChannelSingleThreadTest,TestSendTwoOffers)1688 TEST_F(VoiceChannelSingleThreadTest, TestSendTwoOffers) {
1689 Base::TestSendTwoOffers();
1690 }
1691
TEST_F(VoiceChannelSingleThreadTest,TestReceiveTwoOffers)1692 TEST_F(VoiceChannelSingleThreadTest, TestReceiveTwoOffers) {
1693 Base::TestReceiveTwoOffers();
1694 }
1695
TEST_F(VoiceChannelSingleThreadTest,TestSendPrAnswer)1696 TEST_F(VoiceChannelSingleThreadTest, TestSendPrAnswer) {
1697 Base::TestSendPrAnswer();
1698 }
1699
TEST_F(VoiceChannelSingleThreadTest,TestReceivePrAnswer)1700 TEST_F(VoiceChannelSingleThreadTest, TestReceivePrAnswer) {
1701 Base::TestReceivePrAnswer();
1702 }
1703
TEST_F(VoiceChannelSingleThreadTest,TestOnTransportReadyToSend)1704 TEST_F(VoiceChannelSingleThreadTest, TestOnTransportReadyToSend) {
1705 Base::TestOnTransportReadyToSend();
1706 }
1707
TEST_F(VoiceChannelSingleThreadTest,SendBundleToBundle)1708 TEST_F(VoiceChannelSingleThreadTest, SendBundleToBundle) {
1709 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, false);
1710 }
1711
TEST_F(VoiceChannelSingleThreadTest,SendBundleToBundleSecure)1712 TEST_F(VoiceChannelSingleThreadTest, SendBundleToBundleSecure) {
1713 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, true);
1714 }
1715
TEST_F(VoiceChannelSingleThreadTest,SendBundleToBundleWithRtcpMux)1716 TEST_F(VoiceChannelSingleThreadTest, SendBundleToBundleWithRtcpMux) {
1717 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, false);
1718 }
1719
TEST_F(VoiceChannelSingleThreadTest,SendBundleToBundleWithRtcpMuxSecure)1720 TEST_F(VoiceChannelSingleThreadTest, SendBundleToBundleWithRtcpMuxSecure) {
1721 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, true);
1722 }
1723
TEST_F(VoiceChannelSingleThreadTest,DefaultMaxBitrateIsUnlimited)1724 TEST_F(VoiceChannelSingleThreadTest, DefaultMaxBitrateIsUnlimited) {
1725 Base::DefaultMaxBitrateIsUnlimited();
1726 }
1727
TEST_F(VoiceChannelSingleThreadTest,SocketOptionsMergedOnSetTransport)1728 TEST_F(VoiceChannelSingleThreadTest, SocketOptionsMergedOnSetTransport) {
1729 Base::SocketOptionsMergedOnSetTransport();
1730 }
1731
1732 // VoiceChannelDoubleThreadTest
TEST_F(VoiceChannelDoubleThreadTest,TestInit)1733 TEST_F(VoiceChannelDoubleThreadTest, TestInit) {
1734 Base::TestInit();
1735 EXPECT_FALSE(media_channel1()->IsStreamMuted(0));
1736 EXPECT_TRUE(media_channel1()->dtmf_info_queue().empty());
1737 }
1738
TEST_F(VoiceChannelDoubleThreadTest,TestDeinit)1739 TEST_F(VoiceChannelDoubleThreadTest, TestDeinit) {
1740 Base::TestDeinit();
1741 }
1742
TEST_F(VoiceChannelDoubleThreadTest,TestSetContents)1743 TEST_F(VoiceChannelDoubleThreadTest, TestSetContents) {
1744 Base::TestSetContents();
1745 }
1746
TEST_F(VoiceChannelDoubleThreadTest,TestSetContentsExtmapAllowMixedAsCaller)1747 TEST_F(VoiceChannelDoubleThreadTest, TestSetContentsExtmapAllowMixedAsCaller) {
1748 Base::TestSetContentsExtmapAllowMixedCaller(/*offer=*/true, /*answer=*/true);
1749 }
1750
TEST_F(VoiceChannelDoubleThreadTest,TestSetContentsExtmapAllowMixedNotSupportedAsCaller)1751 TEST_F(VoiceChannelDoubleThreadTest,
1752 TestSetContentsExtmapAllowMixedNotSupportedAsCaller) {
1753 Base::TestSetContentsExtmapAllowMixedCaller(/*offer=*/true, /*answer=*/false);
1754 }
1755
TEST_F(VoiceChannelDoubleThreadTest,TestSetContentsExtmapAllowMixedAsCallee)1756 TEST_F(VoiceChannelDoubleThreadTest, TestSetContentsExtmapAllowMixedAsCallee) {
1757 Base::TestSetContentsExtmapAllowMixedCallee(/*offer=*/true, /*answer=*/true);
1758 }
1759
TEST_F(VoiceChannelDoubleThreadTest,TestSetContentsExtmapAllowMixedNotSupportedAsCallee)1760 TEST_F(VoiceChannelDoubleThreadTest,
1761 TestSetContentsExtmapAllowMixedNotSupportedAsCallee) {
1762 Base::TestSetContentsExtmapAllowMixedCallee(/*offer=*/true, /*answer=*/false);
1763 }
1764
TEST_F(VoiceChannelDoubleThreadTest,TestSetContentsNullOffer)1765 TEST_F(VoiceChannelDoubleThreadTest, TestSetContentsNullOffer) {
1766 Base::TestSetContentsNullOffer();
1767 }
1768
TEST_F(VoiceChannelDoubleThreadTest,TestSetContentsRtcpMux)1769 TEST_F(VoiceChannelDoubleThreadTest, TestSetContentsRtcpMux) {
1770 Base::TestSetContentsRtcpMux();
1771 }
1772
TEST_F(VoiceChannelDoubleThreadTest,TestSetContentsRtcpMuxWithPrAnswer)1773 TEST_F(VoiceChannelDoubleThreadTest, TestSetContentsRtcpMuxWithPrAnswer) {
1774 Base::TestSetContentsRtcpMux();
1775 }
1776
TEST_F(VoiceChannelDoubleThreadTest,TestChangeStreamParamsInContent)1777 TEST_F(VoiceChannelDoubleThreadTest, TestChangeStreamParamsInContent) {
1778 Base::TestChangeStreamParamsInContent();
1779 }
1780
TEST_F(VoiceChannelDoubleThreadTest,TestPlayoutAndSendingStates)1781 TEST_F(VoiceChannelDoubleThreadTest, TestPlayoutAndSendingStates) {
1782 Base::TestPlayoutAndSendingStates();
1783 }
1784
TEST_F(VoiceChannelDoubleThreadTest,TestMediaContentDirection)1785 TEST_F(VoiceChannelDoubleThreadTest, TestMediaContentDirection) {
1786 Base::TestMediaContentDirection();
1787 }
1788
TEST_F(VoiceChannelDoubleThreadTest,TestNetworkRouteChanges)1789 TEST_F(VoiceChannelDoubleThreadTest, TestNetworkRouteChanges) {
1790 Base::TestNetworkRouteChanges();
1791 }
1792
TEST_F(VoiceChannelDoubleThreadTest,TestCallSetup)1793 TEST_F(VoiceChannelDoubleThreadTest, TestCallSetup) {
1794 Base::TestCallSetup();
1795 }
1796
TEST_F(VoiceChannelDoubleThreadTest,SendRtpToRtp)1797 TEST_F(VoiceChannelDoubleThreadTest, SendRtpToRtp) {
1798 Base::SendRtpToRtp();
1799 }
1800
TEST_F(VoiceChannelDoubleThreadTest,SendDtlsSrtpToDtlsSrtp)1801 TEST_F(VoiceChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtp) {
1802 Base::SendDtlsSrtpToDtlsSrtp(0, 0);
1803 }
1804
TEST_F(VoiceChannelDoubleThreadTest,SendDtlsSrtpToDtlsSrtpRtcpMux)1805 TEST_F(VoiceChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) {
1806 Base::SendDtlsSrtpToDtlsSrtp(RTCP_MUX, RTCP_MUX);
1807 }
1808
TEST_F(VoiceChannelDoubleThreadTest,SendEarlyMediaUsingRtcpMuxSrtp)1809 TEST_F(VoiceChannelDoubleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) {
1810 Base::SendEarlyMediaUsingRtcpMuxSrtp();
1811 }
1812
TEST_F(VoiceChannelDoubleThreadTest,SendRtpToRtpOnThread)1813 TEST_F(VoiceChannelDoubleThreadTest, SendRtpToRtpOnThread) {
1814 Base::SendRtpToRtpOnThread();
1815 }
1816
TEST_F(VoiceChannelDoubleThreadTest,SendWithWritabilityLoss)1817 TEST_F(VoiceChannelDoubleThreadTest, SendWithWritabilityLoss) {
1818 Base::SendWithWritabilityLoss();
1819 }
1820
TEST_F(VoiceChannelDoubleThreadTest,TestSetContentFailure)1821 TEST_F(VoiceChannelDoubleThreadTest, TestSetContentFailure) {
1822 Base::TestSetContentFailure();
1823 }
1824
TEST_F(VoiceChannelDoubleThreadTest,TestSendTwoOffers)1825 TEST_F(VoiceChannelDoubleThreadTest, TestSendTwoOffers) {
1826 Base::TestSendTwoOffers();
1827 }
1828
TEST_F(VoiceChannelDoubleThreadTest,TestReceiveTwoOffers)1829 TEST_F(VoiceChannelDoubleThreadTest, TestReceiveTwoOffers) {
1830 Base::TestReceiveTwoOffers();
1831 }
1832
TEST_F(VoiceChannelDoubleThreadTest,TestSendPrAnswer)1833 TEST_F(VoiceChannelDoubleThreadTest, TestSendPrAnswer) {
1834 Base::TestSendPrAnswer();
1835 }
1836
TEST_F(VoiceChannelDoubleThreadTest,TestReceivePrAnswer)1837 TEST_F(VoiceChannelDoubleThreadTest, TestReceivePrAnswer) {
1838 Base::TestReceivePrAnswer();
1839 }
1840
TEST_F(VoiceChannelDoubleThreadTest,TestOnTransportReadyToSend)1841 TEST_F(VoiceChannelDoubleThreadTest, TestOnTransportReadyToSend) {
1842 Base::TestOnTransportReadyToSend();
1843 }
1844
TEST_F(VoiceChannelDoubleThreadTest,SendBundleToBundle)1845 TEST_F(VoiceChannelDoubleThreadTest, SendBundleToBundle) {
1846 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, false);
1847 }
1848
TEST_F(VoiceChannelDoubleThreadTest,SendBundleToBundleSecure)1849 TEST_F(VoiceChannelDoubleThreadTest, SendBundleToBundleSecure) {
1850 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, true);
1851 }
1852
TEST_F(VoiceChannelDoubleThreadTest,SendBundleToBundleWithRtcpMux)1853 TEST_F(VoiceChannelDoubleThreadTest, SendBundleToBundleWithRtcpMux) {
1854 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, false);
1855 }
1856
TEST_F(VoiceChannelDoubleThreadTest,SendBundleToBundleWithRtcpMuxSecure)1857 TEST_F(VoiceChannelDoubleThreadTest, SendBundleToBundleWithRtcpMuxSecure) {
1858 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, true);
1859 }
1860
TEST_F(VoiceChannelDoubleThreadTest,DefaultMaxBitrateIsUnlimited)1861 TEST_F(VoiceChannelDoubleThreadTest, DefaultMaxBitrateIsUnlimited) {
1862 Base::DefaultMaxBitrateIsUnlimited();
1863 }
1864
TEST_F(VoiceChannelDoubleThreadTest,SocketOptionsMergedOnSetTransport)1865 TEST_F(VoiceChannelDoubleThreadTest, SocketOptionsMergedOnSetTransport) {
1866 Base::SocketOptionsMergedOnSetTransport();
1867 }
1868
1869 // VideoChannelSingleThreadTest
TEST_F(VideoChannelSingleThreadTest,TestInit)1870 TEST_F(VideoChannelSingleThreadTest, TestInit) {
1871 Base::TestInit();
1872 }
1873
TEST_F(VideoChannelSingleThreadTest,TestDeinit)1874 TEST_F(VideoChannelSingleThreadTest, TestDeinit) {
1875 Base::TestDeinit();
1876 }
1877
TEST_F(VideoChannelSingleThreadTest,TestSetContents)1878 TEST_F(VideoChannelSingleThreadTest, TestSetContents) {
1879 Base::TestSetContents();
1880 }
1881
TEST_F(VideoChannelSingleThreadTest,TestSetContentsExtmapAllowMixedAsCaller)1882 TEST_F(VideoChannelSingleThreadTest, TestSetContentsExtmapAllowMixedAsCaller) {
1883 Base::TestSetContentsExtmapAllowMixedCaller(/*offer=*/true, /*answer=*/true);
1884 }
1885
TEST_F(VideoChannelSingleThreadTest,TestSetContentsExtmapAllowMixedNotSupportedAsCaller)1886 TEST_F(VideoChannelSingleThreadTest,
1887 TestSetContentsExtmapAllowMixedNotSupportedAsCaller) {
1888 Base::TestSetContentsExtmapAllowMixedCaller(/*offer=*/true, /*answer=*/false);
1889 }
1890
TEST_F(VideoChannelSingleThreadTest,TestSetContentsExtmapAllowMixedAsCallee)1891 TEST_F(VideoChannelSingleThreadTest, TestSetContentsExtmapAllowMixedAsCallee) {
1892 Base::TestSetContentsExtmapAllowMixedCallee(/*offer=*/true, /*answer=*/true);
1893 }
1894
TEST_F(VideoChannelSingleThreadTest,TestSetContentsExtmapAllowMixedNotSupportedAsCallee)1895 TEST_F(VideoChannelSingleThreadTest,
1896 TestSetContentsExtmapAllowMixedNotSupportedAsCallee) {
1897 Base::TestSetContentsExtmapAllowMixedCallee(/*offer=*/true, /*answer=*/false);
1898 }
1899
TEST_F(VideoChannelSingleThreadTest,TestSetContentsNullOffer)1900 TEST_F(VideoChannelSingleThreadTest, TestSetContentsNullOffer) {
1901 Base::TestSetContentsNullOffer();
1902 }
1903
TEST_F(VideoChannelSingleThreadTest,TestSetContentsRtcpMux)1904 TEST_F(VideoChannelSingleThreadTest, TestSetContentsRtcpMux) {
1905 Base::TestSetContentsRtcpMux();
1906 }
1907
TEST_F(VideoChannelSingleThreadTest,TestSetContentsRtcpMuxWithPrAnswer)1908 TEST_F(VideoChannelSingleThreadTest, TestSetContentsRtcpMuxWithPrAnswer) {
1909 Base::TestSetContentsRtcpMux();
1910 }
1911
TEST_F(VideoChannelSingleThreadTest,TestChangeStreamParamsInContent)1912 TEST_F(VideoChannelSingleThreadTest, TestChangeStreamParamsInContent) {
1913 Base::TestChangeStreamParamsInContent();
1914 }
1915
TEST_F(VideoChannelSingleThreadTest,TestPlayoutAndSendingStates)1916 TEST_F(VideoChannelSingleThreadTest, TestPlayoutAndSendingStates) {
1917 Base::TestPlayoutAndSendingStates();
1918 }
1919
TEST_F(VideoChannelSingleThreadTest,TestMediaContentDirection)1920 TEST_F(VideoChannelSingleThreadTest, TestMediaContentDirection) {
1921 Base::TestMediaContentDirection();
1922 }
1923
TEST_F(VideoChannelSingleThreadTest,TestNetworkRouteChanges)1924 TEST_F(VideoChannelSingleThreadTest, TestNetworkRouteChanges) {
1925 Base::TestNetworkRouteChanges();
1926 }
1927
TEST_F(VideoChannelSingleThreadTest,TestCallSetup)1928 TEST_F(VideoChannelSingleThreadTest, TestCallSetup) {
1929 Base::TestCallSetup();
1930 }
1931
TEST_F(VideoChannelSingleThreadTest,SendRtpToRtp)1932 TEST_F(VideoChannelSingleThreadTest, SendRtpToRtp) {
1933 Base::SendRtpToRtp();
1934 }
1935
TEST_F(VideoChannelSingleThreadTest,SendDtlsSrtpToDtlsSrtp)1936 TEST_F(VideoChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtp) {
1937 Base::SendDtlsSrtpToDtlsSrtp(0, 0);
1938 }
1939
TEST_F(VideoChannelSingleThreadTest,SendDtlsSrtpToDtlsSrtpRtcpMux)1940 TEST_F(VideoChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) {
1941 Base::SendDtlsSrtpToDtlsSrtp(RTCP_MUX, RTCP_MUX);
1942 }
1943
TEST_F(VideoChannelSingleThreadTest,SendEarlyMediaUsingRtcpMuxSrtp)1944 TEST_F(VideoChannelSingleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) {
1945 Base::SendEarlyMediaUsingRtcpMuxSrtp();
1946 }
1947
TEST_F(VideoChannelSingleThreadTest,SendRtpToRtpOnThread)1948 TEST_F(VideoChannelSingleThreadTest, SendRtpToRtpOnThread) {
1949 Base::SendRtpToRtpOnThread();
1950 }
1951
TEST_F(VideoChannelSingleThreadTest,SendWithWritabilityLoss)1952 TEST_F(VideoChannelSingleThreadTest, SendWithWritabilityLoss) {
1953 Base::SendWithWritabilityLoss();
1954 }
1955
TEST_F(VideoChannelSingleThreadTest,TestSetContentFailure)1956 TEST_F(VideoChannelSingleThreadTest, TestSetContentFailure) {
1957 Base::TestSetContentFailure();
1958 }
1959
TEST_F(VideoChannelSingleThreadTest,TestSendTwoOffers)1960 TEST_F(VideoChannelSingleThreadTest, TestSendTwoOffers) {
1961 Base::TestSendTwoOffers();
1962 }
1963
TEST_F(VideoChannelSingleThreadTest,TestReceiveTwoOffers)1964 TEST_F(VideoChannelSingleThreadTest, TestReceiveTwoOffers) {
1965 Base::TestReceiveTwoOffers();
1966 }
1967
TEST_F(VideoChannelSingleThreadTest,TestSendPrAnswer)1968 TEST_F(VideoChannelSingleThreadTest, TestSendPrAnswer) {
1969 Base::TestSendPrAnswer();
1970 }
1971
TEST_F(VideoChannelSingleThreadTest,TestReceivePrAnswer)1972 TEST_F(VideoChannelSingleThreadTest, TestReceivePrAnswer) {
1973 Base::TestReceivePrAnswer();
1974 }
1975
TEST_F(VideoChannelSingleThreadTest,SendBundleToBundle)1976 TEST_F(VideoChannelSingleThreadTest, SendBundleToBundle) {
1977 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, false);
1978 }
1979
TEST_F(VideoChannelSingleThreadTest,SendBundleToBundleSecure)1980 TEST_F(VideoChannelSingleThreadTest, SendBundleToBundleSecure) {
1981 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, true);
1982 }
1983
TEST_F(VideoChannelSingleThreadTest,SendBundleToBundleWithRtcpMux)1984 TEST_F(VideoChannelSingleThreadTest, SendBundleToBundleWithRtcpMux) {
1985 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, false);
1986 }
1987
TEST_F(VideoChannelSingleThreadTest,SendBundleToBundleWithRtcpMuxSecure)1988 TEST_F(VideoChannelSingleThreadTest, SendBundleToBundleWithRtcpMuxSecure) {
1989 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, true);
1990 }
1991
TEST_F(VideoChannelSingleThreadTest,TestOnTransportReadyToSend)1992 TEST_F(VideoChannelSingleThreadTest, TestOnTransportReadyToSend) {
1993 Base::TestOnTransportReadyToSend();
1994 }
1995
TEST_F(VideoChannelSingleThreadTest,DefaultMaxBitrateIsUnlimited)1996 TEST_F(VideoChannelSingleThreadTest, DefaultMaxBitrateIsUnlimited) {
1997 Base::DefaultMaxBitrateIsUnlimited();
1998 }
1999
TEST_F(VideoChannelSingleThreadTest,SocketOptionsMergedOnSetTransport)2000 TEST_F(VideoChannelSingleThreadTest, SocketOptionsMergedOnSetTransport) {
2001 Base::SocketOptionsMergedOnSetTransport();
2002 }
2003
TEST_F(VideoChannelSingleThreadTest,UpdateLocalStreamsWithSimulcast)2004 TEST_F(VideoChannelSingleThreadTest, UpdateLocalStreamsWithSimulcast) {
2005 Base::TestUpdateLocalStreamsWithSimulcast();
2006 }
2007
TEST_F(VideoChannelSingleThreadTest,TestSetLocalOfferWithPacketization)2008 TEST_F(VideoChannelSingleThreadTest, TestSetLocalOfferWithPacketization) {
2009 const cricket::VideoCodec kVp8Codec(97, "VP8");
2010 cricket::VideoCodec vp9_codec(98, "VP9");
2011 vp9_codec.packetization = cricket::kPacketizationParamRaw;
2012 cricket::VideoContentDescription video;
2013 video.set_codecs({kVp8Codec, vp9_codec});
2014
2015 CreateChannels(0, 0);
2016
2017 std::string err;
2018 EXPECT_TRUE(channel1_->SetLocalContent(&video, SdpType::kOffer, err));
2019 EXPECT_THAT(media_channel1()->send_codecs(), testing::IsEmpty());
2020 ASSERT_THAT(media_channel1()->recv_codecs(), testing::SizeIs(2));
2021 EXPECT_TRUE(
2022 media_channel1()->recv_codecs()[0].Matches(kVp8Codec, &field_trials_));
2023 EXPECT_EQ(media_channel1()->recv_codecs()[0].packetization, absl::nullopt);
2024 EXPECT_TRUE(
2025 media_channel1()->recv_codecs()[1].Matches(vp9_codec, &field_trials_));
2026 EXPECT_EQ(media_channel1()->recv_codecs()[1].packetization,
2027 cricket::kPacketizationParamRaw);
2028 }
2029
TEST_F(VideoChannelSingleThreadTest,TestSetRemoteOfferWithPacketization)2030 TEST_F(VideoChannelSingleThreadTest, TestSetRemoteOfferWithPacketization) {
2031 const cricket::VideoCodec kVp8Codec(97, "VP8");
2032 cricket::VideoCodec vp9_codec(98, "VP9");
2033 vp9_codec.packetization = cricket::kPacketizationParamRaw;
2034 cricket::VideoContentDescription video;
2035 video.set_codecs({kVp8Codec, vp9_codec});
2036
2037 CreateChannels(0, 0);
2038
2039 std::string err;
2040 EXPECT_TRUE(channel1_->SetRemoteContent(&video, SdpType::kOffer, err));
2041 EXPECT_TRUE(err.empty());
2042 EXPECT_THAT(media_channel1()->recv_codecs(), testing::IsEmpty());
2043 ASSERT_THAT(media_channel1()->send_codecs(), testing::SizeIs(2));
2044 EXPECT_TRUE(
2045 media_channel1()->send_codecs()[0].Matches(kVp8Codec, &field_trials_));
2046 EXPECT_EQ(media_channel1()->send_codecs()[0].packetization, absl::nullopt);
2047 EXPECT_TRUE(
2048 media_channel1()->send_codecs()[1].Matches(vp9_codec, &field_trials_));
2049 EXPECT_EQ(media_channel1()->send_codecs()[1].packetization,
2050 cricket::kPacketizationParamRaw);
2051 }
2052
TEST_F(VideoChannelSingleThreadTest,TestSetAnswerWithPacketization)2053 TEST_F(VideoChannelSingleThreadTest, TestSetAnswerWithPacketization) {
2054 const cricket::VideoCodec kVp8Codec(97, "VP8");
2055 cricket::VideoCodec vp9_codec(98, "VP9");
2056 vp9_codec.packetization = cricket::kPacketizationParamRaw;
2057 cricket::VideoContentDescription video;
2058 video.set_codecs({kVp8Codec, vp9_codec});
2059
2060 CreateChannels(0, 0);
2061
2062 std::string err;
2063 EXPECT_TRUE(channel1_->SetLocalContent(&video, SdpType::kOffer, err));
2064 EXPECT_TRUE(err.empty());
2065 EXPECT_TRUE(channel1_->SetRemoteContent(&video, SdpType::kAnswer, err));
2066 EXPECT_TRUE(err.empty());
2067 ASSERT_THAT(media_channel1()->recv_codecs(), testing::SizeIs(2));
2068 EXPECT_TRUE(
2069 media_channel1()->recv_codecs()[0].Matches(kVp8Codec, &field_trials_));
2070 EXPECT_EQ(media_channel1()->recv_codecs()[0].packetization, absl::nullopt);
2071 EXPECT_TRUE(
2072 media_channel1()->recv_codecs()[1].Matches(vp9_codec, &field_trials_));
2073 EXPECT_EQ(media_channel1()->recv_codecs()[1].packetization,
2074 cricket::kPacketizationParamRaw);
2075 EXPECT_THAT(media_channel1()->send_codecs(), testing::SizeIs(2));
2076 EXPECT_TRUE(
2077 media_channel1()->send_codecs()[0].Matches(kVp8Codec, &field_trials_));
2078 EXPECT_EQ(media_channel1()->send_codecs()[0].packetization, absl::nullopt);
2079 EXPECT_TRUE(
2080 media_channel1()->send_codecs()[1].Matches(vp9_codec, &field_trials_));
2081 EXPECT_EQ(media_channel1()->send_codecs()[1].packetization,
2082 cricket::kPacketizationParamRaw);
2083 }
2084
TEST_F(VideoChannelSingleThreadTest,TestSetLocalAnswerWithoutPacketization)2085 TEST_F(VideoChannelSingleThreadTest, TestSetLocalAnswerWithoutPacketization) {
2086 const cricket::VideoCodec kLocalCodec(98, "VP8");
2087 cricket::VideoCodec remote_codec(99, "VP8");
2088 remote_codec.packetization = cricket::kPacketizationParamRaw;
2089 cricket::VideoContentDescription local_video;
2090 local_video.set_codecs({kLocalCodec});
2091 cricket::VideoContentDescription remote_video;
2092 remote_video.set_codecs({remote_codec});
2093
2094 CreateChannels(0, 0);
2095
2096 std::string err;
2097 EXPECT_TRUE(channel1_->SetRemoteContent(&remote_video, SdpType::kOffer, err));
2098 EXPECT_TRUE(channel1_->SetLocalContent(&local_video, SdpType::kAnswer, err));
2099 ASSERT_THAT(media_channel1()->recv_codecs(), testing::SizeIs(1));
2100 EXPECT_EQ(media_channel1()->recv_codecs()[0].packetization, absl::nullopt);
2101 ASSERT_THAT(media_channel1()->send_codecs(), testing::SizeIs(1));
2102 EXPECT_EQ(media_channel1()->send_codecs()[0].packetization, absl::nullopt);
2103 }
2104
TEST_F(VideoChannelSingleThreadTest,TestSetRemoteAnswerWithoutPacketization)2105 TEST_F(VideoChannelSingleThreadTest, TestSetRemoteAnswerWithoutPacketization) {
2106 cricket::VideoCodec local_codec(98, "VP8");
2107 local_codec.packetization = cricket::kPacketizationParamRaw;
2108 const cricket::VideoCodec kRemoteCodec(99, "VP8");
2109 cricket::VideoContentDescription local_video;
2110 local_video.set_codecs({local_codec});
2111 cricket::VideoContentDescription remote_video;
2112 remote_video.set_codecs({kRemoteCodec});
2113
2114 CreateChannels(0, 0);
2115
2116 std::string err;
2117 EXPECT_TRUE(channel1_->SetLocalContent(&local_video, SdpType::kOffer, err));
2118 EXPECT_TRUE(
2119 channel1_->SetRemoteContent(&remote_video, SdpType::kAnswer, err));
2120 ASSERT_THAT(media_channel1()->recv_codecs(), testing::SizeIs(1));
2121 EXPECT_EQ(media_channel1()->recv_codecs()[0].packetization, absl::nullopt);
2122 ASSERT_THAT(media_channel1()->send_codecs(), testing::SizeIs(1));
2123 EXPECT_EQ(media_channel1()->send_codecs()[0].packetization, absl::nullopt);
2124 }
2125
TEST_F(VideoChannelSingleThreadTest,TestSetRemoteAnswerWithInvalidPacketization)2126 TEST_F(VideoChannelSingleThreadTest,
2127 TestSetRemoteAnswerWithInvalidPacketization) {
2128 cricket::VideoCodec local_codec(98, "VP8");
2129 local_codec.packetization = cricket::kPacketizationParamRaw;
2130 cricket::VideoCodec remote_codec(99, "VP8");
2131 remote_codec.packetization = "unknownpacketizationattributevalue";
2132 cricket::VideoContentDescription local_video;
2133 local_video.set_codecs({local_codec});
2134 cricket::VideoContentDescription remote_video;
2135 remote_video.set_codecs({remote_codec});
2136
2137 CreateChannels(0, 0);
2138
2139 std::string err;
2140 EXPECT_TRUE(channel1_->SetLocalContent(&local_video, SdpType::kOffer, err));
2141 EXPECT_TRUE(err.empty());
2142 EXPECT_FALSE(
2143 channel1_->SetRemoteContent(&remote_video, SdpType::kAnswer, err));
2144 EXPECT_FALSE(err.empty());
2145 ASSERT_THAT(media_channel1()->recv_codecs(), testing::SizeIs(1));
2146 EXPECT_EQ(media_channel1()->recv_codecs()[0].packetization,
2147 cricket::kPacketizationParamRaw);
2148 EXPECT_THAT(media_channel1()->send_codecs(), testing::IsEmpty());
2149 }
2150
TEST_F(VideoChannelSingleThreadTest,TestSetLocalAnswerWithInvalidPacketization)2151 TEST_F(VideoChannelSingleThreadTest,
2152 TestSetLocalAnswerWithInvalidPacketization) {
2153 cricket::VideoCodec local_codec(98, "VP8");
2154 local_codec.packetization = cricket::kPacketizationParamRaw;
2155 const cricket::VideoCodec kRemoteCodec(99, "VP8");
2156 cricket::VideoContentDescription local_video;
2157 local_video.set_codecs({local_codec});
2158 cricket::VideoContentDescription remote_video;
2159 remote_video.set_codecs({kRemoteCodec});
2160
2161 CreateChannels(0, 0);
2162
2163 std::string err;
2164 EXPECT_TRUE(channel1_->SetRemoteContent(&remote_video, SdpType::kOffer, err));
2165 EXPECT_TRUE(err.empty());
2166 EXPECT_FALSE(channel1_->SetLocalContent(&local_video, SdpType::kAnswer, err));
2167 EXPECT_FALSE(err.empty());
2168 EXPECT_THAT(media_channel1()->recv_codecs(), testing::IsEmpty());
2169 ASSERT_THAT(media_channel1()->send_codecs(), testing::SizeIs(1));
2170 EXPECT_EQ(media_channel1()->send_codecs()[0].packetization, absl::nullopt);
2171 }
2172
2173 // VideoChannelDoubleThreadTest
TEST_F(VideoChannelDoubleThreadTest,TestInit)2174 TEST_F(VideoChannelDoubleThreadTest, TestInit) {
2175 Base::TestInit();
2176 }
2177
TEST_F(VideoChannelDoubleThreadTest,TestDeinit)2178 TEST_F(VideoChannelDoubleThreadTest, TestDeinit) {
2179 Base::TestDeinit();
2180 }
2181
TEST_F(VideoChannelDoubleThreadTest,TestSetContents)2182 TEST_F(VideoChannelDoubleThreadTest, TestSetContents) {
2183 Base::TestSetContents();
2184 }
2185
TEST_F(VideoChannelDoubleThreadTest,TestSetContentsExtmapAllowMixedAsCaller)2186 TEST_F(VideoChannelDoubleThreadTest, TestSetContentsExtmapAllowMixedAsCaller) {
2187 Base::TestSetContentsExtmapAllowMixedCaller(/*offer=*/true, /*answer=*/true);
2188 }
2189
TEST_F(VideoChannelDoubleThreadTest,TestSetContentsExtmapAllowMixedNotSupportedAsCaller)2190 TEST_F(VideoChannelDoubleThreadTest,
2191 TestSetContentsExtmapAllowMixedNotSupportedAsCaller) {
2192 Base::TestSetContentsExtmapAllowMixedCaller(/*offer=*/true, /*answer=*/false);
2193 }
2194
TEST_F(VideoChannelDoubleThreadTest,TestSetContentsExtmapAllowMixedAsCallee)2195 TEST_F(VideoChannelDoubleThreadTest, TestSetContentsExtmapAllowMixedAsCallee) {
2196 Base::TestSetContentsExtmapAllowMixedCallee(/*offer=*/true, /*answer=*/true);
2197 }
2198
TEST_F(VideoChannelDoubleThreadTest,TestSetContentsExtmapAllowMixedNotSupportedAsCallee)2199 TEST_F(VideoChannelDoubleThreadTest,
2200 TestSetContentsExtmapAllowMixedNotSupportedAsCallee) {
2201 Base::TestSetContentsExtmapAllowMixedCallee(/*offer=*/true, /*answer=*/false);
2202 }
2203
TEST_F(VideoChannelDoubleThreadTest,TestSetContentsNullOffer)2204 TEST_F(VideoChannelDoubleThreadTest, TestSetContentsNullOffer) {
2205 Base::TestSetContentsNullOffer();
2206 }
2207
TEST_F(VideoChannelDoubleThreadTest,TestSetContentsRtcpMux)2208 TEST_F(VideoChannelDoubleThreadTest, TestSetContentsRtcpMux) {
2209 Base::TestSetContentsRtcpMux();
2210 }
2211
TEST_F(VideoChannelDoubleThreadTest,TestSetContentsRtcpMuxWithPrAnswer)2212 TEST_F(VideoChannelDoubleThreadTest, TestSetContentsRtcpMuxWithPrAnswer) {
2213 Base::TestSetContentsRtcpMux();
2214 }
2215
TEST_F(VideoChannelDoubleThreadTest,TestChangeStreamParamsInContent)2216 TEST_F(VideoChannelDoubleThreadTest, TestChangeStreamParamsInContent) {
2217 Base::TestChangeStreamParamsInContent();
2218 }
2219
TEST_F(VideoChannelDoubleThreadTest,TestPlayoutAndSendingStates)2220 TEST_F(VideoChannelDoubleThreadTest, TestPlayoutAndSendingStates) {
2221 Base::TestPlayoutAndSendingStates();
2222 }
2223
TEST_F(VideoChannelDoubleThreadTest,TestMediaContentDirection)2224 TEST_F(VideoChannelDoubleThreadTest, TestMediaContentDirection) {
2225 Base::TestMediaContentDirection();
2226 }
2227
TEST_F(VideoChannelDoubleThreadTest,TestNetworkRouteChanges)2228 TEST_F(VideoChannelDoubleThreadTest, TestNetworkRouteChanges) {
2229 Base::TestNetworkRouteChanges();
2230 }
2231
TEST_F(VideoChannelDoubleThreadTest,TestCallSetup)2232 TEST_F(VideoChannelDoubleThreadTest, TestCallSetup) {
2233 Base::TestCallSetup();
2234 }
2235
TEST_F(VideoChannelDoubleThreadTest,SendRtpToRtp)2236 TEST_F(VideoChannelDoubleThreadTest, SendRtpToRtp) {
2237 Base::SendRtpToRtp();
2238 }
2239
TEST_F(VideoChannelDoubleThreadTest,SendDtlsSrtpToDtlsSrtp)2240 TEST_F(VideoChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtp) {
2241 Base::SendDtlsSrtpToDtlsSrtp(0, 0);
2242 }
2243
TEST_F(VideoChannelDoubleThreadTest,SendDtlsSrtpToDtlsSrtpRtcpMux)2244 TEST_F(VideoChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) {
2245 Base::SendDtlsSrtpToDtlsSrtp(RTCP_MUX, RTCP_MUX);
2246 }
2247
TEST_F(VideoChannelDoubleThreadTest,SendEarlyMediaUsingRtcpMuxSrtp)2248 TEST_F(VideoChannelDoubleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) {
2249 Base::SendEarlyMediaUsingRtcpMuxSrtp();
2250 }
2251
TEST_F(VideoChannelDoubleThreadTest,SendRtpToRtpOnThread)2252 TEST_F(VideoChannelDoubleThreadTest, SendRtpToRtpOnThread) {
2253 Base::SendRtpToRtpOnThread();
2254 }
2255
TEST_F(VideoChannelDoubleThreadTest,SendWithWritabilityLoss)2256 TEST_F(VideoChannelDoubleThreadTest, SendWithWritabilityLoss) {
2257 Base::SendWithWritabilityLoss();
2258 }
2259
TEST_F(VideoChannelDoubleThreadTest,TestSetContentFailure)2260 TEST_F(VideoChannelDoubleThreadTest, TestSetContentFailure) {
2261 Base::TestSetContentFailure();
2262 }
2263
TEST_F(VideoChannelDoubleThreadTest,TestSendTwoOffers)2264 TEST_F(VideoChannelDoubleThreadTest, TestSendTwoOffers) {
2265 Base::TestSendTwoOffers();
2266 }
2267
TEST_F(VideoChannelDoubleThreadTest,TestReceiveTwoOffers)2268 TEST_F(VideoChannelDoubleThreadTest, TestReceiveTwoOffers) {
2269 Base::TestReceiveTwoOffers();
2270 }
2271
TEST_F(VideoChannelDoubleThreadTest,TestSendPrAnswer)2272 TEST_F(VideoChannelDoubleThreadTest, TestSendPrAnswer) {
2273 Base::TestSendPrAnswer();
2274 }
2275
TEST_F(VideoChannelDoubleThreadTest,TestReceivePrAnswer)2276 TEST_F(VideoChannelDoubleThreadTest, TestReceivePrAnswer) {
2277 Base::TestReceivePrAnswer();
2278 }
2279
TEST_F(VideoChannelDoubleThreadTest,SendBundleToBundle)2280 TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundle) {
2281 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, false);
2282 }
2283
TEST_F(VideoChannelDoubleThreadTest,SendBundleToBundleSecure)2284 TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundleSecure) {
2285 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, true);
2286 }
2287
TEST_F(VideoChannelDoubleThreadTest,SendBundleToBundleWithRtcpMux)2288 TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundleWithRtcpMux) {
2289 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, false);
2290 }
2291
TEST_F(VideoChannelDoubleThreadTest,SendBundleToBundleWithRtcpMuxSecure)2292 TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundleWithRtcpMuxSecure) {
2293 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, true);
2294 }
2295
TEST_F(VideoChannelDoubleThreadTest,TestOnTransportReadyToSend)2296 TEST_F(VideoChannelDoubleThreadTest, TestOnTransportReadyToSend) {
2297 Base::TestOnTransportReadyToSend();
2298 }
2299
TEST_F(VideoChannelDoubleThreadTest,DefaultMaxBitrateIsUnlimited)2300 TEST_F(VideoChannelDoubleThreadTest, DefaultMaxBitrateIsUnlimited) {
2301 Base::DefaultMaxBitrateIsUnlimited();
2302 }
2303
TEST_F(VideoChannelDoubleThreadTest,SocketOptionsMergedOnSetTransport)2304 TEST_F(VideoChannelDoubleThreadTest, SocketOptionsMergedOnSetTransport) {
2305 Base::SocketOptionsMergedOnSetTransport();
2306 }
2307
2308
2309 // TODO(pthatcher): TestSetReceiver?
2310