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