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 | |
kwiberg | 3102294 | 2016-03-11 14:18:21 -0800 | [diff] [blame] | 11 | #include <memory> |
| 12 | |
tfarina | 5237aaf | 2015-11-10 23:44:30 -0800 | [diff] [blame] | 13 | #include "webrtc/base/arraysize.h" |
ossu | 292d658 | 2016-03-17 02:31:13 -0700 | [diff] [blame^] | 14 | #include "webrtc/base/criticalsection.h" |
buildbot@webrtc.org | 65b98d1 | 2014-08-07 22:09:08 +0000 | [diff] [blame] | 15 | #include "webrtc/base/fileutils.h" |
| 16 | #include "webrtc/base/gunit.h" |
| 17 | #include "webrtc/base/helpers.h" |
| 18 | #include "webrtc/base/logging.h" |
| 19 | #include "webrtc/base/pathutils.h" |
| 20 | #include "webrtc/base/signalthread.h" |
| 21 | #include "webrtc/base/ssladapter.h" |
| 22 | #include "webrtc/base/sslidentity.h" |
| 23 | #include "webrtc/base/window.h" |
kjellander | a96e2d7 | 2016-02-04 23:52:28 -0800 | [diff] [blame] | 24 | #include "webrtc/media/base/fakemediaengine.h" |
| 25 | #include "webrtc/media/base/fakertp.h" |
| 26 | #include "webrtc/media/base/fakescreencapturerfactory.h" |
| 27 | #include "webrtc/media/base/fakevideocapturer.h" |
| 28 | #include "webrtc/media/base/mediachannel.h" |
| 29 | #include "webrtc/media/base/rtpdump.h" |
| 30 | #include "webrtc/media/base/screencastid.h" |
| 31 | #include "webrtc/media/base/testutils.h" |
Tommi | f888bb5 | 2015-12-12 01:37:01 +0100 | [diff] [blame] | 32 | #include "webrtc/p2p/base/faketransportcontroller.h" |
kjellander@webrtc.org | 9b8df25 | 2016-02-12 06:47:59 +0100 | [diff] [blame] | 33 | #include "webrtc/pc/channel.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 34 | |
| 35 | #define MAYBE_SKIP_TEST(feature) \ |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 36 | if (!(rtc::SSLStreamAdapter::feature())) { \ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 37 | LOG(LS_INFO) << "Feature disabled... skipping"; \ |
| 38 | return; \ |
| 39 | } |
| 40 | |
| 41 | using cricket::CA_OFFER; |
| 42 | using cricket::CA_PRANSWER; |
| 43 | using cricket::CA_ANSWER; |
| 44 | using cricket::CA_UPDATE; |
| 45 | using cricket::FakeVoiceMediaChannel; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 46 | using cricket::ScreencastId; |
| 47 | using cricket::StreamParams; |
| 48 | using cricket::TransportChannel; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 49 | using rtc::WindowId; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 50 | |
| 51 | static const cricket::AudioCodec kPcmuCodec(0, "PCMU", 64000, 8000, 1, 0); |
| 52 | static const cricket::AudioCodec kPcmaCodec(8, "PCMA", 64000, 8000, 1, 0); |
| 53 | static const cricket::AudioCodec kIsacCodec(103, "ISAC", 40000, 16000, 1, 0); |
| 54 | static const cricket::VideoCodec kH264Codec(97, "H264", 640, 400, 30, 0); |
| 55 | static const cricket::VideoCodec kH264SvcCodec(99, "H264-SVC", 320, 200, 15, 0); |
| 56 | static const cricket::DataCodec kGoogleDataCodec(101, "google-data", 0); |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 57 | static const uint32_t kSsrc1 = 0x1111; |
| 58 | static const uint32_t kSsrc2 = 0x2222; |
| 59 | static const uint32_t kSsrc3 = 0x3333; |
buildbot@webrtc.org | 5ee0f05 | 2014-05-05 20:18:08 +0000 | [diff] [blame] | 60 | static const int kAudioPts[] = {0, 8}; |
| 61 | static const int kVideoPts[] = {97, 99}; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 62 | |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 63 | template <class ChannelT, |
| 64 | class MediaChannelT, |
| 65 | class ContentT, |
| 66 | class CodecT, |
| 67 | class MediaInfoT, |
| 68 | class OptionsT> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 69 | class Traits { |
| 70 | public: |
| 71 | typedef ChannelT Channel; |
| 72 | typedef MediaChannelT MediaChannel; |
| 73 | typedef ContentT Content; |
| 74 | typedef CodecT Codec; |
| 75 | typedef MediaInfoT MediaInfo; |
Fredrik Solenberg | b071a19 | 2015-09-17 16:42:56 +0200 | [diff] [blame] | 76 | typedef OptionsT Options; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 77 | }; |
| 78 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 79 | // Controls how long we wait for a session to send messages that we |
| 80 | // expect, in milliseconds. We put it high to avoid flaky tests. |
| 81 | static const int kEventTimeout = 5000; |
| 82 | |
| 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 | |
| 97 | class DataTraits : public Traits<cricket::DataChannel, |
| 98 | cricket::FakeDataMediaChannel, |
| 99 | cricket::DataContentDescription, |
| 100 | cricket::DataCodec, |
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 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 104 | rtc::StreamInterface* Open(const std::string& path) { |
| 105 | return rtc::Filesystem::OpenFile( |
| 106 | rtc::Pathname(path), "wb"); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | // Base class for Voice/VideoChannel tests |
| 110 | template<class T> |
| 111 | class ChannelTest : public testing::Test, public sigslot::has_slots<> { |
| 112 | public: |
| 113 | enum Flags { RTCP = 0x1, RTCP_MUX = 0x2, SECURE = 0x4, SSRC_MUX = 0x8, |
| 114 | DTLS = 0x10 }; |
| 115 | |
Peter Boström | 34fbfff | 2015-09-24 19:20:30 +0200 | [diff] [blame] | 116 | ChannelTest(bool verify_playout, |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 117 | const uint8_t* rtp_data, |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 118 | int rtp_len, |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 119 | const uint8_t* rtcp_data, |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 120 | int rtcp_len) |
Peter Boström | 34fbfff | 2015-09-24 19:20:30 +0200 | [diff] [blame] | 121 | : verify_playout_(verify_playout), |
| 122 | transport_controller1_(cricket::ICEROLE_CONTROLLING), |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 123 | transport_controller2_(cricket::ICEROLE_CONTROLLED), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 124 | media_channel1_(NULL), |
| 125 | media_channel2_(NULL), |
| 126 | rtp_packet_(reinterpret_cast<const char*>(rtp_data), rtp_len), |
| 127 | rtcp_packet_(reinterpret_cast<const char*>(rtcp_data), rtcp_len), |
| 128 | media_info_callbacks1_(), |
solenberg | 5b14b42 | 2015-10-01 04:10:31 -0700 | [diff] [blame] | 129 | media_info_callbacks2_() {} |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 130 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 131 | void CreateChannels(int flags1, int flags2) { |
Fredrik Solenberg | b071a19 | 2015-09-17 16:42:56 +0200 | [diff] [blame] | 132 | CreateChannels(new typename T::MediaChannel(NULL, typename T::Options()), |
| 133 | new typename T::MediaChannel(NULL, typename T::Options()), |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 134 | flags1, flags2, rtc::Thread::Current()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 135 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 136 | void CreateChannels( |
| 137 | typename T::MediaChannel* ch1, typename T::MediaChannel* ch2, |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 138 | int flags1, int flags2, rtc::Thread* thread) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 139 | media_channel1_ = ch1; |
| 140 | media_channel2_ = ch2; |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 141 | channel1_.reset(CreateChannel(thread, &media_engine_, ch1, |
| 142 | &transport_controller1_, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 143 | (flags1 & RTCP) != 0)); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 144 | channel2_.reset(CreateChannel(thread, &media_engine_, ch2, |
| 145 | &transport_controller2_, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 146 | (flags2 & RTCP) != 0)); |
| 147 | channel1_->SignalMediaMonitor.connect( |
| 148 | this, &ChannelTest<T>::OnMediaMonitor); |
| 149 | channel2_->SignalMediaMonitor.connect( |
| 150 | this, &ChannelTest<T>::OnMediaMonitor); |
mallinath@webrtc.org | 19f27e6 | 2013-10-13 17:18:27 +0000 | [diff] [blame] | 151 | if ((flags1 & DTLS) && (flags2 & DTLS)) { |
| 152 | flags1 = (flags1 & ~SECURE); |
| 153 | flags2 = (flags2 & ~SECURE); |
| 154 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 155 | CreateContent(flags1, kPcmuCodec, kH264Codec, |
| 156 | &local_media_content1_); |
| 157 | CreateContent(flags2, kPcmuCodec, kH264Codec, |
| 158 | &local_media_content2_); |
| 159 | CopyContent(local_media_content1_, &remote_media_content1_); |
| 160 | CopyContent(local_media_content2_, &remote_media_content2_); |
| 161 | |
| 162 | if (flags1 & DTLS) { |
Torbjorn Granlund | b6d4ec4 | 2015-08-17 14:08:59 +0200 | [diff] [blame] | 163 | // Confirmed to work with KT_RSA and KT_ECDSA. |
kwiberg | 0eb15ed | 2015-12-17 03:04:15 -0800 | [diff] [blame] | 164 | transport_controller1_.SetLocalCertificate( |
| 165 | rtc::RTCCertificate::Create(rtc::scoped_ptr<rtc::SSLIdentity>( |
| 166 | rtc::SSLIdentity::Generate("session1", rtc::KT_DEFAULT)))); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 167 | } |
| 168 | if (flags2 & DTLS) { |
Torbjorn Granlund | b6d4ec4 | 2015-08-17 14:08:59 +0200 | [diff] [blame] | 169 | // Confirmed to work with KT_RSA and KT_ECDSA. |
kwiberg | 0eb15ed | 2015-12-17 03:04:15 -0800 | [diff] [blame] | 170 | transport_controller2_.SetLocalCertificate( |
| 171 | rtc::RTCCertificate::Create(rtc::scoped_ptr<rtc::SSLIdentity>( |
| 172 | rtc::SSLIdentity::Generate("session2", rtc::KT_DEFAULT)))); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | // Add stream information (SSRC) to the local content but not to the remote |
| 176 | // content. This means that we per default know the SSRC of what we send but |
| 177 | // not what we receive. |
| 178 | AddLegacyStreamInContent(kSsrc1, flags1, &local_media_content1_); |
| 179 | AddLegacyStreamInContent(kSsrc2, flags2, &local_media_content2_); |
| 180 | |
| 181 | // If SSRC_MUX is used we also need to know the SSRC of the incoming stream. |
| 182 | if (flags1 & SSRC_MUX) { |
| 183 | AddLegacyStreamInContent(kSsrc1, flags1, &remote_media_content1_); |
| 184 | } |
| 185 | if (flags2 & SSRC_MUX) { |
| 186 | AddLegacyStreamInContent(kSsrc2, flags2, &remote_media_content2_); |
| 187 | } |
| 188 | } |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 189 | typename T::Channel* CreateChannel( |
| 190 | rtc::Thread* thread, |
| 191 | cricket::MediaEngineInterface* engine, |
| 192 | typename T::MediaChannel* ch, |
| 193 | cricket::TransportController* transport_controller, |
| 194 | bool rtcp) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 195 | typename T::Channel* channel = new typename T::Channel( |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 196 | thread, engine, ch, transport_controller, cricket::CN_AUDIO, rtcp); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 197 | if (!channel->Init()) { |
| 198 | delete channel; |
| 199 | channel = NULL; |
| 200 | } |
| 201 | return channel; |
| 202 | } |
| 203 | |
| 204 | bool SendInitiate() { |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 205 | bool result = channel1_->SetLocalContent(&local_media_content1_, |
| 206 | CA_OFFER, NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 207 | if (result) { |
| 208 | channel1_->Enable(true); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 209 | result = channel2_->SetRemoteContent(&remote_media_content1_, |
| 210 | CA_OFFER, NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 211 | if (result) { |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 212 | transport_controller1_.Connect(&transport_controller2_); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 213 | |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 214 | result = channel2_->SetLocalContent(&local_media_content2_, |
| 215 | CA_ANSWER, NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 216 | } |
| 217 | } |
| 218 | return result; |
| 219 | } |
| 220 | |
| 221 | bool SendAccept() { |
| 222 | channel2_->Enable(true); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 223 | return channel1_->SetRemoteContent(&remote_media_content2_, |
| 224 | CA_ANSWER, NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | bool SendOffer() { |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 228 | bool result = channel1_->SetLocalContent(&local_media_content1_, |
| 229 | CA_OFFER, NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 230 | if (result) { |
| 231 | channel1_->Enable(true); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 232 | result = channel2_->SetRemoteContent(&remote_media_content1_, |
| 233 | CA_OFFER, NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 234 | } |
| 235 | return result; |
| 236 | } |
| 237 | |
| 238 | bool SendProvisionalAnswer() { |
| 239 | bool result = channel2_->SetLocalContent(&local_media_content2_, |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 240 | CA_PRANSWER, NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 241 | if (result) { |
| 242 | channel2_->Enable(true); |
| 243 | result = channel1_->SetRemoteContent(&remote_media_content2_, |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 244 | CA_PRANSWER, NULL); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 245 | transport_controller1_.Connect(&transport_controller2_); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 246 | } |
| 247 | return result; |
| 248 | } |
| 249 | |
| 250 | bool SendFinalAnswer() { |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 251 | bool result = channel2_->SetLocalContent(&local_media_content2_, |
| 252 | CA_ANSWER, NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 253 | if (result) |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 254 | result = channel1_->SetRemoteContent(&remote_media_content2_, |
| 255 | CA_ANSWER, NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 256 | return result; |
| 257 | } |
| 258 | |
| 259 | bool SendTerminate() { |
| 260 | channel1_.reset(); |
| 261 | channel2_.reset(); |
| 262 | return true; |
| 263 | } |
| 264 | |
| 265 | bool AddStream1(int id) { |
| 266 | return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id)); |
| 267 | } |
| 268 | bool RemoveStream1(int id) { |
| 269 | return channel1_->RemoveRecvStream(id); |
| 270 | } |
| 271 | |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 272 | // Calling "_w" method here is ok since we only use one thread for this test |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 273 | cricket::FakeTransport* GetTransport1() { |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 274 | return transport_controller1_.GetTransport_w(channel1_->content_name()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 275 | } |
| 276 | cricket::FakeTransport* GetTransport2() { |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 277 | return transport_controller2_.GetTransport_w(channel2_->content_name()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | bool SendRtp1() { |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 281 | return media_channel1_->SendRtp(rtp_packet_.c_str(), |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 282 | static_cast<int>(rtp_packet_.size()), |
| 283 | rtc::PacketOptions()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 284 | } |
| 285 | bool SendRtp2() { |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 286 | return media_channel2_->SendRtp(rtp_packet_.c_str(), |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 287 | static_cast<int>(rtp_packet_.size()), |
| 288 | rtc::PacketOptions()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 289 | } |
| 290 | bool SendRtcp1() { |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 291 | return media_channel1_->SendRtcp(rtcp_packet_.c_str(), |
| 292 | static_cast<int>(rtcp_packet_.size())); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 293 | } |
| 294 | bool SendRtcp2() { |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 295 | return media_channel2_->SendRtcp(rtcp_packet_.c_str(), |
| 296 | static_cast<int>(rtcp_packet_.size())); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 297 | } |
| 298 | // Methods to send custom data. |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 299 | bool SendCustomRtp1(uint32_t ssrc, int sequence_number, int pl_type = -1) { |
buildbot@webrtc.org | 5ee0f05 | 2014-05-05 20:18:08 +0000 | [diff] [blame] | 300 | std::string data(CreateRtpData(ssrc, sequence_number, pl_type)); |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 301 | return media_channel1_->SendRtp(data.c_str(), static_cast<int>(data.size()), |
| 302 | rtc::PacketOptions()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 303 | } |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 304 | bool SendCustomRtp2(uint32_t ssrc, int sequence_number, int pl_type = -1) { |
buildbot@webrtc.org | 5ee0f05 | 2014-05-05 20:18:08 +0000 | [diff] [blame] | 305 | std::string data(CreateRtpData(ssrc, sequence_number, pl_type)); |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 306 | return media_channel2_->SendRtp(data.c_str(), static_cast<int>(data.size()), |
| 307 | rtc::PacketOptions()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 308 | } |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 309 | bool SendCustomRtcp1(uint32_t ssrc) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 310 | std::string data(CreateRtcpData(ssrc)); |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 311 | return media_channel1_->SendRtcp(data.c_str(), |
| 312 | static_cast<int>(data.size())); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 313 | } |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 314 | bool SendCustomRtcp2(uint32_t ssrc) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 315 | std::string data(CreateRtcpData(ssrc)); |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 316 | return media_channel2_->SendRtcp(data.c_str(), |
| 317 | static_cast<int>(data.size())); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 318 | } |
| 319 | bool CheckRtp1() { |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 320 | return media_channel1_->CheckRtp(rtp_packet_.c_str(), |
| 321 | static_cast<int>(rtp_packet_.size())); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 322 | } |
| 323 | bool CheckRtp2() { |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 324 | return media_channel2_->CheckRtp(rtp_packet_.c_str(), |
| 325 | static_cast<int>(rtp_packet_.size())); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 326 | } |
| 327 | bool CheckRtcp1() { |
| 328 | return media_channel1_->CheckRtcp(rtcp_packet_.c_str(), |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 329 | static_cast<int>(rtcp_packet_.size())); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 330 | } |
| 331 | bool CheckRtcp2() { |
| 332 | return media_channel2_->CheckRtcp(rtcp_packet_.c_str(), |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 333 | static_cast<int>(rtcp_packet_.size())); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 334 | } |
| 335 | // Methods to check custom data. |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 336 | bool CheckCustomRtp1(uint32_t ssrc, int sequence_number, int pl_type = -1) { |
buildbot@webrtc.org | 5ee0f05 | 2014-05-05 20:18:08 +0000 | [diff] [blame] | 337 | std::string data(CreateRtpData(ssrc, sequence_number, pl_type)); |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 338 | return media_channel1_->CheckRtp(data.c_str(), |
| 339 | static_cast<int>(data.size())); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 340 | } |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 341 | bool CheckCustomRtp2(uint32_t ssrc, int sequence_number, int pl_type = -1) { |
buildbot@webrtc.org | 5ee0f05 | 2014-05-05 20:18:08 +0000 | [diff] [blame] | 342 | std::string data(CreateRtpData(ssrc, sequence_number, pl_type)); |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 343 | return media_channel2_->CheckRtp(data.c_str(), |
| 344 | static_cast<int>(data.size())); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 345 | } |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 346 | bool CheckCustomRtcp1(uint32_t ssrc) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 347 | std::string data(CreateRtcpData(ssrc)); |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 348 | return media_channel1_->CheckRtcp(data.c_str(), |
| 349 | static_cast<int>(data.size())); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 350 | } |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 351 | bool CheckCustomRtcp2(uint32_t ssrc) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 352 | std::string data(CreateRtcpData(ssrc)); |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 353 | return media_channel2_->CheckRtcp(data.c_str(), |
| 354 | static_cast<int>(data.size())); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 355 | } |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 356 | std::string CreateRtpData(uint32_t ssrc, int sequence_number, int pl_type) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 357 | std::string data(rtp_packet_); |
| 358 | // Set SSRC in the rtp packet copy. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 359 | rtc::SetBE32(const_cast<char*>(data.c_str()) + 8, ssrc); |
| 360 | rtc::SetBE16(const_cast<char*>(data.c_str()) + 2, sequence_number); |
buildbot@webrtc.org | 5ee0f05 | 2014-05-05 20:18:08 +0000 | [diff] [blame] | 361 | if (pl_type >= 0) { |
pkasting@chromium.org | 0e81fdf | 2015-02-02 23:54:03 +0000 | [diff] [blame] | 362 | rtc::Set8(const_cast<char*>(data.c_str()), 1, |
| 363 | static_cast<uint8_t>(pl_type)); |
buildbot@webrtc.org | 5ee0f05 | 2014-05-05 20:18:08 +0000 | [diff] [blame] | 364 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 365 | return data; |
| 366 | } |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 367 | std::string CreateRtcpData(uint32_t ssrc) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 368 | std::string data(rtcp_packet_); |
| 369 | // Set SSRC in the rtcp packet copy. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 370 | rtc::SetBE32(const_cast<char*>(data.c_str()) + 4, ssrc); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 371 | return data; |
| 372 | } |
| 373 | |
| 374 | bool CheckNoRtp1() { |
| 375 | return media_channel1_->CheckNoRtp(); |
| 376 | } |
| 377 | bool CheckNoRtp2() { |
| 378 | return media_channel2_->CheckNoRtp(); |
| 379 | } |
| 380 | bool CheckNoRtcp1() { |
| 381 | return media_channel1_->CheckNoRtcp(); |
| 382 | } |
| 383 | bool CheckNoRtcp2() { |
| 384 | return media_channel2_->CheckNoRtcp(); |
| 385 | } |
| 386 | |
| 387 | void CreateContent(int flags, |
| 388 | const cricket::AudioCodec& audio_codec, |
| 389 | const cricket::VideoCodec& video_codec, |
| 390 | typename T::Content* content) { |
| 391 | // overridden in specialized classes |
| 392 | } |
| 393 | void CopyContent(const typename T::Content& source, |
| 394 | typename T::Content* content) { |
| 395 | // overridden in specialized classes |
| 396 | } |
| 397 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 398 | // Creates a cricket::SessionDescription with one MediaContent and one stream. |
| 399 | // kPcmuCodec is used as audio codec and kH264Codec is used as video codec. |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 400 | cricket::SessionDescription* CreateSessionDescriptionWithStream( |
| 401 | uint32_t ssrc) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 402 | typename T::Content content; |
| 403 | cricket::SessionDescription* sdesc = new cricket::SessionDescription(); |
| 404 | CreateContent(SECURE, kPcmuCodec, kH264Codec, &content); |
| 405 | AddLegacyStreamInContent(ssrc, 0, &content); |
| 406 | sdesc->AddContent("DUMMY_CONTENT_NAME", |
| 407 | cricket::NS_JINGLE_RTP, content.Copy()); |
| 408 | return sdesc; |
| 409 | } |
| 410 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 411 | class CallThread : public rtc::SignalThread { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 412 | public: |
| 413 | typedef bool (ChannelTest<T>::*Method)(); |
ossu | 292d658 | 2016-03-17 02:31:13 -0700 | [diff] [blame^] | 414 | CallThread(ChannelTest<T>* obj, Method method, bool* result = nullptr) |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 415 | : obj_(obj), |
| 416 | method_(method), |
ossu | 292d658 | 2016-03-17 02:31:13 -0700 | [diff] [blame^] | 417 | result_(false), |
| 418 | result_ptr_(result) { |
| 419 | if (result_ptr_) |
| 420 | *result_ptr_ = false; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 421 | } |
ossu | 292d658 | 2016-03-17 02:31:13 -0700 | [diff] [blame^] | 422 | |
| 423 | ~CallThread() { |
| 424 | if (result_ptr_) { |
| 425 | rtc::CritScope cs(&result_lock_); |
| 426 | *result_ptr_ = result_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 427 | } |
| 428 | } |
ossu | 292d658 | 2016-03-17 02:31:13 -0700 | [diff] [blame^] | 429 | |
| 430 | virtual void DoWork() { |
| 431 | SetResult((*obj_.*method_)()); |
| 432 | } |
| 433 | |
| 434 | bool result() { |
| 435 | rtc::CritScope cs(&result_lock_); |
| 436 | return result_; |
| 437 | } |
| 438 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 439 | private: |
ossu | 292d658 | 2016-03-17 02:31:13 -0700 | [diff] [blame^] | 440 | void SetResult(const bool& result) { |
| 441 | rtc::CritScope cs(&result_lock_); |
| 442 | result_ = result; |
| 443 | } |
| 444 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 445 | ChannelTest<T>* obj_; |
| 446 | Method method_; |
ossu | 292d658 | 2016-03-17 02:31:13 -0700 | [diff] [blame^] | 447 | rtc::CriticalSection result_lock_; |
| 448 | bool result_ GUARDED_BY(result_lock_); |
| 449 | bool* result_ptr_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 450 | }; |
ossu | 292d658 | 2016-03-17 02:31:13 -0700 | [diff] [blame^] | 451 | |
| 452 | // Will manage the lifetime of a CallThread, making sure it's |
| 453 | // destroyed before this object goes out of scope. |
| 454 | class ScopedCallThread { |
| 455 | public: |
| 456 | using Method = typename CallThread::Method; |
| 457 | |
| 458 | ScopedCallThread(ChannelTest<T>* obj, Method method) |
| 459 | : thread_(new CallThread(obj, method)) { |
| 460 | thread_->Start(); |
| 461 | } |
| 462 | |
| 463 | ~ScopedCallThread() { |
| 464 | thread_->Destroy(true); |
| 465 | } |
| 466 | |
| 467 | bool result() const { return thread_->result(); } |
| 468 | |
| 469 | private: |
| 470 | CallThread* thread_; |
| 471 | }; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 472 | |
| 473 | void CallOnThreadAndWaitForDone(typename CallThread::Method method, |
| 474 | bool* result) { |
| 475 | CallThread* thread = new CallThread(this, method, result); |
| 476 | thread->Start(); |
| 477 | thread->Destroy(true); |
| 478 | } |
| 479 | |
| 480 | bool CodecMatches(const typename T::Codec& c1, const typename T::Codec& c2) { |
| 481 | return false; // overridden in specialized classes |
| 482 | } |
| 483 | |
| 484 | void OnMediaMonitor(typename T::Channel* channel, |
| 485 | const typename T::MediaInfo& info) { |
| 486 | if (channel == channel1_.get()) { |
| 487 | media_info_callbacks1_++; |
| 488 | } else if (channel == channel2_.get()) { |
| 489 | media_info_callbacks2_++; |
| 490 | } |
| 491 | } |
| 492 | |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 493 | void AddLegacyStreamInContent(uint32_t ssrc, |
| 494 | int flags, |
| 495 | typename T::Content* content) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 496 | // Base implementation. |
| 497 | } |
| 498 | |
| 499 | // Tests that can be used by derived classes. |
| 500 | |
| 501 | // Basic sanity check. |
| 502 | void TestInit() { |
| 503 | CreateChannels(0, 0); |
| 504 | EXPECT_FALSE(channel1_->secure()); |
| 505 | EXPECT_FALSE(media_channel1_->sending()); |
Peter Boström | 34fbfff | 2015-09-24 19:20:30 +0200 | [diff] [blame] | 506 | if (verify_playout_) { |
| 507 | EXPECT_FALSE(media_channel1_->playout()); |
| 508 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 509 | EXPECT_TRUE(media_channel1_->codecs().empty()); |
| 510 | EXPECT_TRUE(media_channel1_->recv_streams().empty()); |
| 511 | EXPECT_TRUE(media_channel1_->rtp_packets().empty()); |
| 512 | EXPECT_TRUE(media_channel1_->rtcp_packets().empty()); |
| 513 | } |
| 514 | |
| 515 | // Test that SetLocalContent and SetRemoteContent properly configure |
| 516 | // the codecs. |
| 517 | void TestSetContents() { |
| 518 | CreateChannels(0, 0); |
| 519 | typename T::Content content; |
| 520 | CreateContent(0, kPcmuCodec, kH264Codec, &content); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 521 | EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 522 | EXPECT_EQ(0U, media_channel1_->codecs().size()); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 523 | EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 524 | ASSERT_EQ(1U, media_channel1_->codecs().size()); |
| 525 | EXPECT_TRUE(CodecMatches(content.codecs()[0], |
| 526 | media_channel1_->codecs()[0])); |
| 527 | } |
| 528 | |
| 529 | // Test that SetLocalContent and SetRemoteContent properly deals |
| 530 | // with an empty offer. |
| 531 | void TestSetContentsNullOffer() { |
| 532 | CreateChannels(0, 0); |
| 533 | typename T::Content content; |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 534 | EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 535 | CreateContent(0, kPcmuCodec, kH264Codec, &content); |
| 536 | EXPECT_EQ(0U, media_channel1_->codecs().size()); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 537 | EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 538 | ASSERT_EQ(1U, media_channel1_->codecs().size()); |
| 539 | EXPECT_TRUE(CodecMatches(content.codecs()[0], |
| 540 | media_channel1_->codecs()[0])); |
| 541 | } |
| 542 | |
| 543 | // Test that SetLocalContent and SetRemoteContent properly set RTCP |
| 544 | // mux. |
| 545 | void TestSetContentsRtcpMux() { |
| 546 | CreateChannels(RTCP, RTCP); |
| 547 | EXPECT_TRUE(channel1_->rtcp_transport_channel() != NULL); |
| 548 | EXPECT_TRUE(channel2_->rtcp_transport_channel() != NULL); |
| 549 | typename T::Content content; |
| 550 | CreateContent(0, kPcmuCodec, kH264Codec, &content); |
| 551 | // Both sides agree on mux. Should no longer be a separate RTCP channel. |
| 552 | content.set_rtcp_mux(true); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 553 | EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); |
| 554 | EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 555 | EXPECT_TRUE(channel1_->rtcp_transport_channel() == NULL); |
| 556 | // Only initiator supports mux. Should still have a separate RTCP channel. |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 557 | EXPECT_TRUE(channel2_->SetLocalContent(&content, CA_OFFER, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 558 | content.set_rtcp_mux(false); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 559 | EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_ANSWER, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 560 | EXPECT_TRUE(channel2_->rtcp_transport_channel() != NULL); |
| 561 | } |
| 562 | |
| 563 | // Test that SetLocalContent and SetRemoteContent properly set RTCP |
| 564 | // mux when a provisional answer is received. |
| 565 | void TestSetContentsRtcpMuxWithPrAnswer() { |
| 566 | CreateChannels(RTCP, RTCP); |
| 567 | EXPECT_TRUE(channel1_->rtcp_transport_channel() != NULL); |
| 568 | EXPECT_TRUE(channel2_->rtcp_transport_channel() != NULL); |
| 569 | typename T::Content content; |
| 570 | CreateContent(0, kPcmuCodec, kH264Codec, &content); |
| 571 | content.set_rtcp_mux(true); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 572 | EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); |
| 573 | EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_PRANSWER, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 574 | EXPECT_TRUE(channel1_->rtcp_transport_channel() != NULL); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 575 | EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 576 | // Both sides agree on mux. Should no longer be a separate RTCP channel. |
| 577 | EXPECT_TRUE(channel1_->rtcp_transport_channel() == NULL); |
| 578 | // Only initiator supports mux. Should still have a separate RTCP channel. |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 579 | EXPECT_TRUE(channel2_->SetLocalContent(&content, CA_OFFER, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 580 | content.set_rtcp_mux(false); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 581 | EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_PRANSWER, NULL)); |
| 582 | EXPECT_TRUE(channel2_->SetRemoteContent(&content, CA_ANSWER, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 583 | EXPECT_TRUE(channel2_->rtcp_transport_channel() != NULL); |
| 584 | } |
| 585 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 586 | // Test that SetRemoteContent properly deals with a content update. |
| 587 | void TestSetRemoteContentUpdate() { |
| 588 | CreateChannels(0, 0); |
| 589 | typename T::Content content; |
| 590 | CreateContent(RTCP | RTCP_MUX | SECURE, |
| 591 | kPcmuCodec, kH264Codec, |
| 592 | &content); |
| 593 | EXPECT_EQ(0U, media_channel1_->codecs().size()); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 594 | EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); |
| 595 | EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 596 | ASSERT_EQ(1U, media_channel1_->codecs().size()); |
| 597 | EXPECT_TRUE(CodecMatches(content.codecs()[0], |
| 598 | media_channel1_->codecs()[0])); |
| 599 | // Now update with other codecs. |
| 600 | typename T::Content update_content; |
| 601 | update_content.set_partial(true); |
| 602 | CreateContent(0, kIsacCodec, kH264SvcCodec, |
| 603 | &update_content); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 604 | EXPECT_TRUE(channel1_->SetRemoteContent(&update_content, CA_UPDATE, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 605 | ASSERT_EQ(1U, media_channel1_->codecs().size()); |
| 606 | EXPECT_TRUE(CodecMatches(update_content.codecs()[0], |
| 607 | media_channel1_->codecs()[0])); |
| 608 | // Now update without any codecs. This is ignored. |
| 609 | typename T::Content empty_content; |
| 610 | empty_content.set_partial(true); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 611 | EXPECT_TRUE(channel1_->SetRemoteContent(&empty_content, CA_UPDATE, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 612 | ASSERT_EQ(1U, media_channel1_->codecs().size()); |
| 613 | EXPECT_TRUE(CodecMatches(update_content.codecs()[0], |
| 614 | media_channel1_->codecs()[0])); |
| 615 | } |
| 616 | |
| 617 | // Test that Add/RemoveStream properly forward to the media channel. |
| 618 | void TestStreams() { |
| 619 | CreateChannels(0, 0); |
| 620 | EXPECT_TRUE(AddStream1(1)); |
| 621 | EXPECT_TRUE(AddStream1(2)); |
| 622 | EXPECT_EQ(2U, media_channel1_->recv_streams().size()); |
| 623 | EXPECT_TRUE(RemoveStream1(2)); |
| 624 | EXPECT_EQ(1U, media_channel1_->recv_streams().size()); |
| 625 | EXPECT_TRUE(RemoveStream1(1)); |
| 626 | EXPECT_EQ(0U, media_channel1_->recv_streams().size()); |
| 627 | } |
| 628 | |
| 629 | // Test that SetLocalContent properly handles adding and removing StreamParams |
| 630 | // to the local content description. |
| 631 | // This test uses the CA_UPDATE action that don't require a full |
| 632 | // MediaContentDescription to do an update. |
| 633 | void TestUpdateStreamsInLocalContent() { |
| 634 | cricket::StreamParams stream1; |
| 635 | stream1.groupid = "group1"; |
| 636 | stream1.id = "stream1"; |
| 637 | stream1.ssrcs.push_back(kSsrc1); |
| 638 | stream1.cname = "stream1_cname"; |
| 639 | |
| 640 | cricket::StreamParams stream2; |
| 641 | stream2.groupid = "group2"; |
| 642 | stream2.id = "stream2"; |
| 643 | stream2.ssrcs.push_back(kSsrc2); |
| 644 | stream2.cname = "stream2_cname"; |
| 645 | |
| 646 | cricket::StreamParams stream3; |
| 647 | stream3.groupid = "group3"; |
| 648 | stream3.id = "stream3"; |
| 649 | stream3.ssrcs.push_back(kSsrc3); |
| 650 | stream3.cname = "stream3_cname"; |
| 651 | |
| 652 | CreateChannels(0, 0); |
| 653 | typename T::Content content1; |
| 654 | CreateContent(0, kPcmuCodec, kH264Codec, &content1); |
| 655 | content1.AddStream(stream1); |
| 656 | EXPECT_EQ(0u, media_channel1_->send_streams().size()); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 657 | EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 658 | |
| 659 | ASSERT_EQ(1u, media_channel1_->send_streams().size()); |
| 660 | EXPECT_EQ(stream1, media_channel1_->send_streams()[0]); |
| 661 | |
| 662 | // Update the local streams by adding another sending stream. |
| 663 | // Use a partial updated session description. |
| 664 | typename T::Content content2; |
| 665 | content2.AddStream(stream2); |
| 666 | content2.AddStream(stream3); |
| 667 | content2.set_partial(true); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 668 | EXPECT_TRUE(channel1_->SetLocalContent(&content2, CA_UPDATE, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 669 | ASSERT_EQ(3u, media_channel1_->send_streams().size()); |
| 670 | EXPECT_EQ(stream1, media_channel1_->send_streams()[0]); |
| 671 | EXPECT_EQ(stream2, media_channel1_->send_streams()[1]); |
| 672 | EXPECT_EQ(stream3, media_channel1_->send_streams()[2]); |
| 673 | |
| 674 | // Update the local streams by removing the first sending stream. |
| 675 | // This is done by removing all SSRCS for this particular stream. |
| 676 | typename T::Content content3; |
| 677 | stream1.ssrcs.clear(); |
| 678 | content3.AddStream(stream1); |
| 679 | content3.set_partial(true); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 680 | EXPECT_TRUE(channel1_->SetLocalContent(&content3, CA_UPDATE, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 681 | ASSERT_EQ(2u, media_channel1_->send_streams().size()); |
| 682 | EXPECT_EQ(stream2, media_channel1_->send_streams()[0]); |
| 683 | EXPECT_EQ(stream3, media_channel1_->send_streams()[1]); |
| 684 | |
| 685 | // Update the local streams with a stream that does not change. |
| 686 | // THe update is ignored. |
| 687 | typename T::Content content4; |
| 688 | content4.AddStream(stream2); |
| 689 | content4.set_partial(true); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 690 | EXPECT_TRUE(channel1_->SetLocalContent(&content4, CA_UPDATE, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 691 | ASSERT_EQ(2u, media_channel1_->send_streams().size()); |
| 692 | EXPECT_EQ(stream2, media_channel1_->send_streams()[0]); |
| 693 | EXPECT_EQ(stream3, media_channel1_->send_streams()[1]); |
| 694 | } |
| 695 | |
| 696 | // Test that SetRemoteContent properly handles adding and removing |
| 697 | // StreamParams to the remote content description. |
| 698 | // This test uses the CA_UPDATE action that don't require a full |
| 699 | // MediaContentDescription to do an update. |
| 700 | void TestUpdateStreamsInRemoteContent() { |
| 701 | cricket::StreamParams stream1; |
| 702 | stream1.id = "Stream1"; |
| 703 | stream1.groupid = "1"; |
| 704 | stream1.ssrcs.push_back(kSsrc1); |
| 705 | stream1.cname = "stream1_cname"; |
| 706 | |
| 707 | cricket::StreamParams stream2; |
| 708 | stream2.id = "Stream2"; |
| 709 | stream2.groupid = "2"; |
| 710 | stream2.ssrcs.push_back(kSsrc2); |
| 711 | stream2.cname = "stream2_cname"; |
| 712 | |
| 713 | cricket::StreamParams stream3; |
| 714 | stream3.id = "Stream3"; |
| 715 | stream3.groupid = "3"; |
| 716 | stream3.ssrcs.push_back(kSsrc3); |
| 717 | stream3.cname = "stream3_cname"; |
| 718 | |
| 719 | CreateChannels(0, 0); |
| 720 | typename T::Content content1; |
| 721 | CreateContent(0, kPcmuCodec, kH264Codec, &content1); |
| 722 | content1.AddStream(stream1); |
| 723 | EXPECT_EQ(0u, media_channel1_->recv_streams().size()); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 724 | EXPECT_TRUE(channel1_->SetRemoteContent(&content1, CA_OFFER, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 725 | |
| 726 | ASSERT_EQ(1u, media_channel1_->codecs().size()); |
| 727 | ASSERT_EQ(1u, media_channel1_->recv_streams().size()); |
| 728 | EXPECT_EQ(stream1, media_channel1_->recv_streams()[0]); |
| 729 | |
| 730 | // Update the remote streams by adding another sending stream. |
| 731 | // Use a partial updated session description. |
| 732 | typename T::Content content2; |
| 733 | content2.AddStream(stream2); |
| 734 | content2.AddStream(stream3); |
| 735 | content2.set_partial(true); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 736 | EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_UPDATE, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 737 | ASSERT_EQ(3u, media_channel1_->recv_streams().size()); |
| 738 | EXPECT_EQ(stream1, media_channel1_->recv_streams()[0]); |
| 739 | EXPECT_EQ(stream2, media_channel1_->recv_streams()[1]); |
| 740 | EXPECT_EQ(stream3, media_channel1_->recv_streams()[2]); |
| 741 | |
| 742 | // Update the remote streams by removing the first stream. |
| 743 | // This is done by removing all SSRCS for this particular stream. |
| 744 | typename T::Content content3; |
| 745 | stream1.ssrcs.clear(); |
| 746 | content3.AddStream(stream1); |
| 747 | content3.set_partial(true); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 748 | EXPECT_TRUE(channel1_->SetRemoteContent(&content3, CA_UPDATE, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 749 | ASSERT_EQ(2u, media_channel1_->recv_streams().size()); |
| 750 | EXPECT_EQ(stream2, media_channel1_->recv_streams()[0]); |
| 751 | EXPECT_EQ(stream3, media_channel1_->recv_streams()[1]); |
| 752 | |
| 753 | // Update the remote streams with a stream that does not change. |
| 754 | // The update is ignored. |
| 755 | typename T::Content content4; |
| 756 | content4.AddStream(stream2); |
| 757 | content4.set_partial(true); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 758 | EXPECT_TRUE(channel1_->SetRemoteContent(&content4, CA_UPDATE, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 759 | ASSERT_EQ(2u, media_channel1_->recv_streams().size()); |
| 760 | EXPECT_EQ(stream2, media_channel1_->recv_streams()[0]); |
| 761 | EXPECT_EQ(stream3, media_channel1_->recv_streams()[1]); |
| 762 | } |
| 763 | |
| 764 | // Test that SetLocalContent and SetRemoteContent properly |
| 765 | // handles adding and removing StreamParams when the action is a full |
| 766 | // CA_OFFER / CA_ANSWER. |
| 767 | void TestChangeStreamParamsInContent() { |
| 768 | cricket::StreamParams stream1; |
| 769 | stream1.groupid = "group1"; |
| 770 | stream1.id = "stream1"; |
| 771 | stream1.ssrcs.push_back(kSsrc1); |
| 772 | stream1.cname = "stream1_cname"; |
| 773 | |
| 774 | cricket::StreamParams stream2; |
| 775 | stream2.groupid = "group1"; |
| 776 | stream2.id = "stream2"; |
| 777 | stream2.ssrcs.push_back(kSsrc2); |
| 778 | stream2.cname = "stream2_cname"; |
| 779 | |
| 780 | // Setup a call where channel 1 send |stream1| to channel 2. |
| 781 | CreateChannels(0, 0); |
| 782 | typename T::Content content1; |
| 783 | CreateContent(0, kPcmuCodec, kH264Codec, &content1); |
| 784 | content1.AddStream(stream1); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 785 | EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 786 | EXPECT_TRUE(channel1_->Enable(true)); |
| 787 | EXPECT_EQ(1u, media_channel1_->send_streams().size()); |
| 788 | |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 789 | EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 790 | EXPECT_EQ(1u, media_channel2_->recv_streams().size()); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 791 | transport_controller1_.Connect(&transport_controller2_); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 792 | |
| 793 | // Channel 2 do not send anything. |
| 794 | typename T::Content content2; |
| 795 | CreateContent(0, kPcmuCodec, kH264Codec, &content2); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 796 | EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_ANSWER, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 797 | EXPECT_EQ(0u, media_channel1_->recv_streams().size()); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 798 | EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_ANSWER, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 799 | EXPECT_TRUE(channel2_->Enable(true)); |
| 800 | EXPECT_EQ(0u, media_channel2_->send_streams().size()); |
| 801 | |
| 802 | EXPECT_TRUE(SendCustomRtp1(kSsrc1, 0)); |
| 803 | EXPECT_TRUE(CheckCustomRtp2(kSsrc1, 0)); |
| 804 | |
| 805 | // Let channel 2 update the content by sending |stream2| and enable SRTP. |
| 806 | typename T::Content content3; |
| 807 | CreateContent(SECURE, kPcmuCodec, kH264Codec, &content3); |
| 808 | content3.AddStream(stream2); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 809 | EXPECT_TRUE(channel2_->SetLocalContent(&content3, CA_OFFER, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 810 | ASSERT_EQ(1u, media_channel2_->send_streams().size()); |
| 811 | EXPECT_EQ(stream2, media_channel2_->send_streams()[0]); |
| 812 | |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 813 | EXPECT_TRUE(channel1_->SetRemoteContent(&content3, CA_OFFER, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 814 | ASSERT_EQ(1u, media_channel1_->recv_streams().size()); |
| 815 | EXPECT_EQ(stream2, media_channel1_->recv_streams()[0]); |
| 816 | |
| 817 | // Channel 1 replies but stop sending stream1. |
| 818 | typename T::Content content4; |
| 819 | CreateContent(SECURE, kPcmuCodec, kH264Codec, &content4); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 820 | EXPECT_TRUE(channel1_->SetLocalContent(&content4, CA_ANSWER, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 821 | EXPECT_EQ(0u, media_channel1_->send_streams().size()); |
| 822 | |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 823 | EXPECT_TRUE(channel2_->SetRemoteContent(&content4, CA_ANSWER, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 824 | EXPECT_EQ(0u, media_channel2_->recv_streams().size()); |
| 825 | |
| 826 | EXPECT_TRUE(channel1_->secure()); |
| 827 | EXPECT_TRUE(channel2_->secure()); |
| 828 | EXPECT_TRUE(SendCustomRtp2(kSsrc2, 0)); |
| 829 | EXPECT_TRUE(CheckCustomRtp1(kSsrc2, 0)); |
| 830 | } |
| 831 | |
| 832 | // Test that we only start playout and sending at the right times. |
| 833 | void TestPlayoutAndSendingStates() { |
| 834 | CreateChannels(0, 0); |
Peter Boström | 34fbfff | 2015-09-24 19:20:30 +0200 | [diff] [blame] | 835 | if (verify_playout_) { |
| 836 | EXPECT_FALSE(media_channel1_->playout()); |
| 837 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 838 | EXPECT_FALSE(media_channel1_->sending()); |
Peter Boström | 34fbfff | 2015-09-24 19:20:30 +0200 | [diff] [blame] | 839 | if (verify_playout_) { |
| 840 | EXPECT_FALSE(media_channel2_->playout()); |
| 841 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 842 | EXPECT_FALSE(media_channel2_->sending()); |
| 843 | EXPECT_TRUE(channel1_->Enable(true)); |
Peter Boström | 34fbfff | 2015-09-24 19:20:30 +0200 | [diff] [blame] | 844 | if (verify_playout_) { |
| 845 | EXPECT_FALSE(media_channel1_->playout()); |
| 846 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 847 | EXPECT_FALSE(media_channel1_->sending()); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 848 | EXPECT_TRUE(channel1_->SetLocalContent(&local_media_content1_, |
| 849 | CA_OFFER, NULL)); |
Peter Boström | 34fbfff | 2015-09-24 19:20:30 +0200 | [diff] [blame] | 850 | if (verify_playout_) { |
| 851 | EXPECT_TRUE(media_channel1_->playout()); |
| 852 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 853 | EXPECT_FALSE(media_channel1_->sending()); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 854 | EXPECT_TRUE(channel2_->SetRemoteContent(&local_media_content1_, |
| 855 | CA_OFFER, NULL)); |
Peter Boström | 34fbfff | 2015-09-24 19:20:30 +0200 | [diff] [blame] | 856 | if (verify_playout_) { |
| 857 | EXPECT_FALSE(media_channel2_->playout()); |
| 858 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 859 | EXPECT_FALSE(media_channel2_->sending()); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 860 | EXPECT_TRUE(channel2_->SetLocalContent(&local_media_content2_, |
| 861 | CA_ANSWER, NULL)); |
Peter Boström | 34fbfff | 2015-09-24 19:20:30 +0200 | [diff] [blame] | 862 | if (verify_playout_) { |
| 863 | EXPECT_FALSE(media_channel2_->playout()); |
| 864 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 865 | EXPECT_FALSE(media_channel2_->sending()); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 866 | transport_controller1_.Connect(&transport_controller2_); |
Peter Boström | 34fbfff | 2015-09-24 19:20:30 +0200 | [diff] [blame] | 867 | if (verify_playout_) { |
| 868 | EXPECT_TRUE(media_channel1_->playout()); |
| 869 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 870 | EXPECT_FALSE(media_channel1_->sending()); |
Peter Boström | 34fbfff | 2015-09-24 19:20:30 +0200 | [diff] [blame] | 871 | if (verify_playout_) { |
| 872 | EXPECT_FALSE(media_channel2_->playout()); |
| 873 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 874 | EXPECT_FALSE(media_channel2_->sending()); |
| 875 | EXPECT_TRUE(channel2_->Enable(true)); |
Peter Boström | 34fbfff | 2015-09-24 19:20:30 +0200 | [diff] [blame] | 876 | if (verify_playout_) { |
| 877 | EXPECT_TRUE(media_channel2_->playout()); |
| 878 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 879 | EXPECT_TRUE(media_channel2_->sending()); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 880 | EXPECT_TRUE(channel1_->SetRemoteContent(&local_media_content2_, |
| 881 | CA_ANSWER, NULL)); |
Peter Boström | 34fbfff | 2015-09-24 19:20:30 +0200 | [diff] [blame] | 882 | if (verify_playout_) { |
| 883 | EXPECT_TRUE(media_channel1_->playout()); |
| 884 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 885 | EXPECT_TRUE(media_channel1_->sending()); |
| 886 | } |
| 887 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 888 | // Test that changing the MediaContentDirection in the local and remote |
| 889 | // session description start playout and sending at the right time. |
| 890 | void TestMediaContentDirection() { |
| 891 | CreateChannels(0, 0); |
| 892 | typename T::Content content1; |
| 893 | CreateContent(0, kPcmuCodec, kH264Codec, &content1); |
| 894 | typename T::Content content2; |
| 895 | CreateContent(0, kPcmuCodec, kH264Codec, &content2); |
| 896 | // Set |content2| to be InActive. |
| 897 | content2.set_direction(cricket::MD_INACTIVE); |
| 898 | |
| 899 | EXPECT_TRUE(channel1_->Enable(true)); |
| 900 | EXPECT_TRUE(channel2_->Enable(true)); |
Peter Boström | 34fbfff | 2015-09-24 19:20:30 +0200 | [diff] [blame] | 901 | if (verify_playout_) { |
| 902 | EXPECT_FALSE(media_channel1_->playout()); |
| 903 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 904 | EXPECT_FALSE(media_channel1_->sending()); |
Peter Boström | 34fbfff | 2015-09-24 19:20:30 +0200 | [diff] [blame] | 905 | if (verify_playout_) { |
| 906 | EXPECT_FALSE(media_channel2_->playout()); |
| 907 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 908 | EXPECT_FALSE(media_channel2_->sending()); |
| 909 | |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 910 | EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL)); |
| 911 | EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, NULL)); |
| 912 | EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_PRANSWER, NULL)); |
| 913 | EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_PRANSWER, NULL)); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 914 | transport_controller1_.Connect(&transport_controller2_); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 915 | |
Peter Boström | 34fbfff | 2015-09-24 19:20:30 +0200 | [diff] [blame] | 916 | if (verify_playout_) { |
| 917 | EXPECT_TRUE(media_channel1_->playout()); |
| 918 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 919 | EXPECT_FALSE(media_channel1_->sending()); // remote InActive |
Peter Boström | 34fbfff | 2015-09-24 19:20:30 +0200 | [diff] [blame] | 920 | if (verify_playout_) { |
| 921 | EXPECT_FALSE(media_channel2_->playout()); // local InActive |
| 922 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 923 | EXPECT_FALSE(media_channel2_->sending()); // local InActive |
| 924 | |
| 925 | // Update |content2| to be RecvOnly. |
| 926 | content2.set_direction(cricket::MD_RECVONLY); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 927 | EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_PRANSWER, NULL)); |
| 928 | EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_PRANSWER, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 929 | |
Peter Boström | 34fbfff | 2015-09-24 19:20:30 +0200 | [diff] [blame] | 930 | if (verify_playout_) { |
| 931 | EXPECT_TRUE(media_channel1_->playout()); |
| 932 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 933 | EXPECT_TRUE(media_channel1_->sending()); |
Peter Boström | 34fbfff | 2015-09-24 19:20:30 +0200 | [diff] [blame] | 934 | if (verify_playout_) { |
| 935 | EXPECT_TRUE(media_channel2_->playout()); // local RecvOnly |
| 936 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 937 | EXPECT_FALSE(media_channel2_->sending()); // local RecvOnly |
| 938 | |
| 939 | // Update |content2| to be SendRecv. |
| 940 | content2.set_direction(cricket::MD_SENDRECV); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 941 | EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_ANSWER, NULL)); |
| 942 | EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_ANSWER, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 943 | |
Peter Boström | 34fbfff | 2015-09-24 19:20:30 +0200 | [diff] [blame] | 944 | if (verify_playout_) { |
| 945 | EXPECT_TRUE(media_channel1_->playout()); |
| 946 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 947 | EXPECT_TRUE(media_channel1_->sending()); |
Peter Boström | 34fbfff | 2015-09-24 19:20:30 +0200 | [diff] [blame] | 948 | if (verify_playout_) { |
| 949 | EXPECT_TRUE(media_channel2_->playout()); |
| 950 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 951 | EXPECT_TRUE(media_channel2_->sending()); |
| 952 | } |
| 953 | |
| 954 | // Test setting up a call. |
| 955 | void TestCallSetup() { |
| 956 | CreateChannels(0, 0); |
| 957 | EXPECT_FALSE(channel1_->secure()); |
| 958 | EXPECT_TRUE(SendInitiate()); |
Peter Boström | 34fbfff | 2015-09-24 19:20:30 +0200 | [diff] [blame] | 959 | if (verify_playout_) { |
| 960 | EXPECT_TRUE(media_channel1_->playout()); |
| 961 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 962 | EXPECT_FALSE(media_channel1_->sending()); |
| 963 | EXPECT_TRUE(SendAccept()); |
| 964 | EXPECT_FALSE(channel1_->secure()); |
| 965 | EXPECT_TRUE(media_channel1_->sending()); |
| 966 | EXPECT_EQ(1U, media_channel1_->codecs().size()); |
Peter Boström | 34fbfff | 2015-09-24 19:20:30 +0200 | [diff] [blame] | 967 | if (verify_playout_) { |
| 968 | EXPECT_TRUE(media_channel2_->playout()); |
| 969 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 970 | EXPECT_TRUE(media_channel2_->sending()); |
| 971 | EXPECT_EQ(1U, media_channel2_->codecs().size()); |
| 972 | } |
| 973 | |
| 974 | // Test that we don't crash if packets are sent during call teardown |
| 975 | // when RTCP mux is enabled. This is a regression test against a specific |
| 976 | // race condition that would only occur when a RTCP packet was sent during |
| 977 | // teardown of a channel on which RTCP mux was enabled. |
| 978 | void TestCallTeardownRtcpMux() { |
| 979 | class LastWordMediaChannel : public T::MediaChannel { |
| 980 | public: |
Fredrik Solenberg | b071a19 | 2015-09-17 16:42:56 +0200 | [diff] [blame] | 981 | LastWordMediaChannel() : T::MediaChannel(NULL, typename T::Options()) {} |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 982 | ~LastWordMediaChannel() { |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 983 | T::MediaChannel::SendRtp(kPcmuFrame, sizeof(kPcmuFrame), |
| 984 | rtc::PacketOptions()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 985 | T::MediaChannel::SendRtcp(kRtcpReport, sizeof(kRtcpReport)); |
| 986 | } |
| 987 | }; |
| 988 | CreateChannels(new LastWordMediaChannel(), new LastWordMediaChannel(), |
| 989 | RTCP | RTCP_MUX, RTCP | RTCP_MUX, |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 990 | rtc::Thread::Current()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 991 | EXPECT_TRUE(SendInitiate()); |
| 992 | EXPECT_TRUE(SendAccept()); |
| 993 | EXPECT_TRUE(SendTerminate()); |
| 994 | } |
| 995 | |
| 996 | // Send voice RTP data to the other side and ensure it gets there. |
| 997 | void SendRtpToRtp() { |
| 998 | CreateChannels(0, 0); |
| 999 | EXPECT_TRUE(SendInitiate()); |
| 1000 | EXPECT_TRUE(SendAccept()); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1001 | ASSERT_TRUE(GetTransport1()); |
| 1002 | ASSERT_TRUE(GetTransport2()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1003 | EXPECT_EQ(1U, GetTransport1()->channels().size()); |
| 1004 | EXPECT_EQ(1U, GetTransport2()->channels().size()); |
| 1005 | EXPECT_TRUE(SendRtp1()); |
| 1006 | EXPECT_TRUE(SendRtp2()); |
| 1007 | EXPECT_TRUE(CheckRtp1()); |
| 1008 | EXPECT_TRUE(CheckRtp2()); |
| 1009 | EXPECT_TRUE(CheckNoRtp1()); |
| 1010 | EXPECT_TRUE(CheckNoRtp2()); |
| 1011 | } |
| 1012 | |
| 1013 | // Check that RTCP is not transmitted if both sides don't support RTCP. |
| 1014 | void SendNoRtcpToNoRtcp() { |
| 1015 | CreateChannels(0, 0); |
| 1016 | EXPECT_TRUE(SendInitiate()); |
| 1017 | EXPECT_TRUE(SendAccept()); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1018 | ASSERT_TRUE(GetTransport1()); |
| 1019 | ASSERT_TRUE(GetTransport2()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1020 | EXPECT_EQ(1U, GetTransport1()->channels().size()); |
| 1021 | EXPECT_EQ(1U, GetTransport2()->channels().size()); |
| 1022 | EXPECT_FALSE(SendRtcp1()); |
| 1023 | EXPECT_FALSE(SendRtcp2()); |
| 1024 | EXPECT_TRUE(CheckNoRtcp1()); |
| 1025 | EXPECT_TRUE(CheckNoRtcp2()); |
| 1026 | } |
| 1027 | |
| 1028 | // Check that RTCP is not transmitted if the callee doesn't support RTCP. |
| 1029 | void SendNoRtcpToRtcp() { |
| 1030 | CreateChannels(0, RTCP); |
| 1031 | EXPECT_TRUE(SendInitiate()); |
| 1032 | EXPECT_TRUE(SendAccept()); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1033 | ASSERT_TRUE(GetTransport1()); |
| 1034 | ASSERT_TRUE(GetTransport2()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1035 | EXPECT_EQ(1U, GetTransport1()->channels().size()); |
| 1036 | EXPECT_EQ(2U, GetTransport2()->channels().size()); |
| 1037 | EXPECT_FALSE(SendRtcp1()); |
| 1038 | EXPECT_FALSE(SendRtcp2()); |
| 1039 | EXPECT_TRUE(CheckNoRtcp1()); |
| 1040 | EXPECT_TRUE(CheckNoRtcp2()); |
| 1041 | } |
| 1042 | |
| 1043 | // Check that RTCP is not transmitted if the caller doesn't support RTCP. |
| 1044 | void SendRtcpToNoRtcp() { |
| 1045 | CreateChannels(RTCP, 0); |
| 1046 | EXPECT_TRUE(SendInitiate()); |
| 1047 | EXPECT_TRUE(SendAccept()); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1048 | ASSERT_TRUE(GetTransport1()); |
| 1049 | ASSERT_TRUE(GetTransport2()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1050 | EXPECT_EQ(2U, GetTransport1()->channels().size()); |
| 1051 | EXPECT_EQ(1U, GetTransport2()->channels().size()); |
| 1052 | EXPECT_FALSE(SendRtcp1()); |
| 1053 | EXPECT_FALSE(SendRtcp2()); |
| 1054 | EXPECT_TRUE(CheckNoRtcp1()); |
| 1055 | EXPECT_TRUE(CheckNoRtcp2()); |
| 1056 | } |
| 1057 | |
| 1058 | // Check that RTCP is transmitted if both sides support RTCP. |
| 1059 | void SendRtcpToRtcp() { |
| 1060 | CreateChannels(RTCP, RTCP); |
| 1061 | EXPECT_TRUE(SendInitiate()); |
| 1062 | EXPECT_TRUE(SendAccept()); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1063 | ASSERT_TRUE(GetTransport1()); |
| 1064 | ASSERT_TRUE(GetTransport2()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1065 | EXPECT_EQ(2U, GetTransport1()->channels().size()); |
| 1066 | EXPECT_EQ(2U, GetTransport2()->channels().size()); |
| 1067 | EXPECT_TRUE(SendRtcp1()); |
| 1068 | EXPECT_TRUE(SendRtcp2()); |
| 1069 | EXPECT_TRUE(CheckRtcp1()); |
| 1070 | EXPECT_TRUE(CheckRtcp2()); |
| 1071 | EXPECT_TRUE(CheckNoRtcp1()); |
| 1072 | EXPECT_TRUE(CheckNoRtcp2()); |
| 1073 | } |
| 1074 | |
| 1075 | // Check that RTCP is transmitted if only the initiator supports mux. |
| 1076 | void SendRtcpMuxToRtcp() { |
| 1077 | CreateChannels(RTCP | RTCP_MUX, RTCP); |
| 1078 | EXPECT_TRUE(SendInitiate()); |
| 1079 | EXPECT_TRUE(SendAccept()); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1080 | ASSERT_TRUE(GetTransport1()); |
| 1081 | ASSERT_TRUE(GetTransport2()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1082 | EXPECT_EQ(2U, GetTransport1()->channels().size()); |
| 1083 | EXPECT_EQ(2U, GetTransport2()->channels().size()); |
| 1084 | EXPECT_TRUE(SendRtcp1()); |
| 1085 | EXPECT_TRUE(SendRtcp2()); |
| 1086 | EXPECT_TRUE(CheckRtcp1()); |
| 1087 | EXPECT_TRUE(CheckRtcp2()); |
| 1088 | EXPECT_TRUE(CheckNoRtcp1()); |
| 1089 | EXPECT_TRUE(CheckNoRtcp2()); |
| 1090 | } |
| 1091 | |
| 1092 | // Check that RTP and RTCP are transmitted ok when both sides support mux. |
| 1093 | void SendRtcpMuxToRtcpMux() { |
| 1094 | CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); |
| 1095 | EXPECT_TRUE(SendInitiate()); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1096 | ASSERT_TRUE(GetTransport1()); |
| 1097 | ASSERT_TRUE(GetTransport2()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1098 | EXPECT_EQ(2U, GetTransport1()->channels().size()); |
| 1099 | EXPECT_EQ(1U, GetTransport2()->channels().size()); |
| 1100 | EXPECT_TRUE(SendAccept()); |
| 1101 | EXPECT_EQ(1U, GetTransport1()->channels().size()); |
| 1102 | EXPECT_TRUE(SendRtp1()); |
| 1103 | EXPECT_TRUE(SendRtp2()); |
| 1104 | EXPECT_TRUE(SendRtcp1()); |
| 1105 | EXPECT_TRUE(SendRtcp2()); |
| 1106 | EXPECT_TRUE(CheckRtp1()); |
| 1107 | EXPECT_TRUE(CheckRtp2()); |
| 1108 | EXPECT_TRUE(CheckNoRtp1()); |
| 1109 | EXPECT_TRUE(CheckNoRtp2()); |
| 1110 | EXPECT_TRUE(CheckRtcp1()); |
| 1111 | EXPECT_TRUE(CheckRtcp2()); |
| 1112 | EXPECT_TRUE(CheckNoRtcp1()); |
| 1113 | EXPECT_TRUE(CheckNoRtcp2()); |
| 1114 | } |
| 1115 | |
Peter Thatcher | af55ccc | 2015-05-21 07:48:41 -0700 | [diff] [blame] | 1116 | // Check that RTP and RTCP are transmitted ok when both sides |
| 1117 | // support mux and one the offerer requires mux. |
| 1118 | void SendRequireRtcpMuxToRtcpMux() { |
| 1119 | CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); |
| 1120 | channel1_->ActivateRtcpMux(); |
| 1121 | EXPECT_TRUE(SendInitiate()); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1122 | ASSERT_TRUE(GetTransport1()); |
| 1123 | ASSERT_TRUE(GetTransport2()); |
Peter Thatcher | af55ccc | 2015-05-21 07:48:41 -0700 | [diff] [blame] | 1124 | EXPECT_EQ(1U, GetTransport1()->channels().size()); |
| 1125 | EXPECT_EQ(1U, GetTransport2()->channels().size()); |
| 1126 | EXPECT_TRUE(SendAccept()); |
| 1127 | EXPECT_TRUE(SendRtp1()); |
| 1128 | EXPECT_TRUE(SendRtp2()); |
| 1129 | EXPECT_TRUE(SendRtcp1()); |
| 1130 | EXPECT_TRUE(SendRtcp2()); |
| 1131 | EXPECT_TRUE(CheckRtp1()); |
| 1132 | EXPECT_TRUE(CheckRtp2()); |
| 1133 | EXPECT_TRUE(CheckNoRtp1()); |
| 1134 | EXPECT_TRUE(CheckNoRtp2()); |
| 1135 | EXPECT_TRUE(CheckRtcp1()); |
| 1136 | EXPECT_TRUE(CheckRtcp2()); |
| 1137 | EXPECT_TRUE(CheckNoRtcp1()); |
| 1138 | EXPECT_TRUE(CheckNoRtcp2()); |
| 1139 | } |
| 1140 | |
| 1141 | // Check that RTP and RTCP are transmitted ok when both sides |
| 1142 | // support mux and one the answerer requires rtcp mux. |
| 1143 | void SendRtcpMuxToRequireRtcpMux() { |
| 1144 | CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); |
| 1145 | channel2_->ActivateRtcpMux(); |
| 1146 | EXPECT_TRUE(SendInitiate()); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1147 | ASSERT_TRUE(GetTransport1()); |
| 1148 | ASSERT_TRUE(GetTransport2()); |
Peter Thatcher | af55ccc | 2015-05-21 07:48:41 -0700 | [diff] [blame] | 1149 | EXPECT_EQ(2U, GetTransport1()->channels().size()); |
| 1150 | EXPECT_EQ(1U, GetTransport2()->channels().size()); |
| 1151 | EXPECT_TRUE(SendAccept()); |
| 1152 | EXPECT_EQ(1U, GetTransport1()->channels().size()); |
| 1153 | EXPECT_TRUE(SendRtp1()); |
| 1154 | EXPECT_TRUE(SendRtp2()); |
| 1155 | EXPECT_TRUE(SendRtcp1()); |
| 1156 | EXPECT_TRUE(SendRtcp2()); |
| 1157 | EXPECT_TRUE(CheckRtp1()); |
| 1158 | EXPECT_TRUE(CheckRtp2()); |
| 1159 | EXPECT_TRUE(CheckNoRtp1()); |
| 1160 | EXPECT_TRUE(CheckNoRtp2()); |
| 1161 | EXPECT_TRUE(CheckRtcp1()); |
| 1162 | EXPECT_TRUE(CheckRtcp2()); |
| 1163 | EXPECT_TRUE(CheckNoRtcp1()); |
| 1164 | EXPECT_TRUE(CheckNoRtcp2()); |
| 1165 | } |
| 1166 | |
| 1167 | // Check that RTP and RTCP are transmitted ok when both sides |
| 1168 | // require mux. |
| 1169 | void SendRequireRtcpMuxToRequireRtcpMux() { |
| 1170 | CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); |
| 1171 | channel1_->ActivateRtcpMux(); |
| 1172 | channel2_->ActivateRtcpMux(); |
| 1173 | EXPECT_TRUE(SendInitiate()); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1174 | ASSERT_TRUE(GetTransport1()); |
| 1175 | ASSERT_TRUE(GetTransport2()); |
Peter Thatcher | af55ccc | 2015-05-21 07:48:41 -0700 | [diff] [blame] | 1176 | EXPECT_EQ(1U, GetTransport1()->channels().size()); |
| 1177 | EXPECT_EQ(1U, GetTransport2()->channels().size()); |
| 1178 | EXPECT_TRUE(SendAccept()); |
| 1179 | EXPECT_EQ(1U, GetTransport1()->channels().size()); |
| 1180 | EXPECT_TRUE(SendRtp1()); |
| 1181 | EXPECT_TRUE(SendRtp2()); |
| 1182 | EXPECT_TRUE(SendRtcp1()); |
| 1183 | EXPECT_TRUE(SendRtcp2()); |
| 1184 | EXPECT_TRUE(CheckRtp1()); |
| 1185 | EXPECT_TRUE(CheckRtp2()); |
| 1186 | EXPECT_TRUE(CheckNoRtp1()); |
| 1187 | EXPECT_TRUE(CheckNoRtp2()); |
| 1188 | EXPECT_TRUE(CheckRtcp1()); |
| 1189 | EXPECT_TRUE(CheckRtcp2()); |
| 1190 | EXPECT_TRUE(CheckNoRtcp1()); |
| 1191 | EXPECT_TRUE(CheckNoRtcp2()); |
| 1192 | } |
| 1193 | |
| 1194 | // Check that SendAccept fails if the answerer doesn't support mux |
| 1195 | // and the offerer requires it. |
| 1196 | void SendRequireRtcpMuxToNoRtcpMux() { |
| 1197 | CreateChannels(RTCP | RTCP_MUX, RTCP); |
| 1198 | channel1_->ActivateRtcpMux(); |
| 1199 | EXPECT_TRUE(SendInitiate()); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1200 | ASSERT_TRUE(GetTransport1()); |
| 1201 | ASSERT_TRUE(GetTransport2()); |
Peter Thatcher | af55ccc | 2015-05-21 07:48:41 -0700 | [diff] [blame] | 1202 | EXPECT_EQ(1U, GetTransport1()->channels().size()); |
| 1203 | EXPECT_EQ(2U, GetTransport2()->channels().size()); |
| 1204 | EXPECT_FALSE(SendAccept()); |
| 1205 | } |
| 1206 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1207 | // Check that RTCP data sent by the initiator before the accept is not muxed. |
| 1208 | void SendEarlyRtcpMuxToRtcp() { |
| 1209 | CreateChannels(RTCP | RTCP_MUX, RTCP); |
| 1210 | EXPECT_TRUE(SendInitiate()); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1211 | ASSERT_TRUE(GetTransport1()); |
| 1212 | ASSERT_TRUE(GetTransport2()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1213 | EXPECT_EQ(2U, GetTransport1()->channels().size()); |
| 1214 | EXPECT_EQ(2U, GetTransport2()->channels().size()); |
| 1215 | |
| 1216 | // RTCP can be sent before the call is accepted, if the transport is ready. |
| 1217 | // It should not be muxed though, as the remote side doesn't support mux. |
| 1218 | EXPECT_TRUE(SendRtcp1()); |
| 1219 | EXPECT_TRUE(CheckNoRtp2()); |
| 1220 | EXPECT_TRUE(CheckRtcp2()); |
| 1221 | |
| 1222 | // Send RTCP packet from callee and verify that it is received. |
| 1223 | EXPECT_TRUE(SendRtcp2()); |
| 1224 | EXPECT_TRUE(CheckNoRtp1()); |
| 1225 | EXPECT_TRUE(CheckRtcp1()); |
| 1226 | |
| 1227 | // Complete call setup and ensure everything is still OK. |
| 1228 | EXPECT_TRUE(SendAccept()); |
| 1229 | EXPECT_EQ(2U, GetTransport1()->channels().size()); |
| 1230 | EXPECT_TRUE(SendRtcp1()); |
| 1231 | EXPECT_TRUE(CheckRtcp2()); |
| 1232 | EXPECT_TRUE(SendRtcp2()); |
| 1233 | EXPECT_TRUE(CheckRtcp1()); |
| 1234 | } |
| 1235 | |
| 1236 | |
| 1237 | // Check that RTCP data is not muxed until both sides have enabled muxing, |
| 1238 | // but that we properly demux before we get the accept message, since there |
| 1239 | // is a race between RTP data and the jingle accept. |
| 1240 | void SendEarlyRtcpMuxToRtcpMux() { |
| 1241 | CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); |
| 1242 | EXPECT_TRUE(SendInitiate()); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1243 | ASSERT_TRUE(GetTransport1()); |
| 1244 | ASSERT_TRUE(GetTransport2()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1245 | EXPECT_EQ(2U, GetTransport1()->channels().size()); |
| 1246 | EXPECT_EQ(1U, GetTransport2()->channels().size()); |
| 1247 | |
| 1248 | // RTCP can't be sent yet, since the RTCP transport isn't writable, and |
| 1249 | // we haven't yet received the accept that says we should mux. |
| 1250 | EXPECT_FALSE(SendRtcp1()); |
| 1251 | |
| 1252 | // Send muxed RTCP packet from callee and verify that it is received. |
| 1253 | EXPECT_TRUE(SendRtcp2()); |
| 1254 | EXPECT_TRUE(CheckNoRtp1()); |
| 1255 | EXPECT_TRUE(CheckRtcp1()); |
| 1256 | |
| 1257 | // Complete call setup and ensure everything is still OK. |
| 1258 | EXPECT_TRUE(SendAccept()); |
| 1259 | EXPECT_EQ(1U, GetTransport1()->channels().size()); |
| 1260 | EXPECT_TRUE(SendRtcp1()); |
| 1261 | EXPECT_TRUE(CheckRtcp2()); |
| 1262 | EXPECT_TRUE(SendRtcp2()); |
| 1263 | EXPECT_TRUE(CheckRtcp1()); |
| 1264 | } |
| 1265 | |
| 1266 | // Test that we properly send SRTP with RTCP in both directions. |
| 1267 | // You can pass in DTLS and/or RTCP_MUX as flags. |
| 1268 | void SendSrtpToSrtp(int flags1_in = 0, int flags2_in = 0) { |
| 1269 | ASSERT((flags1_in & ~(RTCP_MUX | DTLS)) == 0); |
| 1270 | ASSERT((flags2_in & ~(RTCP_MUX | DTLS)) == 0); |
| 1271 | |
| 1272 | int flags1 = RTCP | SECURE | flags1_in; |
| 1273 | int flags2 = RTCP | SECURE | flags2_in; |
| 1274 | bool dtls1 = !!(flags1_in & DTLS); |
| 1275 | bool dtls2 = !!(flags2_in & DTLS); |
| 1276 | CreateChannels(flags1, flags2); |
| 1277 | EXPECT_FALSE(channel1_->secure()); |
| 1278 | EXPECT_FALSE(channel2_->secure()); |
| 1279 | EXPECT_TRUE(SendInitiate()); |
| 1280 | EXPECT_TRUE_WAIT(channel1_->writable(), kEventTimeout); |
| 1281 | EXPECT_TRUE_WAIT(channel2_->writable(), kEventTimeout); |
| 1282 | EXPECT_TRUE(SendAccept()); |
| 1283 | EXPECT_TRUE(channel1_->secure()); |
| 1284 | EXPECT_TRUE(channel2_->secure()); |
| 1285 | EXPECT_EQ(dtls1 && dtls2, channel1_->secure_dtls()); |
| 1286 | EXPECT_EQ(dtls1 && dtls2, channel2_->secure_dtls()); |
| 1287 | EXPECT_TRUE(SendRtp1()); |
| 1288 | EXPECT_TRUE(SendRtp2()); |
| 1289 | EXPECT_TRUE(SendRtcp1()); |
| 1290 | EXPECT_TRUE(SendRtcp2()); |
| 1291 | EXPECT_TRUE(CheckRtp1()); |
| 1292 | EXPECT_TRUE(CheckRtp2()); |
| 1293 | EXPECT_TRUE(CheckNoRtp1()); |
| 1294 | EXPECT_TRUE(CheckNoRtp2()); |
| 1295 | EXPECT_TRUE(CheckRtcp1()); |
| 1296 | EXPECT_TRUE(CheckRtcp2()); |
| 1297 | EXPECT_TRUE(CheckNoRtcp1()); |
| 1298 | EXPECT_TRUE(CheckNoRtcp2()); |
| 1299 | } |
| 1300 | |
| 1301 | // Test that we properly handling SRTP negotiating down to RTP. |
| 1302 | void SendSrtpToRtp() { |
| 1303 | CreateChannels(RTCP | SECURE, RTCP); |
| 1304 | EXPECT_FALSE(channel1_->secure()); |
| 1305 | EXPECT_FALSE(channel2_->secure()); |
| 1306 | EXPECT_TRUE(SendInitiate()); |
| 1307 | EXPECT_TRUE(SendAccept()); |
| 1308 | EXPECT_FALSE(channel1_->secure()); |
| 1309 | EXPECT_FALSE(channel2_->secure()); |
| 1310 | EXPECT_TRUE(SendRtp1()); |
| 1311 | EXPECT_TRUE(SendRtp2()); |
| 1312 | EXPECT_TRUE(SendRtcp1()); |
| 1313 | EXPECT_TRUE(SendRtcp2()); |
| 1314 | EXPECT_TRUE(CheckRtp1()); |
| 1315 | EXPECT_TRUE(CheckRtp2()); |
| 1316 | EXPECT_TRUE(CheckNoRtp1()); |
| 1317 | EXPECT_TRUE(CheckNoRtp2()); |
| 1318 | EXPECT_TRUE(CheckRtcp1()); |
| 1319 | EXPECT_TRUE(CheckRtcp2()); |
| 1320 | EXPECT_TRUE(CheckNoRtcp1()); |
| 1321 | EXPECT_TRUE(CheckNoRtcp2()); |
| 1322 | } |
| 1323 | |
| 1324 | // Test that we can send and receive early media when a provisional answer is |
| 1325 | // sent and received. The test uses SRTP, RTCP mux and SSRC mux. |
| 1326 | void SendEarlyMediaUsingRtcpMuxSrtp() { |
| 1327 | int sequence_number1_1 = 0, sequence_number2_2 = 0; |
| 1328 | |
| 1329 | CreateChannels(SSRC_MUX | RTCP | RTCP_MUX | SECURE, |
| 1330 | SSRC_MUX | RTCP | RTCP_MUX | SECURE); |
| 1331 | EXPECT_TRUE(SendOffer()); |
| 1332 | EXPECT_TRUE(SendProvisionalAnswer()); |
| 1333 | EXPECT_TRUE(channel1_->secure()); |
| 1334 | EXPECT_TRUE(channel2_->secure()); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1335 | ASSERT_TRUE(GetTransport1()); |
| 1336 | ASSERT_TRUE(GetTransport2()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1337 | EXPECT_EQ(2U, GetTransport1()->channels().size()); |
| 1338 | EXPECT_EQ(2U, GetTransport2()->channels().size()); |
| 1339 | EXPECT_TRUE(SendCustomRtcp1(kSsrc1)); |
| 1340 | EXPECT_TRUE(CheckCustomRtcp2(kSsrc1)); |
| 1341 | EXPECT_TRUE(SendCustomRtp1(kSsrc1, ++sequence_number1_1)); |
| 1342 | EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1)); |
| 1343 | |
| 1344 | // Send packets from callee and verify that it is received. |
| 1345 | EXPECT_TRUE(SendCustomRtcp2(kSsrc2)); |
| 1346 | EXPECT_TRUE(CheckCustomRtcp1(kSsrc2)); |
| 1347 | EXPECT_TRUE(SendCustomRtp2(kSsrc2, ++sequence_number2_2)); |
| 1348 | EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2)); |
| 1349 | |
| 1350 | // Complete call setup and ensure everything is still OK. |
| 1351 | EXPECT_TRUE(SendFinalAnswer()); |
| 1352 | EXPECT_EQ(1U, GetTransport1()->channels().size()); |
| 1353 | EXPECT_EQ(1U, GetTransport2()->channels().size()); |
| 1354 | EXPECT_TRUE(channel1_->secure()); |
| 1355 | EXPECT_TRUE(channel2_->secure()); |
| 1356 | EXPECT_TRUE(SendCustomRtcp1(kSsrc1)); |
| 1357 | EXPECT_TRUE(CheckCustomRtcp2(kSsrc1)); |
| 1358 | EXPECT_TRUE(SendCustomRtp1(kSsrc1, ++sequence_number1_1)); |
| 1359 | EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1)); |
| 1360 | EXPECT_TRUE(SendCustomRtcp2(kSsrc2)); |
| 1361 | EXPECT_TRUE(CheckCustomRtcp1(kSsrc2)); |
| 1362 | EXPECT_TRUE(SendCustomRtp2(kSsrc2, ++sequence_number2_2)); |
| 1363 | EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2)); |
| 1364 | } |
| 1365 | |
| 1366 | // Test that we properly send RTP without SRTP from a thread. |
| 1367 | void SendRtpToRtpOnThread() { |
buildbot@webrtc.org | 6bfd619 | 2014-05-15 16:15:59 +0000 | [diff] [blame] | 1368 | CreateChannels(RTCP, RTCP); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1369 | EXPECT_TRUE(SendInitiate()); |
| 1370 | EXPECT_TRUE(SendAccept()); |
ossu | 292d658 | 2016-03-17 02:31:13 -0700 | [diff] [blame^] | 1371 | ScopedCallThread send_rtp1(this, &ChannelTest<T>::SendRtp1); |
| 1372 | ScopedCallThread send_rtp2(this, &ChannelTest<T>::SendRtp2); |
| 1373 | ScopedCallThread send_rtcp1(this, &ChannelTest<T>::SendRtcp1); |
| 1374 | ScopedCallThread send_rtcp2(this, &ChannelTest<T>::SendRtcp2); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1375 | EXPECT_TRUE_WAIT(CheckRtp1(), 1000); |
| 1376 | EXPECT_TRUE_WAIT(CheckRtp2(), 1000); |
ossu | 292d658 | 2016-03-17 02:31:13 -0700 | [diff] [blame^] | 1377 | EXPECT_TRUE_WAIT(send_rtp1.result(), 1000); |
| 1378 | EXPECT_TRUE_WAIT(send_rtp2.result(), 1000); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1379 | EXPECT_TRUE(CheckNoRtp1()); |
| 1380 | EXPECT_TRUE(CheckNoRtp2()); |
| 1381 | EXPECT_TRUE_WAIT(CheckRtcp1(), 1000); |
| 1382 | EXPECT_TRUE_WAIT(CheckRtcp2(), 1000); |
ossu | 292d658 | 2016-03-17 02:31:13 -0700 | [diff] [blame^] | 1383 | EXPECT_TRUE_WAIT(send_rtcp1.result(), 1000); |
| 1384 | EXPECT_TRUE_WAIT(send_rtcp2.result(), 1000); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1385 | EXPECT_TRUE(CheckNoRtcp1()); |
| 1386 | EXPECT_TRUE(CheckNoRtcp2()); |
| 1387 | } |
| 1388 | |
| 1389 | // Test that we properly send SRTP with RTCP from a thread. |
| 1390 | void SendSrtpToSrtpOnThread() { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1391 | CreateChannels(RTCP | SECURE, RTCP | SECURE); |
| 1392 | EXPECT_TRUE(SendInitiate()); |
| 1393 | EXPECT_TRUE(SendAccept()); |
ossu | 292d658 | 2016-03-17 02:31:13 -0700 | [diff] [blame^] | 1394 | ScopedCallThread send_rtp1(this, &ChannelTest<T>::SendRtp1); |
| 1395 | ScopedCallThread send_rtp2(this, &ChannelTest<T>::SendRtp2); |
| 1396 | ScopedCallThread send_rtcp1(this, &ChannelTest<T>::SendRtcp1); |
| 1397 | ScopedCallThread send_rtcp2(this, &ChannelTest<T>::SendRtcp2); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1398 | EXPECT_TRUE_WAIT(CheckRtp1(), 1000); |
| 1399 | EXPECT_TRUE_WAIT(CheckRtp2(), 1000); |
ossu | 292d658 | 2016-03-17 02:31:13 -0700 | [diff] [blame^] | 1400 | EXPECT_TRUE_WAIT(send_rtp1.result(), 1000); |
| 1401 | EXPECT_TRUE_WAIT(send_rtp2.result(), 1000); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1402 | EXPECT_TRUE(CheckNoRtp1()); |
| 1403 | EXPECT_TRUE(CheckNoRtp2()); |
| 1404 | EXPECT_TRUE_WAIT(CheckRtcp1(), 1000); |
| 1405 | EXPECT_TRUE_WAIT(CheckRtcp2(), 1000); |
ossu | 292d658 | 2016-03-17 02:31:13 -0700 | [diff] [blame^] | 1406 | EXPECT_TRUE_WAIT(send_rtcp1.result(), 1000); |
| 1407 | EXPECT_TRUE_WAIT(send_rtcp2.result(), 1000); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1408 | EXPECT_TRUE(CheckNoRtcp1()); |
| 1409 | EXPECT_TRUE(CheckNoRtcp2()); |
| 1410 | } |
| 1411 | |
| 1412 | // Test that the mediachannel retains its sending state after the transport |
| 1413 | // becomes non-writable. |
| 1414 | void SendWithWritabilityLoss() { |
| 1415 | CreateChannels(0, 0); |
| 1416 | EXPECT_TRUE(SendInitiate()); |
| 1417 | EXPECT_TRUE(SendAccept()); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1418 | ASSERT_TRUE(GetTransport1()); |
| 1419 | ASSERT_TRUE(GetTransport2()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1420 | EXPECT_EQ(1U, GetTransport1()->channels().size()); |
| 1421 | EXPECT_EQ(1U, GetTransport2()->channels().size()); |
| 1422 | EXPECT_TRUE(SendRtp1()); |
| 1423 | EXPECT_TRUE(SendRtp2()); |
| 1424 | EXPECT_TRUE(CheckRtp1()); |
| 1425 | EXPECT_TRUE(CheckRtp2()); |
| 1426 | EXPECT_TRUE(CheckNoRtp1()); |
| 1427 | EXPECT_TRUE(CheckNoRtp2()); |
| 1428 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 1429 | // Lose writability, which should fail. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1430 | GetTransport1()->SetWritable(false); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1431 | EXPECT_FALSE(SendRtp1()); |
| 1432 | EXPECT_TRUE(SendRtp2()); |
| 1433 | EXPECT_TRUE(CheckRtp1()); |
| 1434 | EXPECT_TRUE(CheckNoRtp2()); |
| 1435 | |
| 1436 | // Regain writability |
| 1437 | GetTransport1()->SetWritable(true); |
| 1438 | EXPECT_TRUE(media_channel1_->sending()); |
| 1439 | EXPECT_TRUE(SendRtp1()); |
| 1440 | EXPECT_TRUE(SendRtp2()); |
| 1441 | EXPECT_TRUE(CheckRtp1()); |
| 1442 | EXPECT_TRUE(CheckRtp2()); |
| 1443 | EXPECT_TRUE(CheckNoRtp1()); |
| 1444 | EXPECT_TRUE(CheckNoRtp2()); |
| 1445 | |
| 1446 | // Lose writability completely |
| 1447 | GetTransport1()->SetDestination(NULL); |
| 1448 | EXPECT_TRUE(media_channel1_->sending()); |
| 1449 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 1450 | // Should fail also. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1451 | EXPECT_FALSE(SendRtp1()); |
| 1452 | EXPECT_TRUE(SendRtp2()); |
| 1453 | EXPECT_TRUE(CheckRtp1()); |
| 1454 | EXPECT_TRUE(CheckNoRtp2()); |
| 1455 | |
| 1456 | // Gain writability back |
| 1457 | GetTransport1()->SetDestination(GetTransport2()); |
| 1458 | EXPECT_TRUE(media_channel1_->sending()); |
| 1459 | EXPECT_TRUE(SendRtp1()); |
| 1460 | EXPECT_TRUE(SendRtp2()); |
| 1461 | EXPECT_TRUE(CheckRtp1()); |
| 1462 | EXPECT_TRUE(CheckRtp2()); |
| 1463 | EXPECT_TRUE(CheckNoRtp1()); |
| 1464 | EXPECT_TRUE(CheckNoRtp2()); |
| 1465 | } |
| 1466 | |
buildbot@webrtc.org | 5ee0f05 | 2014-05-05 20:18:08 +0000 | [diff] [blame] | 1467 | void SendBundleToBundle( |
| 1468 | const int* pl_types, int len, bool rtcp_mux, bool secure) { |
| 1469 | ASSERT_EQ(2, len); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1470 | int sequence_number1_1 = 0, sequence_number2_2 = 0; |
buildbot@webrtc.org | 5ee0f05 | 2014-05-05 20:18:08 +0000 | [diff] [blame] | 1471 | // Only pl_type1 was added to the bundle filter for both |channel1_| |
| 1472 | // and |channel2_|. |
| 1473 | int pl_type1 = pl_types[0]; |
| 1474 | int pl_type2 = pl_types[1]; |
| 1475 | int flags = SSRC_MUX | RTCP; |
| 1476 | if (secure) flags |= SECURE; |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 1477 | uint32_t expected_channels = 2U; |
buildbot@webrtc.org | 5ee0f05 | 2014-05-05 20:18:08 +0000 | [diff] [blame] | 1478 | if (rtcp_mux) { |
| 1479 | flags |= RTCP_MUX; |
| 1480 | expected_channels = 1U; |
| 1481 | } |
| 1482 | CreateChannels(flags, flags); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1483 | EXPECT_TRUE(SendInitiate()); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1484 | ASSERT_TRUE(GetTransport1()); |
| 1485 | ASSERT_TRUE(GetTransport2()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1486 | EXPECT_EQ(2U, GetTransport1()->channels().size()); |
buildbot@webrtc.org | 5ee0f05 | 2014-05-05 20:18:08 +0000 | [diff] [blame] | 1487 | EXPECT_EQ(expected_channels, GetTransport2()->channels().size()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1488 | EXPECT_TRUE(SendAccept()); |
buildbot@webrtc.org | 5ee0f05 | 2014-05-05 20:18:08 +0000 | [diff] [blame] | 1489 | EXPECT_EQ(expected_channels, GetTransport1()->channels().size()); |
| 1490 | EXPECT_EQ(expected_channels, GetTransport2()->channels().size()); |
| 1491 | EXPECT_TRUE(channel1_->bundle_filter()->FindPayloadType(pl_type1)); |
| 1492 | EXPECT_TRUE(channel2_->bundle_filter()->FindPayloadType(pl_type1)); |
| 1493 | EXPECT_FALSE(channel1_->bundle_filter()->FindPayloadType(pl_type2)); |
| 1494 | EXPECT_FALSE(channel2_->bundle_filter()->FindPayloadType(pl_type2)); |
buildbot@webrtc.org | 5ee0f05 | 2014-05-05 20:18:08 +0000 | [diff] [blame] | 1495 | |
| 1496 | // Both channels can receive pl_type1 only. |
| 1497 | EXPECT_TRUE(SendCustomRtp1(kSsrc1, ++sequence_number1_1, pl_type1)); |
| 1498 | EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1, pl_type1)); |
| 1499 | EXPECT_TRUE(SendCustomRtp2(kSsrc2, ++sequence_number2_2, pl_type1)); |
| 1500 | EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2, pl_type1)); |
| 1501 | EXPECT_TRUE(CheckNoRtp1()); |
| 1502 | EXPECT_TRUE(CheckNoRtp2()); |
| 1503 | |
| 1504 | // RTCP test |
| 1505 | EXPECT_TRUE(SendCustomRtp1(kSsrc1, ++sequence_number1_1, pl_type2)); |
| 1506 | EXPECT_FALSE(CheckCustomRtp2(kSsrc1, sequence_number1_1, pl_type2)); |
| 1507 | EXPECT_TRUE(SendCustomRtp2(kSsrc2, ++sequence_number2_2, pl_type2)); |
| 1508 | EXPECT_FALSE(CheckCustomRtp1(kSsrc2, sequence_number2_2, pl_type2)); |
| 1509 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1510 | EXPECT_TRUE(SendCustomRtcp1(kSsrc1)); |
| 1511 | EXPECT_TRUE(SendCustomRtcp2(kSsrc2)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1512 | EXPECT_TRUE(CheckCustomRtcp1(kSsrc2)); |
| 1513 | EXPECT_TRUE(CheckNoRtcp1()); |
| 1514 | EXPECT_TRUE(CheckCustomRtcp2(kSsrc1)); |
| 1515 | EXPECT_TRUE(CheckNoRtcp2()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1516 | |
buildbot@webrtc.org | 5ee0f05 | 2014-05-05 20:18:08 +0000 | [diff] [blame] | 1517 | EXPECT_TRUE(SendCustomRtcp1(kSsrc2)); |
| 1518 | EXPECT_TRUE(SendCustomRtcp2(kSsrc1)); |
pbos | 482b12e | 2015-11-16 10:19:58 -0800 | [diff] [blame] | 1519 | // Bundle filter shouldn't filter out any RTCP. |
| 1520 | EXPECT_TRUE(CheckCustomRtcp1(kSsrc1)); |
| 1521 | EXPECT_TRUE(CheckCustomRtcp2(kSsrc2)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1522 | } |
| 1523 | |
| 1524 | // Test that the media monitor can be run and gives timely callbacks. |
| 1525 | void TestMediaMonitor() { |
| 1526 | static const int kTimeout = 500; |
| 1527 | CreateChannels(0, 0); |
| 1528 | EXPECT_TRUE(SendInitiate()); |
| 1529 | EXPECT_TRUE(SendAccept()); |
| 1530 | channel1_->StartMediaMonitor(100); |
| 1531 | channel2_->StartMediaMonitor(100); |
| 1532 | // Ensure we get callbacks and stop. |
| 1533 | EXPECT_TRUE_WAIT(media_info_callbacks1_ > 0, kTimeout); |
| 1534 | EXPECT_TRUE_WAIT(media_info_callbacks2_ > 0, kTimeout); |
| 1535 | channel1_->StopMediaMonitor(); |
| 1536 | channel2_->StopMediaMonitor(); |
| 1537 | // Ensure a restart of a stopped monitor works. |
| 1538 | channel1_->StartMediaMonitor(100); |
| 1539 | EXPECT_TRUE_WAIT(media_info_callbacks1_ > 0, kTimeout); |
| 1540 | channel1_->StopMediaMonitor(); |
| 1541 | // Ensure stopping a stopped monitor is OK. |
| 1542 | channel1_->StopMediaMonitor(); |
| 1543 | } |
| 1544 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1545 | void TestSetContentFailure() { |
| 1546 | CreateChannels(0, 0); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1547 | |
Peter Thatcher | a6d2444 | 2015-07-09 21:26:36 -0700 | [diff] [blame] | 1548 | auto sdesc = cricket::SessionDescription(); |
| 1549 | sdesc.AddContent(cricket::CN_AUDIO, cricket::NS_JINGLE_RTP, |
| 1550 | new cricket::AudioContentDescription()); |
| 1551 | sdesc.AddContent(cricket::CN_VIDEO, cricket::NS_JINGLE_RTP, |
| 1552 | new cricket::VideoContentDescription()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1553 | |
Peter Thatcher | a6d2444 | 2015-07-09 21:26:36 -0700 | [diff] [blame] | 1554 | std::string err; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1555 | media_channel1_->set_fail_set_recv_codecs(true); |
Peter Thatcher | a6d2444 | 2015-07-09 21:26:36 -0700 | [diff] [blame] | 1556 | EXPECT_FALSE(channel1_->PushdownLocalDescription( |
| 1557 | &sdesc, cricket::CA_OFFER, &err)); |
| 1558 | EXPECT_FALSE(channel1_->PushdownLocalDescription( |
| 1559 | &sdesc, cricket::CA_ANSWER, &err)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1560 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1561 | media_channel1_->set_fail_set_send_codecs(true); |
Peter Thatcher | a6d2444 | 2015-07-09 21:26:36 -0700 | [diff] [blame] | 1562 | EXPECT_FALSE(channel1_->PushdownRemoteDescription( |
| 1563 | &sdesc, cricket::CA_OFFER, &err)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1564 | media_channel1_->set_fail_set_send_codecs(true); |
Peter Thatcher | a6d2444 | 2015-07-09 21:26:36 -0700 | [diff] [blame] | 1565 | EXPECT_FALSE(channel1_->PushdownRemoteDescription( |
| 1566 | &sdesc, cricket::CA_ANSWER, &err)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1567 | } |
| 1568 | |
| 1569 | void TestSendTwoOffers() { |
| 1570 | CreateChannels(0, 0); |
| 1571 | |
Peter Thatcher | a6d2444 | 2015-07-09 21:26:36 -0700 | [diff] [blame] | 1572 | std::string err; |
kwiberg | 3102294 | 2016-03-11 14:18:21 -0800 | [diff] [blame] | 1573 | std::unique_ptr<cricket::SessionDescription> sdesc1( |
Peter Thatcher | a6d2444 | 2015-07-09 21:26:36 -0700 | [diff] [blame] | 1574 | CreateSessionDescriptionWithStream(1)); |
| 1575 | EXPECT_TRUE(channel1_->PushdownLocalDescription( |
| 1576 | sdesc1.get(), cricket::CA_OFFER, &err)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1577 | EXPECT_TRUE(media_channel1_->HasSendStream(1)); |
| 1578 | |
kwiberg | 3102294 | 2016-03-11 14:18:21 -0800 | [diff] [blame] | 1579 | std::unique_ptr<cricket::SessionDescription> sdesc2( |
Peter Thatcher | a6d2444 | 2015-07-09 21:26:36 -0700 | [diff] [blame] | 1580 | CreateSessionDescriptionWithStream(2)); |
| 1581 | EXPECT_TRUE(channel1_->PushdownLocalDescription( |
| 1582 | sdesc2.get(), cricket::CA_OFFER, &err)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1583 | EXPECT_FALSE(media_channel1_->HasSendStream(1)); |
| 1584 | EXPECT_TRUE(media_channel1_->HasSendStream(2)); |
| 1585 | } |
| 1586 | |
| 1587 | void TestReceiveTwoOffers() { |
| 1588 | CreateChannels(0, 0); |
| 1589 | |
Peter Thatcher | a6d2444 | 2015-07-09 21:26:36 -0700 | [diff] [blame] | 1590 | std::string err; |
kwiberg | 3102294 | 2016-03-11 14:18:21 -0800 | [diff] [blame] | 1591 | std::unique_ptr<cricket::SessionDescription> sdesc1( |
Peter Thatcher | a6d2444 | 2015-07-09 21:26:36 -0700 | [diff] [blame] | 1592 | CreateSessionDescriptionWithStream(1)); |
| 1593 | EXPECT_TRUE(channel1_->PushdownRemoteDescription( |
| 1594 | sdesc1.get(), cricket::CA_OFFER, &err)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1595 | EXPECT_TRUE(media_channel1_->HasRecvStream(1)); |
| 1596 | |
kwiberg | 3102294 | 2016-03-11 14:18:21 -0800 | [diff] [blame] | 1597 | std::unique_ptr<cricket::SessionDescription> sdesc2( |
Peter Thatcher | a6d2444 | 2015-07-09 21:26:36 -0700 | [diff] [blame] | 1598 | CreateSessionDescriptionWithStream(2)); |
| 1599 | EXPECT_TRUE(channel1_->PushdownRemoteDescription( |
| 1600 | sdesc2.get(), cricket::CA_OFFER, &err)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1601 | EXPECT_FALSE(media_channel1_->HasRecvStream(1)); |
| 1602 | EXPECT_TRUE(media_channel1_->HasRecvStream(2)); |
| 1603 | } |
| 1604 | |
| 1605 | void TestSendPrAnswer() { |
| 1606 | CreateChannels(0, 0); |
| 1607 | |
Peter Thatcher | a6d2444 | 2015-07-09 21:26:36 -0700 | [diff] [blame] | 1608 | std::string err; |
| 1609 | // Receive offer |
kwiberg | 3102294 | 2016-03-11 14:18:21 -0800 | [diff] [blame] | 1610 | std::unique_ptr<cricket::SessionDescription> sdesc1( |
Peter Thatcher | a6d2444 | 2015-07-09 21:26:36 -0700 | [diff] [blame] | 1611 | CreateSessionDescriptionWithStream(1)); |
| 1612 | EXPECT_TRUE(channel1_->PushdownRemoteDescription( |
| 1613 | sdesc1.get(), cricket::CA_OFFER, &err)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1614 | EXPECT_TRUE(media_channel1_->HasRecvStream(1)); |
| 1615 | |
Peter Thatcher | a6d2444 | 2015-07-09 21:26:36 -0700 | [diff] [blame] | 1616 | // Send PR answer |
kwiberg | 3102294 | 2016-03-11 14:18:21 -0800 | [diff] [blame] | 1617 | std::unique_ptr<cricket::SessionDescription> sdesc2( |
Peter Thatcher | a6d2444 | 2015-07-09 21:26:36 -0700 | [diff] [blame] | 1618 | CreateSessionDescriptionWithStream(2)); |
| 1619 | EXPECT_TRUE(channel1_->PushdownLocalDescription( |
| 1620 | sdesc2.get(), cricket::CA_PRANSWER, &err)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1621 | EXPECT_TRUE(media_channel1_->HasRecvStream(1)); |
| 1622 | EXPECT_TRUE(media_channel1_->HasSendStream(2)); |
| 1623 | |
Peter Thatcher | a6d2444 | 2015-07-09 21:26:36 -0700 | [diff] [blame] | 1624 | // Send answer |
kwiberg | 3102294 | 2016-03-11 14:18:21 -0800 | [diff] [blame] | 1625 | std::unique_ptr<cricket::SessionDescription> sdesc3( |
Peter Thatcher | a6d2444 | 2015-07-09 21:26:36 -0700 | [diff] [blame] | 1626 | CreateSessionDescriptionWithStream(3)); |
| 1627 | EXPECT_TRUE(channel1_->PushdownLocalDescription( |
| 1628 | sdesc3.get(), cricket::CA_ANSWER, &err)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1629 | EXPECT_TRUE(media_channel1_->HasRecvStream(1)); |
| 1630 | EXPECT_FALSE(media_channel1_->HasSendStream(2)); |
| 1631 | EXPECT_TRUE(media_channel1_->HasSendStream(3)); |
| 1632 | } |
| 1633 | |
| 1634 | void TestReceivePrAnswer() { |
| 1635 | CreateChannels(0, 0); |
| 1636 | |
Peter Thatcher | a6d2444 | 2015-07-09 21:26:36 -0700 | [diff] [blame] | 1637 | std::string err; |
| 1638 | // Send offer |
kwiberg | 3102294 | 2016-03-11 14:18:21 -0800 | [diff] [blame] | 1639 | std::unique_ptr<cricket::SessionDescription> sdesc1( |
Peter Thatcher | a6d2444 | 2015-07-09 21:26:36 -0700 | [diff] [blame] | 1640 | CreateSessionDescriptionWithStream(1)); |
| 1641 | EXPECT_TRUE(channel1_->PushdownLocalDescription( |
| 1642 | sdesc1.get(), cricket::CA_OFFER, &err)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1643 | EXPECT_TRUE(media_channel1_->HasSendStream(1)); |
| 1644 | |
Peter Thatcher | a6d2444 | 2015-07-09 21:26:36 -0700 | [diff] [blame] | 1645 | // Receive PR answer |
kwiberg | 3102294 | 2016-03-11 14:18:21 -0800 | [diff] [blame] | 1646 | std::unique_ptr<cricket::SessionDescription> sdesc2( |
Peter Thatcher | a6d2444 | 2015-07-09 21:26:36 -0700 | [diff] [blame] | 1647 | CreateSessionDescriptionWithStream(2)); |
| 1648 | EXPECT_TRUE(channel1_->PushdownRemoteDescription( |
| 1649 | sdesc2.get(), cricket::CA_PRANSWER, &err)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1650 | EXPECT_TRUE(media_channel1_->HasSendStream(1)); |
| 1651 | EXPECT_TRUE(media_channel1_->HasRecvStream(2)); |
| 1652 | |
Peter Thatcher | a6d2444 | 2015-07-09 21:26:36 -0700 | [diff] [blame] | 1653 | // Receive answer |
kwiberg | 3102294 | 2016-03-11 14:18:21 -0800 | [diff] [blame] | 1654 | std::unique_ptr<cricket::SessionDescription> sdesc3( |
Peter Thatcher | a6d2444 | 2015-07-09 21:26:36 -0700 | [diff] [blame] | 1655 | CreateSessionDescriptionWithStream(3)); |
| 1656 | EXPECT_TRUE(channel1_->PushdownRemoteDescription( |
| 1657 | sdesc3.get(), cricket::CA_ANSWER, &err)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1658 | EXPECT_TRUE(media_channel1_->HasSendStream(1)); |
| 1659 | EXPECT_FALSE(media_channel1_->HasRecvStream(2)); |
| 1660 | EXPECT_TRUE(media_channel1_->HasRecvStream(3)); |
| 1661 | } |
| 1662 | |
| 1663 | void TestFlushRtcp() { |
| 1664 | bool send_rtcp1; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1665 | CreateChannels(RTCP, RTCP); |
| 1666 | EXPECT_TRUE(SendInitiate()); |
| 1667 | EXPECT_TRUE(SendAccept()); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1668 | ASSERT_TRUE(GetTransport1()); |
| 1669 | ASSERT_TRUE(GetTransport2()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1670 | EXPECT_EQ(2U, GetTransport1()->channels().size()); |
| 1671 | EXPECT_EQ(2U, GetTransport2()->channels().size()); |
| 1672 | |
| 1673 | // Send RTCP1 from a different thread. |
| 1674 | CallOnThreadAndWaitForDone(&ChannelTest<T>::SendRtcp1, &send_rtcp1); |
| 1675 | EXPECT_TRUE(send_rtcp1); |
| 1676 | // The sending message is only posted. channel2_ should be empty. |
| 1677 | EXPECT_TRUE(CheckNoRtcp2()); |
| 1678 | |
| 1679 | // When channel1_ is deleted, the RTCP packet should be sent out to |
| 1680 | // channel2_. |
| 1681 | channel1_.reset(); |
| 1682 | EXPECT_TRUE(CheckRtcp2()); |
| 1683 | } |
| 1684 | |
buildbot@webrtc.org | 5ee0f05 | 2014-05-05 20:18:08 +0000 | [diff] [blame] | 1685 | void TestSrtpError(int pl_type) { |
solenberg | 5b14b42 | 2015-10-01 04:10:31 -0700 | [diff] [blame] | 1686 | struct SrtpErrorHandler : public sigslot::has_slots<> { |
| 1687 | SrtpErrorHandler() : |
| 1688 | mode_(cricket::SrtpFilter::UNPROTECT), |
| 1689 | error_(cricket::SrtpFilter::ERROR_NONE) {} |
| 1690 | void OnSrtpError(uint32 ssrc, cricket::SrtpFilter::Mode mode, |
| 1691 | cricket::SrtpFilter::Error error) { |
| 1692 | mode_ = mode; |
| 1693 | error_ = error; |
| 1694 | } |
| 1695 | cricket::SrtpFilter::Mode mode_; |
| 1696 | cricket::SrtpFilter::Error error_; |
| 1697 | } error_handler; |
| 1698 | |
buildbot@webrtc.org | 5ee0f05 | 2014-05-05 20:18:08 +0000 | [diff] [blame] | 1699 | // For Audio, only pl_type 0 is added to the bundle filter. |
| 1700 | // For Video, only pl_type 97 is added to the bundle filter. |
| 1701 | // So we need to pass in pl_type so that the packet can pass through |
| 1702 | // the bundle filter before it can be processed by the srtp filter. |
| 1703 | // The packet is not a valid srtp packet because it is too short. |
pbos@webrtc.org | 910473b | 2014-06-06 15:44:00 +0000 | [diff] [blame] | 1704 | unsigned const char kBadPacket[] = {0x84, |
| 1705 | static_cast<unsigned char>(pl_type), |
| 1706 | 0x00, |
| 1707 | 0x01, |
| 1708 | 0x00, |
| 1709 | 0x00, |
| 1710 | 0x00, |
| 1711 | 0x00, |
| 1712 | 0x00, |
| 1713 | 0x00, |
| 1714 | 0x00, |
| 1715 | 0x01}; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1716 | CreateChannels(RTCP | SECURE, RTCP | SECURE); |
| 1717 | EXPECT_FALSE(channel1_->secure()); |
| 1718 | EXPECT_FALSE(channel2_->secure()); |
| 1719 | EXPECT_TRUE(SendInitiate()); |
| 1720 | EXPECT_TRUE(SendAccept()); |
| 1721 | EXPECT_TRUE(channel1_->secure()); |
| 1722 | EXPECT_TRUE(channel2_->secure()); |
solenberg | 5629a1d | 2015-10-01 08:45:57 -0700 | [diff] [blame] | 1723 | channel2_->srtp_filter()->set_signal_silent_time(250); |
solenberg | 5b14b42 | 2015-10-01 04:10:31 -0700 | [diff] [blame] | 1724 | channel2_->srtp_filter()->SignalSrtpError.connect( |
| 1725 | &error_handler, &SrtpErrorHandler::OnSrtpError); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1726 | |
| 1727 | // Testing failures in sending packets. |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 1728 | EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket), |
| 1729 | rtc::PacketOptions())); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1730 | // The first failure will trigger an error. |
solenberg | 5b14b42 | 2015-10-01 04:10:31 -0700 | [diff] [blame] | 1731 | EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500); |
| 1732 | EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_); |
| 1733 | error_handler.error_ = cricket::SrtpFilter::ERROR_NONE; |
solenberg | 5629a1d | 2015-10-01 08:45:57 -0700 | [diff] [blame] | 1734 | error_handler.mode_ = cricket::SrtpFilter::UNPROTECT; |
| 1735 | // The next 250 ms failures will not trigger an error. |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 1736 | EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket), |
| 1737 | rtc::PacketOptions())); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1738 | // Wait for a while to ensure no message comes in. |
solenberg | 5629a1d | 2015-10-01 08:45:57 -0700 | [diff] [blame] | 1739 | rtc::Thread::Current()->ProcessMessages(200); |
solenberg | 5b14b42 | 2015-10-01 04:10:31 -0700 | [diff] [blame] | 1740 | EXPECT_EQ(cricket::SrtpFilter::ERROR_NONE, error_handler.error_); |
solenberg | 5629a1d | 2015-10-01 08:45:57 -0700 | [diff] [blame] | 1741 | EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_); |
| 1742 | // Wait for a little more - the error will be triggered again. |
| 1743 | rtc::Thread::Current()->ProcessMessages(200); |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 1744 | EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket), |
| 1745 | rtc::PacketOptions())); |
solenberg | 5b14b42 | 2015-10-01 04:10:31 -0700 | [diff] [blame] | 1746 | EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500); |
| 1747 | EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1748 | |
| 1749 | // Testing failures in receiving packets. |
solenberg | 5b14b42 | 2015-10-01 04:10:31 -0700 | [diff] [blame] | 1750 | error_handler.error_ = cricket::SrtpFilter::ERROR_NONE; |
solenberg | 5629a1d | 2015-10-01 08:45:57 -0700 | [diff] [blame] | 1751 | error_handler.mode_ = cricket::SrtpFilter::UNPROTECT; |
solenberg | 5b14b42 | 2015-10-01 04:10:31 -0700 | [diff] [blame] | 1752 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1753 | cricket::TransportChannel* transport_channel = |
| 1754 | channel2_->transport_channel(); |
| 1755 | transport_channel->SignalReadPacket( |
| 1756 | transport_channel, reinterpret_cast<const char*>(kBadPacket), |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 1757 | sizeof(kBadPacket), rtc::PacketTime(), 0); |
solenberg | 5b14b42 | 2015-10-01 04:10:31 -0700 | [diff] [blame] | 1758 | EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500); |
| 1759 | EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1760 | } |
| 1761 | |
| 1762 | void TestOnReadyToSend() { |
| 1763 | CreateChannels(RTCP, RTCP); |
| 1764 | TransportChannel* rtp = channel1_->transport_channel(); |
| 1765 | TransportChannel* rtcp = channel1_->rtcp_transport_channel(); |
| 1766 | EXPECT_FALSE(media_channel1_->ready_to_send()); |
| 1767 | rtp->SignalReadyToSend(rtp); |
| 1768 | EXPECT_FALSE(media_channel1_->ready_to_send()); |
| 1769 | rtcp->SignalReadyToSend(rtcp); |
| 1770 | // MediaChannel::OnReadyToSend only be called when both rtp and rtcp |
| 1771 | // channel are ready to send. |
| 1772 | EXPECT_TRUE(media_channel1_->ready_to_send()); |
| 1773 | |
| 1774 | // rtp channel becomes not ready to send will be propagated to mediachannel |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1775 | channel1_->SetReadyToSend(false, false); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1776 | EXPECT_FALSE(media_channel1_->ready_to_send()); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1777 | channel1_->SetReadyToSend(false, true); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1778 | EXPECT_TRUE(media_channel1_->ready_to_send()); |
| 1779 | |
| 1780 | // rtcp channel becomes not ready to send will be propagated to mediachannel |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1781 | channel1_->SetReadyToSend(true, false); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1782 | EXPECT_FALSE(media_channel1_->ready_to_send()); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1783 | channel1_->SetReadyToSend(true, true); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1784 | EXPECT_TRUE(media_channel1_->ready_to_send()); |
| 1785 | } |
| 1786 | |
| 1787 | void TestOnReadyToSendWithRtcpMux() { |
| 1788 | CreateChannels(RTCP, RTCP); |
| 1789 | typename T::Content content; |
| 1790 | CreateContent(0, kPcmuCodec, kH264Codec, &content); |
| 1791 | // Both sides agree on mux. Should no longer be a separate RTCP channel. |
| 1792 | content.set_rtcp_mux(true); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1793 | EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); |
| 1794 | EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1795 | EXPECT_TRUE(channel1_->rtcp_transport_channel() == NULL); |
| 1796 | TransportChannel* rtp = channel1_->transport_channel(); |
| 1797 | EXPECT_FALSE(media_channel1_->ready_to_send()); |
| 1798 | // In the case of rtcp mux, the SignalReadyToSend() from rtp channel |
| 1799 | // should trigger the MediaChannel's OnReadyToSend. |
| 1800 | rtp->SignalReadyToSend(rtp); |
| 1801 | EXPECT_TRUE(media_channel1_->ready_to_send()); |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1802 | channel1_->SetReadyToSend(false, false); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1803 | EXPECT_FALSE(media_channel1_->ready_to_send()); |
| 1804 | } |
| 1805 | |
skvlad | dc1c62c | 2016-03-16 19:07:43 -0700 | [diff] [blame] | 1806 | bool SetRemoteContentWithBitrateLimit(int remote_limit) { |
| 1807 | typename T::Content content; |
| 1808 | CreateContent(0, kPcmuCodec, kH264Codec, &content); |
| 1809 | content.set_bandwidth(remote_limit); |
| 1810 | return channel1_->SetRemoteContent(&content, CA_OFFER, NULL); |
| 1811 | } |
| 1812 | |
| 1813 | webrtc::RtpParameters BitrateLimitedParameters(int limit) { |
| 1814 | webrtc::RtpParameters parameters; |
| 1815 | webrtc::RtpEncodingParameters encoding; |
| 1816 | encoding.max_bitrate_bps = limit; |
| 1817 | parameters.encodings.push_back(encoding); |
| 1818 | return parameters; |
| 1819 | } |
| 1820 | |
| 1821 | void VerifyMaxBitrate(const webrtc::RtpParameters& parameters, |
| 1822 | int expected_bitrate) { |
| 1823 | EXPECT_EQ(1UL, parameters.encodings.size()); |
| 1824 | EXPECT_EQ(expected_bitrate, parameters.encodings[0].max_bitrate_bps); |
| 1825 | } |
| 1826 | |
| 1827 | void DefaultMaxBitrateIsUnlimited() { |
| 1828 | CreateChannels(0, 0); |
| 1829 | EXPECT_TRUE( |
| 1830 | channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL)); |
| 1831 | EXPECT_EQ(media_channel1_->max_bps(), -1); |
| 1832 | VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), -1); |
| 1833 | } |
| 1834 | |
| 1835 | void CanChangeMaxBitrate() { |
| 1836 | CreateChannels(0, 0); |
| 1837 | EXPECT_TRUE( |
| 1838 | channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL)); |
| 1839 | |
| 1840 | EXPECT_TRUE( |
| 1841 | channel1_->SetRtpParameters(kSsrc1, BitrateLimitedParameters(1000))); |
| 1842 | VerifyMaxBitrate(channel1_->GetRtpParameters(kSsrc1), 1000); |
| 1843 | VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), 1000); |
| 1844 | EXPECT_EQ(-1, media_channel1_->max_bps()); |
| 1845 | |
| 1846 | EXPECT_TRUE( |
| 1847 | channel1_->SetRtpParameters(kSsrc1, BitrateLimitedParameters(-1))); |
| 1848 | VerifyMaxBitrate(channel1_->GetRtpParameters(kSsrc1), -1); |
| 1849 | VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), -1); |
| 1850 | EXPECT_EQ(-1, media_channel1_->max_bps()); |
| 1851 | } |
| 1852 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1853 | protected: |
Peter Boström | 34fbfff | 2015-09-24 19:20:30 +0200 | [diff] [blame] | 1854 | // TODO(pbos): Remove playout from all media channels and let renderers mute |
| 1855 | // themselves. |
| 1856 | const bool verify_playout_; |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1857 | cricket::FakeTransportController transport_controller1_; |
| 1858 | cricket::FakeTransportController transport_controller2_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1859 | cricket::FakeMediaEngine media_engine_; |
| 1860 | // The media channels are owned by the voice channel objects below. |
| 1861 | typename T::MediaChannel* media_channel1_; |
| 1862 | typename T::MediaChannel* media_channel2_; |
kwiberg | 3102294 | 2016-03-11 14:18:21 -0800 | [diff] [blame] | 1863 | std::unique_ptr<typename T::Channel> channel1_; |
| 1864 | std::unique_ptr<typename T::Channel> channel2_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1865 | typename T::Content local_media_content1_; |
| 1866 | typename T::Content local_media_content2_; |
| 1867 | typename T::Content remote_media_content1_; |
| 1868 | typename T::Content remote_media_content2_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1869 | // The RTP and RTCP packets to send in the tests. |
| 1870 | std::string rtp_packet_; |
| 1871 | std::string rtcp_packet_; |
| 1872 | int media_info_callbacks1_; |
| 1873 | int media_info_callbacks2_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1874 | }; |
| 1875 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1876 | template<> |
| 1877 | void ChannelTest<VoiceTraits>::CreateContent( |
| 1878 | int flags, |
| 1879 | const cricket::AudioCodec& audio_codec, |
| 1880 | const cricket::VideoCodec& video_codec, |
| 1881 | cricket::AudioContentDescription* audio) { |
| 1882 | audio->AddCodec(audio_codec); |
| 1883 | audio->set_rtcp_mux((flags & RTCP_MUX) != 0); |
| 1884 | if (flags & SECURE) { |
| 1885 | audio->AddCrypto(cricket::CryptoParams( |
Guo-wei Shieh | 456696a | 2015-09-30 21:48:54 -0700 | [diff] [blame] | 1886 | 1, rtc::CS_AES_CM_128_HMAC_SHA1_32, |
| 1887 | "inline:" + rtc::CreateRandomString(40), std::string())); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1888 | } |
| 1889 | } |
| 1890 | |
| 1891 | template<> |
| 1892 | void ChannelTest<VoiceTraits>::CopyContent( |
| 1893 | const cricket::AudioContentDescription& source, |
| 1894 | cricket::AudioContentDescription* audio) { |
| 1895 | *audio = source; |
| 1896 | } |
| 1897 | |
| 1898 | template<> |
| 1899 | bool ChannelTest<VoiceTraits>::CodecMatches(const cricket::AudioCodec& c1, |
| 1900 | const cricket::AudioCodec& c2) { |
| 1901 | return c1.name == c2.name && c1.clockrate == c2.clockrate && |
| 1902 | c1.bitrate == c2.bitrate && c1.channels == c2.channels; |
| 1903 | } |
| 1904 | |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 1905 | template <> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1906 | void ChannelTest<VoiceTraits>::AddLegacyStreamInContent( |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 1907 | uint32_t ssrc, |
| 1908 | int flags, |
| 1909 | cricket::AudioContentDescription* audio) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1910 | audio->AddLegacyStream(ssrc); |
| 1911 | } |
| 1912 | |
| 1913 | class VoiceChannelTest |
| 1914 | : public ChannelTest<VoiceTraits> { |
| 1915 | public: |
solenberg | 1dd98f3 | 2015-09-10 01:57:14 -0700 | [diff] [blame] | 1916 | typedef ChannelTest<VoiceTraits> Base; |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1917 | VoiceChannelTest() |
Peter Boström | 34fbfff | 2015-09-24 19:20:30 +0200 | [diff] [blame] | 1918 | : Base(true, |
| 1919 | kPcmuFrame, |
| 1920 | sizeof(kPcmuFrame), |
| 1921 | kRtcpReport, |
| 1922 | sizeof(kRtcpReport)) {} |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1923 | }; |
| 1924 | |
| 1925 | // override to add NULL parameter |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1926 | template <> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1927 | cricket::VideoChannel* ChannelTest<VideoTraits>::CreateChannel( |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1928 | rtc::Thread* thread, |
| 1929 | cricket::MediaEngineInterface* engine, |
| 1930 | cricket::FakeVideoMediaChannel* ch, |
| 1931 | cricket::TransportController* transport_controller, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1932 | bool rtcp) { |
| 1933 | cricket::VideoChannel* channel = new cricket::VideoChannel( |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1934 | thread, ch, transport_controller, cricket::CN_VIDEO, rtcp); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1935 | if (!channel->Init()) { |
| 1936 | delete channel; |
| 1937 | channel = NULL; |
| 1938 | } |
| 1939 | return channel; |
| 1940 | } |
| 1941 | |
| 1942 | // override to add 0 parameter |
| 1943 | template<> |
| 1944 | bool ChannelTest<VideoTraits>::AddStream1(int id) { |
| 1945 | return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id)); |
| 1946 | } |
| 1947 | |
| 1948 | template<> |
| 1949 | void ChannelTest<VideoTraits>::CreateContent( |
| 1950 | int flags, |
| 1951 | const cricket::AudioCodec& audio_codec, |
| 1952 | const cricket::VideoCodec& video_codec, |
| 1953 | cricket::VideoContentDescription* video) { |
| 1954 | video->AddCodec(video_codec); |
| 1955 | video->set_rtcp_mux((flags & RTCP_MUX) != 0); |
| 1956 | if (flags & SECURE) { |
| 1957 | video->AddCrypto(cricket::CryptoParams( |
Guo-wei Shieh | 456696a | 2015-09-30 21:48:54 -0700 | [diff] [blame] | 1958 | 1, rtc::CS_AES_CM_128_HMAC_SHA1_80, |
| 1959 | "inline:" + rtc::CreateRandomString(40), std::string())); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1960 | } |
| 1961 | } |
| 1962 | |
| 1963 | template<> |
| 1964 | void ChannelTest<VideoTraits>::CopyContent( |
| 1965 | const cricket::VideoContentDescription& source, |
| 1966 | cricket::VideoContentDescription* video) { |
| 1967 | *video = source; |
| 1968 | } |
| 1969 | |
| 1970 | template<> |
| 1971 | bool ChannelTest<VideoTraits>::CodecMatches(const cricket::VideoCodec& c1, |
| 1972 | const cricket::VideoCodec& c2) { |
| 1973 | return c1.name == c2.name && c1.width == c2.width && c1.height == c2.height && |
| 1974 | c1.framerate == c2.framerate; |
| 1975 | } |
| 1976 | |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 1977 | template <> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1978 | void ChannelTest<VideoTraits>::AddLegacyStreamInContent( |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 1979 | uint32_t ssrc, |
| 1980 | int flags, |
| 1981 | cricket::VideoContentDescription* video) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1982 | video->AddLegacyStream(ssrc); |
| 1983 | } |
| 1984 | |
| 1985 | class VideoChannelTest |
| 1986 | : public ChannelTest<VideoTraits> { |
| 1987 | public: |
solenberg | 1dd98f3 | 2015-09-10 01:57:14 -0700 | [diff] [blame] | 1988 | typedef ChannelTest<VideoTraits> Base; |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1989 | VideoChannelTest() |
Peter Boström | 34fbfff | 2015-09-24 19:20:30 +0200 | [diff] [blame] | 1990 | : Base(false, |
| 1991 | kH264Packet, |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 1992 | sizeof(kH264Packet), |
| 1993 | kRtcpReport, |
| 1994 | sizeof(kRtcpReport)) {} |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1995 | }; |
| 1996 | |
| 1997 | |
| 1998 | // VoiceChannelTest |
| 1999 | |
| 2000 | TEST_F(VoiceChannelTest, TestInit) { |
| 2001 | Base::TestInit(); |
| 2002 | EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); |
| 2003 | EXPECT_TRUE(media_channel1_->dtmf_info_queue().empty()); |
| 2004 | } |
| 2005 | |
| 2006 | TEST_F(VoiceChannelTest, TestSetContents) { |
| 2007 | Base::TestSetContents(); |
| 2008 | } |
| 2009 | |
| 2010 | TEST_F(VoiceChannelTest, TestSetContentsNullOffer) { |
| 2011 | Base::TestSetContentsNullOffer(); |
| 2012 | } |
| 2013 | |
| 2014 | TEST_F(VoiceChannelTest, TestSetContentsRtcpMux) { |
| 2015 | Base::TestSetContentsRtcpMux(); |
| 2016 | } |
| 2017 | |
| 2018 | TEST_F(VoiceChannelTest, TestSetContentsRtcpMuxWithPrAnswer) { |
| 2019 | Base::TestSetContentsRtcpMux(); |
| 2020 | } |
| 2021 | |
| 2022 | TEST_F(VoiceChannelTest, TestSetRemoteContentUpdate) { |
| 2023 | Base::TestSetRemoteContentUpdate(); |
| 2024 | } |
| 2025 | |
| 2026 | TEST_F(VoiceChannelTest, TestStreams) { |
| 2027 | Base::TestStreams(); |
| 2028 | } |
| 2029 | |
| 2030 | TEST_F(VoiceChannelTest, TestUpdateStreamsInLocalContent) { |
| 2031 | Base::TestUpdateStreamsInLocalContent(); |
| 2032 | } |
| 2033 | |
| 2034 | TEST_F(VoiceChannelTest, TestUpdateRemoteStreamsInContent) { |
| 2035 | Base::TestUpdateStreamsInRemoteContent(); |
| 2036 | } |
| 2037 | |
| 2038 | TEST_F(VoiceChannelTest, TestChangeStreamParamsInContent) { |
| 2039 | Base::TestChangeStreamParamsInContent(); |
| 2040 | } |
| 2041 | |
| 2042 | TEST_F(VoiceChannelTest, TestPlayoutAndSendingStates) { |
| 2043 | Base::TestPlayoutAndSendingStates(); |
| 2044 | } |
| 2045 | |
| 2046 | TEST_F(VoiceChannelTest, TestMuteStream) { |
solenberg | 1dd98f3 | 2015-09-10 01:57:14 -0700 | [diff] [blame] | 2047 | CreateChannels(0, 0); |
| 2048 | // Test that we can Mute the default channel even though the sending SSRC |
| 2049 | // is unknown. |
| 2050 | EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); |
solenberg | 1dd98f3 | 2015-09-10 01:57:14 -0700 | [diff] [blame] | 2051 | EXPECT_TRUE(channel1_->SetAudioSend(0, false, nullptr, nullptr)); |
solenberg | dfc8f4f | 2015-10-01 02:31:10 -0700 | [diff] [blame] | 2052 | EXPECT_TRUE(media_channel1_->IsStreamMuted(0)); |
| 2053 | EXPECT_TRUE(channel1_->SetAudioSend(0, true, nullptr, nullptr)); |
solenberg | 1dd98f3 | 2015-09-10 01:57:14 -0700 | [diff] [blame] | 2054 | EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); |
| 2055 | |
| 2056 | // Test that we can not mute an unknown SSRC. |
solenberg | dfc8f4f | 2015-10-01 02:31:10 -0700 | [diff] [blame] | 2057 | EXPECT_FALSE(channel1_->SetAudioSend(kSsrc1, false, nullptr, nullptr)); |
solenberg | 1dd98f3 | 2015-09-10 01:57:14 -0700 | [diff] [blame] | 2058 | |
| 2059 | SendInitiate(); |
| 2060 | // After the local session description has been set, we can mute a stream |
| 2061 | // with its SSRC. |
solenberg | 1dd98f3 | 2015-09-10 01:57:14 -0700 | [diff] [blame] | 2062 | EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, false, nullptr, nullptr)); |
solenberg | dfc8f4f | 2015-10-01 02:31:10 -0700 | [diff] [blame] | 2063 | EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1)); |
| 2064 | EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, true, nullptr, nullptr)); |
solenberg | 1dd98f3 | 2015-09-10 01:57:14 -0700 | [diff] [blame] | 2065 | EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2066 | } |
| 2067 | |
| 2068 | TEST_F(VoiceChannelTest, TestMediaContentDirection) { |
| 2069 | Base::TestMediaContentDirection(); |
| 2070 | } |
| 2071 | |
| 2072 | TEST_F(VoiceChannelTest, TestCallSetup) { |
| 2073 | Base::TestCallSetup(); |
| 2074 | } |
| 2075 | |
| 2076 | TEST_F(VoiceChannelTest, TestCallTeardownRtcpMux) { |
| 2077 | Base::TestCallTeardownRtcpMux(); |
| 2078 | } |
| 2079 | |
| 2080 | TEST_F(VoiceChannelTest, SendRtpToRtp) { |
| 2081 | Base::SendRtpToRtp(); |
| 2082 | } |
| 2083 | |
| 2084 | TEST_F(VoiceChannelTest, SendNoRtcpToNoRtcp) { |
| 2085 | Base::SendNoRtcpToNoRtcp(); |
| 2086 | } |
| 2087 | |
| 2088 | TEST_F(VoiceChannelTest, SendNoRtcpToRtcp) { |
| 2089 | Base::SendNoRtcpToRtcp(); |
| 2090 | } |
| 2091 | |
| 2092 | TEST_F(VoiceChannelTest, SendRtcpToNoRtcp) { |
| 2093 | Base::SendRtcpToNoRtcp(); |
| 2094 | } |
| 2095 | |
| 2096 | TEST_F(VoiceChannelTest, SendRtcpToRtcp) { |
| 2097 | Base::SendRtcpToRtcp(); |
| 2098 | } |
| 2099 | |
| 2100 | TEST_F(VoiceChannelTest, SendRtcpMuxToRtcp) { |
| 2101 | Base::SendRtcpMuxToRtcp(); |
| 2102 | } |
| 2103 | |
| 2104 | TEST_F(VoiceChannelTest, SendRtcpMuxToRtcpMux) { |
| 2105 | Base::SendRtcpMuxToRtcpMux(); |
| 2106 | } |
| 2107 | |
Peter Thatcher | af55ccc | 2015-05-21 07:48:41 -0700 | [diff] [blame] | 2108 | TEST_F(VoiceChannelTest, SendRequireRtcpMuxToRtcpMux) { |
| 2109 | Base::SendRequireRtcpMuxToRtcpMux(); |
| 2110 | } |
| 2111 | |
| 2112 | TEST_F(VoiceChannelTest, SendRtcpMuxToRequireRtcpMux) { |
| 2113 | Base::SendRtcpMuxToRequireRtcpMux(); |
| 2114 | } |
| 2115 | |
| 2116 | TEST_F(VoiceChannelTest, SendRequireRtcpMuxToRequireRtcpMux) { |
| 2117 | Base::SendRequireRtcpMuxToRequireRtcpMux(); |
| 2118 | } |
| 2119 | |
| 2120 | TEST_F(VoiceChannelTest, SendRequireRtcpMuxToNoRtcpMux) { |
| 2121 | Base::SendRequireRtcpMuxToNoRtcpMux(); |
| 2122 | } |
| 2123 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2124 | TEST_F(VoiceChannelTest, SendEarlyRtcpMuxToRtcp) { |
| 2125 | Base::SendEarlyRtcpMuxToRtcp(); |
| 2126 | } |
| 2127 | |
| 2128 | TEST_F(VoiceChannelTest, SendEarlyRtcpMuxToRtcpMux) { |
| 2129 | Base::SendEarlyRtcpMuxToRtcpMux(); |
| 2130 | } |
| 2131 | |
| 2132 | TEST_F(VoiceChannelTest, SendSrtpToSrtpRtcpMux) { |
| 2133 | Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX); |
| 2134 | } |
| 2135 | |
| 2136 | TEST_F(VoiceChannelTest, SendSrtpToRtp) { |
| 2137 | Base::SendSrtpToSrtp(); |
| 2138 | } |
| 2139 | |
| 2140 | TEST_F(VoiceChannelTest, SendSrtcpMux) { |
| 2141 | Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX); |
| 2142 | } |
| 2143 | |
| 2144 | TEST_F(VoiceChannelTest, SendDtlsSrtpToSrtp) { |
| 2145 | MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 2146 | Base::SendSrtpToSrtp(DTLS, 0); |
| 2147 | } |
| 2148 | |
| 2149 | TEST_F(VoiceChannelTest, SendDtlsSrtpToDtlsSrtp) { |
| 2150 | MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 2151 | Base::SendSrtpToSrtp(DTLS, DTLS); |
| 2152 | } |
| 2153 | |
| 2154 | TEST_F(VoiceChannelTest, SendDtlsSrtpToDtlsSrtpRtcpMux) { |
| 2155 | MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 2156 | Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX); |
| 2157 | } |
| 2158 | |
| 2159 | TEST_F(VoiceChannelTest, SendEarlyMediaUsingRtcpMuxSrtp) { |
| 2160 | Base::SendEarlyMediaUsingRtcpMuxSrtp(); |
| 2161 | } |
| 2162 | |
| 2163 | TEST_F(VoiceChannelTest, SendRtpToRtpOnThread) { |
| 2164 | Base::SendRtpToRtpOnThread(); |
| 2165 | } |
| 2166 | |
| 2167 | TEST_F(VoiceChannelTest, SendSrtpToSrtpOnThread) { |
| 2168 | Base::SendSrtpToSrtpOnThread(); |
| 2169 | } |
| 2170 | |
| 2171 | TEST_F(VoiceChannelTest, SendWithWritabilityLoss) { |
| 2172 | Base::SendWithWritabilityLoss(); |
| 2173 | } |
| 2174 | |
| 2175 | TEST_F(VoiceChannelTest, TestMediaMonitor) { |
| 2176 | Base::TestMediaMonitor(); |
| 2177 | } |
| 2178 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2179 | // Test that InsertDtmf properly forwards to the media channel. |
| 2180 | TEST_F(VoiceChannelTest, TestInsertDtmf) { |
| 2181 | CreateChannels(0, 0); |
| 2182 | EXPECT_TRUE(SendInitiate()); |
| 2183 | EXPECT_TRUE(SendAccept()); |
| 2184 | EXPECT_EQ(0U, media_channel1_->dtmf_info_queue().size()); |
| 2185 | |
solenberg | 1d63dd0 | 2015-12-02 12:35:09 -0800 | [diff] [blame] | 2186 | EXPECT_TRUE(channel1_->InsertDtmf(1, 3, 100)); |
| 2187 | EXPECT_TRUE(channel1_->InsertDtmf(2, 5, 110)); |
| 2188 | EXPECT_TRUE(channel1_->InsertDtmf(3, 7, 120)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2189 | |
henrike@webrtc.org | 9de257d | 2013-07-17 14:42:53 +0000 | [diff] [blame] | 2190 | ASSERT_EQ(3U, media_channel1_->dtmf_info_queue().size()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2191 | EXPECT_TRUE(CompareDtmfInfo(media_channel1_->dtmf_info_queue()[0], |
solenberg | 1d63dd0 | 2015-12-02 12:35:09 -0800 | [diff] [blame] | 2192 | 1, 3, 100)); |
henrike@webrtc.org | 9de257d | 2013-07-17 14:42:53 +0000 | [diff] [blame] | 2193 | EXPECT_TRUE(CompareDtmfInfo(media_channel1_->dtmf_info_queue()[1], |
solenberg | 1d63dd0 | 2015-12-02 12:35:09 -0800 | [diff] [blame] | 2194 | 2, 5, 110)); |
henrike@webrtc.org | 9de257d | 2013-07-17 14:42:53 +0000 | [diff] [blame] | 2195 | EXPECT_TRUE(CompareDtmfInfo(media_channel1_->dtmf_info_queue()[2], |
solenberg | 1d63dd0 | 2015-12-02 12:35:09 -0800 | [diff] [blame] | 2196 | 3, 7, 120)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2197 | } |
| 2198 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2199 | TEST_F(VoiceChannelTest, TestSetContentFailure) { |
| 2200 | Base::TestSetContentFailure(); |
| 2201 | } |
| 2202 | |
| 2203 | TEST_F(VoiceChannelTest, TestSendTwoOffers) { |
| 2204 | Base::TestSendTwoOffers(); |
| 2205 | } |
| 2206 | |
| 2207 | TEST_F(VoiceChannelTest, TestReceiveTwoOffers) { |
| 2208 | Base::TestReceiveTwoOffers(); |
| 2209 | } |
| 2210 | |
| 2211 | TEST_F(VoiceChannelTest, TestSendPrAnswer) { |
| 2212 | Base::TestSendPrAnswer(); |
| 2213 | } |
| 2214 | |
| 2215 | TEST_F(VoiceChannelTest, TestReceivePrAnswer) { |
| 2216 | Base::TestReceivePrAnswer(); |
| 2217 | } |
| 2218 | |
| 2219 | TEST_F(VoiceChannelTest, TestFlushRtcp) { |
| 2220 | Base::TestFlushRtcp(); |
| 2221 | } |
| 2222 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2223 | TEST_F(VoiceChannelTest, TestSrtpError) { |
buildbot@webrtc.org | 5ee0f05 | 2014-05-05 20:18:08 +0000 | [diff] [blame] | 2224 | Base::TestSrtpError(kAudioPts[0]); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2225 | } |
| 2226 | |
| 2227 | TEST_F(VoiceChannelTest, TestOnReadyToSend) { |
| 2228 | Base::TestOnReadyToSend(); |
| 2229 | } |
| 2230 | |
| 2231 | TEST_F(VoiceChannelTest, TestOnReadyToSendWithRtcpMux) { |
| 2232 | Base::TestOnReadyToSendWithRtcpMux(); |
| 2233 | } |
| 2234 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2235 | // Test that we can scale the output volume properly for 1:1 calls. |
| 2236 | TEST_F(VoiceChannelTest, TestScaleVolume1to1Call) { |
| 2237 | CreateChannels(RTCP, RTCP); |
| 2238 | EXPECT_TRUE(SendInitiate()); |
| 2239 | EXPECT_TRUE(SendAccept()); |
solenberg | 4bac9c5 | 2015-10-09 02:32:53 -0700 | [diff] [blame] | 2240 | double volume; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2241 | |
solenberg | 4bac9c5 | 2015-10-09 02:32:53 -0700 | [diff] [blame] | 2242 | // Default is (1.0). |
| 2243 | EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume)); |
| 2244 | EXPECT_DOUBLE_EQ(1.0, volume); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2245 | // invalid ssrc. |
solenberg | 4bac9c5 | 2015-10-09 02:32:53 -0700 | [diff] [blame] | 2246 | EXPECT_FALSE(media_channel1_->GetOutputVolume(3, &volume)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2247 | |
solenberg | 4bac9c5 | 2015-10-09 02:32:53 -0700 | [diff] [blame] | 2248 | // Set scale to (1.5). |
| 2249 | EXPECT_TRUE(channel1_->SetOutputVolume(0, 1.5)); |
| 2250 | EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume)); |
| 2251 | EXPECT_DOUBLE_EQ(1.5, volume); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2252 | |
solenberg | 4bac9c5 | 2015-10-09 02:32:53 -0700 | [diff] [blame] | 2253 | // Set scale to (0). |
| 2254 | EXPECT_TRUE(channel1_->SetOutputVolume(0, 0.0)); |
| 2255 | EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume)); |
| 2256 | EXPECT_DOUBLE_EQ(0.0, volume); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2257 | } |
| 2258 | |
| 2259 | // Test that we can scale the output volume properly for multiway calls. |
| 2260 | TEST_F(VoiceChannelTest, TestScaleVolumeMultiwayCall) { |
| 2261 | CreateChannels(RTCP, RTCP); |
| 2262 | EXPECT_TRUE(SendInitiate()); |
| 2263 | EXPECT_TRUE(SendAccept()); |
| 2264 | EXPECT_TRUE(AddStream1(1)); |
| 2265 | EXPECT_TRUE(AddStream1(2)); |
| 2266 | |
solenberg | 4bac9c5 | 2015-10-09 02:32:53 -0700 | [diff] [blame] | 2267 | double volume; |
| 2268 | // Default is (1.0). |
| 2269 | EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume)); |
| 2270 | EXPECT_DOUBLE_EQ(1.0, volume); |
| 2271 | EXPECT_TRUE(media_channel1_->GetOutputVolume(1, &volume)); |
| 2272 | EXPECT_DOUBLE_EQ(1.0, volume); |
| 2273 | EXPECT_TRUE(media_channel1_->GetOutputVolume(2, &volume)); |
| 2274 | EXPECT_DOUBLE_EQ(1.0, volume); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2275 | // invalid ssrc. |
solenberg | 4bac9c5 | 2015-10-09 02:32:53 -0700 | [diff] [blame] | 2276 | EXPECT_FALSE(media_channel1_->GetOutputVolume(3, &volume)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2277 | |
solenberg | 4bac9c5 | 2015-10-09 02:32:53 -0700 | [diff] [blame] | 2278 | // Set scale to (1.5) for ssrc = 1. |
| 2279 | EXPECT_TRUE(channel1_->SetOutputVolume(1, 1.5)); |
| 2280 | EXPECT_TRUE(media_channel1_->GetOutputVolume(1, &volume)); |
| 2281 | EXPECT_DOUBLE_EQ(1.5, volume); |
| 2282 | EXPECT_TRUE(media_channel1_->GetOutputVolume(2, &volume)); |
| 2283 | EXPECT_DOUBLE_EQ(1.0, volume); |
| 2284 | EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume)); |
| 2285 | EXPECT_DOUBLE_EQ(1.0, volume); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2286 | |
solenberg | 4bac9c5 | 2015-10-09 02:32:53 -0700 | [diff] [blame] | 2287 | // Set scale to (0) for all ssrcs. |
| 2288 | EXPECT_TRUE(channel1_->SetOutputVolume(0, 0.0)); |
| 2289 | EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume)); |
| 2290 | EXPECT_DOUBLE_EQ(0.0, volume); |
| 2291 | EXPECT_TRUE(media_channel1_->GetOutputVolume(1, &volume)); |
| 2292 | EXPECT_DOUBLE_EQ(0.0, volume); |
| 2293 | EXPECT_TRUE(media_channel1_->GetOutputVolume(2, &volume)); |
| 2294 | EXPECT_DOUBLE_EQ(0.0, volume); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2295 | } |
| 2296 | |
buildbot@webrtc.org | 5ee0f05 | 2014-05-05 20:18:08 +0000 | [diff] [blame] | 2297 | TEST_F(VoiceChannelTest, SendBundleToBundle) { |
tfarina | 5237aaf | 2015-11-10 23:44:30 -0800 | [diff] [blame] | 2298 | Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, false); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2299 | } |
| 2300 | |
buildbot@webrtc.org | 5ee0f05 | 2014-05-05 20:18:08 +0000 | [diff] [blame] | 2301 | TEST_F(VoiceChannelTest, SendBundleToBundleSecure) { |
tfarina | 5237aaf | 2015-11-10 23:44:30 -0800 | [diff] [blame] | 2302 | Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, true); |
buildbot@webrtc.org | 5ee0f05 | 2014-05-05 20:18:08 +0000 | [diff] [blame] | 2303 | } |
| 2304 | |
| 2305 | TEST_F(VoiceChannelTest, SendBundleToBundleWithRtcpMux) { |
tfarina | 5237aaf | 2015-11-10 23:44:30 -0800 | [diff] [blame] | 2306 | Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, false); |
buildbot@webrtc.org | 5ee0f05 | 2014-05-05 20:18:08 +0000 | [diff] [blame] | 2307 | } |
| 2308 | |
| 2309 | TEST_F(VoiceChannelTest, SendBundleToBundleWithRtcpMuxSecure) { |
tfarina | 5237aaf | 2015-11-10 23:44:30 -0800 | [diff] [blame] | 2310 | Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, true); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2311 | } |
| 2312 | |
skvlad | dc1c62c | 2016-03-16 19:07:43 -0700 | [diff] [blame] | 2313 | TEST_F(VoiceChannelTest, GetRtpParametersIsNotImplemented) { |
| 2314 | // These tests verify that the Get/SetRtpParameters methods for VoiceChannel |
| 2315 | // always fail as they are not implemented. |
| 2316 | // TODO(skvlad): Replace with full tests when support for bitrate limiting |
| 2317 | // for audio RtpSenders is added. |
| 2318 | CreateChannels(0, 0); |
| 2319 | EXPECT_TRUE( |
| 2320 | channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL)); |
| 2321 | webrtc::RtpParameters voice_parameters = channel1_->GetRtpParameters(kSsrc1); |
| 2322 | EXPECT_EQ(0UL, voice_parameters.encodings.size()); |
| 2323 | } |
| 2324 | |
| 2325 | TEST_F(VoiceChannelTest, SetRtpParametersIsNotImplemented) { |
| 2326 | CreateChannels(0, 0); |
| 2327 | EXPECT_TRUE( |
| 2328 | channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL)); |
| 2329 | EXPECT_FALSE( |
| 2330 | channel1_->SetRtpParameters(kSsrc1, BitrateLimitedParameters(1000))); |
| 2331 | } |
| 2332 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2333 | // VideoChannelTest |
| 2334 | TEST_F(VideoChannelTest, TestInit) { |
| 2335 | Base::TestInit(); |
| 2336 | } |
| 2337 | |
| 2338 | TEST_F(VideoChannelTest, TestSetContents) { |
| 2339 | Base::TestSetContents(); |
| 2340 | } |
| 2341 | |
| 2342 | TEST_F(VideoChannelTest, TestSetContentsNullOffer) { |
| 2343 | Base::TestSetContentsNullOffer(); |
| 2344 | } |
| 2345 | |
| 2346 | TEST_F(VideoChannelTest, TestSetContentsRtcpMux) { |
| 2347 | Base::TestSetContentsRtcpMux(); |
| 2348 | } |
| 2349 | |
| 2350 | TEST_F(VideoChannelTest, TestSetContentsRtcpMuxWithPrAnswer) { |
| 2351 | Base::TestSetContentsRtcpMux(); |
| 2352 | } |
| 2353 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2354 | TEST_F(VideoChannelTest, TestSetRemoteContentUpdate) { |
| 2355 | Base::TestSetRemoteContentUpdate(); |
| 2356 | } |
| 2357 | |
| 2358 | TEST_F(VideoChannelTest, TestStreams) { |
| 2359 | Base::TestStreams(); |
| 2360 | } |
| 2361 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2362 | TEST_F(VideoChannelTest, TestUpdateStreamsInLocalContent) { |
| 2363 | Base::TestUpdateStreamsInLocalContent(); |
| 2364 | } |
| 2365 | |
| 2366 | TEST_F(VideoChannelTest, TestUpdateRemoteStreamsInContent) { |
| 2367 | Base::TestUpdateStreamsInRemoteContent(); |
| 2368 | } |
| 2369 | |
| 2370 | TEST_F(VideoChannelTest, TestChangeStreamParamsInContent) { |
| 2371 | Base::TestChangeStreamParamsInContent(); |
| 2372 | } |
| 2373 | |
| 2374 | TEST_F(VideoChannelTest, TestPlayoutAndSendingStates) { |
| 2375 | Base::TestPlayoutAndSendingStates(); |
| 2376 | } |
| 2377 | |
| 2378 | TEST_F(VideoChannelTest, TestMuteStream) { |
solenberg | 1dd98f3 | 2015-09-10 01:57:14 -0700 | [diff] [blame] | 2379 | CreateChannels(0, 0); |
| 2380 | // Test that we can Mute the default channel even though the sending SSRC |
| 2381 | // is unknown. |
| 2382 | EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); |
solenberg | 1dd98f3 | 2015-09-10 01:57:14 -0700 | [diff] [blame] | 2383 | EXPECT_TRUE(channel1_->SetVideoSend(0, false, nullptr)); |
solenberg | dfc8f4f | 2015-10-01 02:31:10 -0700 | [diff] [blame] | 2384 | EXPECT_TRUE(media_channel1_->IsStreamMuted(0)); |
| 2385 | EXPECT_TRUE(channel1_->SetVideoSend(0, true, nullptr)); |
solenberg | 1dd98f3 | 2015-09-10 01:57:14 -0700 | [diff] [blame] | 2386 | EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); |
| 2387 | // Test that we can not mute an unknown SSRC. |
solenberg | dfc8f4f | 2015-10-01 02:31:10 -0700 | [diff] [blame] | 2388 | EXPECT_FALSE(channel1_->SetVideoSend(kSsrc1, false, nullptr)); |
solenberg | 1dd98f3 | 2015-09-10 01:57:14 -0700 | [diff] [blame] | 2389 | SendInitiate(); |
| 2390 | // After the local session description has been set, we can mute a stream |
| 2391 | // with its SSRC. |
solenberg | 1dd98f3 | 2015-09-10 01:57:14 -0700 | [diff] [blame] | 2392 | EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, false, nullptr)); |
solenberg | dfc8f4f | 2015-10-01 02:31:10 -0700 | [diff] [blame] | 2393 | EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1)); |
| 2394 | EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, true, nullptr)); |
solenberg | 1dd98f3 | 2015-09-10 01:57:14 -0700 | [diff] [blame] | 2395 | EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2396 | } |
| 2397 | |
| 2398 | TEST_F(VideoChannelTest, TestMediaContentDirection) { |
| 2399 | Base::TestMediaContentDirection(); |
| 2400 | } |
| 2401 | |
| 2402 | TEST_F(VideoChannelTest, TestCallSetup) { |
| 2403 | Base::TestCallSetup(); |
| 2404 | } |
| 2405 | |
| 2406 | TEST_F(VideoChannelTest, TestCallTeardownRtcpMux) { |
| 2407 | Base::TestCallTeardownRtcpMux(); |
| 2408 | } |
| 2409 | |
| 2410 | TEST_F(VideoChannelTest, SendRtpToRtp) { |
| 2411 | Base::SendRtpToRtp(); |
| 2412 | } |
| 2413 | |
| 2414 | TEST_F(VideoChannelTest, SendNoRtcpToNoRtcp) { |
| 2415 | Base::SendNoRtcpToNoRtcp(); |
| 2416 | } |
| 2417 | |
| 2418 | TEST_F(VideoChannelTest, SendNoRtcpToRtcp) { |
| 2419 | Base::SendNoRtcpToRtcp(); |
| 2420 | } |
| 2421 | |
| 2422 | TEST_F(VideoChannelTest, SendRtcpToNoRtcp) { |
| 2423 | Base::SendRtcpToNoRtcp(); |
| 2424 | } |
| 2425 | |
| 2426 | TEST_F(VideoChannelTest, SendRtcpToRtcp) { |
| 2427 | Base::SendRtcpToRtcp(); |
| 2428 | } |
| 2429 | |
| 2430 | TEST_F(VideoChannelTest, SendRtcpMuxToRtcp) { |
| 2431 | Base::SendRtcpMuxToRtcp(); |
| 2432 | } |
| 2433 | |
| 2434 | TEST_F(VideoChannelTest, SendRtcpMuxToRtcpMux) { |
| 2435 | Base::SendRtcpMuxToRtcpMux(); |
| 2436 | } |
| 2437 | |
Peter Thatcher | af55ccc | 2015-05-21 07:48:41 -0700 | [diff] [blame] | 2438 | TEST_F(VideoChannelTest, SendRequireRtcpMuxToRtcpMux) { |
| 2439 | Base::SendRequireRtcpMuxToRtcpMux(); |
| 2440 | } |
| 2441 | |
| 2442 | TEST_F(VideoChannelTest, SendRtcpMuxToRequireRtcpMux) { |
| 2443 | Base::SendRtcpMuxToRequireRtcpMux(); |
| 2444 | } |
| 2445 | |
| 2446 | TEST_F(VideoChannelTest, SendRequireRtcpMuxToRequireRtcpMux) { |
| 2447 | Base::SendRequireRtcpMuxToRequireRtcpMux(); |
| 2448 | } |
| 2449 | |
| 2450 | TEST_F(VideoChannelTest, SendRequireRtcpMuxToNoRtcpMux) { |
| 2451 | Base::SendRequireRtcpMuxToNoRtcpMux(); |
| 2452 | } |
| 2453 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2454 | TEST_F(VideoChannelTest, SendEarlyRtcpMuxToRtcp) { |
| 2455 | Base::SendEarlyRtcpMuxToRtcp(); |
| 2456 | } |
| 2457 | |
| 2458 | TEST_F(VideoChannelTest, SendEarlyRtcpMuxToRtcpMux) { |
| 2459 | Base::SendEarlyRtcpMuxToRtcpMux(); |
| 2460 | } |
| 2461 | |
| 2462 | TEST_F(VideoChannelTest, SendSrtpToSrtp) { |
| 2463 | Base::SendSrtpToSrtp(); |
| 2464 | } |
| 2465 | |
| 2466 | TEST_F(VideoChannelTest, SendSrtpToRtp) { |
| 2467 | Base::SendSrtpToSrtp(); |
| 2468 | } |
| 2469 | |
| 2470 | TEST_F(VideoChannelTest, SendDtlsSrtpToSrtp) { |
| 2471 | MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 2472 | Base::SendSrtpToSrtp(DTLS, 0); |
| 2473 | } |
| 2474 | |
| 2475 | TEST_F(VideoChannelTest, SendDtlsSrtpToDtlsSrtp) { |
| 2476 | MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 2477 | Base::SendSrtpToSrtp(DTLS, DTLS); |
| 2478 | } |
| 2479 | |
| 2480 | TEST_F(VideoChannelTest, SendDtlsSrtpToDtlsSrtpRtcpMux) { |
| 2481 | MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 2482 | Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX); |
| 2483 | } |
| 2484 | |
| 2485 | TEST_F(VideoChannelTest, SendSrtcpMux) { |
| 2486 | Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX); |
| 2487 | } |
| 2488 | |
| 2489 | TEST_F(VideoChannelTest, SendEarlyMediaUsingRtcpMuxSrtp) { |
| 2490 | Base::SendEarlyMediaUsingRtcpMuxSrtp(); |
| 2491 | } |
| 2492 | |
| 2493 | TEST_F(VideoChannelTest, SendRtpToRtpOnThread) { |
| 2494 | Base::SendRtpToRtpOnThread(); |
| 2495 | } |
| 2496 | |
| 2497 | TEST_F(VideoChannelTest, SendSrtpToSrtpOnThread) { |
| 2498 | Base::SendSrtpToSrtpOnThread(); |
| 2499 | } |
| 2500 | |
| 2501 | TEST_F(VideoChannelTest, SendWithWritabilityLoss) { |
| 2502 | Base::SendWithWritabilityLoss(); |
| 2503 | } |
| 2504 | |
| 2505 | TEST_F(VideoChannelTest, TestMediaMonitor) { |
| 2506 | Base::TestMediaMonitor(); |
| 2507 | } |
| 2508 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2509 | TEST_F(VideoChannelTest, TestSetContentFailure) { |
| 2510 | Base::TestSetContentFailure(); |
| 2511 | } |
| 2512 | |
| 2513 | TEST_F(VideoChannelTest, TestSendTwoOffers) { |
| 2514 | Base::TestSendTwoOffers(); |
| 2515 | } |
| 2516 | |
| 2517 | TEST_F(VideoChannelTest, TestReceiveTwoOffers) { |
| 2518 | Base::TestReceiveTwoOffers(); |
| 2519 | } |
| 2520 | |
| 2521 | TEST_F(VideoChannelTest, TestSendPrAnswer) { |
| 2522 | Base::TestSendPrAnswer(); |
| 2523 | } |
| 2524 | |
| 2525 | TEST_F(VideoChannelTest, TestReceivePrAnswer) { |
| 2526 | Base::TestReceivePrAnswer(); |
| 2527 | } |
| 2528 | |
| 2529 | TEST_F(VideoChannelTest, TestFlushRtcp) { |
| 2530 | Base::TestFlushRtcp(); |
| 2531 | } |
| 2532 | |
buildbot@webrtc.org | 5ee0f05 | 2014-05-05 20:18:08 +0000 | [diff] [blame] | 2533 | TEST_F(VideoChannelTest, SendBundleToBundle) { |
tfarina | 5237aaf | 2015-11-10 23:44:30 -0800 | [diff] [blame] | 2534 | Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, false); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2535 | } |
| 2536 | |
buildbot@webrtc.org | 5ee0f05 | 2014-05-05 20:18:08 +0000 | [diff] [blame] | 2537 | TEST_F(VideoChannelTest, SendBundleToBundleSecure) { |
tfarina | 5237aaf | 2015-11-10 23:44:30 -0800 | [diff] [blame] | 2538 | Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, true); |
buildbot@webrtc.org | 5ee0f05 | 2014-05-05 20:18:08 +0000 | [diff] [blame] | 2539 | } |
| 2540 | |
| 2541 | TEST_F(VideoChannelTest, SendBundleToBundleWithRtcpMux) { |
tfarina | 5237aaf | 2015-11-10 23:44:30 -0800 | [diff] [blame] | 2542 | Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, false); |
buildbot@webrtc.org | 5ee0f05 | 2014-05-05 20:18:08 +0000 | [diff] [blame] | 2543 | } |
| 2544 | |
| 2545 | TEST_F(VideoChannelTest, SendBundleToBundleWithRtcpMuxSecure) { |
tfarina | 5237aaf | 2015-11-10 23:44:30 -0800 | [diff] [blame] | 2546 | Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, true); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2547 | } |
| 2548 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2549 | TEST_F(VideoChannelTest, TestSrtpError) { |
buildbot@webrtc.org | 5ee0f05 | 2014-05-05 20:18:08 +0000 | [diff] [blame] | 2550 | Base::TestSrtpError(kVideoPts[0]); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2551 | } |
| 2552 | |
| 2553 | TEST_F(VideoChannelTest, TestOnReadyToSend) { |
| 2554 | Base::TestOnReadyToSend(); |
| 2555 | } |
| 2556 | |
| 2557 | TEST_F(VideoChannelTest, TestOnReadyToSendWithRtcpMux) { |
| 2558 | Base::TestOnReadyToSendWithRtcpMux(); |
| 2559 | } |
| 2560 | |
skvlad | dc1c62c | 2016-03-16 19:07:43 -0700 | [diff] [blame] | 2561 | TEST_F(VideoChannelTest, DefaultMaxBitrateIsUnlimited) { |
| 2562 | Base::DefaultMaxBitrateIsUnlimited(); |
| 2563 | } |
| 2564 | |
| 2565 | TEST_F(VideoChannelTest, CanChangeMaxBitrate) { |
| 2566 | Base::CanChangeMaxBitrate(); |
| 2567 | } |
| 2568 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2569 | // DataChannelTest |
| 2570 | |
| 2571 | class DataChannelTest |
| 2572 | : public ChannelTest<DataTraits> { |
| 2573 | public: |
| 2574 | typedef ChannelTest<DataTraits> |
| 2575 | Base; |
Peter Boström | 34fbfff | 2015-09-24 19:20:30 +0200 | [diff] [blame] | 2576 | DataChannelTest() |
| 2577 | : Base(true, |
| 2578 | kDataPacket, |
| 2579 | sizeof(kDataPacket), |
| 2580 | kRtcpReport, |
| 2581 | sizeof(kRtcpReport)) {} |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2582 | }; |
| 2583 | |
| 2584 | // Override to avoid engine channel parameter. |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 2585 | template <> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2586 | cricket::DataChannel* ChannelTest<DataTraits>::CreateChannel( |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 2587 | rtc::Thread* thread, |
| 2588 | cricket::MediaEngineInterface* engine, |
| 2589 | cricket::FakeDataMediaChannel* ch, |
| 2590 | cricket::TransportController* transport_controller, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2591 | bool rtcp) { |
| 2592 | cricket::DataChannel* channel = new cricket::DataChannel( |
deadbeef | cbecd35 | 2015-09-23 11:50:27 -0700 | [diff] [blame] | 2593 | thread, ch, transport_controller, cricket::CN_DATA, rtcp); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2594 | if (!channel->Init()) { |
| 2595 | delete channel; |
| 2596 | channel = NULL; |
| 2597 | } |
| 2598 | return channel; |
| 2599 | } |
| 2600 | |
| 2601 | template<> |
| 2602 | void ChannelTest<DataTraits>::CreateContent( |
| 2603 | int flags, |
| 2604 | const cricket::AudioCodec& audio_codec, |
| 2605 | const cricket::VideoCodec& video_codec, |
| 2606 | cricket::DataContentDescription* data) { |
| 2607 | data->AddCodec(kGoogleDataCodec); |
| 2608 | data->set_rtcp_mux((flags & RTCP_MUX) != 0); |
| 2609 | if (flags & SECURE) { |
| 2610 | data->AddCrypto(cricket::CryptoParams( |
Guo-wei Shieh | 456696a | 2015-09-30 21:48:54 -0700 | [diff] [blame] | 2611 | 1, rtc::CS_AES_CM_128_HMAC_SHA1_32, |
| 2612 | "inline:" + rtc::CreateRandomString(40), std::string())); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2613 | } |
| 2614 | } |
| 2615 | |
| 2616 | template<> |
| 2617 | void ChannelTest<DataTraits>::CopyContent( |
| 2618 | const cricket::DataContentDescription& source, |
| 2619 | cricket::DataContentDescription* data) { |
| 2620 | *data = source; |
| 2621 | } |
| 2622 | |
| 2623 | template<> |
| 2624 | bool ChannelTest<DataTraits>::CodecMatches(const cricket::DataCodec& c1, |
| 2625 | const cricket::DataCodec& c2) { |
| 2626 | return c1.name == c2.name; |
| 2627 | } |
| 2628 | |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 2629 | template <> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2630 | void ChannelTest<DataTraits>::AddLegacyStreamInContent( |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 2631 | uint32_t ssrc, |
| 2632 | int flags, |
| 2633 | cricket::DataContentDescription* data) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2634 | data->AddLegacyStream(ssrc); |
| 2635 | } |
| 2636 | |
| 2637 | TEST_F(DataChannelTest, TestInit) { |
| 2638 | Base::TestInit(); |
| 2639 | EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); |
| 2640 | } |
| 2641 | |
| 2642 | TEST_F(DataChannelTest, TestSetContents) { |
| 2643 | Base::TestSetContents(); |
| 2644 | } |
| 2645 | |
| 2646 | TEST_F(DataChannelTest, TestSetContentsNullOffer) { |
| 2647 | Base::TestSetContentsNullOffer(); |
| 2648 | } |
| 2649 | |
| 2650 | TEST_F(DataChannelTest, TestSetContentsRtcpMux) { |
| 2651 | Base::TestSetContentsRtcpMux(); |
| 2652 | } |
| 2653 | |
| 2654 | TEST_F(DataChannelTest, TestSetRemoteContentUpdate) { |
| 2655 | Base::TestSetRemoteContentUpdate(); |
| 2656 | } |
| 2657 | |
| 2658 | TEST_F(DataChannelTest, TestStreams) { |
| 2659 | Base::TestStreams(); |
| 2660 | } |
| 2661 | |
| 2662 | TEST_F(DataChannelTest, TestUpdateStreamsInLocalContent) { |
| 2663 | Base::TestUpdateStreamsInLocalContent(); |
| 2664 | } |
| 2665 | |
| 2666 | TEST_F(DataChannelTest, TestUpdateRemoteStreamsInContent) { |
| 2667 | Base::TestUpdateStreamsInRemoteContent(); |
| 2668 | } |
| 2669 | |
| 2670 | TEST_F(DataChannelTest, TestChangeStreamParamsInContent) { |
| 2671 | Base::TestChangeStreamParamsInContent(); |
| 2672 | } |
| 2673 | |
| 2674 | TEST_F(DataChannelTest, TestPlayoutAndSendingStates) { |
| 2675 | Base::TestPlayoutAndSendingStates(); |
| 2676 | } |
| 2677 | |
| 2678 | TEST_F(DataChannelTest, TestMediaContentDirection) { |
| 2679 | Base::TestMediaContentDirection(); |
| 2680 | } |
| 2681 | |
| 2682 | TEST_F(DataChannelTest, TestCallSetup) { |
| 2683 | Base::TestCallSetup(); |
| 2684 | } |
| 2685 | |
| 2686 | TEST_F(DataChannelTest, TestCallTeardownRtcpMux) { |
| 2687 | Base::TestCallTeardownRtcpMux(); |
| 2688 | } |
| 2689 | |
| 2690 | TEST_F(DataChannelTest, TestOnReadyToSend) { |
| 2691 | Base::TestOnReadyToSend(); |
| 2692 | } |
| 2693 | |
| 2694 | TEST_F(DataChannelTest, TestOnReadyToSendWithRtcpMux) { |
| 2695 | Base::TestOnReadyToSendWithRtcpMux(); |
| 2696 | } |
| 2697 | |
| 2698 | TEST_F(DataChannelTest, SendRtpToRtp) { |
| 2699 | Base::SendRtpToRtp(); |
| 2700 | } |
| 2701 | |
| 2702 | TEST_F(DataChannelTest, SendNoRtcpToNoRtcp) { |
| 2703 | Base::SendNoRtcpToNoRtcp(); |
| 2704 | } |
| 2705 | |
| 2706 | TEST_F(DataChannelTest, SendNoRtcpToRtcp) { |
| 2707 | Base::SendNoRtcpToRtcp(); |
| 2708 | } |
| 2709 | |
| 2710 | TEST_F(DataChannelTest, SendRtcpToNoRtcp) { |
| 2711 | Base::SendRtcpToNoRtcp(); |
| 2712 | } |
| 2713 | |
| 2714 | TEST_F(DataChannelTest, SendRtcpToRtcp) { |
| 2715 | Base::SendRtcpToRtcp(); |
| 2716 | } |
| 2717 | |
| 2718 | TEST_F(DataChannelTest, SendRtcpMuxToRtcp) { |
| 2719 | Base::SendRtcpMuxToRtcp(); |
| 2720 | } |
| 2721 | |
| 2722 | TEST_F(DataChannelTest, SendRtcpMuxToRtcpMux) { |
| 2723 | Base::SendRtcpMuxToRtcpMux(); |
| 2724 | } |
| 2725 | |
| 2726 | TEST_F(DataChannelTest, SendEarlyRtcpMuxToRtcp) { |
| 2727 | Base::SendEarlyRtcpMuxToRtcp(); |
| 2728 | } |
| 2729 | |
| 2730 | TEST_F(DataChannelTest, SendEarlyRtcpMuxToRtcpMux) { |
| 2731 | Base::SendEarlyRtcpMuxToRtcpMux(); |
| 2732 | } |
| 2733 | |
| 2734 | TEST_F(DataChannelTest, SendSrtpToSrtp) { |
| 2735 | Base::SendSrtpToSrtp(); |
| 2736 | } |
| 2737 | |
| 2738 | TEST_F(DataChannelTest, SendSrtpToRtp) { |
| 2739 | Base::SendSrtpToSrtp(); |
| 2740 | } |
| 2741 | |
| 2742 | TEST_F(DataChannelTest, SendSrtcpMux) { |
| 2743 | Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX); |
| 2744 | } |
| 2745 | |
| 2746 | TEST_F(DataChannelTest, SendRtpToRtpOnThread) { |
| 2747 | Base::SendRtpToRtpOnThread(); |
| 2748 | } |
| 2749 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2750 | TEST_F(DataChannelTest, SendSrtpToSrtpOnThread) { |
| 2751 | Base::SendSrtpToSrtpOnThread(); |
| 2752 | } |
| 2753 | |
| 2754 | TEST_F(DataChannelTest, SendWithWritabilityLoss) { |
| 2755 | Base::SendWithWritabilityLoss(); |
| 2756 | } |
| 2757 | |
| 2758 | TEST_F(DataChannelTest, TestMediaMonitor) { |
| 2759 | Base::TestMediaMonitor(); |
| 2760 | } |
| 2761 | |
| 2762 | TEST_F(DataChannelTest, TestSendData) { |
| 2763 | CreateChannels(0, 0); |
| 2764 | EXPECT_TRUE(SendInitiate()); |
| 2765 | EXPECT_TRUE(SendAccept()); |
| 2766 | |
| 2767 | cricket::SendDataParams params; |
| 2768 | params.ssrc = 42; |
| 2769 | unsigned char data[] = { |
| 2770 | 'f', 'o', 'o' |
| 2771 | }; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 2772 | rtc::Buffer payload(data, 3); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2773 | cricket::SendDataResult result; |
| 2774 | ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); |
| 2775 | EXPECT_EQ(params.ssrc, |
| 2776 | media_channel1_->last_sent_data_params().ssrc); |
| 2777 | EXPECT_EQ("foo", media_channel1_->last_sent_data()); |
| 2778 | } |
| 2779 | |
| 2780 | // TODO(pthatcher): TestSetReceiver? |