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