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