| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2009 Google Inc. | 3 * Copyright 2009 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #include "talk/media/base/fakemediaengine.h" | 28 #include "talk/media/base/fakemediaengine.h" |
| 29 #include "talk/media/base/fakertp.h" | 29 #include "talk/media/base/fakertp.h" |
| 30 #include "talk/media/base/fakescreencapturerfactory.h" | 30 #include "talk/media/base/fakescreencapturerfactory.h" |
| 31 #include "talk/media/base/fakevideocapturer.h" | 31 #include "talk/media/base/fakevideocapturer.h" |
| 32 #include "talk/media/base/mediachannel.h" | 32 #include "talk/media/base/mediachannel.h" |
| 33 #include "talk/media/base/rtpdump.h" | 33 #include "talk/media/base/rtpdump.h" |
| 34 #include "talk/media/base/screencastid.h" | 34 #include "talk/media/base/screencastid.h" |
| 35 #include "talk/media/base/testutils.h" | 35 #include "talk/media/base/testutils.h" |
| 36 #include "webrtc/p2p/base/fakesession.h" | 36 #include "webrtc/p2p/base/faketransportcontroller.h" |
| 37 #include "talk/session/media/channel.h" | 37 #include "talk/session/media/channel.h" |
| 38 #include "webrtc/base/fileutils.h" | 38 #include "webrtc/base/fileutils.h" |
| 39 #include "webrtc/base/gunit.h" | 39 #include "webrtc/base/gunit.h" |
| 40 #include "webrtc/base/helpers.h" | 40 #include "webrtc/base/helpers.h" |
| 41 #include "webrtc/base/logging.h" | 41 #include "webrtc/base/logging.h" |
| 42 #include "webrtc/base/pathutils.h" | 42 #include "webrtc/base/pathutils.h" |
| 43 #include "webrtc/base/signalthread.h" | 43 #include "webrtc/base/signalthread.h" |
| 44 #include "webrtc/base/ssladapter.h" | 44 #include "webrtc/base/ssladapter.h" |
| 45 #include "webrtc/base/sslidentity.h" | 45 #include "webrtc/base/sslidentity.h" |
| 46 #include "webrtc/base/window.h" | 46 #include "webrtc/base/window.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 66 static const cricket::AudioCodec kIsacCodec(103, "ISAC", 40000, 16000, 1, 0); | 66 static const cricket::AudioCodec kIsacCodec(103, "ISAC", 40000, 16000, 1, 0); |
| 67 static const cricket::VideoCodec kH264Codec(97, "H264", 640, 400, 30, 0); | 67 static const cricket::VideoCodec kH264Codec(97, "H264", 640, 400, 30, 0); |
| 68 static const cricket::VideoCodec kH264SvcCodec(99, "H264-SVC", 320, 200, 15, 0); | 68 static const cricket::VideoCodec kH264SvcCodec(99, "H264-SVC", 320, 200, 15, 0); |
| 69 static const cricket::DataCodec kGoogleDataCodec(101, "google-data", 0); | 69 static const cricket::DataCodec kGoogleDataCodec(101, "google-data", 0); |
| 70 static const uint32 kSsrc1 = 0x1111; | 70 static const uint32 kSsrc1 = 0x1111; |
| 71 static const uint32 kSsrc2 = 0x2222; | 71 static const uint32 kSsrc2 = 0x2222; |
| 72 static const uint32 kSsrc3 = 0x3333; | 72 static const uint32 kSsrc3 = 0x3333; |
| 73 static const int kAudioPts[] = {0, 8}; | 73 static const int kAudioPts[] = {0, 8}; |
| 74 static const int kVideoPts[] = {97, 99}; | 74 static const int kVideoPts[] = {97, 99}; |
| 75 | 75 |
| 76 template<class ChannelT, | 76 template <class ChannelT, |
| 77 class MediaChannelT, | 77 class MediaChannelT, |
| 78 class ContentT, | 78 class ContentT, |
| 79 class CodecT, | 79 class CodecT, |
| 80 class MediaInfoT, | 80 class MediaInfoT, |
| 81 class OptionsT> | 81 class OptionsT> |
| 82 class Traits { | 82 class Traits { |
| 83 public: | 83 public: |
| 84 typedef ChannelT Channel; | 84 typedef ChannelT Channel; |
| 85 typedef MediaChannelT MediaChannel; | 85 typedef MediaChannelT MediaChannel; |
| 86 typedef ContentT Content; | 86 typedef ContentT Content; |
| 87 typedef CodecT Codec; | 87 typedef CodecT Codec; |
| 88 typedef MediaInfoT MediaInfo; | 88 typedef MediaInfoT MediaInfo; |
| 89 typedef OptionsT Options; | 89 typedef OptionsT Options; |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 // Controls how long we wait for a session to send messages that we | 92 // Controls how long we wait for a session to send messages that we |
| 93 // expect, in milliseconds. We put it high to avoid flaky tests. | 93 // expect, in milliseconds. We put it high to avoid flaky tests. |
| 94 static const int kEventTimeout = 5000; | 94 static const int kEventTimeout = 5000; |
| 95 | 95 |
| 96 class VoiceTraits : public Traits<cricket::VoiceChannel, | 96 class VoiceTraits : public Traits<cricket::VoiceChannel, |
| 97 cricket::FakeVoiceMediaChannel, | 97 cricket::FakeVoiceMediaChannel, |
| 98 cricket::AudioContentDescription, | 98 cricket::AudioContentDescription, |
| 99 cricket::AudioCodec, | 99 cricket::AudioCodec, |
| 100 cricket::VoiceMediaInfo, | 100 cricket::VoiceMediaInfo, |
| 101 cricket::AudioOptions> { | 101 cricket::AudioOptions> {}; |
| 102 }; | |
| 103 | 102 |
| 104 class VideoTraits : public Traits<cricket::VideoChannel, | 103 class VideoTraits : public Traits<cricket::VideoChannel, |
| 105 cricket::FakeVideoMediaChannel, | 104 cricket::FakeVideoMediaChannel, |
| 106 cricket::VideoContentDescription, | 105 cricket::VideoContentDescription, |
| 107 cricket::VideoCodec, | 106 cricket::VideoCodec, |
| 108 cricket::VideoMediaInfo, | 107 cricket::VideoMediaInfo, |
| 109 cricket::VideoOptions> { | 108 cricket::VideoOptions> {}; |
| 110 }; | |
| 111 | 109 |
| 112 class DataTraits : public Traits<cricket::DataChannel, | 110 class DataTraits : public Traits<cricket::DataChannel, |
| 113 cricket::FakeDataMediaChannel, | 111 cricket::FakeDataMediaChannel, |
| 114 cricket::DataContentDescription, | 112 cricket::DataContentDescription, |
| 115 cricket::DataCodec, | 113 cricket::DataCodec, |
| 116 cricket::DataMediaInfo, | 114 cricket::DataMediaInfo, |
| 117 cricket::DataOptions> { | 115 cricket::DataOptions> {}; |
| 118 }; | |
| 119 | |
| 120 | 116 |
| 121 rtc::StreamInterface* Open(const std::string& path) { | 117 rtc::StreamInterface* Open(const std::string& path) { |
| 122 return rtc::Filesystem::OpenFile( | 118 return rtc::Filesystem::OpenFile( |
| 123 rtc::Pathname(path), "wb"); | 119 rtc::Pathname(path), "wb"); |
| 124 } | 120 } |
| 125 | 121 |
| 126 // Base class for Voice/VideoChannel tests | 122 // Base class for Voice/VideoChannel tests |
| 127 template<class T> | 123 template<class T> |
| 128 class ChannelTest : public testing::Test, public sigslot::has_slots<> { | 124 class ChannelTest : public testing::Test, public sigslot::has_slots<> { |
| 129 public: | 125 public: |
| 130 enum Flags { RTCP = 0x1, RTCP_MUX = 0x2, SECURE = 0x4, SSRC_MUX = 0x8, | 126 enum Flags { RTCP = 0x1, RTCP_MUX = 0x2, SECURE = 0x4, SSRC_MUX = 0x8, |
| 131 DTLS = 0x10 }; | 127 DTLS = 0x10 }; |
| 132 | 128 |
| 133 ChannelTest(const uint8* rtp_data, int rtp_len, | 129 ChannelTest(const uint8* rtp_data, |
| 134 const uint8* rtcp_data, int rtcp_len) | 130 int rtp_len, |
| 135 : session1_(true), | 131 const uint8* rtcp_data, |
| 136 session2_(false), | 132 int rtcp_len) |
| 133 : transport_controller1_(cricket::ICEROLE_CONTROLLING), |
| 134 transport_controller2_(cricket::ICEROLE_CONTROLLED), |
| 137 media_channel1_(NULL), | 135 media_channel1_(NULL), |
| 138 media_channel2_(NULL), | 136 media_channel2_(NULL), |
| 139 rtp_packet_(reinterpret_cast<const char*>(rtp_data), rtp_len), | 137 rtp_packet_(reinterpret_cast<const char*>(rtp_data), rtp_len), |
| 140 rtcp_packet_(reinterpret_cast<const char*>(rtcp_data), rtcp_len), | 138 rtcp_packet_(reinterpret_cast<const char*>(rtcp_data), rtcp_len), |
| 141 media_info_callbacks1_(), | 139 media_info_callbacks1_(), |
| 142 media_info_callbacks2_(), | 140 media_info_callbacks2_(), |
| 143 ssrc_(0), | 141 ssrc_(0), |
| 144 error_(T::MediaChannel::ERROR_NONE) { | 142 error_(T::MediaChannel::ERROR_NONE) {} |
| 145 } | |
| 146 | 143 |
| 147 void CreateChannels(int flags1, int flags2) { | 144 void CreateChannels(int flags1, int flags2) { |
| 148 CreateChannels(new typename T::MediaChannel(NULL, typename T::Options()), | 145 CreateChannels(new typename T::MediaChannel(NULL, typename T::Options()), |
| 149 new typename T::MediaChannel(NULL, typename T::Options()), | 146 new typename T::MediaChannel(NULL, typename T::Options()), |
| 150 flags1, flags2, rtc::Thread::Current()); | 147 flags1, flags2, rtc::Thread::Current()); |
| 151 } | 148 } |
| 152 void CreateChannels( | 149 void CreateChannels( |
| 153 typename T::MediaChannel* ch1, typename T::MediaChannel* ch2, | 150 typename T::MediaChannel* ch1, typename T::MediaChannel* ch2, |
| 154 int flags1, int flags2, rtc::Thread* thread) { | 151 int flags1, int flags2, rtc::Thread* thread) { |
| 155 media_channel1_ = ch1; | 152 media_channel1_ = ch1; |
| 156 media_channel2_ = ch2; | 153 media_channel2_ = ch2; |
| 157 channel1_.reset(CreateChannel(thread, &media_engine_, ch1, &session1_, | 154 channel1_.reset(CreateChannel(thread, &media_engine_, ch1, |
| 155 &transport_controller1_, |
| 158 (flags1 & RTCP) != 0)); | 156 (flags1 & RTCP) != 0)); |
| 159 channel2_.reset(CreateChannel(thread, &media_engine_, ch2, &session2_, | 157 channel2_.reset(CreateChannel(thread, &media_engine_, ch2, |
| 158 &transport_controller2_, |
| 160 (flags2 & RTCP) != 0)); | 159 (flags2 & RTCP) != 0)); |
| 161 channel1_->SignalMediaMonitor.connect( | 160 channel1_->SignalMediaMonitor.connect( |
| 162 this, &ChannelTest<T>::OnMediaMonitor); | 161 this, &ChannelTest<T>::OnMediaMonitor); |
| 163 channel2_->SignalMediaMonitor.connect( | 162 channel2_->SignalMediaMonitor.connect( |
| 164 this, &ChannelTest<T>::OnMediaMonitor); | 163 this, &ChannelTest<T>::OnMediaMonitor); |
| 165 channel1_->SignalMediaError.connect( | 164 channel1_->SignalMediaError.connect( |
| 166 this, &ChannelTest<T>::OnMediaChannelError); | 165 this, &ChannelTest<T>::OnMediaChannelError); |
| 167 channel2_->SignalMediaError.connect( | 166 channel2_->SignalMediaError.connect( |
| 168 this, &ChannelTest<T>::OnMediaChannelError); | 167 this, &ChannelTest<T>::OnMediaChannelError); |
| 169 if ((flags1 & DTLS) && (flags2 & DTLS)) { | 168 if ((flags1 & DTLS) && (flags2 & DTLS)) { |
| 170 flags1 = (flags1 & ~SECURE); | 169 flags1 = (flags1 & ~SECURE); |
| 171 flags2 = (flags2 & ~SECURE); | 170 flags2 = (flags2 & ~SECURE); |
| 172 } | 171 } |
| 173 CreateContent(flags1, kPcmuCodec, kH264Codec, | 172 CreateContent(flags1, kPcmuCodec, kH264Codec, |
| 174 &local_media_content1_); | 173 &local_media_content1_); |
| 175 CreateContent(flags2, kPcmuCodec, kH264Codec, | 174 CreateContent(flags2, kPcmuCodec, kH264Codec, |
| 176 &local_media_content2_); | 175 &local_media_content2_); |
| 177 CopyContent(local_media_content1_, &remote_media_content1_); | 176 CopyContent(local_media_content1_, &remote_media_content1_); |
| 178 CopyContent(local_media_content2_, &remote_media_content2_); | 177 CopyContent(local_media_content2_, &remote_media_content2_); |
| 179 | 178 |
| 180 if (flags1 & DTLS) { | 179 if (flags1 & DTLS) { |
| 181 // Confirmed to work with KT_RSA and KT_ECDSA. | 180 // Confirmed to work with KT_RSA and KT_ECDSA. |
| 182 session1_.set_ssl_rtccertificate(rtc::RTCCertificate::Create( | 181 transport_controller1_.SetLocalCertificate(rtc::RTCCertificate::Create( |
| 183 rtc::scoped_ptr<rtc::SSLIdentity>(rtc::SSLIdentity::Generate( | 182 rtc::scoped_ptr<rtc::SSLIdentity>( |
| 184 "session1", rtc::KT_DEFAULT)).Pass())); | 183 rtc::SSLIdentity::Generate("session1", rtc::KT_DEFAULT)) |
| 184 .Pass())); |
| 185 } | 185 } |
| 186 if (flags2 & DTLS) { | 186 if (flags2 & DTLS) { |
| 187 // Confirmed to work with KT_RSA and KT_ECDSA. | 187 // Confirmed to work with KT_RSA and KT_ECDSA. |
| 188 session2_.set_ssl_rtccertificate(rtc::RTCCertificate::Create( | 188 transport_controller2_.SetLocalCertificate(rtc::RTCCertificate::Create( |
| 189 rtc::scoped_ptr<rtc::SSLIdentity>(rtc::SSLIdentity::Generate( | 189 rtc::scoped_ptr<rtc::SSLIdentity>( |
| 190 "session2", rtc::KT_DEFAULT)).Pass())); | 190 rtc::SSLIdentity::Generate("session2", rtc::KT_DEFAULT)) |
| 191 .Pass())); |
| 191 } | 192 } |
| 192 | 193 |
| 193 // Add stream information (SSRC) to the local content but not to the remote | 194 // Add stream information (SSRC) to the local content but not to the remote |
| 194 // content. This means that we per default know the SSRC of what we send but | 195 // content. This means that we per default know the SSRC of what we send but |
| 195 // not what we receive. | 196 // not what we receive. |
| 196 AddLegacyStreamInContent(kSsrc1, flags1, &local_media_content1_); | 197 AddLegacyStreamInContent(kSsrc1, flags1, &local_media_content1_); |
| 197 AddLegacyStreamInContent(kSsrc2, flags2, &local_media_content2_); | 198 AddLegacyStreamInContent(kSsrc2, flags2, &local_media_content2_); |
| 198 | 199 |
| 199 // If SSRC_MUX is used we also need to know the SSRC of the incoming stream. | 200 // If SSRC_MUX is used we also need to know the SSRC of the incoming stream. |
| 200 if (flags1 & SSRC_MUX) { | 201 if (flags1 & SSRC_MUX) { |
| 201 AddLegacyStreamInContent(kSsrc1, flags1, &remote_media_content1_); | 202 AddLegacyStreamInContent(kSsrc1, flags1, &remote_media_content1_); |
| 202 } | 203 } |
| 203 if (flags2 & SSRC_MUX) { | 204 if (flags2 & SSRC_MUX) { |
| 204 AddLegacyStreamInContent(kSsrc2, flags2, &remote_media_content2_); | 205 AddLegacyStreamInContent(kSsrc2, flags2, &remote_media_content2_); |
| 205 } | 206 } |
| 206 } | 207 } |
| 207 typename T::Channel* CreateChannel(rtc::Thread* thread, | 208 typename T::Channel* CreateChannel( |
| 208 cricket::MediaEngineInterface* engine, | 209 rtc::Thread* thread, |
| 209 typename T::MediaChannel* ch, | 210 cricket::MediaEngineInterface* engine, |
| 210 cricket::BaseSession* session, | 211 typename T::MediaChannel* ch, |
| 211 bool rtcp) { | 212 cricket::TransportController* transport_controller, |
| 213 bool rtcp) { |
| 212 typename T::Channel* channel = new typename T::Channel( | 214 typename T::Channel* channel = new typename T::Channel( |
| 213 thread, engine, ch, session, cricket::CN_AUDIO, rtcp); | 215 thread, engine, ch, transport_controller, cricket::CN_AUDIO, rtcp); |
| 214 if (!channel->Init()) { | 216 if (!channel->Init()) { |
| 215 delete channel; | 217 delete channel; |
| 216 channel = NULL; | 218 channel = NULL; |
| 217 } | 219 } |
| 218 return channel; | 220 return channel; |
| 219 } | 221 } |
| 220 | 222 |
| 221 bool SendInitiate() { | 223 bool SendInitiate() { |
| 222 bool result = channel1_->SetLocalContent(&local_media_content1_, | 224 bool result = channel1_->SetLocalContent(&local_media_content1_, |
| 223 CA_OFFER, NULL); | 225 CA_OFFER, NULL); |
| 224 if (result) { | 226 if (result) { |
| 225 channel1_->Enable(true); | 227 channel1_->Enable(true); |
| 226 result = channel2_->SetRemoteContent(&remote_media_content1_, | 228 result = channel2_->SetRemoteContent(&remote_media_content1_, |
| 227 CA_OFFER, NULL); | 229 CA_OFFER, NULL); |
| 228 if (result) { | 230 if (result) { |
| 229 session1_.Connect(&session2_); | 231 transport_controller1_.Connect(&transport_controller2_); |
| 230 | 232 |
| 231 result = channel2_->SetLocalContent(&local_media_content2_, | 233 result = channel2_->SetLocalContent(&local_media_content2_, |
| 232 CA_ANSWER, NULL); | 234 CA_ANSWER, NULL); |
| 233 } | 235 } |
| 234 } | 236 } |
| 235 return result; | 237 return result; |
| 236 } | 238 } |
| 237 | 239 |
| 238 bool SendAccept() { | 240 bool SendAccept() { |
| 239 channel2_->Enable(true); | 241 channel2_->Enable(true); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 252 return result; | 254 return result; |
| 253 } | 255 } |
| 254 | 256 |
| 255 bool SendProvisionalAnswer() { | 257 bool SendProvisionalAnswer() { |
| 256 bool result = channel2_->SetLocalContent(&local_media_content2_, | 258 bool result = channel2_->SetLocalContent(&local_media_content2_, |
| 257 CA_PRANSWER, NULL); | 259 CA_PRANSWER, NULL); |
| 258 if (result) { | 260 if (result) { |
| 259 channel2_->Enable(true); | 261 channel2_->Enable(true); |
| 260 result = channel1_->SetRemoteContent(&remote_media_content2_, | 262 result = channel1_->SetRemoteContent(&remote_media_content2_, |
| 261 CA_PRANSWER, NULL); | 263 CA_PRANSWER, NULL); |
| 262 session1_.Connect(&session2_); | 264 transport_controller1_.Connect(&transport_controller2_); |
| 263 } | 265 } |
| 264 return result; | 266 return result; |
| 265 } | 267 } |
| 266 | 268 |
| 267 bool SendFinalAnswer() { | 269 bool SendFinalAnswer() { |
| 268 bool result = channel2_->SetLocalContent(&local_media_content2_, | 270 bool result = channel2_->SetLocalContent(&local_media_content2_, |
| 269 CA_ANSWER, NULL); | 271 CA_ANSWER, NULL); |
| 270 if (result) | 272 if (result) |
| 271 result = channel1_->SetRemoteContent(&remote_media_content2_, | 273 result = channel1_->SetRemoteContent(&remote_media_content2_, |
| 272 CA_ANSWER, NULL); | 274 CA_ANSWER, NULL); |
| 273 return result; | 275 return result; |
| 274 } | 276 } |
| 275 | 277 |
| 276 bool SendTerminate() { | 278 bool SendTerminate() { |
| 277 channel1_.reset(); | 279 channel1_.reset(); |
| 278 channel2_.reset(); | 280 channel2_.reset(); |
| 279 return true; | 281 return true; |
| 280 } | 282 } |
| 281 | 283 |
| 282 bool AddStream1(int id) { | 284 bool AddStream1(int id) { |
| 283 return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id)); | 285 return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id)); |
| 284 } | 286 } |
| 285 bool RemoveStream1(int id) { | 287 bool RemoveStream1(int id) { |
| 286 return channel1_->RemoveRecvStream(id); | 288 return channel1_->RemoveRecvStream(id); |
| 287 } | 289 } |
| 288 | 290 |
| 291 // Calling "_w" method here is ok since we only use one thread for this test |
| 289 cricket::FakeTransport* GetTransport1() { | 292 cricket::FakeTransport* GetTransport1() { |
| 290 return session1_.GetTransport(channel1_->content_name()); | 293 return transport_controller1_.GetTransport_w(channel1_->content_name()); |
| 291 } | 294 } |
| 292 cricket::FakeTransport* GetTransport2() { | 295 cricket::FakeTransport* GetTransport2() { |
| 293 return session2_.GetTransport(channel2_->content_name()); | 296 return transport_controller2_.GetTransport_w(channel2_->content_name()); |
| 294 } | 297 } |
| 295 | 298 |
| 296 bool SendRtp1() { | 299 bool SendRtp1() { |
| 297 return media_channel1_->SendRtp(rtp_packet_.c_str(), | 300 return media_channel1_->SendRtp(rtp_packet_.c_str(), |
| 298 static_cast<int>(rtp_packet_.size())); | 301 static_cast<int>(rtp_packet_.size())); |
| 299 } | 302 } |
| 300 bool SendRtp2() { | 303 bool SendRtp2() { |
| 301 return media_channel2_->SendRtp(rtp_packet_.c_str(), | 304 return media_channel2_->SendRtp(rtp_packet_.c_str(), |
| 302 static_cast<int>(rtp_packet_.size())); | 305 static_cast<int>(rtp_packet_.size())); |
| 303 } | 306 } |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 CreateChannels(0, 0); | 765 CreateChannels(0, 0); |
| 763 typename T::Content content1; | 766 typename T::Content content1; |
| 764 CreateContent(0, kPcmuCodec, kH264Codec, &content1); | 767 CreateContent(0, kPcmuCodec, kH264Codec, &content1); |
| 765 content1.AddStream(stream1); | 768 content1.AddStream(stream1); |
| 766 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL)); | 769 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL)); |
| 767 EXPECT_TRUE(channel1_->Enable(true)); | 770 EXPECT_TRUE(channel1_->Enable(true)); |
| 768 EXPECT_EQ(1u, media_channel1_->send_streams().size()); | 771 EXPECT_EQ(1u, media_channel1_->send_streams().size()); |
| 769 | 772 |
| 770 EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, NULL)); | 773 EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, NULL)); |
| 771 EXPECT_EQ(1u, media_channel2_->recv_streams().size()); | 774 EXPECT_EQ(1u, media_channel2_->recv_streams().size()); |
| 772 session1_.Connect(&session2_); | 775 transport_controller1_.Connect(&transport_controller2_); |
| 773 | 776 |
| 774 // Channel 2 do not send anything. | 777 // Channel 2 do not send anything. |
| 775 typename T::Content content2; | 778 typename T::Content content2; |
| 776 CreateContent(0, kPcmuCodec, kH264Codec, &content2); | 779 CreateContent(0, kPcmuCodec, kH264Codec, &content2); |
| 777 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_ANSWER, NULL)); | 780 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_ANSWER, NULL)); |
| 778 EXPECT_EQ(0u, media_channel1_->recv_streams().size()); | 781 EXPECT_EQ(0u, media_channel1_->recv_streams().size()); |
| 779 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_ANSWER, NULL)); | 782 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_ANSWER, NULL)); |
| 780 EXPECT_TRUE(channel2_->Enable(true)); | 783 EXPECT_TRUE(channel2_->Enable(true)); |
| 781 EXPECT_EQ(0u, media_channel2_->send_streams().size()); | 784 EXPECT_EQ(0u, media_channel2_->send_streams().size()); |
| 782 | 785 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 EXPECT_TRUE(media_channel1_->playout()); | 828 EXPECT_TRUE(media_channel1_->playout()); |
| 826 EXPECT_FALSE(media_channel1_->sending()); | 829 EXPECT_FALSE(media_channel1_->sending()); |
| 827 EXPECT_TRUE(channel2_->SetRemoteContent(&local_media_content1_, | 830 EXPECT_TRUE(channel2_->SetRemoteContent(&local_media_content1_, |
| 828 CA_OFFER, NULL)); | 831 CA_OFFER, NULL)); |
| 829 EXPECT_FALSE(media_channel2_->playout()); | 832 EXPECT_FALSE(media_channel2_->playout()); |
| 830 EXPECT_FALSE(media_channel2_->sending()); | 833 EXPECT_FALSE(media_channel2_->sending()); |
| 831 EXPECT_TRUE(channel2_->SetLocalContent(&local_media_content2_, | 834 EXPECT_TRUE(channel2_->SetLocalContent(&local_media_content2_, |
| 832 CA_ANSWER, NULL)); | 835 CA_ANSWER, NULL)); |
| 833 EXPECT_FALSE(media_channel2_->playout()); | 836 EXPECT_FALSE(media_channel2_->playout()); |
| 834 EXPECT_FALSE(media_channel2_->sending()); | 837 EXPECT_FALSE(media_channel2_->sending()); |
| 835 session1_.Connect(&session2_); | 838 transport_controller1_.Connect(&transport_controller2_); |
| 836 EXPECT_TRUE(media_channel1_->playout()); | 839 EXPECT_TRUE(media_channel1_->playout()); |
| 837 EXPECT_FALSE(media_channel1_->sending()); | 840 EXPECT_FALSE(media_channel1_->sending()); |
| 838 EXPECT_FALSE(media_channel2_->playout()); | 841 EXPECT_FALSE(media_channel2_->playout()); |
| 839 EXPECT_FALSE(media_channel2_->sending()); | 842 EXPECT_FALSE(media_channel2_->sending()); |
| 840 EXPECT_TRUE(channel2_->Enable(true)); | 843 EXPECT_TRUE(channel2_->Enable(true)); |
| 841 EXPECT_TRUE(media_channel2_->playout()); | 844 EXPECT_TRUE(media_channel2_->playout()); |
| 842 EXPECT_TRUE(media_channel2_->sending()); | 845 EXPECT_TRUE(media_channel2_->sending()); |
| 843 EXPECT_TRUE(channel1_->SetRemoteContent(&local_media_content2_, | 846 EXPECT_TRUE(channel1_->SetRemoteContent(&local_media_content2_, |
| 844 CA_ANSWER, NULL)); | 847 CA_ANSWER, NULL)); |
| 845 EXPECT_TRUE(media_channel1_->playout()); | 848 EXPECT_TRUE(media_channel1_->playout()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 861 EXPECT_TRUE(channel2_->Enable(true)); | 864 EXPECT_TRUE(channel2_->Enable(true)); |
| 862 EXPECT_FALSE(media_channel1_->playout()); | 865 EXPECT_FALSE(media_channel1_->playout()); |
| 863 EXPECT_FALSE(media_channel1_->sending()); | 866 EXPECT_FALSE(media_channel1_->sending()); |
| 864 EXPECT_FALSE(media_channel2_->playout()); | 867 EXPECT_FALSE(media_channel2_->playout()); |
| 865 EXPECT_FALSE(media_channel2_->sending()); | 868 EXPECT_FALSE(media_channel2_->sending()); |
| 866 | 869 |
| 867 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL)); | 870 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL)); |
| 868 EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, NULL)); | 871 EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, NULL)); |
| 869 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_PRANSWER, NULL)); | 872 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_PRANSWER, NULL)); |
| 870 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_PRANSWER, NULL)); | 873 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_PRANSWER, NULL)); |
| 871 session1_.Connect(&session2_); | 874 transport_controller1_.Connect(&transport_controller2_); |
| 872 | 875 |
| 873 EXPECT_TRUE(media_channel1_->playout()); | 876 EXPECT_TRUE(media_channel1_->playout()); |
| 874 EXPECT_FALSE(media_channel1_->sending()); // remote InActive | 877 EXPECT_FALSE(media_channel1_->sending()); // remote InActive |
| 875 EXPECT_FALSE(media_channel2_->playout()); // local InActive | 878 EXPECT_FALSE(media_channel2_->playout()); // local InActive |
| 876 EXPECT_FALSE(media_channel2_->sending()); // local InActive | 879 EXPECT_FALSE(media_channel2_->sending()); // local InActive |
| 877 | 880 |
| 878 // Update |content2| to be RecvOnly. | 881 // Update |content2| to be RecvOnly. |
| 879 content2.set_direction(cricket::MD_RECVONLY); | 882 content2.set_direction(cricket::MD_RECVONLY); |
| 880 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_PRANSWER, NULL)); | 883 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_PRANSWER, NULL)); |
| 881 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_PRANSWER, NULL)); | 884 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_PRANSWER, NULL)); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 EXPECT_TRUE(SendInitiate()); | 934 EXPECT_TRUE(SendInitiate()); |
| 932 EXPECT_TRUE(SendAccept()); | 935 EXPECT_TRUE(SendAccept()); |
| 933 EXPECT_TRUE(SendTerminate()); | 936 EXPECT_TRUE(SendTerminate()); |
| 934 } | 937 } |
| 935 | 938 |
| 936 // Send voice RTP data to the other side and ensure it gets there. | 939 // Send voice RTP data to the other side and ensure it gets there. |
| 937 void SendRtpToRtp() { | 940 void SendRtpToRtp() { |
| 938 CreateChannels(0, 0); | 941 CreateChannels(0, 0); |
| 939 EXPECT_TRUE(SendInitiate()); | 942 EXPECT_TRUE(SendInitiate()); |
| 940 EXPECT_TRUE(SendAccept()); | 943 EXPECT_TRUE(SendAccept()); |
| 944 ASSERT_TRUE(GetTransport1()); |
| 945 ASSERT_TRUE(GetTransport2()); |
| 941 EXPECT_EQ(1U, GetTransport1()->channels().size()); | 946 EXPECT_EQ(1U, GetTransport1()->channels().size()); |
| 942 EXPECT_EQ(1U, GetTransport2()->channels().size()); | 947 EXPECT_EQ(1U, GetTransport2()->channels().size()); |
| 943 EXPECT_TRUE(SendRtp1()); | 948 EXPECT_TRUE(SendRtp1()); |
| 944 EXPECT_TRUE(SendRtp2()); | 949 EXPECT_TRUE(SendRtp2()); |
| 945 EXPECT_TRUE(CheckRtp1()); | 950 EXPECT_TRUE(CheckRtp1()); |
| 946 EXPECT_TRUE(CheckRtp2()); | 951 EXPECT_TRUE(CheckRtp2()); |
| 947 EXPECT_TRUE(CheckNoRtp1()); | 952 EXPECT_TRUE(CheckNoRtp1()); |
| 948 EXPECT_TRUE(CheckNoRtp2()); | 953 EXPECT_TRUE(CheckNoRtp2()); |
| 949 } | 954 } |
| 950 | 955 |
| 951 // Check that RTCP is not transmitted if both sides don't support RTCP. | 956 // Check that RTCP is not transmitted if both sides don't support RTCP. |
| 952 void SendNoRtcpToNoRtcp() { | 957 void SendNoRtcpToNoRtcp() { |
| 953 CreateChannels(0, 0); | 958 CreateChannels(0, 0); |
| 954 EXPECT_TRUE(SendInitiate()); | 959 EXPECT_TRUE(SendInitiate()); |
| 955 EXPECT_TRUE(SendAccept()); | 960 EXPECT_TRUE(SendAccept()); |
| 961 ASSERT_TRUE(GetTransport1()); |
| 962 ASSERT_TRUE(GetTransport2()); |
| 956 EXPECT_EQ(1U, GetTransport1()->channels().size()); | 963 EXPECT_EQ(1U, GetTransport1()->channels().size()); |
| 957 EXPECT_EQ(1U, GetTransport2()->channels().size()); | 964 EXPECT_EQ(1U, GetTransport2()->channels().size()); |
| 958 EXPECT_FALSE(SendRtcp1()); | 965 EXPECT_FALSE(SendRtcp1()); |
| 959 EXPECT_FALSE(SendRtcp2()); | 966 EXPECT_FALSE(SendRtcp2()); |
| 960 EXPECT_TRUE(CheckNoRtcp1()); | 967 EXPECT_TRUE(CheckNoRtcp1()); |
| 961 EXPECT_TRUE(CheckNoRtcp2()); | 968 EXPECT_TRUE(CheckNoRtcp2()); |
| 962 } | 969 } |
| 963 | 970 |
| 964 // Check that RTCP is not transmitted if the callee doesn't support RTCP. | 971 // Check that RTCP is not transmitted if the callee doesn't support RTCP. |
| 965 void SendNoRtcpToRtcp() { | 972 void SendNoRtcpToRtcp() { |
| 966 CreateChannels(0, RTCP); | 973 CreateChannels(0, RTCP); |
| 967 EXPECT_TRUE(SendInitiate()); | 974 EXPECT_TRUE(SendInitiate()); |
| 968 EXPECT_TRUE(SendAccept()); | 975 EXPECT_TRUE(SendAccept()); |
| 976 ASSERT_TRUE(GetTransport1()); |
| 977 ASSERT_TRUE(GetTransport2()); |
| 969 EXPECT_EQ(1U, GetTransport1()->channels().size()); | 978 EXPECT_EQ(1U, GetTransport1()->channels().size()); |
| 970 EXPECT_EQ(2U, GetTransport2()->channels().size()); | 979 EXPECT_EQ(2U, GetTransport2()->channels().size()); |
| 971 EXPECT_FALSE(SendRtcp1()); | 980 EXPECT_FALSE(SendRtcp1()); |
| 972 EXPECT_FALSE(SendRtcp2()); | 981 EXPECT_FALSE(SendRtcp2()); |
| 973 EXPECT_TRUE(CheckNoRtcp1()); | 982 EXPECT_TRUE(CheckNoRtcp1()); |
| 974 EXPECT_TRUE(CheckNoRtcp2()); | 983 EXPECT_TRUE(CheckNoRtcp2()); |
| 975 } | 984 } |
| 976 | 985 |
| 977 // Check that RTCP is not transmitted if the caller doesn't support RTCP. | 986 // Check that RTCP is not transmitted if the caller doesn't support RTCP. |
| 978 void SendRtcpToNoRtcp() { | 987 void SendRtcpToNoRtcp() { |
| 979 CreateChannels(RTCP, 0); | 988 CreateChannels(RTCP, 0); |
| 980 EXPECT_TRUE(SendInitiate()); | 989 EXPECT_TRUE(SendInitiate()); |
| 981 EXPECT_TRUE(SendAccept()); | 990 EXPECT_TRUE(SendAccept()); |
| 991 ASSERT_TRUE(GetTransport1()); |
| 992 ASSERT_TRUE(GetTransport2()); |
| 982 EXPECT_EQ(2U, GetTransport1()->channels().size()); | 993 EXPECT_EQ(2U, GetTransport1()->channels().size()); |
| 983 EXPECT_EQ(1U, GetTransport2()->channels().size()); | 994 EXPECT_EQ(1U, GetTransport2()->channels().size()); |
| 984 EXPECT_FALSE(SendRtcp1()); | 995 EXPECT_FALSE(SendRtcp1()); |
| 985 EXPECT_FALSE(SendRtcp2()); | 996 EXPECT_FALSE(SendRtcp2()); |
| 986 EXPECT_TRUE(CheckNoRtcp1()); | 997 EXPECT_TRUE(CheckNoRtcp1()); |
| 987 EXPECT_TRUE(CheckNoRtcp2()); | 998 EXPECT_TRUE(CheckNoRtcp2()); |
| 988 } | 999 } |
| 989 | 1000 |
| 990 // Check that RTCP is transmitted if both sides support RTCP. | 1001 // Check that RTCP is transmitted if both sides support RTCP. |
| 991 void SendRtcpToRtcp() { | 1002 void SendRtcpToRtcp() { |
| 992 CreateChannels(RTCP, RTCP); | 1003 CreateChannels(RTCP, RTCP); |
| 993 EXPECT_TRUE(SendInitiate()); | 1004 EXPECT_TRUE(SendInitiate()); |
| 994 EXPECT_TRUE(SendAccept()); | 1005 EXPECT_TRUE(SendAccept()); |
| 1006 ASSERT_TRUE(GetTransport1()); |
| 1007 ASSERT_TRUE(GetTransport2()); |
| 995 EXPECT_EQ(2U, GetTransport1()->channels().size()); | 1008 EXPECT_EQ(2U, GetTransport1()->channels().size()); |
| 996 EXPECT_EQ(2U, GetTransport2()->channels().size()); | 1009 EXPECT_EQ(2U, GetTransport2()->channels().size()); |
| 997 EXPECT_TRUE(SendRtcp1()); | 1010 EXPECT_TRUE(SendRtcp1()); |
| 998 EXPECT_TRUE(SendRtcp2()); | 1011 EXPECT_TRUE(SendRtcp2()); |
| 999 EXPECT_TRUE(CheckRtcp1()); | 1012 EXPECT_TRUE(CheckRtcp1()); |
| 1000 EXPECT_TRUE(CheckRtcp2()); | 1013 EXPECT_TRUE(CheckRtcp2()); |
| 1001 EXPECT_TRUE(CheckNoRtcp1()); | 1014 EXPECT_TRUE(CheckNoRtcp1()); |
| 1002 EXPECT_TRUE(CheckNoRtcp2()); | 1015 EXPECT_TRUE(CheckNoRtcp2()); |
| 1003 } | 1016 } |
| 1004 | 1017 |
| 1005 // Check that RTCP is transmitted if only the initiator supports mux. | 1018 // Check that RTCP is transmitted if only the initiator supports mux. |
| 1006 void SendRtcpMuxToRtcp() { | 1019 void SendRtcpMuxToRtcp() { |
| 1007 CreateChannels(RTCP | RTCP_MUX, RTCP); | 1020 CreateChannels(RTCP | RTCP_MUX, RTCP); |
| 1008 EXPECT_TRUE(SendInitiate()); | 1021 EXPECT_TRUE(SendInitiate()); |
| 1009 EXPECT_TRUE(SendAccept()); | 1022 EXPECT_TRUE(SendAccept()); |
| 1023 ASSERT_TRUE(GetTransport1()); |
| 1024 ASSERT_TRUE(GetTransport2()); |
| 1010 EXPECT_EQ(2U, GetTransport1()->channels().size()); | 1025 EXPECT_EQ(2U, GetTransport1()->channels().size()); |
| 1011 EXPECT_EQ(2U, GetTransport2()->channels().size()); | 1026 EXPECT_EQ(2U, GetTransport2()->channels().size()); |
| 1012 EXPECT_TRUE(SendRtcp1()); | 1027 EXPECT_TRUE(SendRtcp1()); |
| 1013 EXPECT_TRUE(SendRtcp2()); | 1028 EXPECT_TRUE(SendRtcp2()); |
| 1014 EXPECT_TRUE(CheckRtcp1()); | 1029 EXPECT_TRUE(CheckRtcp1()); |
| 1015 EXPECT_TRUE(CheckRtcp2()); | 1030 EXPECT_TRUE(CheckRtcp2()); |
| 1016 EXPECT_TRUE(CheckNoRtcp1()); | 1031 EXPECT_TRUE(CheckNoRtcp1()); |
| 1017 EXPECT_TRUE(CheckNoRtcp2()); | 1032 EXPECT_TRUE(CheckNoRtcp2()); |
| 1018 } | 1033 } |
| 1019 | 1034 |
| 1020 // Check that RTP and RTCP are transmitted ok when both sides support mux. | 1035 // Check that RTP and RTCP are transmitted ok when both sides support mux. |
| 1021 void SendRtcpMuxToRtcpMux() { | 1036 void SendRtcpMuxToRtcpMux() { |
| 1022 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); | 1037 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); |
| 1023 EXPECT_TRUE(SendInitiate()); | 1038 EXPECT_TRUE(SendInitiate()); |
| 1039 ASSERT_TRUE(GetTransport1()); |
| 1040 ASSERT_TRUE(GetTransport2()); |
| 1024 EXPECT_EQ(2U, GetTransport1()->channels().size()); | 1041 EXPECT_EQ(2U, GetTransport1()->channels().size()); |
| 1025 EXPECT_EQ(1U, GetTransport2()->channels().size()); | 1042 EXPECT_EQ(1U, GetTransport2()->channels().size()); |
| 1026 EXPECT_TRUE(SendAccept()); | 1043 EXPECT_TRUE(SendAccept()); |
| 1027 EXPECT_EQ(1U, GetTransport1()->channels().size()); | 1044 EXPECT_EQ(1U, GetTransport1()->channels().size()); |
| 1028 EXPECT_TRUE(SendRtp1()); | 1045 EXPECT_TRUE(SendRtp1()); |
| 1029 EXPECT_TRUE(SendRtp2()); | 1046 EXPECT_TRUE(SendRtp2()); |
| 1030 EXPECT_TRUE(SendRtcp1()); | 1047 EXPECT_TRUE(SendRtcp1()); |
| 1031 EXPECT_TRUE(SendRtcp2()); | 1048 EXPECT_TRUE(SendRtcp2()); |
| 1032 EXPECT_TRUE(CheckRtp1()); | 1049 EXPECT_TRUE(CheckRtp1()); |
| 1033 EXPECT_TRUE(CheckRtp2()); | 1050 EXPECT_TRUE(CheckRtp2()); |
| 1034 EXPECT_TRUE(CheckNoRtp1()); | 1051 EXPECT_TRUE(CheckNoRtp1()); |
| 1035 EXPECT_TRUE(CheckNoRtp2()); | 1052 EXPECT_TRUE(CheckNoRtp2()); |
| 1036 EXPECT_TRUE(CheckRtcp1()); | 1053 EXPECT_TRUE(CheckRtcp1()); |
| 1037 EXPECT_TRUE(CheckRtcp2()); | 1054 EXPECT_TRUE(CheckRtcp2()); |
| 1038 EXPECT_TRUE(CheckNoRtcp1()); | 1055 EXPECT_TRUE(CheckNoRtcp1()); |
| 1039 EXPECT_TRUE(CheckNoRtcp2()); | 1056 EXPECT_TRUE(CheckNoRtcp2()); |
| 1040 } | 1057 } |
| 1041 | 1058 |
| 1042 // Check that RTP and RTCP are transmitted ok when both sides | 1059 // Check that RTP and RTCP are transmitted ok when both sides |
| 1043 // support mux and one the offerer requires mux. | 1060 // support mux and one the offerer requires mux. |
| 1044 void SendRequireRtcpMuxToRtcpMux() { | 1061 void SendRequireRtcpMuxToRtcpMux() { |
| 1045 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); | 1062 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); |
| 1046 channel1_->ActivateRtcpMux(); | 1063 channel1_->ActivateRtcpMux(); |
| 1047 EXPECT_TRUE(SendInitiate()); | 1064 EXPECT_TRUE(SendInitiate()); |
| 1065 ASSERT_TRUE(GetTransport1()); |
| 1066 ASSERT_TRUE(GetTransport2()); |
| 1048 EXPECT_EQ(1U, GetTransport1()->channels().size()); | 1067 EXPECT_EQ(1U, GetTransport1()->channels().size()); |
| 1049 EXPECT_EQ(1U, GetTransport2()->channels().size()); | 1068 EXPECT_EQ(1U, GetTransport2()->channels().size()); |
| 1050 EXPECT_TRUE(SendAccept()); | 1069 EXPECT_TRUE(SendAccept()); |
| 1051 EXPECT_TRUE(SendRtp1()); | 1070 EXPECT_TRUE(SendRtp1()); |
| 1052 EXPECT_TRUE(SendRtp2()); | 1071 EXPECT_TRUE(SendRtp2()); |
| 1053 EXPECT_TRUE(SendRtcp1()); | 1072 EXPECT_TRUE(SendRtcp1()); |
| 1054 EXPECT_TRUE(SendRtcp2()); | 1073 EXPECT_TRUE(SendRtcp2()); |
| 1055 EXPECT_TRUE(CheckRtp1()); | 1074 EXPECT_TRUE(CheckRtp1()); |
| 1056 EXPECT_TRUE(CheckRtp2()); | 1075 EXPECT_TRUE(CheckRtp2()); |
| 1057 EXPECT_TRUE(CheckNoRtp1()); | 1076 EXPECT_TRUE(CheckNoRtp1()); |
| 1058 EXPECT_TRUE(CheckNoRtp2()); | 1077 EXPECT_TRUE(CheckNoRtp2()); |
| 1059 EXPECT_TRUE(CheckRtcp1()); | 1078 EXPECT_TRUE(CheckRtcp1()); |
| 1060 EXPECT_TRUE(CheckRtcp2()); | 1079 EXPECT_TRUE(CheckRtcp2()); |
| 1061 EXPECT_TRUE(CheckNoRtcp1()); | 1080 EXPECT_TRUE(CheckNoRtcp1()); |
| 1062 EXPECT_TRUE(CheckNoRtcp2()); | 1081 EXPECT_TRUE(CheckNoRtcp2()); |
| 1063 } | 1082 } |
| 1064 | 1083 |
| 1065 // Check that RTP and RTCP are transmitted ok when both sides | 1084 // Check that RTP and RTCP are transmitted ok when both sides |
| 1066 // support mux and one the answerer requires rtcp mux. | 1085 // support mux and one the answerer requires rtcp mux. |
| 1067 void SendRtcpMuxToRequireRtcpMux() { | 1086 void SendRtcpMuxToRequireRtcpMux() { |
| 1068 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); | 1087 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); |
| 1069 channel2_->ActivateRtcpMux(); | 1088 channel2_->ActivateRtcpMux(); |
| 1070 EXPECT_TRUE(SendInitiate()); | 1089 EXPECT_TRUE(SendInitiate()); |
| 1090 ASSERT_TRUE(GetTransport1()); |
| 1091 ASSERT_TRUE(GetTransport2()); |
| 1071 EXPECT_EQ(2U, GetTransport1()->channels().size()); | 1092 EXPECT_EQ(2U, GetTransport1()->channels().size()); |
| 1072 EXPECT_EQ(1U, GetTransport2()->channels().size()); | 1093 EXPECT_EQ(1U, GetTransport2()->channels().size()); |
| 1073 EXPECT_TRUE(SendAccept()); | 1094 EXPECT_TRUE(SendAccept()); |
| 1074 EXPECT_EQ(1U, GetTransport1()->channels().size()); | 1095 EXPECT_EQ(1U, GetTransport1()->channels().size()); |
| 1075 EXPECT_TRUE(SendRtp1()); | 1096 EXPECT_TRUE(SendRtp1()); |
| 1076 EXPECT_TRUE(SendRtp2()); | 1097 EXPECT_TRUE(SendRtp2()); |
| 1077 EXPECT_TRUE(SendRtcp1()); | 1098 EXPECT_TRUE(SendRtcp1()); |
| 1078 EXPECT_TRUE(SendRtcp2()); | 1099 EXPECT_TRUE(SendRtcp2()); |
| 1079 EXPECT_TRUE(CheckRtp1()); | 1100 EXPECT_TRUE(CheckRtp1()); |
| 1080 EXPECT_TRUE(CheckRtp2()); | 1101 EXPECT_TRUE(CheckRtp2()); |
| 1081 EXPECT_TRUE(CheckNoRtp1()); | 1102 EXPECT_TRUE(CheckNoRtp1()); |
| 1082 EXPECT_TRUE(CheckNoRtp2()); | 1103 EXPECT_TRUE(CheckNoRtp2()); |
| 1083 EXPECT_TRUE(CheckRtcp1()); | 1104 EXPECT_TRUE(CheckRtcp1()); |
| 1084 EXPECT_TRUE(CheckRtcp2()); | 1105 EXPECT_TRUE(CheckRtcp2()); |
| 1085 EXPECT_TRUE(CheckNoRtcp1()); | 1106 EXPECT_TRUE(CheckNoRtcp1()); |
| 1086 EXPECT_TRUE(CheckNoRtcp2()); | 1107 EXPECT_TRUE(CheckNoRtcp2()); |
| 1087 } | 1108 } |
| 1088 | 1109 |
| 1089 // Check that RTP and RTCP are transmitted ok when both sides | 1110 // Check that RTP and RTCP are transmitted ok when both sides |
| 1090 // require mux. | 1111 // require mux. |
| 1091 void SendRequireRtcpMuxToRequireRtcpMux() { | 1112 void SendRequireRtcpMuxToRequireRtcpMux() { |
| 1092 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); | 1113 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); |
| 1093 channel1_->ActivateRtcpMux(); | 1114 channel1_->ActivateRtcpMux(); |
| 1094 channel2_->ActivateRtcpMux(); | 1115 channel2_->ActivateRtcpMux(); |
| 1095 EXPECT_TRUE(SendInitiate()); | 1116 EXPECT_TRUE(SendInitiate()); |
| 1117 ASSERT_TRUE(GetTransport1()); |
| 1118 ASSERT_TRUE(GetTransport2()); |
| 1096 EXPECT_EQ(1U, GetTransport1()->channels().size()); | 1119 EXPECT_EQ(1U, GetTransport1()->channels().size()); |
| 1097 EXPECT_EQ(1U, GetTransport2()->channels().size()); | 1120 EXPECT_EQ(1U, GetTransport2()->channels().size()); |
| 1098 EXPECT_TRUE(SendAccept()); | 1121 EXPECT_TRUE(SendAccept()); |
| 1099 EXPECT_EQ(1U, GetTransport1()->channels().size()); | 1122 EXPECT_EQ(1U, GetTransport1()->channels().size()); |
| 1100 EXPECT_TRUE(SendRtp1()); | 1123 EXPECT_TRUE(SendRtp1()); |
| 1101 EXPECT_TRUE(SendRtp2()); | 1124 EXPECT_TRUE(SendRtp2()); |
| 1102 EXPECT_TRUE(SendRtcp1()); | 1125 EXPECT_TRUE(SendRtcp1()); |
| 1103 EXPECT_TRUE(SendRtcp2()); | 1126 EXPECT_TRUE(SendRtcp2()); |
| 1104 EXPECT_TRUE(CheckRtp1()); | 1127 EXPECT_TRUE(CheckRtp1()); |
| 1105 EXPECT_TRUE(CheckRtp2()); | 1128 EXPECT_TRUE(CheckRtp2()); |
| 1106 EXPECT_TRUE(CheckNoRtp1()); | 1129 EXPECT_TRUE(CheckNoRtp1()); |
| 1107 EXPECT_TRUE(CheckNoRtp2()); | 1130 EXPECT_TRUE(CheckNoRtp2()); |
| 1108 EXPECT_TRUE(CheckRtcp1()); | 1131 EXPECT_TRUE(CheckRtcp1()); |
| 1109 EXPECT_TRUE(CheckRtcp2()); | 1132 EXPECT_TRUE(CheckRtcp2()); |
| 1110 EXPECT_TRUE(CheckNoRtcp1()); | 1133 EXPECT_TRUE(CheckNoRtcp1()); |
| 1111 EXPECT_TRUE(CheckNoRtcp2()); | 1134 EXPECT_TRUE(CheckNoRtcp2()); |
| 1112 } | 1135 } |
| 1113 | 1136 |
| 1114 // Check that SendAccept fails if the answerer doesn't support mux | 1137 // Check that SendAccept fails if the answerer doesn't support mux |
| 1115 // and the offerer requires it. | 1138 // and the offerer requires it. |
| 1116 void SendRequireRtcpMuxToNoRtcpMux() { | 1139 void SendRequireRtcpMuxToNoRtcpMux() { |
| 1117 CreateChannels(RTCP | RTCP_MUX, RTCP); | 1140 CreateChannels(RTCP | RTCP_MUX, RTCP); |
| 1118 channel1_->ActivateRtcpMux(); | 1141 channel1_->ActivateRtcpMux(); |
| 1119 EXPECT_TRUE(SendInitiate()); | 1142 EXPECT_TRUE(SendInitiate()); |
| 1143 ASSERT_TRUE(GetTransport1()); |
| 1144 ASSERT_TRUE(GetTransport2()); |
| 1120 EXPECT_EQ(1U, GetTransport1()->channels().size()); | 1145 EXPECT_EQ(1U, GetTransport1()->channels().size()); |
| 1121 EXPECT_EQ(2U, GetTransport2()->channels().size()); | 1146 EXPECT_EQ(2U, GetTransport2()->channels().size()); |
| 1122 EXPECT_FALSE(SendAccept()); | 1147 EXPECT_FALSE(SendAccept()); |
| 1123 } | 1148 } |
| 1124 | 1149 |
| 1125 // Check that RTCP data sent by the initiator before the accept is not muxed. | 1150 // Check that RTCP data sent by the initiator before the accept is not muxed. |
| 1126 void SendEarlyRtcpMuxToRtcp() { | 1151 void SendEarlyRtcpMuxToRtcp() { |
| 1127 CreateChannels(RTCP | RTCP_MUX, RTCP); | 1152 CreateChannels(RTCP | RTCP_MUX, RTCP); |
| 1128 EXPECT_TRUE(SendInitiate()); | 1153 EXPECT_TRUE(SendInitiate()); |
| 1154 ASSERT_TRUE(GetTransport1()); |
| 1155 ASSERT_TRUE(GetTransport2()); |
| 1129 EXPECT_EQ(2U, GetTransport1()->channels().size()); | 1156 EXPECT_EQ(2U, GetTransport1()->channels().size()); |
| 1130 EXPECT_EQ(2U, GetTransport2()->channels().size()); | 1157 EXPECT_EQ(2U, GetTransport2()->channels().size()); |
| 1131 | 1158 |
| 1132 // RTCP can be sent before the call is accepted, if the transport is ready. | 1159 // RTCP can be sent before the call is accepted, if the transport is ready. |
| 1133 // It should not be muxed though, as the remote side doesn't support mux. | 1160 // It should not be muxed though, as the remote side doesn't support mux. |
| 1134 EXPECT_TRUE(SendRtcp1()); | 1161 EXPECT_TRUE(SendRtcp1()); |
| 1135 EXPECT_TRUE(CheckNoRtp2()); | 1162 EXPECT_TRUE(CheckNoRtp2()); |
| 1136 EXPECT_TRUE(CheckRtcp2()); | 1163 EXPECT_TRUE(CheckRtcp2()); |
| 1137 | 1164 |
| 1138 // Send RTCP packet from callee and verify that it is received. | 1165 // Send RTCP packet from callee and verify that it is received. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1149 EXPECT_TRUE(CheckRtcp1()); | 1176 EXPECT_TRUE(CheckRtcp1()); |
| 1150 } | 1177 } |
| 1151 | 1178 |
| 1152 | 1179 |
| 1153 // Check that RTCP data is not muxed until both sides have enabled muxing, | 1180 // Check that RTCP data is not muxed until both sides have enabled muxing, |
| 1154 // but that we properly demux before we get the accept message, since there | 1181 // but that we properly demux before we get the accept message, since there |
| 1155 // is a race between RTP data and the jingle accept. | 1182 // is a race between RTP data and the jingle accept. |
| 1156 void SendEarlyRtcpMuxToRtcpMux() { | 1183 void SendEarlyRtcpMuxToRtcpMux() { |
| 1157 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); | 1184 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); |
| 1158 EXPECT_TRUE(SendInitiate()); | 1185 EXPECT_TRUE(SendInitiate()); |
| 1186 ASSERT_TRUE(GetTransport1()); |
| 1187 ASSERT_TRUE(GetTransport2()); |
| 1159 EXPECT_EQ(2U, GetTransport1()->channels().size()); | 1188 EXPECT_EQ(2U, GetTransport1()->channels().size()); |
| 1160 EXPECT_EQ(1U, GetTransport2()->channels().size()); | 1189 EXPECT_EQ(1U, GetTransport2()->channels().size()); |
| 1161 | 1190 |
| 1162 // RTCP can't be sent yet, since the RTCP transport isn't writable, and | 1191 // RTCP can't be sent yet, since the RTCP transport isn't writable, and |
| 1163 // we haven't yet received the accept that says we should mux. | 1192 // we haven't yet received the accept that says we should mux. |
| 1164 EXPECT_FALSE(SendRtcp1()); | 1193 EXPECT_FALSE(SendRtcp1()); |
| 1165 | 1194 |
| 1166 // Send muxed RTCP packet from callee and verify that it is received. | 1195 // Send muxed RTCP packet from callee and verify that it is received. |
| 1167 EXPECT_TRUE(SendRtcp2()); | 1196 EXPECT_TRUE(SendRtcp2()); |
| 1168 EXPECT_TRUE(CheckNoRtp1()); | 1197 EXPECT_TRUE(CheckNoRtp1()); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1239 // sent and received. The test uses SRTP, RTCP mux and SSRC mux. | 1268 // sent and received. The test uses SRTP, RTCP mux and SSRC mux. |
| 1240 void SendEarlyMediaUsingRtcpMuxSrtp() { | 1269 void SendEarlyMediaUsingRtcpMuxSrtp() { |
| 1241 int sequence_number1_1 = 0, sequence_number2_2 = 0; | 1270 int sequence_number1_1 = 0, sequence_number2_2 = 0; |
| 1242 | 1271 |
| 1243 CreateChannels(SSRC_MUX | RTCP | RTCP_MUX | SECURE, | 1272 CreateChannels(SSRC_MUX | RTCP | RTCP_MUX | SECURE, |
| 1244 SSRC_MUX | RTCP | RTCP_MUX | SECURE); | 1273 SSRC_MUX | RTCP | RTCP_MUX | SECURE); |
| 1245 EXPECT_TRUE(SendOffer()); | 1274 EXPECT_TRUE(SendOffer()); |
| 1246 EXPECT_TRUE(SendProvisionalAnswer()); | 1275 EXPECT_TRUE(SendProvisionalAnswer()); |
| 1247 EXPECT_TRUE(channel1_->secure()); | 1276 EXPECT_TRUE(channel1_->secure()); |
| 1248 EXPECT_TRUE(channel2_->secure()); | 1277 EXPECT_TRUE(channel2_->secure()); |
| 1278 ASSERT_TRUE(GetTransport1()); |
| 1279 ASSERT_TRUE(GetTransport2()); |
| 1249 EXPECT_EQ(2U, GetTransport1()->channels().size()); | 1280 EXPECT_EQ(2U, GetTransport1()->channels().size()); |
| 1250 EXPECT_EQ(2U, GetTransport2()->channels().size()); | 1281 EXPECT_EQ(2U, GetTransport2()->channels().size()); |
| 1251 EXPECT_TRUE(SendCustomRtcp1(kSsrc1)); | 1282 EXPECT_TRUE(SendCustomRtcp1(kSsrc1)); |
| 1252 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1)); | 1283 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1)); |
| 1253 EXPECT_TRUE(SendCustomRtp1(kSsrc1, ++sequence_number1_1)); | 1284 EXPECT_TRUE(SendCustomRtp1(kSsrc1, ++sequence_number1_1)); |
| 1254 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1)); | 1285 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1)); |
| 1255 | 1286 |
| 1256 // Send packets from callee and verify that it is received. | 1287 // Send packets from callee and verify that it is received. |
| 1257 EXPECT_TRUE(SendCustomRtcp2(kSsrc2)); | 1288 EXPECT_TRUE(SendCustomRtcp2(kSsrc2)); |
| 1258 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2)); | 1289 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2)); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1322 EXPECT_TRUE(CheckNoRtcp1()); | 1353 EXPECT_TRUE(CheckNoRtcp1()); |
| 1323 EXPECT_TRUE(CheckNoRtcp2()); | 1354 EXPECT_TRUE(CheckNoRtcp2()); |
| 1324 } | 1355 } |
| 1325 | 1356 |
| 1326 // Test that the mediachannel retains its sending state after the transport | 1357 // Test that the mediachannel retains its sending state after the transport |
| 1327 // becomes non-writable. | 1358 // becomes non-writable. |
| 1328 void SendWithWritabilityLoss() { | 1359 void SendWithWritabilityLoss() { |
| 1329 CreateChannels(0, 0); | 1360 CreateChannels(0, 0); |
| 1330 EXPECT_TRUE(SendInitiate()); | 1361 EXPECT_TRUE(SendInitiate()); |
| 1331 EXPECT_TRUE(SendAccept()); | 1362 EXPECT_TRUE(SendAccept()); |
| 1363 ASSERT_TRUE(GetTransport1()); |
| 1364 ASSERT_TRUE(GetTransport2()); |
| 1332 EXPECT_EQ(1U, GetTransport1()->channels().size()); | 1365 EXPECT_EQ(1U, GetTransport1()->channels().size()); |
| 1333 EXPECT_EQ(1U, GetTransport2()->channels().size()); | 1366 EXPECT_EQ(1U, GetTransport2()->channels().size()); |
| 1334 EXPECT_TRUE(SendRtp1()); | 1367 EXPECT_TRUE(SendRtp1()); |
| 1335 EXPECT_TRUE(SendRtp2()); | 1368 EXPECT_TRUE(SendRtp2()); |
| 1336 EXPECT_TRUE(CheckRtp1()); | 1369 EXPECT_TRUE(CheckRtp1()); |
| 1337 EXPECT_TRUE(CheckRtp2()); | 1370 EXPECT_TRUE(CheckRtp2()); |
| 1338 EXPECT_TRUE(CheckNoRtp1()); | 1371 EXPECT_TRUE(CheckNoRtp1()); |
| 1339 EXPECT_TRUE(CheckNoRtp2()); | 1372 EXPECT_TRUE(CheckNoRtp2()); |
| 1340 | 1373 |
| 1341 // Lose writability, which should fail. | 1374 // Lose writability, which should fail. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1386 int pl_type2 = pl_types[1]; | 1419 int pl_type2 = pl_types[1]; |
| 1387 int flags = SSRC_MUX | RTCP; | 1420 int flags = SSRC_MUX | RTCP; |
| 1388 if (secure) flags |= SECURE; | 1421 if (secure) flags |= SECURE; |
| 1389 uint32 expected_channels = 2U; | 1422 uint32 expected_channels = 2U; |
| 1390 if (rtcp_mux) { | 1423 if (rtcp_mux) { |
| 1391 flags |= RTCP_MUX; | 1424 flags |= RTCP_MUX; |
| 1392 expected_channels = 1U; | 1425 expected_channels = 1U; |
| 1393 } | 1426 } |
| 1394 CreateChannels(flags, flags); | 1427 CreateChannels(flags, flags); |
| 1395 EXPECT_TRUE(SendInitiate()); | 1428 EXPECT_TRUE(SendInitiate()); |
| 1429 ASSERT_TRUE(GetTransport1()); |
| 1430 ASSERT_TRUE(GetTransport2()); |
| 1396 EXPECT_EQ(2U, GetTransport1()->channels().size()); | 1431 EXPECT_EQ(2U, GetTransport1()->channels().size()); |
| 1397 EXPECT_EQ(expected_channels, GetTransport2()->channels().size()); | 1432 EXPECT_EQ(expected_channels, GetTransport2()->channels().size()); |
| 1398 EXPECT_TRUE(SendAccept()); | 1433 EXPECT_TRUE(SendAccept()); |
| 1399 EXPECT_EQ(expected_channels, GetTransport1()->channels().size()); | 1434 EXPECT_EQ(expected_channels, GetTransport1()->channels().size()); |
| 1400 EXPECT_EQ(expected_channels, GetTransport2()->channels().size()); | 1435 EXPECT_EQ(expected_channels, GetTransport2()->channels().size()); |
| 1401 EXPECT_TRUE(channel1_->bundle_filter()->FindPayloadType(pl_type1)); | 1436 EXPECT_TRUE(channel1_->bundle_filter()->FindPayloadType(pl_type1)); |
| 1402 EXPECT_TRUE(channel2_->bundle_filter()->FindPayloadType(pl_type1)); | 1437 EXPECT_TRUE(channel2_->bundle_filter()->FindPayloadType(pl_type1)); |
| 1403 EXPECT_FALSE(channel1_->bundle_filter()->FindPayloadType(pl_type2)); | 1438 EXPECT_FALSE(channel1_->bundle_filter()->FindPayloadType(pl_type2)); |
| 1404 EXPECT_FALSE(channel2_->bundle_filter()->FindPayloadType(pl_type2)); | 1439 EXPECT_FALSE(channel2_->bundle_filter()->FindPayloadType(pl_type2)); |
| 1405 // channel1 - should only have media_content2 as remote. i.e. kSsrc2 | 1440 // channel1 - should only have media_content2 as remote. i.e. kSsrc2 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1574 EXPECT_FALSE(media_channel1_->HasRecvStream(2)); | 1609 EXPECT_FALSE(media_channel1_->HasRecvStream(2)); |
| 1575 EXPECT_TRUE(media_channel1_->HasRecvStream(3)); | 1610 EXPECT_TRUE(media_channel1_->HasRecvStream(3)); |
| 1576 } | 1611 } |
| 1577 | 1612 |
| 1578 void TestFlushRtcp() { | 1613 void TestFlushRtcp() { |
| 1579 bool send_rtcp1; | 1614 bool send_rtcp1; |
| 1580 | 1615 |
| 1581 CreateChannels(RTCP, RTCP); | 1616 CreateChannels(RTCP, RTCP); |
| 1582 EXPECT_TRUE(SendInitiate()); | 1617 EXPECT_TRUE(SendInitiate()); |
| 1583 EXPECT_TRUE(SendAccept()); | 1618 EXPECT_TRUE(SendAccept()); |
| 1619 ASSERT_TRUE(GetTransport1()); |
| 1620 ASSERT_TRUE(GetTransport2()); |
| 1584 EXPECT_EQ(2U, GetTransport1()->channels().size()); | 1621 EXPECT_EQ(2U, GetTransport1()->channels().size()); |
| 1585 EXPECT_EQ(2U, GetTransport2()->channels().size()); | 1622 EXPECT_EQ(2U, GetTransport2()->channels().size()); |
| 1586 | 1623 |
| 1587 // Send RTCP1 from a different thread. | 1624 // Send RTCP1 from a different thread. |
| 1588 CallOnThreadAndWaitForDone(&ChannelTest<T>::SendRtcp1, &send_rtcp1); | 1625 CallOnThreadAndWaitForDone(&ChannelTest<T>::SendRtcp1, &send_rtcp1); |
| 1589 EXPECT_TRUE(send_rtcp1); | 1626 EXPECT_TRUE(send_rtcp1); |
| 1590 // The sending message is only posted. channel2_ should be empty. | 1627 // The sending message is only posted. channel2_ should be empty. |
| 1591 EXPECT_TRUE(CheckNoRtcp2()); | 1628 EXPECT_TRUE(CheckNoRtcp2()); |
| 1592 | 1629 |
| 1593 // When channel1_ is deleted, the RTCP packet should be sent out to | 1630 // When channel1_ is deleted, the RTCP packet should be sent out to |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1662 TransportChannel* rtcp = channel1_->rtcp_transport_channel(); | 1699 TransportChannel* rtcp = channel1_->rtcp_transport_channel(); |
| 1663 EXPECT_FALSE(media_channel1_->ready_to_send()); | 1700 EXPECT_FALSE(media_channel1_->ready_to_send()); |
| 1664 rtp->SignalReadyToSend(rtp); | 1701 rtp->SignalReadyToSend(rtp); |
| 1665 EXPECT_FALSE(media_channel1_->ready_to_send()); | 1702 EXPECT_FALSE(media_channel1_->ready_to_send()); |
| 1666 rtcp->SignalReadyToSend(rtcp); | 1703 rtcp->SignalReadyToSend(rtcp); |
| 1667 // MediaChannel::OnReadyToSend only be called when both rtp and rtcp | 1704 // MediaChannel::OnReadyToSend only be called when both rtp and rtcp |
| 1668 // channel are ready to send. | 1705 // channel are ready to send. |
| 1669 EXPECT_TRUE(media_channel1_->ready_to_send()); | 1706 EXPECT_TRUE(media_channel1_->ready_to_send()); |
| 1670 | 1707 |
| 1671 // rtp channel becomes not ready to send will be propagated to mediachannel | 1708 // rtp channel becomes not ready to send will be propagated to mediachannel |
| 1672 channel1_->SetReadyToSend(rtp, false); | 1709 channel1_->SetReadyToSend(false, false); |
| 1673 EXPECT_FALSE(media_channel1_->ready_to_send()); | 1710 EXPECT_FALSE(media_channel1_->ready_to_send()); |
| 1674 channel1_->SetReadyToSend(rtp, true); | 1711 channel1_->SetReadyToSend(false, true); |
| 1675 EXPECT_TRUE(media_channel1_->ready_to_send()); | 1712 EXPECT_TRUE(media_channel1_->ready_to_send()); |
| 1676 | 1713 |
| 1677 // rtcp channel becomes not ready to send will be propagated to mediachannel | 1714 // rtcp channel becomes not ready to send will be propagated to mediachannel |
| 1678 channel1_->SetReadyToSend(rtcp, false); | 1715 channel1_->SetReadyToSend(true, false); |
| 1679 EXPECT_FALSE(media_channel1_->ready_to_send()); | 1716 EXPECT_FALSE(media_channel1_->ready_to_send()); |
| 1680 channel1_->SetReadyToSend(rtcp, true); | 1717 channel1_->SetReadyToSend(true, true); |
| 1681 EXPECT_TRUE(media_channel1_->ready_to_send()); | 1718 EXPECT_TRUE(media_channel1_->ready_to_send()); |
| 1682 } | 1719 } |
| 1683 | 1720 |
| 1684 void TestOnReadyToSendWithRtcpMux() { | 1721 void TestOnReadyToSendWithRtcpMux() { |
| 1685 CreateChannels(RTCP, RTCP); | 1722 CreateChannels(RTCP, RTCP); |
| 1686 typename T::Content content; | 1723 typename T::Content content; |
| 1687 CreateContent(0, kPcmuCodec, kH264Codec, &content); | 1724 CreateContent(0, kPcmuCodec, kH264Codec, &content); |
| 1688 // Both sides agree on mux. Should no longer be a separate RTCP channel. | 1725 // Both sides agree on mux. Should no longer be a separate RTCP channel. |
| 1689 content.set_rtcp_mux(true); | 1726 content.set_rtcp_mux(true); |
| 1690 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); | 1727 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); |
| 1691 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); | 1728 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); |
| 1692 EXPECT_TRUE(channel1_->rtcp_transport_channel() == NULL); | 1729 EXPECT_TRUE(channel1_->rtcp_transport_channel() == NULL); |
| 1693 TransportChannel* rtp = channel1_->transport_channel(); | 1730 TransportChannel* rtp = channel1_->transport_channel(); |
| 1694 EXPECT_FALSE(media_channel1_->ready_to_send()); | 1731 EXPECT_FALSE(media_channel1_->ready_to_send()); |
| 1695 // In the case of rtcp mux, the SignalReadyToSend() from rtp channel | 1732 // In the case of rtcp mux, the SignalReadyToSend() from rtp channel |
| 1696 // should trigger the MediaChannel's OnReadyToSend. | 1733 // should trigger the MediaChannel's OnReadyToSend. |
| 1697 rtp->SignalReadyToSend(rtp); | 1734 rtp->SignalReadyToSend(rtp); |
| 1698 EXPECT_TRUE(media_channel1_->ready_to_send()); | 1735 EXPECT_TRUE(media_channel1_->ready_to_send()); |
| 1699 channel1_->SetReadyToSend(rtp, false); | 1736 channel1_->SetReadyToSend(false, false); |
| 1700 EXPECT_FALSE(media_channel1_->ready_to_send()); | 1737 EXPECT_FALSE(media_channel1_->ready_to_send()); |
| 1701 } | 1738 } |
| 1702 | 1739 |
| 1703 protected: | 1740 protected: |
| 1704 cricket::FakeSession session1_; | 1741 cricket::FakeTransportController transport_controller1_; |
| 1705 cricket::FakeSession session2_; | 1742 cricket::FakeTransportController transport_controller2_; |
| 1706 cricket::FakeMediaEngine media_engine_; | 1743 cricket::FakeMediaEngine media_engine_; |
| 1707 // The media channels are owned by the voice channel objects below. | 1744 // The media channels are owned by the voice channel objects below. |
| 1708 typename T::MediaChannel* media_channel1_; | 1745 typename T::MediaChannel* media_channel1_; |
| 1709 typename T::MediaChannel* media_channel2_; | 1746 typename T::MediaChannel* media_channel2_; |
| 1710 rtc::scoped_ptr<typename T::Channel> channel1_; | 1747 rtc::scoped_ptr<typename T::Channel> channel1_; |
| 1711 rtc::scoped_ptr<typename T::Channel> channel2_; | 1748 rtc::scoped_ptr<typename T::Channel> channel2_; |
| 1712 typename T::Content local_media_content1_; | 1749 typename T::Content local_media_content1_; |
| 1713 typename T::Content local_media_content2_; | 1750 typename T::Content local_media_content2_; |
| 1714 typename T::Content remote_media_content1_; | 1751 typename T::Content remote_media_content1_; |
| 1715 typename T::Content remote_media_content2_; | 1752 typename T::Content remote_media_content2_; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1756 template<> | 1793 template<> |
| 1757 void ChannelTest<VoiceTraits>::AddLegacyStreamInContent( | 1794 void ChannelTest<VoiceTraits>::AddLegacyStreamInContent( |
| 1758 uint32 ssrc, int flags, cricket::AudioContentDescription* audio) { | 1795 uint32 ssrc, int flags, cricket::AudioContentDescription* audio) { |
| 1759 audio->AddLegacyStream(ssrc); | 1796 audio->AddLegacyStream(ssrc); |
| 1760 } | 1797 } |
| 1761 | 1798 |
| 1762 class VoiceChannelTest | 1799 class VoiceChannelTest |
| 1763 : public ChannelTest<VoiceTraits> { | 1800 : public ChannelTest<VoiceTraits> { |
| 1764 public: | 1801 public: |
| 1765 typedef ChannelTest<VoiceTraits> Base; | 1802 typedef ChannelTest<VoiceTraits> Base; |
| 1766 VoiceChannelTest() : Base(kPcmuFrame, sizeof(kPcmuFrame), | 1803 VoiceChannelTest() |
| 1767 kRtcpReport, sizeof(kRtcpReport)) {} | 1804 : Base(kPcmuFrame, sizeof(kPcmuFrame), kRtcpReport, sizeof(kRtcpReport)) { |
| 1805 } |
| 1768 }; | 1806 }; |
| 1769 | 1807 |
| 1770 // override to add NULL parameter | 1808 // override to add NULL parameter |
| 1771 template<> | 1809 template <> |
| 1772 cricket::VideoChannel* ChannelTest<VideoTraits>::CreateChannel( | 1810 cricket::VideoChannel* ChannelTest<VideoTraits>::CreateChannel( |
| 1773 rtc::Thread* thread, cricket::MediaEngineInterface* engine, | 1811 rtc::Thread* thread, |
| 1774 cricket::FakeVideoMediaChannel* ch, cricket::BaseSession* session, | 1812 cricket::MediaEngineInterface* engine, |
| 1813 cricket::FakeVideoMediaChannel* ch, |
| 1814 cricket::TransportController* transport_controller, |
| 1775 bool rtcp) { | 1815 bool rtcp) { |
| 1776 cricket::VideoChannel* channel = new cricket::VideoChannel( | 1816 cricket::VideoChannel* channel = new cricket::VideoChannel( |
| 1777 thread, ch, session, cricket::CN_VIDEO, rtcp); | 1817 thread, ch, transport_controller, cricket::CN_VIDEO, rtcp); |
| 1778 if (!channel->Init()) { | 1818 if (!channel->Init()) { |
| 1779 delete channel; | 1819 delete channel; |
| 1780 channel = NULL; | 1820 channel = NULL; |
| 1781 } | 1821 } |
| 1782 return channel; | 1822 return channel; |
| 1783 } | 1823 } |
| 1784 | 1824 |
| 1785 // override to add 0 parameter | 1825 // override to add 0 parameter |
| 1786 template<> | 1826 template<> |
| 1787 bool ChannelTest<VideoTraits>::AddStream1(int id) { | 1827 bool ChannelTest<VideoTraits>::AddStream1(int id) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1820 template<> | 1860 template<> |
| 1821 void ChannelTest<VideoTraits>::AddLegacyStreamInContent( | 1861 void ChannelTest<VideoTraits>::AddLegacyStreamInContent( |
| 1822 uint32 ssrc, int flags, cricket::VideoContentDescription* video) { | 1862 uint32 ssrc, int flags, cricket::VideoContentDescription* video) { |
| 1823 video->AddLegacyStream(ssrc); | 1863 video->AddLegacyStream(ssrc); |
| 1824 } | 1864 } |
| 1825 | 1865 |
| 1826 class VideoChannelTest | 1866 class VideoChannelTest |
| 1827 : public ChannelTest<VideoTraits> { | 1867 : public ChannelTest<VideoTraits> { |
| 1828 public: | 1868 public: |
| 1829 typedef ChannelTest<VideoTraits> Base; | 1869 typedef ChannelTest<VideoTraits> Base; |
| 1830 VideoChannelTest() : Base(kH264Packet, sizeof(kH264Packet), | 1870 VideoChannelTest() |
| 1831 kRtcpReport, sizeof(kRtcpReport)) {} | 1871 : Base(kH264Packet, |
| 1872 sizeof(kH264Packet), |
| 1873 kRtcpReport, |
| 1874 sizeof(kRtcpReport)) {} |
| 1832 }; | 1875 }; |
| 1833 | 1876 |
| 1834 | 1877 |
| 1835 // VoiceChannelTest | 1878 // VoiceChannelTest |
| 1836 | 1879 |
| 1837 TEST_F(VoiceChannelTest, TestInit) { | 1880 TEST_F(VoiceChannelTest, TestInit) { |
| 1838 Base::TestInit(); | 1881 Base::TestInit(); |
| 1839 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); | 1882 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); |
| 1840 EXPECT_TRUE(media_channel1_->dtmf_info_queue().empty()); | 1883 EXPECT_TRUE(media_channel1_->dtmf_info_queue().empty()); |
| 1841 } | 1884 } |
| (...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2539 : public ChannelTest<DataTraits> { | 2582 : public ChannelTest<DataTraits> { |
| 2540 public: | 2583 public: |
| 2541 typedef ChannelTest<DataTraits> | 2584 typedef ChannelTest<DataTraits> |
| 2542 Base; | 2585 Base; |
| 2543 DataChannelTest() : Base(kDataPacket, sizeof(kDataPacket), | 2586 DataChannelTest() : Base(kDataPacket, sizeof(kDataPacket), |
| 2544 kRtcpReport, sizeof(kRtcpReport)) { | 2587 kRtcpReport, sizeof(kRtcpReport)) { |
| 2545 } | 2588 } |
| 2546 }; | 2589 }; |
| 2547 | 2590 |
| 2548 // Override to avoid engine channel parameter. | 2591 // Override to avoid engine channel parameter. |
| 2549 template<> | 2592 template <> |
| 2550 cricket::DataChannel* ChannelTest<DataTraits>::CreateChannel( | 2593 cricket::DataChannel* ChannelTest<DataTraits>::CreateChannel( |
| 2551 rtc::Thread* thread, cricket::MediaEngineInterface* engine, | 2594 rtc::Thread* thread, |
| 2552 cricket::FakeDataMediaChannel* ch, cricket::BaseSession* session, | 2595 cricket::MediaEngineInterface* engine, |
| 2596 cricket::FakeDataMediaChannel* ch, |
| 2597 cricket::TransportController* transport_controller, |
| 2553 bool rtcp) { | 2598 bool rtcp) { |
| 2554 cricket::DataChannel* channel = new cricket::DataChannel( | 2599 cricket::DataChannel* channel = new cricket::DataChannel( |
| 2555 thread, ch, session, cricket::CN_DATA, rtcp); | 2600 thread, ch, transport_controller, cricket::CN_DATA, rtcp); |
| 2556 if (!channel->Init()) { | 2601 if (!channel->Init()) { |
| 2557 delete channel; | 2602 delete channel; |
| 2558 channel = NULL; | 2603 channel = NULL; |
| 2559 } | 2604 } |
| 2560 return channel; | 2605 return channel; |
| 2561 } | 2606 } |
| 2562 | 2607 |
| 2563 template<> | 2608 template<> |
| 2564 void ChannelTest<DataTraits>::CreateContent( | 2609 void ChannelTest<DataTraits>::CreateContent( |
| 2565 int flags, | 2610 int flags, |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2731 }; | 2776 }; |
| 2732 rtc::Buffer payload(data, 3); | 2777 rtc::Buffer payload(data, 3); |
| 2733 cricket::SendDataResult result; | 2778 cricket::SendDataResult result; |
| 2734 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); | 2779 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); |
| 2735 EXPECT_EQ(params.ssrc, | 2780 EXPECT_EQ(params.ssrc, |
| 2736 media_channel1_->last_sent_data_params().ssrc); | 2781 media_channel1_->last_sent_data_params().ssrc); |
| 2737 EXPECT_EQ("foo", media_channel1_->last_sent_data()); | 2782 EXPECT_EQ("foo", media_channel1_->last_sent_data()); |
| 2738 } | 2783 } |
| 2739 | 2784 |
| 2740 // TODO(pthatcher): TestSetReceiver? | 2785 // TODO(pthatcher): TestSetReceiver? |
| OLD | NEW |