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