OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2009 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 | 12 |
13 #include "webrtc/base/arraysize.h" | 13 #include "webrtc/base/array_view.h" |
14 #include "webrtc/base/criticalsection.h" | 14 #include "webrtc/base/buffer.h" |
15 #include "webrtc/base/fileutils.h" | |
16 #include "webrtc/base/gunit.h" | 15 #include "webrtc/base/gunit.h" |
17 #include "webrtc/base/helpers.h" | |
18 #include "webrtc/base/logging.h" | 16 #include "webrtc/base/logging.h" |
19 #include "webrtc/base/pathutils.h" | |
20 #include "webrtc/base/signalthread.h" | |
21 #include "webrtc/base/ssladapter.h" | |
22 #include "webrtc/base/sslidentity.h" | |
23 #include "webrtc/base/window.h" | |
24 #include "webrtc/media/base/fakemediaengine.h" | 17 #include "webrtc/media/base/fakemediaengine.h" |
25 #include "webrtc/media/base/fakertp.h" | 18 #include "webrtc/media/base/fakertp.h" |
26 #include "webrtc/media/base/fakescreencapturerfactory.h" | |
27 #include "webrtc/media/base/fakevideocapturer.h" | |
28 #include "webrtc/media/base/mediachannel.h" | 19 #include "webrtc/media/base/mediachannel.h" |
29 #include "webrtc/media/base/rtpdump.h" | |
30 #include "webrtc/media/base/screencastid.h" | |
31 #include "webrtc/media/base/testutils.h" | 20 #include "webrtc/media/base/testutils.h" |
32 #include "webrtc/p2p/base/faketransportcontroller.h" | 21 #include "webrtc/p2p/base/faketransportcontroller.h" |
33 #include "webrtc/pc/channel.h" | 22 #include "webrtc/pc/channel.h" |
34 | 23 |
35 #define MAYBE_SKIP_TEST(feature) \ | 24 #define MAYBE_SKIP_TEST(feature) \ |
36 if (!(rtc::SSLStreamAdapter::feature())) { \ | 25 if (!(rtc::SSLStreamAdapter::feature())) { \ |
37 LOG(LS_INFO) << "Feature disabled... skipping"; \ | 26 LOG(LS_INFO) << "Feature disabled... skipping"; \ |
38 return; \ | 27 return; \ |
39 } | 28 } |
40 | 29 |
41 using cricket::CA_OFFER; | 30 using cricket::CA_OFFER; |
42 using cricket::CA_PRANSWER; | 31 using cricket::CA_PRANSWER; |
43 using cricket::CA_ANSWER; | 32 using cricket::CA_ANSWER; |
44 using cricket::CA_UPDATE; | 33 using cricket::CA_UPDATE; |
45 using cricket::FakeVoiceMediaChannel; | 34 using cricket::FakeVoiceMediaChannel; |
46 using cricket::ScreencastId; | 35 using cricket::ScreencastId; |
47 using cricket::StreamParams; | 36 using cricket::StreamParams; |
48 using cricket::TransportChannel; | 37 using cricket::TransportChannel; |
49 using rtc::WindowId; | |
50 | 38 |
51 static const cricket::AudioCodec kPcmuCodec(0, "PCMU", 64000, 8000, 1); | 39 namespace { |
52 static const cricket::AudioCodec kPcmaCodec(8, "PCMA", 64000, 8000, 1); | 40 const cricket::AudioCodec kPcmuCodec(0, "PCMU", 64000, 8000, 1); |
53 static const cricket::AudioCodec kIsacCodec(103, "ISAC", 40000, 16000, 1); | 41 const cricket::AudioCodec kPcmaCodec(8, "PCMA", 64000, 8000, 1); |
54 static const cricket::VideoCodec kH264Codec(97, "H264", 640, 400, 30); | 42 const cricket::AudioCodec kIsacCodec(103, "ISAC", 40000, 16000, 1); |
55 static const cricket::VideoCodec kH264SvcCodec(99, "H264-SVC", 320, 200, 15); | 43 const cricket::VideoCodec kH264Codec(97, "H264", 640, 400, 30); |
56 static const cricket::DataCodec kGoogleDataCodec(101, "google-data"); | 44 const cricket::VideoCodec kH264SvcCodec(99, "H264-SVC", 320, 200, 15); |
57 static const uint32_t kSsrc1 = 0x1111; | 45 const cricket::DataCodec kGoogleDataCodec(101, "google-data"); |
58 static const uint32_t kSsrc2 = 0x2222; | 46 const uint32_t kSsrc1 = 0x1111; |
59 static const uint32_t kSsrc3 = 0x3333; | 47 const uint32_t kSsrc2 = 0x2222; |
60 static const int kAudioPts[] = {0, 8}; | 48 const uint32_t kSsrc3 = 0x3333; |
61 static const int kVideoPts[] = {97, 99}; | 49 const int kAudioPts[] = {0, 8}; |
| 50 const int kVideoPts[] = {97, 99}; |
| 51 enum class NetworkIsWorker { Yes, No }; |
| 52 } // namespace |
62 | 53 |
63 template <class ChannelT, | 54 template <class ChannelT, |
64 class MediaChannelT, | 55 class MediaChannelT, |
65 class ContentT, | 56 class ContentT, |
66 class CodecT, | 57 class CodecT, |
67 class MediaInfoT, | 58 class MediaInfoT, |
68 class OptionsT> | 59 class OptionsT> |
69 class Traits { | 60 class Traits { |
70 public: | 61 public: |
71 typedef ChannelT Channel; | 62 typedef ChannelT Channel; |
72 typedef MediaChannelT MediaChannel; | 63 typedef MediaChannelT MediaChannel; |
73 typedef ContentT Content; | 64 typedef ContentT Content; |
74 typedef CodecT Codec; | 65 typedef CodecT Codec; |
75 typedef MediaInfoT MediaInfo; | 66 typedef MediaInfoT MediaInfo; |
76 typedef OptionsT Options; | 67 typedef OptionsT Options; |
77 }; | 68 }; |
78 | 69 |
79 // Controls how long we wait for a session to send messages that we | |
80 // expect, in milliseconds. We put it high to avoid flaky tests. | |
81 static const int kEventTimeout = 5000; | |
82 | |
83 class VoiceTraits : public Traits<cricket::VoiceChannel, | 70 class VoiceTraits : public Traits<cricket::VoiceChannel, |
84 cricket::FakeVoiceMediaChannel, | 71 cricket::FakeVoiceMediaChannel, |
85 cricket::AudioContentDescription, | 72 cricket::AudioContentDescription, |
86 cricket::AudioCodec, | 73 cricket::AudioCodec, |
87 cricket::VoiceMediaInfo, | 74 cricket::VoiceMediaInfo, |
88 cricket::AudioOptions> {}; | 75 cricket::AudioOptions> {}; |
89 | 76 |
90 class VideoTraits : public Traits<cricket::VideoChannel, | 77 class VideoTraits : public Traits<cricket::VideoChannel, |
91 cricket::FakeVideoMediaChannel, | 78 cricket::FakeVideoMediaChannel, |
92 cricket::VideoContentDescription, | 79 cricket::VideoContentDescription, |
93 cricket::VideoCodec, | 80 cricket::VideoCodec, |
94 cricket::VideoMediaInfo, | 81 cricket::VideoMediaInfo, |
95 cricket::VideoOptions> {}; | 82 cricket::VideoOptions> {}; |
96 | 83 |
97 class DataTraits : public Traits<cricket::DataChannel, | 84 class DataTraits : public Traits<cricket::DataChannel, |
98 cricket::FakeDataMediaChannel, | 85 cricket::FakeDataMediaChannel, |
99 cricket::DataContentDescription, | 86 cricket::DataContentDescription, |
100 cricket::DataCodec, | 87 cricket::DataCodec, |
101 cricket::DataMediaInfo, | 88 cricket::DataMediaInfo, |
102 cricket::DataOptions> {}; | 89 cricket::DataOptions> {}; |
103 | 90 |
104 rtc::StreamInterface* Open(const std::string& path) { | 91 // Base class for Voice/Video/DataChannel tests |
105 return rtc::Filesystem::OpenFile( | |
106 rtc::Pathname(path), "wb"); | |
107 } | |
108 | |
109 // Base class for Voice/VideoChannel tests | |
110 template<class T> | 92 template<class T> |
111 class ChannelTest : public testing::Test, public sigslot::has_slots<> { | 93 class ChannelTest : public testing::Test, public sigslot::has_slots<> { |
112 public: | 94 public: |
113 enum Flags { RTCP = 0x1, RTCP_MUX = 0x2, SECURE = 0x4, SSRC_MUX = 0x8, | 95 enum Flags { RTCP = 0x1, RTCP_MUX = 0x2, SECURE = 0x4, SSRC_MUX = 0x8, |
114 DTLS = 0x10 }; | 96 DTLS = 0x10 }; |
115 | 97 |
116 ChannelTest(bool verify_playout, | 98 ChannelTest(bool verify_playout, |
117 const uint8_t* rtp_data, | 99 rtc::ArrayView<const uint8_t> rtp_data, |
118 int rtp_len, | 100 rtc::ArrayView<const uint8_t> rtcp_data, |
119 const uint8_t* rtcp_data, | 101 NetworkIsWorker network_is_worker) |
120 int rtcp_len) | |
121 : verify_playout_(verify_playout), | 102 : verify_playout_(verify_playout), |
122 transport_controller1_(cricket::ICEROLE_CONTROLLING), | |
123 transport_controller2_(cricket::ICEROLE_CONTROLLED), | |
124 media_channel1_(NULL), | 103 media_channel1_(NULL), |
125 media_channel2_(NULL), | 104 media_channel2_(NULL), |
126 rtp_packet_(reinterpret_cast<const char*>(rtp_data), rtp_len), | 105 rtp_packet_(rtp_data.data(), rtp_data.size()), |
127 rtcp_packet_(reinterpret_cast<const char*>(rtcp_data), rtcp_len), | 106 rtcp_packet_(rtcp_data.data(), rtcp_data.size()), |
128 media_info_callbacks1_(), | 107 media_info_callbacks1_(), |
129 media_info_callbacks2_() {} | 108 media_info_callbacks2_() { |
| 109 if (network_is_worker == NetworkIsWorker::Yes) { |
| 110 network_thread_ = rtc::Thread::Current(); |
| 111 } else { |
| 112 network_thread_keeper_ = rtc::Thread::Create(); |
| 113 network_thread_keeper_->SetName("Network", nullptr); |
| 114 network_thread_keeper_->Start(); |
| 115 network_thread_ = network_thread_keeper_.get(); |
| 116 } |
| 117 transport_controller1_.reset(new cricket::FakeTransportController( |
| 118 network_thread_, cricket::ICEROLE_CONTROLLING)); |
| 119 transport_controller2_.reset(new cricket::FakeTransportController( |
| 120 network_thread_, cricket::ICEROLE_CONTROLLED)); |
| 121 } |
130 | 122 |
131 void CreateChannels(int flags1, int flags2) { | 123 void CreateChannels(int flags1, int flags2) { |
132 CreateChannels(new typename T::MediaChannel(NULL, typename T::Options()), | 124 CreateChannels(new typename T::MediaChannel(NULL, typename T::Options()), |
133 new typename T::MediaChannel(NULL, typename T::Options()), | 125 new typename T::MediaChannel(NULL, typename T::Options()), |
134 flags1, flags2, rtc::Thread::Current()); | 126 flags1, flags2); |
135 } | 127 } |
136 void CreateChannels( | 128 void CreateChannels(typename T::MediaChannel* ch1, |
137 typename T::MediaChannel* ch1, typename T::MediaChannel* ch2, | 129 typename T::MediaChannel* ch2, |
138 int flags1, int flags2, rtc::Thread* thread) { | 130 int flags1, |
| 131 int flags2) { |
| 132 rtc::Thread* worker_thread = rtc::Thread::Current(); |
139 media_channel1_ = ch1; | 133 media_channel1_ = ch1; |
140 media_channel2_ = ch2; | 134 media_channel2_ = ch2; |
141 channel1_.reset(CreateChannel(thread, &media_engine_, ch1, | 135 channel1_.reset( |
142 &transport_controller1_, | 136 CreateChannel(worker_thread, network_thread_, &media_engine_, ch1, |
143 (flags1 & RTCP) != 0)); | 137 transport_controller1_.get(), (flags1 & RTCP) != 0)); |
144 channel2_.reset(CreateChannel(thread, &media_engine_, ch2, | 138 channel2_.reset( |
145 &transport_controller2_, | 139 CreateChannel(worker_thread, network_thread_, &media_engine_, ch2, |
146 (flags2 & RTCP) != 0)); | 140 transport_controller2_.get(), (flags2 & RTCP) != 0)); |
147 channel1_->SignalMediaMonitor.connect( | 141 channel1_->SignalMediaMonitor.connect(this, |
148 this, &ChannelTest<T>::OnMediaMonitor); | 142 &ChannelTest<T>::OnMediaMonitor1); |
149 channel2_->SignalMediaMonitor.connect( | 143 channel2_->SignalMediaMonitor.connect(this, |
150 this, &ChannelTest<T>::OnMediaMonitor); | 144 &ChannelTest<T>::OnMediaMonitor2); |
151 if ((flags1 & DTLS) && (flags2 & DTLS)) { | 145 if ((flags1 & DTLS) && (flags2 & DTLS)) { |
152 flags1 = (flags1 & ~SECURE); | 146 flags1 = (flags1 & ~SECURE); |
153 flags2 = (flags2 & ~SECURE); | 147 flags2 = (flags2 & ~SECURE); |
154 } | 148 } |
155 CreateContent(flags1, kPcmuCodec, kH264Codec, | 149 CreateContent(flags1, kPcmuCodec, kH264Codec, |
156 &local_media_content1_); | 150 &local_media_content1_); |
157 CreateContent(flags2, kPcmuCodec, kH264Codec, | 151 CreateContent(flags2, kPcmuCodec, kH264Codec, |
158 &local_media_content2_); | 152 &local_media_content2_); |
159 CopyContent(local_media_content1_, &remote_media_content1_); | 153 CopyContent(local_media_content1_, &remote_media_content1_); |
160 CopyContent(local_media_content2_, &remote_media_content2_); | 154 CopyContent(local_media_content2_, &remote_media_content2_); |
161 | 155 |
162 if (flags1 & DTLS) { | 156 if (flags1 & DTLS) { |
163 // Confirmed to work with KT_RSA and KT_ECDSA. | 157 // Confirmed to work with KT_RSA and KT_ECDSA. |
164 transport_controller1_.SetLocalCertificate( | 158 transport_controller1_->SetLocalCertificate( |
165 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>( | 159 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>( |
166 rtc::SSLIdentity::Generate("session1", rtc::KT_DEFAULT)))); | 160 rtc::SSLIdentity::Generate("session1", rtc::KT_DEFAULT)))); |
167 } | 161 } |
168 if (flags2 & DTLS) { | 162 if (flags2 & DTLS) { |
169 // Confirmed to work with KT_RSA and KT_ECDSA. | 163 // Confirmed to work with KT_RSA and KT_ECDSA. |
170 transport_controller2_.SetLocalCertificate( | 164 transport_controller2_->SetLocalCertificate( |
171 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>( | 165 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>( |
172 rtc::SSLIdentity::Generate("session2", rtc::KT_DEFAULT)))); | 166 rtc::SSLIdentity::Generate("session2", rtc::KT_DEFAULT)))); |
173 } | 167 } |
174 | 168 |
175 // Add stream information (SSRC) to the local content but not to the remote | 169 // Add stream information (SSRC) to the local content but not to the remote |
176 // content. This means that we per default know the SSRC of what we send but | 170 // content. This means that we per default know the SSRC of what we send but |
177 // not what we receive. | 171 // not what we receive. |
178 AddLegacyStreamInContent(kSsrc1, flags1, &local_media_content1_); | 172 AddLegacyStreamInContent(kSsrc1, flags1, &local_media_content1_); |
179 AddLegacyStreamInContent(kSsrc2, flags2, &local_media_content2_); | 173 AddLegacyStreamInContent(kSsrc2, flags2, &local_media_content2_); |
180 | 174 |
181 // If SSRC_MUX is used we also need to know the SSRC of the incoming stream. | 175 // If SSRC_MUX is used we also need to know the SSRC of the incoming stream. |
182 if (flags1 & SSRC_MUX) { | 176 if (flags1 & SSRC_MUX) { |
183 AddLegacyStreamInContent(kSsrc1, flags1, &remote_media_content1_); | 177 AddLegacyStreamInContent(kSsrc1, flags1, &remote_media_content1_); |
184 } | 178 } |
185 if (flags2 & SSRC_MUX) { | 179 if (flags2 & SSRC_MUX) { |
186 AddLegacyStreamInContent(kSsrc2, flags2, &remote_media_content2_); | 180 AddLegacyStreamInContent(kSsrc2, flags2, &remote_media_content2_); |
187 } | 181 } |
188 } | 182 } |
189 typename T::Channel* CreateChannel( | 183 typename T::Channel* CreateChannel( |
190 rtc::Thread* thread, | 184 rtc::Thread* worker_thread, |
| 185 rtc::Thread* network_thread, |
191 cricket::MediaEngineInterface* engine, | 186 cricket::MediaEngineInterface* engine, |
192 typename T::MediaChannel* ch, | 187 typename T::MediaChannel* ch, |
193 cricket::TransportController* transport_controller, | 188 cricket::TransportController* transport_controller, |
194 bool rtcp) { | 189 bool rtcp) { |
195 typename T::Channel* channel = new typename T::Channel( | 190 typename T::Channel* channel = |
196 thread, engine, ch, transport_controller, cricket::CN_AUDIO, rtcp); | 191 new typename T::Channel(worker_thread, network_thread, engine, ch, |
| 192 transport_controller, cricket::CN_AUDIO, rtcp); |
197 if (!channel->Init()) { | 193 if (!channel->Init()) { |
198 delete channel; | 194 delete channel; |
199 channel = NULL; | 195 channel = NULL; |
200 } | 196 } |
201 return channel; | 197 return channel; |
202 } | 198 } |
203 | 199 |
204 bool SendInitiate() { | 200 bool SendInitiate() { |
205 bool result = channel1_->SetLocalContent(&local_media_content1_, | 201 bool result = channel1_->SetLocalContent(&local_media_content1_, |
206 CA_OFFER, NULL); | 202 CA_OFFER, NULL); |
207 if (result) { | 203 if (result) { |
208 channel1_->Enable(true); | 204 channel1_->Enable(true); |
209 result = channel2_->SetRemoteContent(&remote_media_content1_, | 205 result = channel2_->SetRemoteContent(&remote_media_content1_, |
210 CA_OFFER, NULL); | 206 CA_OFFER, NULL); |
211 if (result) { | 207 if (result) { |
212 transport_controller1_.Connect(&transport_controller2_); | 208 transport_controller1_->Connect(transport_controller2_.get()); |
213 | 209 |
214 result = channel2_->SetLocalContent(&local_media_content2_, | 210 result = channel2_->SetLocalContent(&local_media_content2_, |
215 CA_ANSWER, NULL); | 211 CA_ANSWER, NULL); |
216 } | 212 } |
217 } | 213 } |
218 return result; | 214 return result; |
219 } | 215 } |
220 | 216 |
221 bool SendAccept() { | 217 bool SendAccept() { |
222 channel2_->Enable(true); | 218 channel2_->Enable(true); |
(...skipping 12 matching lines...) Expand all Loading... |
235 return result; | 231 return result; |
236 } | 232 } |
237 | 233 |
238 bool SendProvisionalAnswer() { | 234 bool SendProvisionalAnswer() { |
239 bool result = channel2_->SetLocalContent(&local_media_content2_, | 235 bool result = channel2_->SetLocalContent(&local_media_content2_, |
240 CA_PRANSWER, NULL); | 236 CA_PRANSWER, NULL); |
241 if (result) { | 237 if (result) { |
242 channel2_->Enable(true); | 238 channel2_->Enable(true); |
243 result = channel1_->SetRemoteContent(&remote_media_content2_, | 239 result = channel1_->SetRemoteContent(&remote_media_content2_, |
244 CA_PRANSWER, NULL); | 240 CA_PRANSWER, NULL); |
245 transport_controller1_.Connect(&transport_controller2_); | 241 transport_controller1_->Connect(transport_controller2_.get()); |
246 } | 242 } |
247 return result; | 243 return result; |
248 } | 244 } |
249 | 245 |
250 bool SendFinalAnswer() { | 246 bool SendFinalAnswer() { |
251 bool result = channel2_->SetLocalContent(&local_media_content2_, | 247 bool result = channel2_->SetLocalContent(&local_media_content2_, |
252 CA_ANSWER, NULL); | 248 CA_ANSWER, NULL); |
253 if (result) | 249 if (result) |
254 result = channel1_->SetRemoteContent(&remote_media_content2_, | 250 result = channel1_->SetRemoteContent(&remote_media_content2_, |
255 CA_ANSWER, NULL); | 251 CA_ANSWER, NULL); |
256 return result; | 252 return result; |
257 } | 253 } |
258 | 254 |
259 bool SendTerminate() { | 255 bool SendTerminate() { |
260 channel1_.reset(); | 256 channel1_.reset(); |
261 channel2_.reset(); | 257 channel2_.reset(); |
262 return true; | 258 return true; |
263 } | 259 } |
264 | 260 |
265 bool AddStream1(int id) { | 261 bool AddStream1(int id) { |
266 return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id)); | 262 return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id)); |
267 } | 263 } |
268 bool RemoveStream1(int id) { | 264 bool RemoveStream1(int id) { |
269 return channel1_->RemoveRecvStream(id); | 265 return channel1_->RemoveRecvStream(id); |
270 } | 266 } |
271 | 267 |
272 // Calling "_w" method here is ok since we only use one thread for this test | |
273 cricket::FakeTransport* GetTransport1() { | 268 cricket::FakeTransport* GetTransport1() { |
274 return transport_controller1_.GetTransport_w(channel1_->content_name()); | 269 std::string name = channel1_->content_name(); |
| 270 return network_thread_->Invoke<cricket::FakeTransport*>( |
| 271 [this, name] { return transport_controller1_->GetTransport_w(name); }); |
275 } | 272 } |
276 cricket::FakeTransport* GetTransport2() { | 273 cricket::FakeTransport* GetTransport2() { |
277 return transport_controller2_.GetTransport_w(channel2_->content_name()); | 274 std::string name = channel2_->content_name(); |
| 275 return network_thread_->Invoke<cricket::FakeTransport*>( |
| 276 [this, name] { return transport_controller2_->GetTransport_w(name); }); |
278 } | 277 } |
279 | 278 |
280 bool SendRtp1() { | 279 void SendRtp1() { |
281 return media_channel1_->SendRtp(rtp_packet_.c_str(), | 280 media_channel1_->SendRtp(rtp_packet_.data(), rtp_packet_.size(), |
282 static_cast<int>(rtp_packet_.size()), | 281 rtc::PacketOptions()); |
283 rtc::PacketOptions()); | |
284 } | 282 } |
285 bool SendRtp2() { | 283 void SendRtp2() { |
286 return media_channel2_->SendRtp(rtp_packet_.c_str(), | 284 media_channel2_->SendRtp(rtp_packet_.data(), rtp_packet_.size(), |
287 static_cast<int>(rtp_packet_.size()), | 285 rtc::PacketOptions()); |
288 rtc::PacketOptions()); | |
289 } | 286 } |
290 bool SendRtcp1() { | 287 void SendRtcp1() { |
291 return media_channel1_->SendRtcp(rtcp_packet_.c_str(), | 288 media_channel1_->SendRtcp(rtcp_packet_.data(), rtcp_packet_.size()); |
292 static_cast<int>(rtcp_packet_.size())); | |
293 } | 289 } |
294 bool SendRtcp2() { | 290 void SendRtcp2() { |
295 return media_channel2_->SendRtcp(rtcp_packet_.c_str(), | 291 media_channel2_->SendRtcp(rtcp_packet_.data(), rtcp_packet_.size()); |
296 static_cast<int>(rtcp_packet_.size())); | |
297 } | 292 } |
298 // Methods to send custom data. | 293 // Methods to send custom data. |
299 bool SendCustomRtp1(uint32_t ssrc, int sequence_number, int pl_type = -1) { | 294 void SendCustomRtp1(uint32_t ssrc, int sequence_number, int pl_type = -1) { |
300 std::string data(CreateRtpData(ssrc, sequence_number, pl_type)); | 295 rtc::Buffer data = CreateRtpData(ssrc, sequence_number, pl_type); |
301 return media_channel1_->SendRtp(data.c_str(), static_cast<int>(data.size()), | 296 media_channel1_->SendRtp(data.data(), data.size(), rtc::PacketOptions()); |
302 rtc::PacketOptions()); | |
303 } | 297 } |
304 bool SendCustomRtp2(uint32_t ssrc, int sequence_number, int pl_type = -1) { | 298 void SendCustomRtp2(uint32_t ssrc, int sequence_number, int pl_type = -1) { |
305 std::string data(CreateRtpData(ssrc, sequence_number, pl_type)); | 299 rtc::Buffer data = CreateRtpData(ssrc, sequence_number, pl_type); |
306 return media_channel2_->SendRtp(data.c_str(), static_cast<int>(data.size()), | 300 media_channel2_->SendRtp(data.data(), data.size(), rtc::PacketOptions()); |
307 rtc::PacketOptions()); | |
308 } | 301 } |
309 bool SendCustomRtcp1(uint32_t ssrc) { | 302 void SendCustomRtcp1(uint32_t ssrc) { |
310 std::string data(CreateRtcpData(ssrc)); | 303 rtc::Buffer data = CreateRtcpData(ssrc); |
311 return media_channel1_->SendRtcp(data.c_str(), | 304 media_channel1_->SendRtcp(data.data(), data.size()); |
312 static_cast<int>(data.size())); | |
313 } | 305 } |
314 bool SendCustomRtcp2(uint32_t ssrc) { | 306 void SendCustomRtcp2(uint32_t ssrc) { |
315 std::string data(CreateRtcpData(ssrc)); | 307 rtc::Buffer data = CreateRtcpData(ssrc); |
316 return media_channel2_->SendRtcp(data.c_str(), | 308 media_channel2_->SendRtcp(data.data(), data.size()); |
317 static_cast<int>(data.size())); | |
318 } | 309 } |
| 310 |
319 bool CheckRtp1() { | 311 bool CheckRtp1() { |
320 return media_channel1_->CheckRtp(rtp_packet_.c_str(), | 312 return media_channel1_->CheckRtp(rtp_packet_.data(), rtp_packet_.size()); |
321 static_cast<int>(rtp_packet_.size())); | |
322 } | 313 } |
323 bool CheckRtp2() { | 314 bool CheckRtp2() { |
324 return media_channel2_->CheckRtp(rtp_packet_.c_str(), | 315 return media_channel2_->CheckRtp(rtp_packet_.data(), rtp_packet_.size()); |
325 static_cast<int>(rtp_packet_.size())); | |
326 } | 316 } |
327 bool CheckRtcp1() { | 317 bool CheckRtcp1() { |
328 return media_channel1_->CheckRtcp(rtcp_packet_.c_str(), | 318 return media_channel1_->CheckRtcp(rtcp_packet_.data(), rtcp_packet_.size()); |
329 static_cast<int>(rtcp_packet_.size())); | |
330 } | 319 } |
331 bool CheckRtcp2() { | 320 bool CheckRtcp2() { |
332 return media_channel2_->CheckRtcp(rtcp_packet_.c_str(), | 321 return media_channel2_->CheckRtcp(rtcp_packet_.data(), rtcp_packet_.size()); |
333 static_cast<int>(rtcp_packet_.size())); | |
334 } | 322 } |
335 // Methods to check custom data. | 323 // Methods to check custom data. |
336 bool CheckCustomRtp1(uint32_t ssrc, int sequence_number, int pl_type = -1) { | 324 bool CheckCustomRtp1(uint32_t ssrc, int sequence_number, int pl_type = -1) { |
337 std::string data(CreateRtpData(ssrc, sequence_number, pl_type)); | 325 rtc::Buffer data = CreateRtpData(ssrc, sequence_number, pl_type); |
338 return media_channel1_->CheckRtp(data.c_str(), | 326 return media_channel1_->CheckRtp(data.data(), data.size()); |
339 static_cast<int>(data.size())); | |
340 } | 327 } |
341 bool CheckCustomRtp2(uint32_t ssrc, int sequence_number, int pl_type = -1) { | 328 bool CheckCustomRtp2(uint32_t ssrc, int sequence_number, int pl_type = -1) { |
342 std::string data(CreateRtpData(ssrc, sequence_number, pl_type)); | 329 rtc::Buffer data = CreateRtpData(ssrc, sequence_number, pl_type); |
343 return media_channel2_->CheckRtp(data.c_str(), | 330 return media_channel2_->CheckRtp(data.data(), data.size()); |
344 static_cast<int>(data.size())); | |
345 } | 331 } |
346 bool CheckCustomRtcp1(uint32_t ssrc) { | 332 bool CheckCustomRtcp1(uint32_t ssrc) { |
347 std::string data(CreateRtcpData(ssrc)); | 333 rtc::Buffer data = CreateRtcpData(ssrc); |
348 return media_channel1_->CheckRtcp(data.c_str(), | 334 return media_channel1_->CheckRtcp(data.data(), data.size()); |
349 static_cast<int>(data.size())); | |
350 } | 335 } |
351 bool CheckCustomRtcp2(uint32_t ssrc) { | 336 bool CheckCustomRtcp2(uint32_t ssrc) { |
352 std::string data(CreateRtcpData(ssrc)); | 337 rtc::Buffer data = CreateRtcpData(ssrc); |
353 return media_channel2_->CheckRtcp(data.c_str(), | 338 return media_channel2_->CheckRtcp(data.data(), data.size()); |
354 static_cast<int>(data.size())); | |
355 } | 339 } |
356 std::string CreateRtpData(uint32_t ssrc, int sequence_number, int pl_type) { | 340 rtc::Buffer CreateRtpData(uint32_t ssrc, int sequence_number, int pl_type) { |
357 std::string data(rtp_packet_); | 341 rtc::Buffer data(rtp_packet_.data(), rtp_packet_.size()); |
358 // Set SSRC in the rtp packet copy. | 342 // Set SSRC in the rtp packet copy. |
359 rtc::SetBE32(const_cast<char*>(data.c_str()) + 8, ssrc); | 343 rtc::SetBE32(data.data() + 8, ssrc); |
360 rtc::SetBE16(const_cast<char*>(data.c_str()) + 2, sequence_number); | 344 rtc::SetBE16(data.data() + 2, sequence_number); |
361 if (pl_type >= 0) { | 345 if (pl_type >= 0) { |
362 rtc::Set8(const_cast<char*>(data.c_str()), 1, | 346 rtc::Set8(data.data(), 1, static_cast<uint8_t>(pl_type)); |
363 static_cast<uint8_t>(pl_type)); | |
364 } | 347 } |
365 return data; | 348 return data; |
366 } | 349 } |
367 std::string CreateRtcpData(uint32_t ssrc) { | 350 rtc::Buffer CreateRtcpData(uint32_t ssrc) { |
368 std::string data(rtcp_packet_); | 351 rtc::Buffer data(rtcp_packet_.data(), rtcp_packet_.size()); |
369 // Set SSRC in the rtcp packet copy. | 352 // Set SSRC in the rtcp packet copy. |
370 rtc::SetBE32(const_cast<char*>(data.c_str()) + 4, ssrc); | 353 rtc::SetBE32(data.data() + 4, ssrc); |
371 return data; | 354 return data; |
372 } | 355 } |
373 | 356 |
374 bool CheckNoRtp1() { | 357 bool CheckNoRtp1() { |
375 return media_channel1_->CheckNoRtp(); | 358 return media_channel1_->CheckNoRtp(); |
376 } | 359 } |
377 bool CheckNoRtp2() { | 360 bool CheckNoRtp2() { |
378 return media_channel2_->CheckNoRtp(); | 361 return media_channel2_->CheckNoRtp(); |
379 } | 362 } |
380 bool CheckNoRtcp1() { | 363 bool CheckNoRtcp1() { |
(...skipping 20 matching lines...) Expand all Loading... |
401 uint32_t ssrc) { | 384 uint32_t ssrc) { |
402 typename T::Content content; | 385 typename T::Content content; |
403 cricket::SessionDescription* sdesc = new cricket::SessionDescription(); | 386 cricket::SessionDescription* sdesc = new cricket::SessionDescription(); |
404 CreateContent(SECURE, kPcmuCodec, kH264Codec, &content); | 387 CreateContent(SECURE, kPcmuCodec, kH264Codec, &content); |
405 AddLegacyStreamInContent(ssrc, 0, &content); | 388 AddLegacyStreamInContent(ssrc, 0, &content); |
406 sdesc->AddContent("DUMMY_CONTENT_NAME", | 389 sdesc->AddContent("DUMMY_CONTENT_NAME", |
407 cricket::NS_JINGLE_RTP, content.Copy()); | 390 cricket::NS_JINGLE_RTP, content.Copy()); |
408 return sdesc; | 391 return sdesc; |
409 } | 392 } |
410 | 393 |
411 class CallThread : public rtc::SignalThread { | |
412 public: | |
413 typedef bool (ChannelTest<T>::*Method)(); | |
414 CallThread(ChannelTest<T>* obj, Method method, bool* result = nullptr) | |
415 : obj_(obj), | |
416 method_(method), | |
417 result_(false), | |
418 result_ptr_(result) { | |
419 if (result_ptr_) | |
420 *result_ptr_ = false; | |
421 } | |
422 | |
423 ~CallThread() { | |
424 if (result_ptr_) { | |
425 rtc::CritScope cs(&result_lock_); | |
426 *result_ptr_ = result_; | |
427 } | |
428 } | |
429 | |
430 virtual void DoWork() { | |
431 SetResult((*obj_.*method_)()); | |
432 } | |
433 | |
434 bool result() { | |
435 rtc::CritScope cs(&result_lock_); | |
436 return result_; | |
437 } | |
438 | |
439 private: | |
440 void SetResult(const bool& result) { | |
441 rtc::CritScope cs(&result_lock_); | |
442 result_ = result; | |
443 } | |
444 | |
445 ChannelTest<T>* obj_; | |
446 Method method_; | |
447 rtc::CriticalSection result_lock_; | |
448 bool result_ GUARDED_BY(result_lock_); | |
449 bool* result_ptr_; | |
450 }; | |
451 | |
452 // Will manage the lifetime of a CallThread, making sure it's | 394 // Will manage the lifetime of a CallThread, making sure it's |
453 // destroyed before this object goes out of scope. | 395 // destroyed before this object goes out of scope. |
454 class ScopedCallThread { | 396 class ScopedCallThread { |
455 public: | 397 public: |
456 using Method = typename CallThread::Method; | 398 template <class FunctorT> |
457 | 399 ScopedCallThread(const FunctorT& functor) |
458 ScopedCallThread(ChannelTest<T>* obj, Method method) | 400 : thread_(rtc::Thread::Create()), |
459 : thread_(new CallThread(obj, method)) { | 401 task_(new rtc::FunctorMessageHandler<void, FunctorT>(functor)) { |
460 thread_->Start(); | 402 thread_->Start(); |
| 403 thread_->Post(task_.get()); |
461 } | 404 } |
462 | 405 |
463 ~ScopedCallThread() { | 406 ~ScopedCallThread() { thread_->Stop(); } |
464 thread_->Destroy(true); | |
465 } | |
466 | 407 |
467 bool result() const { return thread_->result(); } | 408 rtc::Thread* thread() { return thread_.get(); } |
468 | 409 |
469 private: | 410 private: |
470 CallThread* thread_; | 411 std::unique_ptr<rtc::Thread> thread_; |
| 412 std::unique_ptr<rtc::MessageHandler> task_; |
471 }; | 413 }; |
472 | 414 |
473 void CallOnThreadAndWaitForDone(typename CallThread::Method method, | |
474 bool* result) { | |
475 CallThread* thread = new CallThread(this, method, result); | |
476 thread->Start(); | |
477 thread->Destroy(true); | |
478 } | |
479 | |
480 bool CodecMatches(const typename T::Codec& c1, const typename T::Codec& c2) { | 415 bool CodecMatches(const typename T::Codec& c1, const typename T::Codec& c2) { |
481 return false; // overridden in specialized classes | 416 return false; // overridden in specialized classes |
482 } | 417 } |
483 | 418 |
484 void OnMediaMonitor(typename T::Channel* channel, | 419 void OnMediaMonitor1(typename T::Channel* channel, |
485 const typename T::MediaInfo& info) { | 420 const typename T::MediaInfo& info) { |
486 if (channel == channel1_.get()) { | 421 RTC_DCHECK_EQ(channel, channel1_.get()); |
487 media_info_callbacks1_++; | 422 media_info_callbacks1_++; |
488 } else if (channel == channel2_.get()) { | 423 } |
489 media_info_callbacks2_++; | 424 void OnMediaMonitor2(typename T::Channel* channel, |
490 } | 425 const typename T::MediaInfo& info) { |
| 426 RTC_DCHECK_EQ(channel, channel2_.get()); |
| 427 media_info_callbacks2_++; |
491 } | 428 } |
492 | 429 |
493 cricket::CandidatePairInterface* last_selected_candidate_pair() { | 430 cricket::CandidatePairInterface* last_selected_candidate_pair() { |
494 return last_selected_candidate_pair_; | 431 return last_selected_candidate_pair_; |
495 } | 432 } |
496 | 433 |
497 void AddLegacyStreamInContent(uint32_t ssrc, | 434 void AddLegacyStreamInContent(uint32_t ssrc, |
498 int flags, | 435 int flags, |
499 typename T::Content* content) { | 436 typename T::Content* content) { |
500 // Base implementation. | 437 // Base implementation. |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 CreateChannels(0, 0); | 722 CreateChannels(0, 0); |
786 typename T::Content content1; | 723 typename T::Content content1; |
787 CreateContent(0, kPcmuCodec, kH264Codec, &content1); | 724 CreateContent(0, kPcmuCodec, kH264Codec, &content1); |
788 content1.AddStream(stream1); | 725 content1.AddStream(stream1); |
789 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL)); | 726 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL)); |
790 EXPECT_TRUE(channel1_->Enable(true)); | 727 EXPECT_TRUE(channel1_->Enable(true)); |
791 EXPECT_EQ(1u, media_channel1_->send_streams().size()); | 728 EXPECT_EQ(1u, media_channel1_->send_streams().size()); |
792 | 729 |
793 EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, NULL)); | 730 EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, NULL)); |
794 EXPECT_EQ(1u, media_channel2_->recv_streams().size()); | 731 EXPECT_EQ(1u, media_channel2_->recv_streams().size()); |
795 transport_controller1_.Connect(&transport_controller2_); | 732 transport_controller1_->Connect(transport_controller2_.get()); |
796 | 733 |
797 // Channel 2 do not send anything. | 734 // Channel 2 do not send anything. |
798 typename T::Content content2; | 735 typename T::Content content2; |
799 CreateContent(0, kPcmuCodec, kH264Codec, &content2); | 736 CreateContent(0, kPcmuCodec, kH264Codec, &content2); |
800 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_ANSWER, NULL)); | 737 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_ANSWER, NULL)); |
801 EXPECT_EQ(0u, media_channel1_->recv_streams().size()); | 738 EXPECT_EQ(0u, media_channel1_->recv_streams().size()); |
802 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_ANSWER, NULL)); | 739 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_ANSWER, NULL)); |
803 EXPECT_TRUE(channel2_->Enable(true)); | 740 EXPECT_TRUE(channel2_->Enable(true)); |
804 EXPECT_EQ(0u, media_channel2_->send_streams().size()); | 741 EXPECT_EQ(0u, media_channel2_->send_streams().size()); |
805 | 742 |
806 EXPECT_TRUE(SendCustomRtp1(kSsrc1, 0)); | 743 SendCustomRtp1(kSsrc1, 0); |
| 744 WaitForThreads(); |
807 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, 0)); | 745 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, 0)); |
808 | 746 |
809 // Let channel 2 update the content by sending |stream2| and enable SRTP. | 747 // Let channel 2 update the content by sending |stream2| and enable SRTP. |
810 typename T::Content content3; | 748 typename T::Content content3; |
811 CreateContent(SECURE, kPcmuCodec, kH264Codec, &content3); | 749 CreateContent(SECURE, kPcmuCodec, kH264Codec, &content3); |
812 content3.AddStream(stream2); | 750 content3.AddStream(stream2); |
813 EXPECT_TRUE(channel2_->SetLocalContent(&content3, CA_OFFER, NULL)); | 751 EXPECT_TRUE(channel2_->SetLocalContent(&content3, CA_OFFER, NULL)); |
814 ASSERT_EQ(1u, media_channel2_->send_streams().size()); | 752 ASSERT_EQ(1u, media_channel2_->send_streams().size()); |
815 EXPECT_EQ(stream2, media_channel2_->send_streams()[0]); | 753 EXPECT_EQ(stream2, media_channel2_->send_streams()[0]); |
816 | 754 |
817 EXPECT_TRUE(channel1_->SetRemoteContent(&content3, CA_OFFER, NULL)); | 755 EXPECT_TRUE(channel1_->SetRemoteContent(&content3, CA_OFFER, NULL)); |
818 ASSERT_EQ(1u, media_channel1_->recv_streams().size()); | 756 ASSERT_EQ(1u, media_channel1_->recv_streams().size()); |
819 EXPECT_EQ(stream2, media_channel1_->recv_streams()[0]); | 757 EXPECT_EQ(stream2, media_channel1_->recv_streams()[0]); |
820 | 758 |
821 // Channel 1 replies but stop sending stream1. | 759 // Channel 1 replies but stop sending stream1. |
822 typename T::Content content4; | 760 typename T::Content content4; |
823 CreateContent(SECURE, kPcmuCodec, kH264Codec, &content4); | 761 CreateContent(SECURE, kPcmuCodec, kH264Codec, &content4); |
824 EXPECT_TRUE(channel1_->SetLocalContent(&content4, CA_ANSWER, NULL)); | 762 EXPECT_TRUE(channel1_->SetLocalContent(&content4, CA_ANSWER, NULL)); |
825 EXPECT_EQ(0u, media_channel1_->send_streams().size()); | 763 EXPECT_EQ(0u, media_channel1_->send_streams().size()); |
826 | 764 |
827 EXPECT_TRUE(channel2_->SetRemoteContent(&content4, CA_ANSWER, NULL)); | 765 EXPECT_TRUE(channel2_->SetRemoteContent(&content4, CA_ANSWER, NULL)); |
828 EXPECT_EQ(0u, media_channel2_->recv_streams().size()); | 766 EXPECT_EQ(0u, media_channel2_->recv_streams().size()); |
829 | 767 |
830 EXPECT_TRUE(channel1_->secure()); | 768 EXPECT_TRUE(channel1_->secure()); |
831 EXPECT_TRUE(channel2_->secure()); | 769 EXPECT_TRUE(channel2_->secure()); |
832 EXPECT_TRUE(SendCustomRtp2(kSsrc2, 0)); | 770 SendCustomRtp2(kSsrc2, 0); |
| 771 WaitForThreads(); |
833 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, 0)); | 772 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, 0)); |
834 } | 773 } |
835 | 774 |
836 // Test that we only start playout and sending at the right times. | 775 // Test that we only start playout and sending at the right times. |
837 void TestPlayoutAndSendingStates() { | 776 void TestPlayoutAndSendingStates() { |
838 CreateChannels(0, 0); | 777 CreateChannels(0, 0); |
839 if (verify_playout_) { | 778 if (verify_playout_) { |
840 EXPECT_FALSE(media_channel1_->playout()); | 779 EXPECT_FALSE(media_channel1_->playout()); |
841 } | 780 } |
842 EXPECT_FALSE(media_channel1_->sending()); | 781 EXPECT_FALSE(media_channel1_->sending()); |
(...skipping 17 matching lines...) Expand all Loading... |
860 if (verify_playout_) { | 799 if (verify_playout_) { |
861 EXPECT_FALSE(media_channel2_->playout()); | 800 EXPECT_FALSE(media_channel2_->playout()); |
862 } | 801 } |
863 EXPECT_FALSE(media_channel2_->sending()); | 802 EXPECT_FALSE(media_channel2_->sending()); |
864 EXPECT_TRUE(channel2_->SetLocalContent(&local_media_content2_, | 803 EXPECT_TRUE(channel2_->SetLocalContent(&local_media_content2_, |
865 CA_ANSWER, NULL)); | 804 CA_ANSWER, NULL)); |
866 if (verify_playout_) { | 805 if (verify_playout_) { |
867 EXPECT_FALSE(media_channel2_->playout()); | 806 EXPECT_FALSE(media_channel2_->playout()); |
868 } | 807 } |
869 EXPECT_FALSE(media_channel2_->sending()); | 808 EXPECT_FALSE(media_channel2_->sending()); |
870 transport_controller1_.Connect(&transport_controller2_); | 809 transport_controller1_->Connect(transport_controller2_.get()); |
871 if (verify_playout_) { | 810 if (verify_playout_) { |
872 EXPECT_TRUE(media_channel1_->playout()); | 811 EXPECT_TRUE(media_channel1_->playout()); |
873 } | 812 } |
874 EXPECT_FALSE(media_channel1_->sending()); | 813 EXPECT_FALSE(media_channel1_->sending()); |
875 if (verify_playout_) { | 814 if (verify_playout_) { |
876 EXPECT_FALSE(media_channel2_->playout()); | 815 EXPECT_FALSE(media_channel2_->playout()); |
877 } | 816 } |
878 EXPECT_FALSE(media_channel2_->sending()); | 817 EXPECT_FALSE(media_channel2_->sending()); |
879 EXPECT_TRUE(channel2_->Enable(true)); | 818 EXPECT_TRUE(channel2_->Enable(true)); |
880 if (verify_playout_) { | 819 if (verify_playout_) { |
(...skipping 27 matching lines...) Expand all Loading... |
908 EXPECT_FALSE(media_channel1_->sending()); | 847 EXPECT_FALSE(media_channel1_->sending()); |
909 if (verify_playout_) { | 848 if (verify_playout_) { |
910 EXPECT_FALSE(media_channel2_->playout()); | 849 EXPECT_FALSE(media_channel2_->playout()); |
911 } | 850 } |
912 EXPECT_FALSE(media_channel2_->sending()); | 851 EXPECT_FALSE(media_channel2_->sending()); |
913 | 852 |
914 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL)); | 853 EXPECT_TRUE(channel1_->SetLocalContent(&content1, CA_OFFER, NULL)); |
915 EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, NULL)); | 854 EXPECT_TRUE(channel2_->SetRemoteContent(&content1, CA_OFFER, NULL)); |
916 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_PRANSWER, NULL)); | 855 EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_PRANSWER, NULL)); |
917 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_PRANSWER, NULL)); | 856 EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_PRANSWER, NULL)); |
918 transport_controller1_.Connect(&transport_controller2_); | 857 transport_controller1_->Connect(transport_controller2_.get()); |
919 | 858 |
920 if (verify_playout_) { | 859 if (verify_playout_) { |
921 EXPECT_TRUE(media_channel1_->playout()); | 860 EXPECT_TRUE(media_channel1_->playout()); |
922 } | 861 } |
923 EXPECT_FALSE(media_channel1_->sending()); // remote InActive | 862 EXPECT_FALSE(media_channel1_->sending()); // remote InActive |
924 if (verify_playout_) { | 863 if (verify_playout_) { |
925 EXPECT_FALSE(media_channel2_->playout()); // local InActive | 864 EXPECT_FALSE(media_channel2_->playout()); // local InActive |
926 } | 865 } |
927 EXPECT_FALSE(media_channel2_->sending()); // local InActive | 866 EXPECT_FALSE(media_channel2_->sending()); // local InActive |
928 | 867 |
(...skipping 22 matching lines...) Expand all Loading... |
951 EXPECT_TRUE(media_channel1_->sending()); | 890 EXPECT_TRUE(media_channel1_->sending()); |
952 if (verify_playout_) { | 891 if (verify_playout_) { |
953 EXPECT_TRUE(media_channel2_->playout()); | 892 EXPECT_TRUE(media_channel2_->playout()); |
954 } | 893 } |
955 EXPECT_TRUE(media_channel2_->sending()); | 894 EXPECT_TRUE(media_channel2_->sending()); |
956 } | 895 } |
957 | 896 |
958 // Tests that when the transport channel signals a candidate pair change | 897 // Tests that when the transport channel signals a candidate pair change |
959 // event, the media channel will receive a call on the network route change. | 898 // event, the media channel will receive a call on the network route change. |
960 void TestNetworkRouteChanges() { | 899 void TestNetworkRouteChanges() { |
| 900 constexpr uint16_t kLocalNetId = 1; |
| 901 constexpr uint16_t kRemoteNetId = 2; |
| 902 constexpr int kLastPacketId = 100; |
| 903 |
961 CreateChannels(0, 0); | 904 CreateChannels(0, 0); |
962 | 905 |
963 cricket::TransportChannel* transport_channel1 = | 906 cricket::TransportChannel* transport_channel1 = |
964 channel1_->transport_channel(); | 907 channel1_->transport_channel(); |
965 ASSERT_TRUE(transport_channel1 != nullptr); | 908 ASSERT_TRUE(transport_channel1); |
966 typename T::MediaChannel* media_channel1 = | 909 typename T::MediaChannel* media_channel1 = |
967 static_cast<typename T::MediaChannel*>(channel1_->media_channel()); | 910 static_cast<typename T::MediaChannel*>(channel1_->media_channel()); |
968 ASSERT_TRUE(media_channel1 != nullptr); | 911 ASSERT_TRUE(media_channel1); |
969 | 912 |
970 media_channel1_->set_num_network_route_changes(0); | 913 media_channel1->set_num_network_route_changes(0); |
971 // The transport channel becomes disconnected. | 914 network_thread_->Invoke<void>([transport_channel1] { |
972 transport_channel1->SignalSelectedCandidatePairChanged(transport_channel1, | 915 // The transport channel becomes disconnected. |
973 nullptr, -1); | 916 transport_channel1->SignalSelectedCandidatePairChanged(transport_channel1, |
974 EXPECT_EQ(1, media_channel1_->num_network_route_changes()); | 917 nullptr, -1); |
| 918 }); |
| 919 WaitForThreads(); |
| 920 EXPECT_EQ(1, media_channel1->num_network_route_changes()); |
975 EXPECT_FALSE(media_channel1->last_network_route().connected); | 921 EXPECT_FALSE(media_channel1->last_network_route().connected); |
| 922 media_channel1->set_num_network_route_changes(0); |
976 | 923 |
977 media_channel1_->set_num_network_route_changes(0); | 924 network_thread_->Invoke<void>([this, transport_channel1, media_channel1] { |
978 // The transport channel becomes connected. | 925 // The transport channel becomes connected. |
979 rtc::SocketAddress local_address("192.168.1.1", 1000 /* port number */); | 926 rtc::SocketAddress local_address("192.168.1.1", 1000 /* port number */); |
980 rtc::SocketAddress remote_address("192.168.1.2", 2000 /* port number */); | 927 rtc::SocketAddress remote_address("192.168.1.2", 2000 /* port number */); |
981 uint16_t local_net_id = 1; | 928 std::unique_ptr<cricket::CandidatePairInterface> candidate_pair( |
982 uint16_t remote_net_id = 2; | 929 transport_controller1_->CreateFakeCandidatePair( |
983 int last_packet_id = 100; | 930 local_address, kLocalNetId, remote_address, kRemoteNetId)); |
984 std::unique_ptr<cricket::CandidatePairInterface> candidate_pair( | 931 transport_channel1->SignalSelectedCandidatePairChanged( |
985 transport_controller1_.CreateFakeCandidatePair( | 932 transport_channel1, candidate_pair.get(), kLastPacketId); |
986 local_address, local_net_id, remote_address, remote_net_id)); | 933 }); |
987 transport_channel1->SignalSelectedCandidatePairChanged( | 934 WaitForThreads(); |
988 transport_channel1, candidate_pair.get(), last_packet_id); | 935 EXPECT_EQ(1, media_channel1->num_network_route_changes()); |
989 EXPECT_EQ(1, media_channel1_->num_network_route_changes()); | 936 rtc::NetworkRoute expected_network_route(kLocalNetId, kRemoteNetId, |
990 rtc::NetworkRoute expected_network_route(local_net_id, remote_net_id, | 937 kLastPacketId); |
991 last_packet_id); | |
992 EXPECT_EQ(expected_network_route, media_channel1->last_network_route()); | 938 EXPECT_EQ(expected_network_route, media_channel1->last_network_route()); |
993 EXPECT_EQ(last_packet_id, | 939 EXPECT_EQ(kLastPacketId, |
994 media_channel1->last_network_route().last_sent_packet_id); | 940 media_channel1->last_network_route().last_sent_packet_id); |
995 } | 941 } |
996 | 942 |
997 // Test setting up a call. | 943 // Test setting up a call. |
998 void TestCallSetup() { | 944 void TestCallSetup() { |
999 CreateChannels(0, 0); | 945 CreateChannels(0, 0); |
1000 EXPECT_FALSE(channel1_->secure()); | 946 EXPECT_FALSE(channel1_->secure()); |
1001 EXPECT_TRUE(SendInitiate()); | 947 EXPECT_TRUE(SendInitiate()); |
1002 if (verify_playout_) { | 948 if (verify_playout_) { |
1003 EXPECT_TRUE(media_channel1_->playout()); | 949 EXPECT_TRUE(media_channel1_->playout()); |
(...skipping 18 matching lines...) Expand all Loading... |
1022 class LastWordMediaChannel : public T::MediaChannel { | 968 class LastWordMediaChannel : public T::MediaChannel { |
1023 public: | 969 public: |
1024 LastWordMediaChannel() : T::MediaChannel(NULL, typename T::Options()) {} | 970 LastWordMediaChannel() : T::MediaChannel(NULL, typename T::Options()) {} |
1025 ~LastWordMediaChannel() { | 971 ~LastWordMediaChannel() { |
1026 T::MediaChannel::SendRtp(kPcmuFrame, sizeof(kPcmuFrame), | 972 T::MediaChannel::SendRtp(kPcmuFrame, sizeof(kPcmuFrame), |
1027 rtc::PacketOptions()); | 973 rtc::PacketOptions()); |
1028 T::MediaChannel::SendRtcp(kRtcpReport, sizeof(kRtcpReport)); | 974 T::MediaChannel::SendRtcp(kRtcpReport, sizeof(kRtcpReport)); |
1029 } | 975 } |
1030 }; | 976 }; |
1031 CreateChannels(new LastWordMediaChannel(), new LastWordMediaChannel(), | 977 CreateChannels(new LastWordMediaChannel(), new LastWordMediaChannel(), |
1032 RTCP | RTCP_MUX, RTCP | RTCP_MUX, | 978 RTCP | RTCP_MUX, RTCP | RTCP_MUX); |
1033 rtc::Thread::Current()); | |
1034 EXPECT_TRUE(SendInitiate()); | 979 EXPECT_TRUE(SendInitiate()); |
1035 EXPECT_TRUE(SendAccept()); | 980 EXPECT_TRUE(SendAccept()); |
1036 EXPECT_TRUE(SendTerminate()); | 981 EXPECT_TRUE(SendTerminate()); |
1037 } | 982 } |
1038 | 983 |
1039 // Send voice RTP data to the other side and ensure it gets there. | 984 // Send voice RTP data to the other side and ensure it gets there. |
1040 void SendRtpToRtp() { | 985 void SendRtpToRtp() { |
1041 CreateChannels(0, 0); | 986 CreateChannels(0, 0); |
1042 EXPECT_TRUE(SendInitiate()); | 987 EXPECT_TRUE(SendInitiate()); |
1043 EXPECT_TRUE(SendAccept()); | 988 EXPECT_TRUE(SendAccept()); |
1044 ASSERT_TRUE(GetTransport1()); | 989 ASSERT_TRUE(GetTransport1()); |
1045 ASSERT_TRUE(GetTransport2()); | 990 ASSERT_TRUE(GetTransport2()); |
1046 EXPECT_EQ(1U, GetTransport1()->channels().size()); | 991 EXPECT_EQ(1U, GetTransport1()->channels().size()); |
1047 EXPECT_EQ(1U, GetTransport2()->channels().size()); | 992 EXPECT_EQ(1U, GetTransport2()->channels().size()); |
1048 EXPECT_TRUE(SendRtp1()); | 993 SendRtp1(); |
1049 EXPECT_TRUE(SendRtp2()); | 994 SendRtp2(); |
| 995 WaitForThreads(); |
1050 EXPECT_TRUE(CheckRtp1()); | 996 EXPECT_TRUE(CheckRtp1()); |
1051 EXPECT_TRUE(CheckRtp2()); | 997 EXPECT_TRUE(CheckRtp2()); |
1052 EXPECT_TRUE(CheckNoRtp1()); | 998 EXPECT_TRUE(CheckNoRtp1()); |
1053 EXPECT_TRUE(CheckNoRtp2()); | 999 EXPECT_TRUE(CheckNoRtp2()); |
1054 } | 1000 } |
1055 | 1001 |
1056 // Check that RTCP is not transmitted if both sides don't support RTCP. | 1002 // Check that RTCP is not transmitted if both sides don't support RTCP. |
1057 void SendNoRtcpToNoRtcp() { | 1003 void SendNoRtcpToNoRtcp() { |
1058 CreateChannels(0, 0); | 1004 CreateChannels(0, 0); |
1059 EXPECT_TRUE(SendInitiate()); | 1005 EXPECT_TRUE(SendInitiate()); |
1060 EXPECT_TRUE(SendAccept()); | 1006 EXPECT_TRUE(SendAccept()); |
1061 ASSERT_TRUE(GetTransport1()); | 1007 ASSERT_TRUE(GetTransport1()); |
1062 ASSERT_TRUE(GetTransport2()); | 1008 ASSERT_TRUE(GetTransport2()); |
1063 EXPECT_EQ(1U, GetTransport1()->channels().size()); | 1009 EXPECT_EQ(1U, GetTransport1()->channels().size()); |
1064 EXPECT_EQ(1U, GetTransport2()->channels().size()); | 1010 EXPECT_EQ(1U, GetTransport2()->channels().size()); |
1065 EXPECT_FALSE(SendRtcp1()); | 1011 SendRtcp1(); |
1066 EXPECT_FALSE(SendRtcp2()); | 1012 SendRtcp2(); |
| 1013 WaitForThreads(); |
1067 EXPECT_TRUE(CheckNoRtcp1()); | 1014 EXPECT_TRUE(CheckNoRtcp1()); |
1068 EXPECT_TRUE(CheckNoRtcp2()); | 1015 EXPECT_TRUE(CheckNoRtcp2()); |
1069 } | 1016 } |
1070 | 1017 |
1071 // Check that RTCP is not transmitted if the callee doesn't support RTCP. | 1018 // Check that RTCP is not transmitted if the callee doesn't support RTCP. |
1072 void SendNoRtcpToRtcp() { | 1019 void SendNoRtcpToRtcp() { |
1073 CreateChannels(0, RTCP); | 1020 CreateChannels(0, RTCP); |
1074 EXPECT_TRUE(SendInitiate()); | 1021 EXPECT_TRUE(SendInitiate()); |
1075 EXPECT_TRUE(SendAccept()); | 1022 EXPECT_TRUE(SendAccept()); |
1076 ASSERT_TRUE(GetTransport1()); | 1023 ASSERT_TRUE(GetTransport1()); |
1077 ASSERT_TRUE(GetTransport2()); | 1024 ASSERT_TRUE(GetTransport2()); |
1078 EXPECT_EQ(1U, GetTransport1()->channels().size()); | 1025 EXPECT_EQ(1U, GetTransport1()->channels().size()); |
1079 EXPECT_EQ(2U, GetTransport2()->channels().size()); | 1026 EXPECT_EQ(2U, GetTransport2()->channels().size()); |
1080 EXPECT_FALSE(SendRtcp1()); | 1027 SendRtcp1(); |
1081 EXPECT_FALSE(SendRtcp2()); | 1028 SendRtcp2(); |
| 1029 WaitForThreads(); |
1082 EXPECT_TRUE(CheckNoRtcp1()); | 1030 EXPECT_TRUE(CheckNoRtcp1()); |
1083 EXPECT_TRUE(CheckNoRtcp2()); | 1031 EXPECT_TRUE(CheckNoRtcp2()); |
1084 } | 1032 } |
1085 | 1033 |
1086 // Check that RTCP is not transmitted if the caller doesn't support RTCP. | 1034 // Check that RTCP is not transmitted if the caller doesn't support RTCP. |
1087 void SendRtcpToNoRtcp() { | 1035 void SendRtcpToNoRtcp() { |
1088 CreateChannels(RTCP, 0); | 1036 CreateChannels(RTCP, 0); |
1089 EXPECT_TRUE(SendInitiate()); | 1037 EXPECT_TRUE(SendInitiate()); |
1090 EXPECT_TRUE(SendAccept()); | 1038 EXPECT_TRUE(SendAccept()); |
1091 ASSERT_TRUE(GetTransport1()); | 1039 ASSERT_TRUE(GetTransport1()); |
1092 ASSERT_TRUE(GetTransport2()); | 1040 ASSERT_TRUE(GetTransport2()); |
1093 EXPECT_EQ(2U, GetTransport1()->channels().size()); | 1041 EXPECT_EQ(2U, GetTransport1()->channels().size()); |
1094 EXPECT_EQ(1U, GetTransport2()->channels().size()); | 1042 EXPECT_EQ(1U, GetTransport2()->channels().size()); |
1095 EXPECT_FALSE(SendRtcp1()); | 1043 SendRtcp1(); |
1096 EXPECT_FALSE(SendRtcp2()); | 1044 SendRtcp2(); |
| 1045 WaitForThreads(); |
1097 EXPECT_TRUE(CheckNoRtcp1()); | 1046 EXPECT_TRUE(CheckNoRtcp1()); |
1098 EXPECT_TRUE(CheckNoRtcp2()); | 1047 EXPECT_TRUE(CheckNoRtcp2()); |
1099 } | 1048 } |
1100 | 1049 |
1101 // Check that RTCP is transmitted if both sides support RTCP. | 1050 // Check that RTCP is transmitted if both sides support RTCP. |
1102 void SendRtcpToRtcp() { | 1051 void SendRtcpToRtcp() { |
1103 CreateChannels(RTCP, RTCP); | 1052 CreateChannels(RTCP, RTCP); |
1104 EXPECT_TRUE(SendInitiate()); | 1053 EXPECT_TRUE(SendInitiate()); |
1105 EXPECT_TRUE(SendAccept()); | 1054 EXPECT_TRUE(SendAccept()); |
1106 ASSERT_TRUE(GetTransport1()); | 1055 ASSERT_TRUE(GetTransport1()); |
1107 ASSERT_TRUE(GetTransport2()); | 1056 ASSERT_TRUE(GetTransport2()); |
1108 EXPECT_EQ(2U, GetTransport1()->channels().size()); | 1057 EXPECT_EQ(2U, GetTransport1()->channels().size()); |
1109 EXPECT_EQ(2U, GetTransport2()->channels().size()); | 1058 EXPECT_EQ(2U, GetTransport2()->channels().size()); |
1110 EXPECT_TRUE(SendRtcp1()); | 1059 SendRtcp1(); |
1111 EXPECT_TRUE(SendRtcp2()); | 1060 SendRtcp2(); |
| 1061 WaitForThreads(); |
1112 EXPECT_TRUE(CheckRtcp1()); | 1062 EXPECT_TRUE(CheckRtcp1()); |
1113 EXPECT_TRUE(CheckRtcp2()); | 1063 EXPECT_TRUE(CheckRtcp2()); |
1114 EXPECT_TRUE(CheckNoRtcp1()); | 1064 EXPECT_TRUE(CheckNoRtcp1()); |
1115 EXPECT_TRUE(CheckNoRtcp2()); | 1065 EXPECT_TRUE(CheckNoRtcp2()); |
1116 } | 1066 } |
1117 | 1067 |
1118 // Check that RTCP is transmitted if only the initiator supports mux. | 1068 // Check that RTCP is transmitted if only the initiator supports mux. |
1119 void SendRtcpMuxToRtcp() { | 1069 void SendRtcpMuxToRtcp() { |
1120 CreateChannels(RTCP | RTCP_MUX, RTCP); | 1070 CreateChannels(RTCP | RTCP_MUX, RTCP); |
1121 EXPECT_TRUE(SendInitiate()); | 1071 EXPECT_TRUE(SendInitiate()); |
1122 EXPECT_TRUE(SendAccept()); | 1072 EXPECT_TRUE(SendAccept()); |
1123 ASSERT_TRUE(GetTransport1()); | 1073 ASSERT_TRUE(GetTransport1()); |
1124 ASSERT_TRUE(GetTransport2()); | 1074 ASSERT_TRUE(GetTransport2()); |
1125 EXPECT_EQ(2U, GetTransport1()->channels().size()); | 1075 EXPECT_EQ(2U, GetTransport1()->channels().size()); |
1126 EXPECT_EQ(2U, GetTransport2()->channels().size()); | 1076 EXPECT_EQ(2U, GetTransport2()->channels().size()); |
1127 EXPECT_TRUE(SendRtcp1()); | 1077 SendRtcp1(); |
1128 EXPECT_TRUE(SendRtcp2()); | 1078 SendRtcp2(); |
| 1079 WaitForThreads(); |
1129 EXPECT_TRUE(CheckRtcp1()); | 1080 EXPECT_TRUE(CheckRtcp1()); |
1130 EXPECT_TRUE(CheckRtcp2()); | 1081 EXPECT_TRUE(CheckRtcp2()); |
1131 EXPECT_TRUE(CheckNoRtcp1()); | 1082 EXPECT_TRUE(CheckNoRtcp1()); |
1132 EXPECT_TRUE(CheckNoRtcp2()); | 1083 EXPECT_TRUE(CheckNoRtcp2()); |
1133 } | 1084 } |
1134 | 1085 |
1135 // Check that RTP and RTCP are transmitted ok when both sides support mux. | 1086 // Check that RTP and RTCP are transmitted ok when both sides support mux. |
1136 void SendRtcpMuxToRtcpMux() { | 1087 void SendRtcpMuxToRtcpMux() { |
1137 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); | 1088 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); |
1138 EXPECT_TRUE(SendInitiate()); | 1089 EXPECT_TRUE(SendInitiate()); |
1139 ASSERT_TRUE(GetTransport1()); | 1090 ASSERT_TRUE(GetTransport1()); |
1140 ASSERT_TRUE(GetTransport2()); | 1091 ASSERT_TRUE(GetTransport2()); |
1141 EXPECT_EQ(2U, GetTransport1()->channels().size()); | 1092 EXPECT_EQ(2U, GetTransport1()->channels().size()); |
1142 EXPECT_EQ(1U, GetTransport2()->channels().size()); | 1093 EXPECT_EQ(1U, GetTransport2()->channels().size()); |
1143 EXPECT_TRUE(SendAccept()); | 1094 EXPECT_TRUE(SendAccept()); |
1144 EXPECT_EQ(1U, GetTransport1()->channels().size()); | 1095 EXPECT_EQ(1U, GetTransport1()->channels().size()); |
1145 EXPECT_TRUE(SendRtp1()); | 1096 SendRtp1(); |
1146 EXPECT_TRUE(SendRtp2()); | 1097 SendRtp2(); |
1147 EXPECT_TRUE(SendRtcp1()); | 1098 SendRtcp1(); |
1148 EXPECT_TRUE(SendRtcp2()); | 1099 SendRtcp2(); |
| 1100 WaitForThreads(); |
1149 EXPECT_TRUE(CheckRtp1()); | 1101 EXPECT_TRUE(CheckRtp1()); |
1150 EXPECT_TRUE(CheckRtp2()); | 1102 EXPECT_TRUE(CheckRtp2()); |
1151 EXPECT_TRUE(CheckNoRtp1()); | 1103 EXPECT_TRUE(CheckNoRtp1()); |
1152 EXPECT_TRUE(CheckNoRtp2()); | 1104 EXPECT_TRUE(CheckNoRtp2()); |
1153 EXPECT_TRUE(CheckRtcp1()); | 1105 EXPECT_TRUE(CheckRtcp1()); |
1154 EXPECT_TRUE(CheckRtcp2()); | 1106 EXPECT_TRUE(CheckRtcp2()); |
1155 EXPECT_TRUE(CheckNoRtcp1()); | 1107 EXPECT_TRUE(CheckNoRtcp1()); |
1156 EXPECT_TRUE(CheckNoRtcp2()); | 1108 EXPECT_TRUE(CheckNoRtcp2()); |
1157 } | 1109 } |
1158 | 1110 |
1159 // Check that RTP and RTCP are transmitted ok when both sides | 1111 // Check that RTP and RTCP are transmitted ok when both sides |
1160 // support mux and one the offerer requires mux. | 1112 // support mux and one the offerer requires mux. |
1161 void SendRequireRtcpMuxToRtcpMux() { | 1113 void SendRequireRtcpMuxToRtcpMux() { |
1162 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); | 1114 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); |
1163 channel1_->ActivateRtcpMux(); | 1115 channel1_->ActivateRtcpMux(); |
1164 EXPECT_TRUE(SendInitiate()); | 1116 EXPECT_TRUE(SendInitiate()); |
1165 ASSERT_TRUE(GetTransport1()); | 1117 ASSERT_TRUE(GetTransport1()); |
1166 ASSERT_TRUE(GetTransport2()); | 1118 ASSERT_TRUE(GetTransport2()); |
1167 EXPECT_EQ(1U, GetTransport1()->channels().size()); | 1119 EXPECT_EQ(1U, GetTransport1()->channels().size()); |
1168 EXPECT_EQ(1U, GetTransport2()->channels().size()); | 1120 EXPECT_EQ(1U, GetTransport2()->channels().size()); |
1169 EXPECT_TRUE(SendAccept()); | 1121 EXPECT_TRUE(SendAccept()); |
1170 EXPECT_TRUE(SendRtp1()); | 1122 SendRtp1(); |
1171 EXPECT_TRUE(SendRtp2()); | 1123 SendRtp2(); |
1172 EXPECT_TRUE(SendRtcp1()); | 1124 SendRtcp1(); |
1173 EXPECT_TRUE(SendRtcp2()); | 1125 SendRtcp2(); |
| 1126 WaitForThreads(); |
1174 EXPECT_TRUE(CheckRtp1()); | 1127 EXPECT_TRUE(CheckRtp1()); |
1175 EXPECT_TRUE(CheckRtp2()); | 1128 EXPECT_TRUE(CheckRtp2()); |
1176 EXPECT_TRUE(CheckNoRtp1()); | 1129 EXPECT_TRUE(CheckNoRtp1()); |
1177 EXPECT_TRUE(CheckNoRtp2()); | 1130 EXPECT_TRUE(CheckNoRtp2()); |
1178 EXPECT_TRUE(CheckRtcp1()); | 1131 EXPECT_TRUE(CheckRtcp1()); |
1179 EXPECT_TRUE(CheckRtcp2()); | 1132 EXPECT_TRUE(CheckRtcp2()); |
1180 EXPECT_TRUE(CheckNoRtcp1()); | 1133 EXPECT_TRUE(CheckNoRtcp1()); |
1181 EXPECT_TRUE(CheckNoRtcp2()); | 1134 EXPECT_TRUE(CheckNoRtcp2()); |
1182 } | 1135 } |
1183 | 1136 |
1184 // Check that RTP and RTCP are transmitted ok when both sides | 1137 // Check that RTP and RTCP are transmitted ok when both sides |
1185 // support mux and one the answerer requires rtcp mux. | 1138 // support mux and one the answerer requires rtcp mux. |
1186 void SendRtcpMuxToRequireRtcpMux() { | 1139 void SendRtcpMuxToRequireRtcpMux() { |
1187 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); | 1140 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); |
1188 channel2_->ActivateRtcpMux(); | 1141 channel2_->ActivateRtcpMux(); |
1189 EXPECT_TRUE(SendInitiate()); | 1142 EXPECT_TRUE(SendInitiate()); |
1190 ASSERT_TRUE(GetTransport1()); | 1143 ASSERT_TRUE(GetTransport1()); |
1191 ASSERT_TRUE(GetTransport2()); | 1144 ASSERT_TRUE(GetTransport2()); |
1192 EXPECT_EQ(2U, GetTransport1()->channels().size()); | 1145 EXPECT_EQ(2U, GetTransport1()->channels().size()); |
1193 EXPECT_EQ(1U, GetTransport2()->channels().size()); | 1146 EXPECT_EQ(1U, GetTransport2()->channels().size()); |
1194 EXPECT_TRUE(SendAccept()); | 1147 EXPECT_TRUE(SendAccept()); |
1195 EXPECT_EQ(1U, GetTransport1()->channels().size()); | 1148 EXPECT_EQ(1U, GetTransport1()->channels().size()); |
1196 EXPECT_TRUE(SendRtp1()); | 1149 SendRtp1(); |
1197 EXPECT_TRUE(SendRtp2()); | 1150 SendRtp2(); |
1198 EXPECT_TRUE(SendRtcp1()); | 1151 SendRtcp1(); |
1199 EXPECT_TRUE(SendRtcp2()); | 1152 SendRtcp2(); |
| 1153 WaitForThreads(); |
1200 EXPECT_TRUE(CheckRtp1()); | 1154 EXPECT_TRUE(CheckRtp1()); |
1201 EXPECT_TRUE(CheckRtp2()); | 1155 EXPECT_TRUE(CheckRtp2()); |
1202 EXPECT_TRUE(CheckNoRtp1()); | 1156 EXPECT_TRUE(CheckNoRtp1()); |
1203 EXPECT_TRUE(CheckNoRtp2()); | 1157 EXPECT_TRUE(CheckNoRtp2()); |
1204 EXPECT_TRUE(CheckRtcp1()); | 1158 EXPECT_TRUE(CheckRtcp1()); |
1205 EXPECT_TRUE(CheckRtcp2()); | 1159 EXPECT_TRUE(CheckRtcp2()); |
1206 EXPECT_TRUE(CheckNoRtcp1()); | 1160 EXPECT_TRUE(CheckNoRtcp1()); |
1207 EXPECT_TRUE(CheckNoRtcp2()); | 1161 EXPECT_TRUE(CheckNoRtcp2()); |
1208 } | 1162 } |
1209 | 1163 |
1210 // Check that RTP and RTCP are transmitted ok when both sides | 1164 // Check that RTP and RTCP are transmitted ok when both sides |
1211 // require mux. | 1165 // require mux. |
1212 void SendRequireRtcpMuxToRequireRtcpMux() { | 1166 void SendRequireRtcpMuxToRequireRtcpMux() { |
1213 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); | 1167 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); |
1214 channel1_->ActivateRtcpMux(); | 1168 channel1_->ActivateRtcpMux(); |
1215 channel2_->ActivateRtcpMux(); | 1169 channel2_->ActivateRtcpMux(); |
1216 EXPECT_TRUE(SendInitiate()); | 1170 EXPECT_TRUE(SendInitiate()); |
1217 ASSERT_TRUE(GetTransport1()); | 1171 ASSERT_TRUE(GetTransport1()); |
1218 ASSERT_TRUE(GetTransport2()); | 1172 ASSERT_TRUE(GetTransport2()); |
1219 EXPECT_EQ(1U, GetTransport1()->channels().size()); | 1173 EXPECT_EQ(1U, GetTransport1()->channels().size()); |
1220 EXPECT_EQ(1U, GetTransport2()->channels().size()); | 1174 EXPECT_EQ(1U, GetTransport2()->channels().size()); |
1221 EXPECT_TRUE(SendAccept()); | 1175 EXPECT_TRUE(SendAccept()); |
1222 EXPECT_EQ(1U, GetTransport1()->channels().size()); | 1176 EXPECT_EQ(1U, GetTransport1()->channels().size()); |
1223 EXPECT_TRUE(SendRtp1()); | 1177 SendRtp1(); |
1224 EXPECT_TRUE(SendRtp2()); | 1178 SendRtp2(); |
1225 EXPECT_TRUE(SendRtcp1()); | 1179 SendRtcp1(); |
1226 EXPECT_TRUE(SendRtcp2()); | 1180 SendRtcp2(); |
| 1181 WaitForThreads(); |
1227 EXPECT_TRUE(CheckRtp1()); | 1182 EXPECT_TRUE(CheckRtp1()); |
1228 EXPECT_TRUE(CheckRtp2()); | 1183 EXPECT_TRUE(CheckRtp2()); |
1229 EXPECT_TRUE(CheckNoRtp1()); | 1184 EXPECT_TRUE(CheckNoRtp1()); |
1230 EXPECT_TRUE(CheckNoRtp2()); | 1185 EXPECT_TRUE(CheckNoRtp2()); |
1231 EXPECT_TRUE(CheckRtcp1()); | 1186 EXPECT_TRUE(CheckRtcp1()); |
1232 EXPECT_TRUE(CheckRtcp2()); | 1187 EXPECT_TRUE(CheckRtcp2()); |
1233 EXPECT_TRUE(CheckNoRtcp1()); | 1188 EXPECT_TRUE(CheckNoRtcp1()); |
1234 EXPECT_TRUE(CheckNoRtcp2()); | 1189 EXPECT_TRUE(CheckNoRtcp2()); |
1235 } | 1190 } |
1236 | 1191 |
(...skipping 14 matching lines...) Expand all Loading... |
1251 void SendEarlyRtcpMuxToRtcp() { | 1206 void SendEarlyRtcpMuxToRtcp() { |
1252 CreateChannels(RTCP | RTCP_MUX, RTCP); | 1207 CreateChannels(RTCP | RTCP_MUX, RTCP); |
1253 EXPECT_TRUE(SendInitiate()); | 1208 EXPECT_TRUE(SendInitiate()); |
1254 ASSERT_TRUE(GetTransport1()); | 1209 ASSERT_TRUE(GetTransport1()); |
1255 ASSERT_TRUE(GetTransport2()); | 1210 ASSERT_TRUE(GetTransport2()); |
1256 EXPECT_EQ(2U, GetTransport1()->channels().size()); | 1211 EXPECT_EQ(2U, GetTransport1()->channels().size()); |
1257 EXPECT_EQ(2U, GetTransport2()->channels().size()); | 1212 EXPECT_EQ(2U, GetTransport2()->channels().size()); |
1258 | 1213 |
1259 // RTCP can be sent before the call is accepted, if the transport is ready. | 1214 // RTCP can be sent before the call is accepted, if the transport is ready. |
1260 // It should not be muxed though, as the remote side doesn't support mux. | 1215 // It should not be muxed though, as the remote side doesn't support mux. |
1261 EXPECT_TRUE(SendRtcp1()); | 1216 SendRtcp1(); |
| 1217 WaitForThreads(); |
1262 EXPECT_TRUE(CheckNoRtp2()); | 1218 EXPECT_TRUE(CheckNoRtp2()); |
1263 EXPECT_TRUE(CheckRtcp2()); | 1219 EXPECT_TRUE(CheckRtcp2()); |
1264 | 1220 |
1265 // Send RTCP packet from callee and verify that it is received. | 1221 // Send RTCP packet from callee and verify that it is received. |
1266 EXPECT_TRUE(SendRtcp2()); | 1222 SendRtcp2(); |
| 1223 WaitForThreads(); |
1267 EXPECT_TRUE(CheckNoRtp1()); | 1224 EXPECT_TRUE(CheckNoRtp1()); |
1268 EXPECT_TRUE(CheckRtcp1()); | 1225 EXPECT_TRUE(CheckRtcp1()); |
1269 | 1226 |
1270 // Complete call setup and ensure everything is still OK. | 1227 // Complete call setup and ensure everything is still OK. |
1271 EXPECT_TRUE(SendAccept()); | 1228 EXPECT_TRUE(SendAccept()); |
1272 EXPECT_EQ(2U, GetTransport1()->channels().size()); | 1229 EXPECT_EQ(2U, GetTransport1()->channels().size()); |
1273 EXPECT_TRUE(SendRtcp1()); | 1230 SendRtcp1(); |
| 1231 SendRtcp2(); |
| 1232 WaitForThreads(); |
1274 EXPECT_TRUE(CheckRtcp2()); | 1233 EXPECT_TRUE(CheckRtcp2()); |
1275 EXPECT_TRUE(SendRtcp2()); | |
1276 EXPECT_TRUE(CheckRtcp1()); | 1234 EXPECT_TRUE(CheckRtcp1()); |
1277 } | 1235 } |
1278 | 1236 |
1279 | 1237 |
1280 // Check that RTCP data is not muxed until both sides have enabled muxing, | 1238 // Check that RTCP data is not muxed until both sides have enabled muxing, |
1281 // but that we properly demux before we get the accept message, since there | 1239 // but that we properly demux before we get the accept message, since there |
1282 // is a race between RTP data and the jingle accept. | 1240 // is a race between RTP data and the jingle accept. |
1283 void SendEarlyRtcpMuxToRtcpMux() { | 1241 void SendEarlyRtcpMuxToRtcpMux() { |
1284 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); | 1242 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); |
1285 EXPECT_TRUE(SendInitiate()); | 1243 EXPECT_TRUE(SendInitiate()); |
1286 ASSERT_TRUE(GetTransport1()); | 1244 ASSERT_TRUE(GetTransport1()); |
1287 ASSERT_TRUE(GetTransport2()); | 1245 ASSERT_TRUE(GetTransport2()); |
1288 EXPECT_EQ(2U, GetTransport1()->channels().size()); | 1246 EXPECT_EQ(2U, GetTransport1()->channels().size()); |
1289 EXPECT_EQ(1U, GetTransport2()->channels().size()); | 1247 EXPECT_EQ(1U, GetTransport2()->channels().size()); |
1290 | 1248 |
1291 // RTCP can't be sent yet, since the RTCP transport isn't writable, and | 1249 // RTCP can't be sent yet, since the RTCP transport isn't writable, and |
1292 // we haven't yet received the accept that says we should mux. | 1250 // we haven't yet received the accept that says we should mux. |
1293 EXPECT_FALSE(SendRtcp1()); | 1251 SendRtcp1(); |
| 1252 WaitForThreads(); |
| 1253 EXPECT_TRUE(CheckNoRtcp2()); |
1294 | 1254 |
1295 // Send muxed RTCP packet from callee and verify that it is received. | 1255 // Send muxed RTCP packet from callee and verify that it is received. |
1296 EXPECT_TRUE(SendRtcp2()); | 1256 SendRtcp2(); |
| 1257 WaitForThreads(); |
1297 EXPECT_TRUE(CheckNoRtp1()); | 1258 EXPECT_TRUE(CheckNoRtp1()); |
1298 EXPECT_TRUE(CheckRtcp1()); | 1259 EXPECT_TRUE(CheckRtcp1()); |
1299 | 1260 |
1300 // Complete call setup and ensure everything is still OK. | 1261 // Complete call setup and ensure everything is still OK. |
1301 EXPECT_TRUE(SendAccept()); | 1262 EXPECT_TRUE(SendAccept()); |
1302 EXPECT_EQ(1U, GetTransport1()->channels().size()); | 1263 EXPECT_EQ(1U, GetTransport1()->channels().size()); |
1303 EXPECT_TRUE(SendRtcp1()); | 1264 SendRtcp1(); |
| 1265 SendRtcp2(); |
| 1266 WaitForThreads(); |
1304 EXPECT_TRUE(CheckRtcp2()); | 1267 EXPECT_TRUE(CheckRtcp2()); |
1305 EXPECT_TRUE(SendRtcp2()); | |
1306 EXPECT_TRUE(CheckRtcp1()); | 1268 EXPECT_TRUE(CheckRtcp1()); |
1307 } | 1269 } |
1308 | 1270 |
1309 // Test that we properly send SRTP with RTCP in both directions. | 1271 // Test that we properly send SRTP with RTCP in both directions. |
1310 // You can pass in DTLS and/or RTCP_MUX as flags. | 1272 // You can pass in DTLS and/or RTCP_MUX as flags. |
1311 void SendSrtpToSrtp(int flags1_in = 0, int flags2_in = 0) { | 1273 void SendSrtpToSrtp(int flags1_in = 0, int flags2_in = 0) { |
1312 ASSERT((flags1_in & ~(RTCP_MUX | DTLS)) == 0); | 1274 ASSERT((flags1_in & ~(RTCP_MUX | DTLS)) == 0); |
1313 ASSERT((flags2_in & ~(RTCP_MUX | DTLS)) == 0); | 1275 ASSERT((flags2_in & ~(RTCP_MUX | DTLS)) == 0); |
1314 | 1276 |
1315 int flags1 = RTCP | SECURE | flags1_in; | 1277 int flags1 = RTCP | SECURE | flags1_in; |
1316 int flags2 = RTCP | SECURE | flags2_in; | 1278 int flags2 = RTCP | SECURE | flags2_in; |
1317 bool dtls1 = !!(flags1_in & DTLS); | 1279 bool dtls1 = !!(flags1_in & DTLS); |
1318 bool dtls2 = !!(flags2_in & DTLS); | 1280 bool dtls2 = !!(flags2_in & DTLS); |
1319 CreateChannels(flags1, flags2); | 1281 CreateChannels(flags1, flags2); |
1320 EXPECT_FALSE(channel1_->secure()); | 1282 EXPECT_FALSE(channel1_->secure()); |
1321 EXPECT_FALSE(channel2_->secure()); | 1283 EXPECT_FALSE(channel2_->secure()); |
1322 EXPECT_TRUE(SendInitiate()); | 1284 EXPECT_TRUE(SendInitiate()); |
1323 EXPECT_TRUE_WAIT(channel1_->writable(), kEventTimeout); | 1285 WaitForThreads(); |
1324 EXPECT_TRUE_WAIT(channel2_->writable(), kEventTimeout); | 1286 EXPECT_TRUE(channel1_->writable()); |
| 1287 EXPECT_TRUE(channel2_->writable()); |
1325 EXPECT_TRUE(SendAccept()); | 1288 EXPECT_TRUE(SendAccept()); |
1326 EXPECT_TRUE(channel1_->secure()); | 1289 EXPECT_TRUE(channel1_->secure()); |
1327 EXPECT_TRUE(channel2_->secure()); | 1290 EXPECT_TRUE(channel2_->secure()); |
1328 EXPECT_EQ(dtls1 && dtls2, channel1_->secure_dtls()); | 1291 EXPECT_EQ(dtls1 && dtls2, channel1_->secure_dtls()); |
1329 EXPECT_EQ(dtls1 && dtls2, channel2_->secure_dtls()); | 1292 EXPECT_EQ(dtls1 && dtls2, channel2_->secure_dtls()); |
1330 EXPECT_TRUE(SendRtp1()); | 1293 SendRtp1(); |
1331 EXPECT_TRUE(SendRtp2()); | 1294 SendRtp2(); |
1332 EXPECT_TRUE(SendRtcp1()); | 1295 SendRtcp1(); |
1333 EXPECT_TRUE(SendRtcp2()); | 1296 SendRtcp2(); |
| 1297 WaitForThreads(); |
1334 EXPECT_TRUE(CheckRtp1()); | 1298 EXPECT_TRUE(CheckRtp1()); |
1335 EXPECT_TRUE(CheckRtp2()); | 1299 EXPECT_TRUE(CheckRtp2()); |
1336 EXPECT_TRUE(CheckNoRtp1()); | 1300 EXPECT_TRUE(CheckNoRtp1()); |
1337 EXPECT_TRUE(CheckNoRtp2()); | 1301 EXPECT_TRUE(CheckNoRtp2()); |
1338 EXPECT_TRUE(CheckRtcp1()); | 1302 EXPECT_TRUE(CheckRtcp1()); |
1339 EXPECT_TRUE(CheckRtcp2()); | 1303 EXPECT_TRUE(CheckRtcp2()); |
1340 EXPECT_TRUE(CheckNoRtcp1()); | 1304 EXPECT_TRUE(CheckNoRtcp1()); |
1341 EXPECT_TRUE(CheckNoRtcp2()); | 1305 EXPECT_TRUE(CheckNoRtcp2()); |
1342 } | 1306 } |
1343 | 1307 |
1344 // Test that we properly handling SRTP negotiating down to RTP. | 1308 // Test that we properly handling SRTP negotiating down to RTP. |
1345 void SendSrtpToRtp() { | 1309 void SendSrtpToRtp() { |
1346 CreateChannels(RTCP | SECURE, RTCP); | 1310 CreateChannels(RTCP | SECURE, RTCP); |
1347 EXPECT_FALSE(channel1_->secure()); | 1311 EXPECT_FALSE(channel1_->secure()); |
1348 EXPECT_FALSE(channel2_->secure()); | 1312 EXPECT_FALSE(channel2_->secure()); |
1349 EXPECT_TRUE(SendInitiate()); | 1313 EXPECT_TRUE(SendInitiate()); |
1350 EXPECT_TRUE(SendAccept()); | 1314 EXPECT_TRUE(SendAccept()); |
1351 EXPECT_FALSE(channel1_->secure()); | 1315 EXPECT_FALSE(channel1_->secure()); |
1352 EXPECT_FALSE(channel2_->secure()); | 1316 EXPECT_FALSE(channel2_->secure()); |
1353 EXPECT_TRUE(SendRtp1()); | 1317 SendRtp1(); |
1354 EXPECT_TRUE(SendRtp2()); | 1318 SendRtp2(); |
1355 EXPECT_TRUE(SendRtcp1()); | 1319 SendRtcp1(); |
1356 EXPECT_TRUE(SendRtcp2()); | 1320 SendRtcp2(); |
| 1321 WaitForThreads(); |
1357 EXPECT_TRUE(CheckRtp1()); | 1322 EXPECT_TRUE(CheckRtp1()); |
1358 EXPECT_TRUE(CheckRtp2()); | 1323 EXPECT_TRUE(CheckRtp2()); |
1359 EXPECT_TRUE(CheckNoRtp1()); | 1324 EXPECT_TRUE(CheckNoRtp1()); |
1360 EXPECT_TRUE(CheckNoRtp2()); | 1325 EXPECT_TRUE(CheckNoRtp2()); |
1361 EXPECT_TRUE(CheckRtcp1()); | 1326 EXPECT_TRUE(CheckRtcp1()); |
1362 EXPECT_TRUE(CheckRtcp2()); | 1327 EXPECT_TRUE(CheckRtcp2()); |
1363 EXPECT_TRUE(CheckNoRtcp1()); | 1328 EXPECT_TRUE(CheckNoRtcp1()); |
1364 EXPECT_TRUE(CheckNoRtcp2()); | 1329 EXPECT_TRUE(CheckNoRtcp2()); |
1365 } | 1330 } |
1366 | 1331 |
1367 // Test that we can send and receive early media when a provisional answer is | 1332 // Test that we can send and receive early media when a provisional answer is |
1368 // sent and received. The test uses SRTP, RTCP mux and SSRC mux. | 1333 // sent and received. The test uses SRTP, RTCP mux and SSRC mux. |
1369 void SendEarlyMediaUsingRtcpMuxSrtp() { | 1334 void SendEarlyMediaUsingRtcpMuxSrtp() { |
1370 int sequence_number1_1 = 0, sequence_number2_2 = 0; | 1335 int sequence_number1_1 = 0, sequence_number2_2 = 0; |
1371 | 1336 |
1372 CreateChannels(SSRC_MUX | RTCP | RTCP_MUX | SECURE, | 1337 CreateChannels(SSRC_MUX | RTCP | RTCP_MUX | SECURE, |
1373 SSRC_MUX | RTCP | RTCP_MUX | SECURE); | 1338 SSRC_MUX | RTCP | RTCP_MUX | SECURE); |
1374 EXPECT_TRUE(SendOffer()); | 1339 EXPECT_TRUE(SendOffer()); |
1375 EXPECT_TRUE(SendProvisionalAnswer()); | 1340 EXPECT_TRUE(SendProvisionalAnswer()); |
1376 EXPECT_TRUE(channel1_->secure()); | 1341 EXPECT_TRUE(channel1_->secure()); |
1377 EXPECT_TRUE(channel2_->secure()); | 1342 EXPECT_TRUE(channel2_->secure()); |
1378 ASSERT_TRUE(GetTransport1()); | 1343 ASSERT_TRUE(GetTransport1()); |
1379 ASSERT_TRUE(GetTransport2()); | 1344 ASSERT_TRUE(GetTransport2()); |
1380 EXPECT_EQ(2U, GetTransport1()->channels().size()); | 1345 EXPECT_EQ(2U, GetTransport1()->channels().size()); |
1381 EXPECT_EQ(2U, GetTransport2()->channels().size()); | 1346 EXPECT_EQ(2U, GetTransport2()->channels().size()); |
1382 EXPECT_TRUE(SendCustomRtcp1(kSsrc1)); | 1347 WaitForThreads(); // Wait for 'sending' flag go through network thread. |
| 1348 SendCustomRtcp1(kSsrc1); |
| 1349 SendCustomRtp1(kSsrc1, ++sequence_number1_1); |
| 1350 WaitForThreads(); |
1383 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1)); | 1351 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1)); |
1384 EXPECT_TRUE(SendCustomRtp1(kSsrc1, ++sequence_number1_1)); | |
1385 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1)); | 1352 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1)); |
1386 | 1353 |
1387 // Send packets from callee and verify that it is received. | 1354 // Send packets from callee and verify that it is received. |
1388 EXPECT_TRUE(SendCustomRtcp2(kSsrc2)); | 1355 SendCustomRtcp2(kSsrc2); |
| 1356 SendCustomRtp2(kSsrc2, ++sequence_number2_2); |
| 1357 WaitForThreads(); |
1389 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2)); | 1358 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2)); |
1390 EXPECT_TRUE(SendCustomRtp2(kSsrc2, ++sequence_number2_2)); | |
1391 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2)); | 1359 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2)); |
1392 | 1360 |
1393 // Complete call setup and ensure everything is still OK. | 1361 // Complete call setup and ensure everything is still OK. |
1394 EXPECT_TRUE(SendFinalAnswer()); | 1362 EXPECT_TRUE(SendFinalAnswer()); |
1395 EXPECT_EQ(1U, GetTransport1()->channels().size()); | 1363 EXPECT_EQ(1U, GetTransport1()->channels().size()); |
1396 EXPECT_EQ(1U, GetTransport2()->channels().size()); | 1364 EXPECT_EQ(1U, GetTransport2()->channels().size()); |
1397 EXPECT_TRUE(channel1_->secure()); | 1365 EXPECT_TRUE(channel1_->secure()); |
1398 EXPECT_TRUE(channel2_->secure()); | 1366 EXPECT_TRUE(channel2_->secure()); |
1399 EXPECT_TRUE(SendCustomRtcp1(kSsrc1)); | 1367 SendCustomRtcp1(kSsrc1); |
| 1368 SendCustomRtp1(kSsrc1, ++sequence_number1_1); |
| 1369 SendCustomRtcp2(kSsrc2); |
| 1370 SendCustomRtp2(kSsrc2, ++sequence_number2_2); |
| 1371 WaitForThreads(); |
1400 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1)); | 1372 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1)); |
1401 EXPECT_TRUE(SendCustomRtp1(kSsrc1, ++sequence_number1_1)); | |
1402 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1)); | 1373 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1)); |
1403 EXPECT_TRUE(SendCustomRtcp2(kSsrc2)); | |
1404 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2)); | 1374 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2)); |
1405 EXPECT_TRUE(SendCustomRtp2(kSsrc2, ++sequence_number2_2)); | |
1406 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2)); | 1375 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2)); |
1407 } | 1376 } |
1408 | 1377 |
1409 // Test that we properly send RTP without SRTP from a thread. | 1378 // Test that we properly send RTP without SRTP from a thread. |
1410 void SendRtpToRtpOnThread() { | 1379 void SendRtpToRtpOnThread() { |
1411 CreateChannels(RTCP, RTCP); | 1380 CreateChannels(RTCP, RTCP); |
1412 EXPECT_TRUE(SendInitiate()); | 1381 EXPECT_TRUE(SendInitiate()); |
1413 EXPECT_TRUE(SendAccept()); | 1382 EXPECT_TRUE(SendAccept()); |
1414 ScopedCallThread send_rtp1(this, &ChannelTest<T>::SendRtp1); | 1383 ScopedCallThread send_rtp1([this] { SendRtp1(); }); |
1415 ScopedCallThread send_rtp2(this, &ChannelTest<T>::SendRtp2); | 1384 ScopedCallThread send_rtp2([this] { SendRtp2(); }); |
1416 ScopedCallThread send_rtcp1(this, &ChannelTest<T>::SendRtcp1); | 1385 ScopedCallThread send_rtcp1([this] { SendRtcp1(); }); |
1417 ScopedCallThread send_rtcp2(this, &ChannelTest<T>::SendRtcp2); | 1386 ScopedCallThread send_rtcp2([this] { SendRtcp2(); }); |
1418 EXPECT_TRUE_WAIT(CheckRtp1(), 1000); | 1387 rtc::Thread* involved_threads[] = {send_rtp1.thread(), send_rtp2.thread(), |
1419 EXPECT_TRUE_WAIT(CheckRtp2(), 1000); | 1388 send_rtcp1.thread(), |
1420 EXPECT_TRUE_WAIT(send_rtp1.result(), 1000); | 1389 send_rtcp2.thread()}; |
1421 EXPECT_TRUE_WAIT(send_rtp2.result(), 1000); | 1390 WaitForThreads(involved_threads); |
| 1391 EXPECT_TRUE(CheckRtp1()); |
| 1392 EXPECT_TRUE(CheckRtp2()); |
1422 EXPECT_TRUE(CheckNoRtp1()); | 1393 EXPECT_TRUE(CheckNoRtp1()); |
1423 EXPECT_TRUE(CheckNoRtp2()); | 1394 EXPECT_TRUE(CheckNoRtp2()); |
1424 EXPECT_TRUE_WAIT(CheckRtcp1(), 1000); | 1395 EXPECT_TRUE(CheckRtcp1()); |
1425 EXPECT_TRUE_WAIT(CheckRtcp2(), 1000); | 1396 EXPECT_TRUE(CheckRtcp2()); |
1426 EXPECT_TRUE_WAIT(send_rtcp1.result(), 1000); | |
1427 EXPECT_TRUE_WAIT(send_rtcp2.result(), 1000); | |
1428 EXPECT_TRUE(CheckNoRtcp1()); | 1397 EXPECT_TRUE(CheckNoRtcp1()); |
1429 EXPECT_TRUE(CheckNoRtcp2()); | 1398 EXPECT_TRUE(CheckNoRtcp2()); |
1430 } | 1399 } |
1431 | 1400 |
1432 // Test that we properly send SRTP with RTCP from a thread. | 1401 // Test that we properly send SRTP with RTCP from a thread. |
1433 void SendSrtpToSrtpOnThread() { | 1402 void SendSrtpToSrtpOnThread() { |
1434 CreateChannels(RTCP | SECURE, RTCP | SECURE); | 1403 CreateChannels(RTCP | SECURE, RTCP | SECURE); |
1435 EXPECT_TRUE(SendInitiate()); | 1404 EXPECT_TRUE(SendInitiate()); |
1436 EXPECT_TRUE(SendAccept()); | 1405 EXPECT_TRUE(SendAccept()); |
1437 ScopedCallThread send_rtp1(this, &ChannelTest<T>::SendRtp1); | 1406 ScopedCallThread send_rtp1([this] { SendRtp1(); }); |
1438 ScopedCallThread send_rtp2(this, &ChannelTest<T>::SendRtp2); | 1407 ScopedCallThread send_rtp2([this] { SendRtp2(); }); |
1439 ScopedCallThread send_rtcp1(this, &ChannelTest<T>::SendRtcp1); | 1408 ScopedCallThread send_rtcp1([this] { SendRtcp1(); }); |
1440 ScopedCallThread send_rtcp2(this, &ChannelTest<T>::SendRtcp2); | 1409 ScopedCallThread send_rtcp2([this] { SendRtcp2(); }); |
1441 EXPECT_TRUE_WAIT(CheckRtp1(), 1000); | 1410 rtc::Thread* involved_threads[] = {send_rtp1.thread(), send_rtp2.thread(), |
1442 EXPECT_TRUE_WAIT(CheckRtp2(), 1000); | 1411 send_rtcp1.thread(), |
1443 EXPECT_TRUE_WAIT(send_rtp1.result(), 1000); | 1412 send_rtcp2.thread()}; |
1444 EXPECT_TRUE_WAIT(send_rtp2.result(), 1000); | 1413 WaitForThreads(involved_threads); |
| 1414 EXPECT_TRUE(CheckRtp1()); |
| 1415 EXPECT_TRUE(CheckRtp2()); |
1445 EXPECT_TRUE(CheckNoRtp1()); | 1416 EXPECT_TRUE(CheckNoRtp1()); |
1446 EXPECT_TRUE(CheckNoRtp2()); | 1417 EXPECT_TRUE(CheckNoRtp2()); |
1447 EXPECT_TRUE_WAIT(CheckRtcp1(), 1000); | 1418 EXPECT_TRUE(CheckRtcp1()); |
1448 EXPECT_TRUE_WAIT(CheckRtcp2(), 1000); | 1419 EXPECT_TRUE(CheckRtcp2()); |
1449 EXPECT_TRUE_WAIT(send_rtcp1.result(), 1000); | |
1450 EXPECT_TRUE_WAIT(send_rtcp2.result(), 1000); | |
1451 EXPECT_TRUE(CheckNoRtcp1()); | 1420 EXPECT_TRUE(CheckNoRtcp1()); |
1452 EXPECT_TRUE(CheckNoRtcp2()); | 1421 EXPECT_TRUE(CheckNoRtcp2()); |
1453 } | 1422 } |
1454 | 1423 |
1455 // Test that the mediachannel retains its sending state after the transport | 1424 // Test that the mediachannel retains its sending state after the transport |
1456 // becomes non-writable. | 1425 // becomes non-writable. |
1457 void SendWithWritabilityLoss() { | 1426 void SendWithWritabilityLoss() { |
1458 CreateChannels(0, 0); | 1427 CreateChannels(0, 0); |
1459 EXPECT_TRUE(SendInitiate()); | 1428 EXPECT_TRUE(SendInitiate()); |
1460 EXPECT_TRUE(SendAccept()); | 1429 EXPECT_TRUE(SendAccept()); |
1461 ASSERT_TRUE(GetTransport1()); | 1430 ASSERT_TRUE(GetTransport1()); |
1462 ASSERT_TRUE(GetTransport2()); | 1431 ASSERT_TRUE(GetTransport2()); |
1463 EXPECT_EQ(1U, GetTransport1()->channels().size()); | 1432 EXPECT_EQ(1U, GetTransport1()->channels().size()); |
1464 EXPECT_EQ(1U, GetTransport2()->channels().size()); | 1433 EXPECT_EQ(1U, GetTransport2()->channels().size()); |
1465 EXPECT_TRUE(SendRtp1()); | 1434 SendRtp1(); |
1466 EXPECT_TRUE(SendRtp2()); | 1435 SendRtp2(); |
| 1436 WaitForThreads(); |
1467 EXPECT_TRUE(CheckRtp1()); | 1437 EXPECT_TRUE(CheckRtp1()); |
1468 EXPECT_TRUE(CheckRtp2()); | 1438 EXPECT_TRUE(CheckRtp2()); |
1469 EXPECT_TRUE(CheckNoRtp1()); | 1439 EXPECT_TRUE(CheckNoRtp1()); |
1470 EXPECT_TRUE(CheckNoRtp2()); | 1440 EXPECT_TRUE(CheckNoRtp2()); |
1471 | 1441 |
1472 // Lose writability, which should fail. | 1442 // Lose writability, which should fail. |
1473 GetTransport1()->SetWritable(false); | 1443 network_thread_->Invoke<void>( |
1474 EXPECT_FALSE(SendRtp1()); | 1444 [this] { GetTransport1()->SetWritable(false); }); |
1475 EXPECT_TRUE(SendRtp2()); | 1445 SendRtp1(); |
| 1446 SendRtp2(); |
| 1447 WaitForThreads(); |
1476 EXPECT_TRUE(CheckRtp1()); | 1448 EXPECT_TRUE(CheckRtp1()); |
1477 EXPECT_TRUE(CheckNoRtp2()); | 1449 EXPECT_TRUE(CheckNoRtp2()); |
1478 | 1450 |
1479 // Regain writability | 1451 // Regain writability |
1480 GetTransport1()->SetWritable(true); | 1452 network_thread_->Invoke<void>( |
| 1453 [this] { GetTransport1()->SetWritable(true); }); |
1481 EXPECT_TRUE(media_channel1_->sending()); | 1454 EXPECT_TRUE(media_channel1_->sending()); |
1482 EXPECT_TRUE(SendRtp1()); | 1455 SendRtp1(); |
1483 EXPECT_TRUE(SendRtp2()); | 1456 SendRtp2(); |
| 1457 WaitForThreads(); |
1484 EXPECT_TRUE(CheckRtp1()); | 1458 EXPECT_TRUE(CheckRtp1()); |
1485 EXPECT_TRUE(CheckRtp2()); | 1459 EXPECT_TRUE(CheckRtp2()); |
1486 EXPECT_TRUE(CheckNoRtp1()); | 1460 EXPECT_TRUE(CheckNoRtp1()); |
1487 EXPECT_TRUE(CheckNoRtp2()); | 1461 EXPECT_TRUE(CheckNoRtp2()); |
1488 | 1462 |
1489 // Lose writability completely | 1463 // Lose writability completely |
1490 GetTransport1()->SetDestination(NULL); | 1464 network_thread_->Invoke<void>( |
| 1465 [this] { GetTransport1()->SetDestination(NULL); }); |
1491 EXPECT_TRUE(media_channel1_->sending()); | 1466 EXPECT_TRUE(media_channel1_->sending()); |
1492 | 1467 |
1493 // Should fail also. | 1468 // Should fail also. |
1494 EXPECT_FALSE(SendRtp1()); | 1469 SendRtp1(); |
1495 EXPECT_TRUE(SendRtp2()); | 1470 SendRtp2(); |
| 1471 WaitForThreads(); |
1496 EXPECT_TRUE(CheckRtp1()); | 1472 EXPECT_TRUE(CheckRtp1()); |
1497 EXPECT_TRUE(CheckNoRtp2()); | 1473 EXPECT_TRUE(CheckNoRtp2()); |
1498 | 1474 |
1499 // Gain writability back | 1475 // Gain writability back |
1500 GetTransport1()->SetDestination(GetTransport2()); | 1476 network_thread_->Invoke<void>( |
| 1477 [this] { GetTransport1()->SetDestination(GetTransport2()); }); |
1501 EXPECT_TRUE(media_channel1_->sending()); | 1478 EXPECT_TRUE(media_channel1_->sending()); |
1502 EXPECT_TRUE(SendRtp1()); | 1479 SendRtp1(); |
1503 EXPECT_TRUE(SendRtp2()); | 1480 SendRtp2(); |
| 1481 WaitForThreads(); |
1504 EXPECT_TRUE(CheckRtp1()); | 1482 EXPECT_TRUE(CheckRtp1()); |
1505 EXPECT_TRUE(CheckRtp2()); | 1483 EXPECT_TRUE(CheckRtp2()); |
1506 EXPECT_TRUE(CheckNoRtp1()); | 1484 EXPECT_TRUE(CheckNoRtp1()); |
1507 EXPECT_TRUE(CheckNoRtp2()); | 1485 EXPECT_TRUE(CheckNoRtp2()); |
1508 } | 1486 } |
1509 | 1487 |
1510 void SendBundleToBundle( | 1488 void SendBundleToBundle( |
1511 const int* pl_types, int len, bool rtcp_mux, bool secure) { | 1489 const int* pl_types, int len, bool rtcp_mux, bool secure) { |
1512 ASSERT_EQ(2, len); | 1490 ASSERT_EQ(2, len); |
1513 int sequence_number1_1 = 0, sequence_number2_2 = 0; | 1491 int sequence_number1_1 = 0, sequence_number2_2 = 0; |
(...skipping 16 matching lines...) Expand all Loading... |
1530 EXPECT_EQ(expected_channels, GetTransport2()->channels().size()); | 1508 EXPECT_EQ(expected_channels, GetTransport2()->channels().size()); |
1531 EXPECT_TRUE(SendAccept()); | 1509 EXPECT_TRUE(SendAccept()); |
1532 EXPECT_EQ(expected_channels, GetTransport1()->channels().size()); | 1510 EXPECT_EQ(expected_channels, GetTransport1()->channels().size()); |
1533 EXPECT_EQ(expected_channels, GetTransport2()->channels().size()); | 1511 EXPECT_EQ(expected_channels, GetTransport2()->channels().size()); |
1534 EXPECT_TRUE(channel1_->bundle_filter()->FindPayloadType(pl_type1)); | 1512 EXPECT_TRUE(channel1_->bundle_filter()->FindPayloadType(pl_type1)); |
1535 EXPECT_TRUE(channel2_->bundle_filter()->FindPayloadType(pl_type1)); | 1513 EXPECT_TRUE(channel2_->bundle_filter()->FindPayloadType(pl_type1)); |
1536 EXPECT_FALSE(channel1_->bundle_filter()->FindPayloadType(pl_type2)); | 1514 EXPECT_FALSE(channel1_->bundle_filter()->FindPayloadType(pl_type2)); |
1537 EXPECT_FALSE(channel2_->bundle_filter()->FindPayloadType(pl_type2)); | 1515 EXPECT_FALSE(channel2_->bundle_filter()->FindPayloadType(pl_type2)); |
1538 | 1516 |
1539 // Both channels can receive pl_type1 only. | 1517 // Both channels can receive pl_type1 only. |
1540 EXPECT_TRUE(SendCustomRtp1(kSsrc1, ++sequence_number1_1, pl_type1)); | 1518 SendCustomRtp1(kSsrc1, ++sequence_number1_1, pl_type1); |
| 1519 SendCustomRtp2(kSsrc2, ++sequence_number2_2, pl_type1); |
| 1520 WaitForThreads(); |
1541 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1, pl_type1)); | 1521 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1, pl_type1)); |
1542 EXPECT_TRUE(SendCustomRtp2(kSsrc2, ++sequence_number2_2, pl_type1)); | |
1543 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2, pl_type1)); | 1522 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2, pl_type1)); |
1544 EXPECT_TRUE(CheckNoRtp1()); | 1523 EXPECT_TRUE(CheckNoRtp1()); |
1545 EXPECT_TRUE(CheckNoRtp2()); | 1524 EXPECT_TRUE(CheckNoRtp2()); |
1546 | 1525 |
1547 // RTCP test | 1526 // RTCP test |
1548 EXPECT_TRUE(SendCustomRtp1(kSsrc1, ++sequence_number1_1, pl_type2)); | 1527 SendCustomRtp1(kSsrc1, ++sequence_number1_1, pl_type2); |
| 1528 SendCustomRtp2(kSsrc2, ++sequence_number2_2, pl_type2); |
| 1529 WaitForThreads(); |
1549 EXPECT_FALSE(CheckCustomRtp2(kSsrc1, sequence_number1_1, pl_type2)); | 1530 EXPECT_FALSE(CheckCustomRtp2(kSsrc1, sequence_number1_1, pl_type2)); |
1550 EXPECT_TRUE(SendCustomRtp2(kSsrc2, ++sequence_number2_2, pl_type2)); | |
1551 EXPECT_FALSE(CheckCustomRtp1(kSsrc2, sequence_number2_2, pl_type2)); | 1531 EXPECT_FALSE(CheckCustomRtp1(kSsrc2, sequence_number2_2, pl_type2)); |
1552 | 1532 |
1553 EXPECT_TRUE(SendCustomRtcp1(kSsrc1)); | 1533 SendCustomRtcp1(kSsrc1); |
1554 EXPECT_TRUE(SendCustomRtcp2(kSsrc2)); | 1534 SendCustomRtcp2(kSsrc2); |
| 1535 WaitForThreads(); |
1555 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2)); | 1536 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2)); |
1556 EXPECT_TRUE(CheckNoRtcp1()); | 1537 EXPECT_TRUE(CheckNoRtcp1()); |
1557 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1)); | 1538 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1)); |
1558 EXPECT_TRUE(CheckNoRtcp2()); | 1539 EXPECT_TRUE(CheckNoRtcp2()); |
1559 | 1540 |
1560 EXPECT_TRUE(SendCustomRtcp1(kSsrc2)); | 1541 SendCustomRtcp1(kSsrc2); |
1561 EXPECT_TRUE(SendCustomRtcp2(kSsrc1)); | 1542 SendCustomRtcp2(kSsrc1); |
| 1543 WaitForThreads(); |
1562 // Bundle filter shouldn't filter out any RTCP. | 1544 // Bundle filter shouldn't filter out any RTCP. |
1563 EXPECT_TRUE(CheckCustomRtcp1(kSsrc1)); | 1545 EXPECT_TRUE(CheckCustomRtcp1(kSsrc1)); |
1564 EXPECT_TRUE(CheckCustomRtcp2(kSsrc2)); | 1546 EXPECT_TRUE(CheckCustomRtcp2(kSsrc2)); |
1565 } | 1547 } |
1566 | 1548 |
1567 // Test that the media monitor can be run and gives timely callbacks. | 1549 // Test that the media monitor can be run and gives timely callbacks. |
1568 void TestMediaMonitor() { | 1550 void TestMediaMonitor() { |
1569 static const int kTimeout = 500; | 1551 static const int kTimeout = 500; |
1570 CreateChannels(0, 0); | 1552 CreateChannels(0, 0); |
1571 EXPECT_TRUE(SendInitiate()); | 1553 EXPECT_TRUE(SendInitiate()); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1697 std::unique_ptr<cricket::SessionDescription> sdesc3( | 1679 std::unique_ptr<cricket::SessionDescription> sdesc3( |
1698 CreateSessionDescriptionWithStream(3)); | 1680 CreateSessionDescriptionWithStream(3)); |
1699 EXPECT_TRUE(channel1_->PushdownRemoteDescription( | 1681 EXPECT_TRUE(channel1_->PushdownRemoteDescription( |
1700 sdesc3.get(), cricket::CA_ANSWER, &err)); | 1682 sdesc3.get(), cricket::CA_ANSWER, &err)); |
1701 EXPECT_TRUE(media_channel1_->HasSendStream(1)); | 1683 EXPECT_TRUE(media_channel1_->HasSendStream(1)); |
1702 EXPECT_FALSE(media_channel1_->HasRecvStream(2)); | 1684 EXPECT_FALSE(media_channel1_->HasRecvStream(2)); |
1703 EXPECT_TRUE(media_channel1_->HasRecvStream(3)); | 1685 EXPECT_TRUE(media_channel1_->HasRecvStream(3)); |
1704 } | 1686 } |
1705 | 1687 |
1706 void TestFlushRtcp() { | 1688 void TestFlushRtcp() { |
1707 bool send_rtcp1; | |
1708 CreateChannels(RTCP, RTCP); | 1689 CreateChannels(RTCP, RTCP); |
1709 EXPECT_TRUE(SendInitiate()); | 1690 EXPECT_TRUE(SendInitiate()); |
1710 EXPECT_TRUE(SendAccept()); | 1691 EXPECT_TRUE(SendAccept()); |
1711 ASSERT_TRUE(GetTransport1()); | 1692 ASSERT_TRUE(GetTransport1()); |
1712 ASSERT_TRUE(GetTransport2()); | 1693 ASSERT_TRUE(GetTransport2()); |
1713 EXPECT_EQ(2U, GetTransport1()->channels().size()); | 1694 EXPECT_EQ(2U, GetTransport1()->channels().size()); |
1714 EXPECT_EQ(2U, GetTransport2()->channels().size()); | 1695 EXPECT_EQ(2U, GetTransport2()->channels().size()); |
1715 | 1696 |
1716 // Send RTCP1 from a different thread. | 1697 // Send RTCP1 from a different thread. |
1717 CallOnThreadAndWaitForDone(&ChannelTest<T>::SendRtcp1, &send_rtcp1); | 1698 ScopedCallThread send_rtcp([this] { SendRtcp1(); }); |
1718 EXPECT_TRUE(send_rtcp1); | |
1719 // The sending message is only posted. channel2_ should be empty. | 1699 // The sending message is only posted. channel2_ should be empty. |
1720 EXPECT_TRUE(CheckNoRtcp2()); | 1700 EXPECT_TRUE(CheckNoRtcp2()); |
| 1701 rtc::Thread* wait_for[] = {send_rtcp.thread()}; |
| 1702 WaitForThreads(wait_for); // Ensure rtcp was posted |
1721 | 1703 |
1722 // When channel1_ is deleted, the RTCP packet should be sent out to | 1704 // When channel1_ is deleted, the RTCP packet should be sent out to |
1723 // channel2_. | 1705 // channel2_. |
1724 channel1_.reset(); | 1706 channel1_.reset(); |
| 1707 WaitForThreads(); |
1725 EXPECT_TRUE(CheckRtcp2()); | 1708 EXPECT_TRUE(CheckRtcp2()); |
1726 } | 1709 } |
1727 | 1710 |
1728 void TestSrtpError(int pl_type) { | 1711 void TestSrtpError(int pl_type) { |
1729 struct SrtpErrorHandler : public sigslot::has_slots<> { | 1712 struct SrtpErrorHandler : public sigslot::has_slots<> { |
1730 SrtpErrorHandler() : | 1713 SrtpErrorHandler() : |
1731 mode_(cricket::SrtpFilter::UNPROTECT), | 1714 mode_(cricket::SrtpFilter::UNPROTECT), |
1732 error_(cricket::SrtpFilter::ERROR_NONE) {} | 1715 error_(cricket::SrtpFilter::ERROR_NONE) {} |
1733 void OnSrtpError(uint32 ssrc, cricket::SrtpFilter::Mode mode, | 1716 void OnSrtpError(uint32 ssrc, cricket::SrtpFilter::Mode mode, |
1734 cricket::SrtpFilter::Error error) { | 1717 cricket::SrtpFilter::Error error) { |
1735 mode_ = mode; | 1718 mode_ = mode; |
1736 error_ = error; | 1719 error_ = error; |
1737 } | 1720 } |
1738 cricket::SrtpFilter::Mode mode_; | 1721 cricket::SrtpFilter::Mode mode_; |
1739 cricket::SrtpFilter::Error error_; | 1722 cricket::SrtpFilter::Error error_; |
1740 } error_handler; | 1723 } error_handler; |
1741 | 1724 |
1742 // For Audio, only pl_type 0 is added to the bundle filter. | 1725 // For Audio, only pl_type 0 is added to the bundle filter. |
1743 // For Video, only pl_type 97 is added to the bundle filter. | 1726 // For Video, only pl_type 97 is added to the bundle filter. |
1744 // So we need to pass in pl_type so that the packet can pass through | 1727 // So we need to pass in pl_type so that the packet can pass through |
1745 // the bundle filter before it can be processed by the srtp filter. | 1728 // the bundle filter before it can be processed by the srtp filter. |
1746 // The packet is not a valid srtp packet because it is too short. | 1729 // The packet is not a valid srtp packet because it is too short. |
1747 unsigned const char kBadPacket[] = {0x84, | 1730 static unsigned const char kBadPacket[] = { |
1748 static_cast<unsigned char>(pl_type), | 1731 0x84, static_cast<unsigned char>(pl_type), |
1749 0x00, | 1732 0x00, 0x01, |
1750 0x01, | 1733 0x00, 0x00, |
1751 0x00, | 1734 0x00, 0x00, |
1752 0x00, | 1735 0x00, 0x00, |
1753 0x00, | 1736 0x00, 0x01}; |
1754 0x00, | |
1755 0x00, | |
1756 0x00, | |
1757 0x00, | |
1758 0x01}; | |
1759 CreateChannels(RTCP | SECURE, RTCP | SECURE); | 1737 CreateChannels(RTCP | SECURE, RTCP | SECURE); |
1760 EXPECT_FALSE(channel1_->secure()); | 1738 EXPECT_FALSE(channel1_->secure()); |
1761 EXPECT_FALSE(channel2_->secure()); | 1739 EXPECT_FALSE(channel2_->secure()); |
1762 EXPECT_TRUE(SendInitiate()); | 1740 EXPECT_TRUE(SendInitiate()); |
1763 EXPECT_TRUE(SendAccept()); | 1741 EXPECT_TRUE(SendAccept()); |
1764 EXPECT_TRUE(channel1_->secure()); | 1742 EXPECT_TRUE(channel1_->secure()); |
1765 EXPECT_TRUE(channel2_->secure()); | 1743 EXPECT_TRUE(channel2_->secure()); |
1766 channel2_->srtp_filter()->set_signal_silent_time(250); | 1744 channel2_->srtp_filter()->set_signal_silent_time(250); |
1767 channel2_->srtp_filter()->SignalSrtpError.connect( | 1745 channel2_->srtp_filter()->SignalSrtpError.connect( |
1768 &error_handler, &SrtpErrorHandler::OnSrtpError); | 1746 &error_handler, &SrtpErrorHandler::OnSrtpError); |
1769 | 1747 |
1770 // Testing failures in sending packets. | 1748 // Testing failures in sending packets. |
1771 EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket), | 1749 media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket), |
1772 rtc::PacketOptions())); | 1750 rtc::PacketOptions()); |
| 1751 WaitForThreads(); |
1773 // The first failure will trigger an error. | 1752 // The first failure will trigger an error. |
1774 EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500); | 1753 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_); |
1775 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_); | 1754 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_); |
1776 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE; | 1755 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE; |
1777 error_handler.mode_ = cricket::SrtpFilter::UNPROTECT; | 1756 error_handler.mode_ = cricket::SrtpFilter::UNPROTECT; |
1778 // The next 250 ms failures will not trigger an error. | 1757 // The next 250 ms failures will not trigger an error. |
1779 EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket), | 1758 media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket), |
1780 rtc::PacketOptions())); | 1759 rtc::PacketOptions()); |
1781 // Wait for a while to ensure no message comes in. | 1760 // Wait for a while to ensure no message comes in. |
| 1761 WaitForThreads(); |
1782 rtc::Thread::Current()->ProcessMessages(200); | 1762 rtc::Thread::Current()->ProcessMessages(200); |
1783 EXPECT_EQ(cricket::SrtpFilter::ERROR_NONE, error_handler.error_); | 1763 EXPECT_EQ(cricket::SrtpFilter::ERROR_NONE, error_handler.error_); |
1784 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_); | 1764 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_); |
1785 // Wait for a little more - the error will be triggered again. | 1765 // Wait for a little more - the error will be triggered again. |
1786 rtc::Thread::Current()->ProcessMessages(200); | 1766 rtc::Thread::Current()->ProcessMessages(200); |
1787 EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket), | 1767 media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket), |
1788 rtc::PacketOptions())); | 1768 rtc::PacketOptions()); |
1789 EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500); | 1769 WaitForThreads(); |
| 1770 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_); |
1790 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_); | 1771 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_); |
1791 | 1772 |
1792 // Testing failures in receiving packets. | 1773 // Testing failures in receiving packets. |
1793 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE; | 1774 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE; |
1794 error_handler.mode_ = cricket::SrtpFilter::UNPROTECT; | 1775 error_handler.mode_ = cricket::SrtpFilter::UNPROTECT; |
1795 | 1776 |
1796 cricket::TransportChannel* transport_channel = | 1777 network_thread_->Invoke<void>([this] { |
1797 channel2_->transport_channel(); | 1778 cricket::TransportChannel* transport_channel = |
1798 transport_channel->SignalReadPacket( | 1779 channel2_->transport_channel(); |
1799 transport_channel, reinterpret_cast<const char*>(kBadPacket), | 1780 transport_channel->SignalReadPacket( |
1800 sizeof(kBadPacket), rtc::PacketTime(), 0); | 1781 transport_channel, reinterpret_cast<const char*>(kBadPacket), |
1801 EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500); | 1782 sizeof(kBadPacket), rtc::PacketTime(), 0); |
| 1783 }); |
| 1784 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_); |
1802 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_); | 1785 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_); |
1803 } | 1786 } |
1804 | 1787 |
1805 void TestOnReadyToSend() { | 1788 void TestOnReadyToSend() { |
1806 CreateChannels(RTCP, RTCP); | 1789 CreateChannels(RTCP, RTCP); |
1807 TransportChannel* rtp = channel1_->transport_channel(); | 1790 TransportChannel* rtp = channel1_->transport_channel(); |
1808 TransportChannel* rtcp = channel1_->rtcp_transport_channel(); | 1791 TransportChannel* rtcp = channel1_->rtcp_transport_channel(); |
1809 EXPECT_FALSE(media_channel1_->ready_to_send()); | 1792 EXPECT_FALSE(media_channel1_->ready_to_send()); |
1810 rtp->SignalReadyToSend(rtp); | 1793 |
| 1794 network_thread_->Invoke<void>([rtp] { rtp->SignalReadyToSend(rtp); }); |
| 1795 WaitForThreads(); |
1811 EXPECT_FALSE(media_channel1_->ready_to_send()); | 1796 EXPECT_FALSE(media_channel1_->ready_to_send()); |
1812 rtcp->SignalReadyToSend(rtcp); | 1797 |
| 1798 network_thread_->Invoke<void>([rtcp] { rtcp->SignalReadyToSend(rtcp); }); |
| 1799 WaitForThreads(); |
1813 // MediaChannel::OnReadyToSend only be called when both rtp and rtcp | 1800 // MediaChannel::OnReadyToSend only be called when both rtp and rtcp |
1814 // channel are ready to send. | 1801 // channel are ready to send. |
1815 EXPECT_TRUE(media_channel1_->ready_to_send()); | 1802 EXPECT_TRUE(media_channel1_->ready_to_send()); |
1816 | 1803 |
1817 // rtp channel becomes not ready to send will be propagated to mediachannel | 1804 // rtp channel becomes not ready to send will be propagated to mediachannel |
1818 channel1_->SetReadyToSend(false, false); | 1805 network_thread_->Invoke<void>( |
| 1806 [this] { channel1_->SetReadyToSend(false, false); }); |
| 1807 WaitForThreads(); |
1819 EXPECT_FALSE(media_channel1_->ready_to_send()); | 1808 EXPECT_FALSE(media_channel1_->ready_to_send()); |
1820 channel1_->SetReadyToSend(false, true); | 1809 |
| 1810 network_thread_->Invoke<void>( |
| 1811 [this] { channel1_->SetReadyToSend(false, true); }); |
| 1812 WaitForThreads(); |
1821 EXPECT_TRUE(media_channel1_->ready_to_send()); | 1813 EXPECT_TRUE(media_channel1_->ready_to_send()); |
1822 | 1814 |
1823 // rtcp channel becomes not ready to send will be propagated to mediachannel | 1815 // rtcp channel becomes not ready to send will be propagated to mediachannel |
1824 channel1_->SetReadyToSend(true, false); | 1816 network_thread_->Invoke<void>( |
| 1817 [this] { channel1_->SetReadyToSend(true, false); }); |
| 1818 WaitForThreads(); |
1825 EXPECT_FALSE(media_channel1_->ready_to_send()); | 1819 EXPECT_FALSE(media_channel1_->ready_to_send()); |
1826 channel1_->SetReadyToSend(true, true); | 1820 |
| 1821 network_thread_->Invoke<void>( |
| 1822 [this] { channel1_->SetReadyToSend(true, true); }); |
| 1823 WaitForThreads(); |
1827 EXPECT_TRUE(media_channel1_->ready_to_send()); | 1824 EXPECT_TRUE(media_channel1_->ready_to_send()); |
1828 } | 1825 } |
1829 | 1826 |
1830 void TestOnReadyToSendWithRtcpMux() { | 1827 void TestOnReadyToSendWithRtcpMux() { |
1831 CreateChannels(RTCP, RTCP); | 1828 CreateChannels(RTCP, RTCP); |
1832 typename T::Content content; | 1829 typename T::Content content; |
1833 CreateContent(0, kPcmuCodec, kH264Codec, &content); | 1830 CreateContent(0, kPcmuCodec, kH264Codec, &content); |
1834 // Both sides agree on mux. Should no longer be a separate RTCP channel. | 1831 // Both sides agree on mux. Should no longer be a separate RTCP channel. |
1835 content.set_rtcp_mux(true); | 1832 content.set_rtcp_mux(true); |
1836 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); | 1833 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); |
1837 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); | 1834 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); |
1838 EXPECT_TRUE(channel1_->rtcp_transport_channel() == NULL); | 1835 EXPECT_TRUE(channel1_->rtcp_transport_channel() == NULL); |
1839 TransportChannel* rtp = channel1_->transport_channel(); | 1836 TransportChannel* rtp = channel1_->transport_channel(); |
1840 EXPECT_FALSE(media_channel1_->ready_to_send()); | 1837 EXPECT_FALSE(media_channel1_->ready_to_send()); |
1841 // In the case of rtcp mux, the SignalReadyToSend() from rtp channel | 1838 // In the case of rtcp mux, the SignalReadyToSend() from rtp channel |
1842 // should trigger the MediaChannel's OnReadyToSend. | 1839 // should trigger the MediaChannel's OnReadyToSend. |
1843 rtp->SignalReadyToSend(rtp); | 1840 network_thread_->Invoke<void>([rtp] { rtp->SignalReadyToSend(rtp); }); |
| 1841 WaitForThreads(); |
1844 EXPECT_TRUE(media_channel1_->ready_to_send()); | 1842 EXPECT_TRUE(media_channel1_->ready_to_send()); |
1845 channel1_->SetReadyToSend(false, false); | 1843 |
| 1844 network_thread_->Invoke<void>( |
| 1845 [this] { channel1_->SetReadyToSend(false, false); }); |
| 1846 WaitForThreads(); |
1846 EXPECT_FALSE(media_channel1_->ready_to_send()); | 1847 EXPECT_FALSE(media_channel1_->ready_to_send()); |
1847 } | 1848 } |
1848 | 1849 |
1849 bool SetRemoteContentWithBitrateLimit(int remote_limit) { | 1850 bool SetRemoteContentWithBitrateLimit(int remote_limit) { |
1850 typename T::Content content; | 1851 typename T::Content content; |
1851 CreateContent(0, kPcmuCodec, kH264Codec, &content); | 1852 CreateContent(0, kPcmuCodec, kH264Codec, &content); |
1852 content.set_bandwidth(remote_limit); | 1853 content.set_bandwidth(remote_limit); |
1853 return channel1_->SetRemoteContent(&content, CA_OFFER, NULL); | 1854 return channel1_->SetRemoteContent(&content, CA_OFFER, NULL); |
1854 } | 1855 } |
1855 | 1856 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1887 EXPECT_EQ(-1, media_channel1_->max_bps()); | 1888 EXPECT_EQ(-1, media_channel1_->max_bps()); |
1888 | 1889 |
1889 EXPECT_TRUE( | 1890 EXPECT_TRUE( |
1890 channel1_->SetRtpParameters(kSsrc1, BitrateLimitedParameters(-1))); | 1891 channel1_->SetRtpParameters(kSsrc1, BitrateLimitedParameters(-1))); |
1891 VerifyMaxBitrate(channel1_->GetRtpParameters(kSsrc1), -1); | 1892 VerifyMaxBitrate(channel1_->GetRtpParameters(kSsrc1), -1); |
1892 VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), -1); | 1893 VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), -1); |
1893 EXPECT_EQ(-1, media_channel1_->max_bps()); | 1894 EXPECT_EQ(-1, media_channel1_->max_bps()); |
1894 } | 1895 } |
1895 | 1896 |
1896 protected: | 1897 protected: |
| 1898 void WaitForThreads() { WaitForThreads(rtc::ArrayView<rtc::Thread*>()); } |
| 1899 static void ProcessThreadQueue(rtc::Thread* thread) { |
| 1900 RTC_DCHECK(thread->IsCurrent()); |
| 1901 while (!thread->empty()) { |
| 1902 thread->ProcessMessages(0); |
| 1903 } |
| 1904 } |
| 1905 void WaitForThreads(rtc::ArrayView<rtc::Thread*> threads) { |
| 1906 // |threads| and current thread post packets to network thread. |
| 1907 for (rtc::Thread* thread : threads) { |
| 1908 thread->Invoke<void>([thread] { ProcessThreadQueue(thread); }); |
| 1909 } |
| 1910 ProcessThreadQueue(rtc::Thread::Current()); |
| 1911 // Network thread move them around and post back to worker = current thread. |
| 1912 if (!network_thread_->IsCurrent()) { |
| 1913 network_thread_->Invoke<void>( |
| 1914 [this] { ProcessThreadQueue(network_thread_); }); |
| 1915 } |
| 1916 // Worker thread = current Thread process received messages. |
| 1917 ProcessThreadQueue(rtc::Thread::Current()); |
| 1918 } |
1897 // TODO(pbos): Remove playout from all media channels and let renderers mute | 1919 // TODO(pbos): Remove playout from all media channels and let renderers mute |
1898 // themselves. | 1920 // themselves. |
1899 const bool verify_playout_; | 1921 const bool verify_playout_; |
1900 cricket::FakeTransportController transport_controller1_; | 1922 std::unique_ptr<rtc::Thread> network_thread_keeper_; |
1901 cricket::FakeTransportController transport_controller2_; | 1923 rtc::Thread* network_thread_; |
| 1924 std::unique_ptr<cricket::FakeTransportController> transport_controller1_; |
| 1925 std::unique_ptr<cricket::FakeTransportController> transport_controller2_; |
1902 cricket::FakeMediaEngine media_engine_; | 1926 cricket::FakeMediaEngine media_engine_; |
1903 // The media channels are owned by the voice channel objects below. | 1927 // The media channels are owned by the voice channel objects below. |
1904 typename T::MediaChannel* media_channel1_; | 1928 typename T::MediaChannel* media_channel1_; |
1905 typename T::MediaChannel* media_channel2_; | 1929 typename T::MediaChannel* media_channel2_; |
1906 std::unique_ptr<typename T::Channel> channel1_; | 1930 std::unique_ptr<typename T::Channel> channel1_; |
1907 std::unique_ptr<typename T::Channel> channel2_; | 1931 std::unique_ptr<typename T::Channel> channel2_; |
1908 typename T::Content local_media_content1_; | 1932 typename T::Content local_media_content1_; |
1909 typename T::Content local_media_content2_; | 1933 typename T::Content local_media_content2_; |
1910 typename T::Content remote_media_content1_; | 1934 typename T::Content remote_media_content1_; |
1911 typename T::Content remote_media_content2_; | 1935 typename T::Content remote_media_content2_; |
1912 // The RTP and RTCP packets to send in the tests. | 1936 // The RTP and RTCP packets to send in the tests. |
1913 std::string rtp_packet_; | 1937 rtc::Buffer rtp_packet_; |
1914 std::string rtcp_packet_; | 1938 rtc::Buffer rtcp_packet_; |
1915 int media_info_callbacks1_; | 1939 int media_info_callbacks1_; |
1916 int media_info_callbacks2_; | 1940 int media_info_callbacks2_; |
1917 cricket::CandidatePairInterface* last_selected_candidate_pair_; | 1941 cricket::CandidatePairInterface* last_selected_candidate_pair_; |
1918 }; | 1942 }; |
1919 | 1943 |
1920 template<> | 1944 template<> |
1921 void ChannelTest<VoiceTraits>::CreateContent( | 1945 void ChannelTest<VoiceTraits>::CreateContent( |
1922 int flags, | 1946 int flags, |
1923 const cricket::AudioCodec& audio_codec, | 1947 const cricket::AudioCodec& audio_codec, |
1924 const cricket::VideoCodec& video_codec, | 1948 const cricket::VideoCodec& video_codec, |
(...skipping 22 matching lines...) Expand all Loading... |
1947 } | 1971 } |
1948 | 1972 |
1949 template <> | 1973 template <> |
1950 void ChannelTest<VoiceTraits>::AddLegacyStreamInContent( | 1974 void ChannelTest<VoiceTraits>::AddLegacyStreamInContent( |
1951 uint32_t ssrc, | 1975 uint32_t ssrc, |
1952 int flags, | 1976 int flags, |
1953 cricket::AudioContentDescription* audio) { | 1977 cricket::AudioContentDescription* audio) { |
1954 audio->AddLegacyStream(ssrc); | 1978 audio->AddLegacyStream(ssrc); |
1955 } | 1979 } |
1956 | 1980 |
1957 class VoiceChannelTest | 1981 class VoiceChannelSingleThreadTest : public ChannelTest<VoiceTraits> { |
1958 : public ChannelTest<VoiceTraits> { | |
1959 public: | 1982 public: |
1960 typedef ChannelTest<VoiceTraits> Base; | 1983 typedef ChannelTest<VoiceTraits> Base; |
1961 VoiceChannelTest() | 1984 VoiceChannelSingleThreadTest() |
1962 : Base(true, | 1985 : Base(true, kPcmuFrame, kRtcpReport, NetworkIsWorker::Yes) {} |
1963 kPcmuFrame, | 1986 }; |
1964 sizeof(kPcmuFrame), | 1987 |
1965 kRtcpReport, | 1988 class VoiceChannelDoubleThreadTest : public ChannelTest<VoiceTraits> { |
1966 sizeof(kRtcpReport)) {} | 1989 public: |
| 1990 typedef ChannelTest<VoiceTraits> Base; |
| 1991 VoiceChannelDoubleThreadTest() |
| 1992 : Base(true, kPcmuFrame, kRtcpReport, NetworkIsWorker::No) {} |
1967 }; | 1993 }; |
1968 | 1994 |
1969 // override to add NULL parameter | 1995 // override to add NULL parameter |
1970 template <> | 1996 template <> |
1971 cricket::VideoChannel* ChannelTest<VideoTraits>::CreateChannel( | 1997 cricket::VideoChannel* ChannelTest<VideoTraits>::CreateChannel( |
1972 rtc::Thread* thread, | 1998 rtc::Thread* worker_thread, |
| 1999 rtc::Thread* network_thread, |
1973 cricket::MediaEngineInterface* engine, | 2000 cricket::MediaEngineInterface* engine, |
1974 cricket::FakeVideoMediaChannel* ch, | 2001 cricket::FakeVideoMediaChannel* ch, |
1975 cricket::TransportController* transport_controller, | 2002 cricket::TransportController* transport_controller, |
1976 bool rtcp) { | 2003 bool rtcp) { |
1977 cricket::VideoChannel* channel = new cricket::VideoChannel( | 2004 cricket::VideoChannel* channel = |
1978 thread, ch, transport_controller, cricket::CN_VIDEO, rtcp); | 2005 new cricket::VideoChannel(worker_thread, network_thread, ch, |
| 2006 transport_controller, cricket::CN_VIDEO, rtcp); |
1979 if (!channel->Init()) { | 2007 if (!channel->Init()) { |
1980 delete channel; | 2008 delete channel; |
1981 channel = NULL; | 2009 channel = NULL; |
1982 } | 2010 } |
1983 return channel; | 2011 return channel; |
1984 } | 2012 } |
1985 | 2013 |
1986 // override to add 0 parameter | 2014 // override to add 0 parameter |
1987 template<> | 2015 template<> |
1988 bool ChannelTest<VideoTraits>::AddStream1(int id) { | 2016 bool ChannelTest<VideoTraits>::AddStream1(int id) { |
(...skipping 30 matching lines...) Expand all Loading... |
2019 } | 2047 } |
2020 | 2048 |
2021 template <> | 2049 template <> |
2022 void ChannelTest<VideoTraits>::AddLegacyStreamInContent( | 2050 void ChannelTest<VideoTraits>::AddLegacyStreamInContent( |
2023 uint32_t ssrc, | 2051 uint32_t ssrc, |
2024 int flags, | 2052 int flags, |
2025 cricket::VideoContentDescription* video) { | 2053 cricket::VideoContentDescription* video) { |
2026 video->AddLegacyStream(ssrc); | 2054 video->AddLegacyStream(ssrc); |
2027 } | 2055 } |
2028 | 2056 |
2029 class VideoChannelTest | 2057 class VideoChannelSingleThreadTest : public ChannelTest<VideoTraits> { |
2030 : public ChannelTest<VideoTraits> { | |
2031 public: | 2058 public: |
2032 typedef ChannelTest<VideoTraits> Base; | 2059 typedef ChannelTest<VideoTraits> Base; |
2033 VideoChannelTest() | 2060 VideoChannelSingleThreadTest() |
2034 : Base(false, | 2061 : Base(false, kH264Packet, kRtcpReport, NetworkIsWorker::Yes) {} |
2035 kH264Packet, | |
2036 sizeof(kH264Packet), | |
2037 kRtcpReport, | |
2038 sizeof(kRtcpReport)) {} | |
2039 }; | 2062 }; |
2040 | 2063 |
| 2064 class VideoChannelDoubleThreadTest : public ChannelTest<VideoTraits> { |
| 2065 public: |
| 2066 typedef ChannelTest<VideoTraits> Base; |
| 2067 VideoChannelDoubleThreadTest() |
| 2068 : Base(false, kH264Packet, kRtcpReport, NetworkIsWorker::No) {} |
| 2069 }; |
2041 | 2070 |
2042 // VoiceChannelTest | 2071 // VoiceChannelSingleThreadTest |
2043 TEST_F(VoiceChannelTest, TestInit) { | 2072 TEST_F(VoiceChannelSingleThreadTest, TestInit) { |
2044 Base::TestInit(); | 2073 Base::TestInit(); |
2045 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); | 2074 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); |
2046 EXPECT_TRUE(media_channel1_->dtmf_info_queue().empty()); | 2075 EXPECT_TRUE(media_channel1_->dtmf_info_queue().empty()); |
2047 } | 2076 } |
2048 | 2077 |
2049 TEST_F(VoiceChannelTest, TestSetContents) { | 2078 TEST_F(VoiceChannelSingleThreadTest, TestSetContents) { |
2050 Base::TestSetContents(); | 2079 Base::TestSetContents(); |
2051 } | 2080 } |
2052 | 2081 |
2053 TEST_F(VoiceChannelTest, TestSetContentsNullOffer) { | 2082 TEST_F(VoiceChannelSingleThreadTest, TestSetContentsNullOffer) { |
2054 Base::TestSetContentsNullOffer(); | 2083 Base::TestSetContentsNullOffer(); |
2055 } | 2084 } |
2056 | 2085 |
2057 TEST_F(VoiceChannelTest, TestSetContentsRtcpMux) { | 2086 TEST_F(VoiceChannelSingleThreadTest, TestSetContentsRtcpMux) { |
2058 Base::TestSetContentsRtcpMux(); | 2087 Base::TestSetContentsRtcpMux(); |
2059 } | 2088 } |
2060 | 2089 |
2061 TEST_F(VoiceChannelTest, TestSetContentsRtcpMuxWithPrAnswer) { | 2090 TEST_F(VoiceChannelSingleThreadTest, TestSetContentsRtcpMuxWithPrAnswer) { |
2062 Base::TestSetContentsRtcpMux(); | 2091 Base::TestSetContentsRtcpMux(); |
2063 } | 2092 } |
2064 | 2093 |
2065 TEST_F(VoiceChannelTest, TestSetRemoteContentUpdate) { | 2094 TEST_F(VoiceChannelSingleThreadTest, TestSetRemoteContentUpdate) { |
2066 Base::TestSetRemoteContentUpdate(); | 2095 Base::TestSetRemoteContentUpdate(); |
2067 } | 2096 } |
2068 | 2097 |
2069 TEST_F(VoiceChannelTest, TestStreams) { | 2098 TEST_F(VoiceChannelSingleThreadTest, TestStreams) { |
2070 Base::TestStreams(); | 2099 Base::TestStreams(); |
2071 } | 2100 } |
2072 | 2101 |
2073 TEST_F(VoiceChannelTest, TestUpdateStreamsInLocalContent) { | 2102 TEST_F(VoiceChannelSingleThreadTest, TestUpdateStreamsInLocalContent) { |
2074 Base::TestUpdateStreamsInLocalContent(); | 2103 Base::TestUpdateStreamsInLocalContent(); |
2075 } | 2104 } |
2076 | 2105 |
2077 TEST_F(VoiceChannelTest, TestUpdateRemoteStreamsInContent) { | 2106 TEST_F(VoiceChannelSingleThreadTest, TestUpdateRemoteStreamsInContent) { |
2078 Base::TestUpdateStreamsInRemoteContent(); | 2107 Base::TestUpdateStreamsInRemoteContent(); |
2079 } | 2108 } |
2080 | 2109 |
2081 TEST_F(VoiceChannelTest, TestChangeStreamParamsInContent) { | 2110 TEST_F(VoiceChannelSingleThreadTest, TestChangeStreamParamsInContent) { |
2082 Base::TestChangeStreamParamsInContent(); | 2111 Base::TestChangeStreamParamsInContent(); |
2083 } | 2112 } |
2084 | 2113 |
2085 TEST_F(VoiceChannelTest, TestPlayoutAndSendingStates) { | 2114 TEST_F(VoiceChannelSingleThreadTest, TestPlayoutAndSendingStates) { |
2086 Base::TestPlayoutAndSendingStates(); | 2115 Base::TestPlayoutAndSendingStates(); |
2087 } | 2116 } |
2088 | 2117 |
2089 TEST_F(VoiceChannelTest, TestMuteStream) { | 2118 TEST_F(VoiceChannelSingleThreadTest, TestMuteStream) { |
2090 CreateChannels(0, 0); | 2119 CreateChannels(0, 0); |
2091 // Test that we can Mute the default channel even though the sending SSRC | 2120 // Test that we can Mute the default channel even though the sending SSRC |
2092 // is unknown. | 2121 // is unknown. |
2093 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); | 2122 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); |
2094 EXPECT_TRUE(channel1_->SetAudioSend(0, false, nullptr, nullptr)); | 2123 EXPECT_TRUE(channel1_->SetAudioSend(0, false, nullptr, nullptr)); |
2095 EXPECT_TRUE(media_channel1_->IsStreamMuted(0)); | 2124 EXPECT_TRUE(media_channel1_->IsStreamMuted(0)); |
2096 EXPECT_TRUE(channel1_->SetAudioSend(0, true, nullptr, nullptr)); | 2125 EXPECT_TRUE(channel1_->SetAudioSend(0, true, nullptr, nullptr)); |
2097 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); | 2126 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); |
2098 | 2127 |
2099 // Test that we can not mute an unknown SSRC. | 2128 // Test that we can not mute an unknown SSRC. |
2100 EXPECT_FALSE(channel1_->SetAudioSend(kSsrc1, false, nullptr, nullptr)); | 2129 EXPECT_FALSE(channel1_->SetAudioSend(kSsrc1, false, nullptr, nullptr)); |
2101 | 2130 |
2102 SendInitiate(); | 2131 SendInitiate(); |
2103 // After the local session description has been set, we can mute a stream | 2132 // After the local session description has been set, we can mute a stream |
2104 // with its SSRC. | 2133 // with its SSRC. |
2105 EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, false, nullptr, nullptr)); | 2134 EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, false, nullptr, nullptr)); |
2106 EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1)); | 2135 EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1)); |
2107 EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, true, nullptr, nullptr)); | 2136 EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, true, nullptr, nullptr)); |
2108 EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1)); | 2137 EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1)); |
2109 } | 2138 } |
2110 | 2139 |
2111 TEST_F(VoiceChannelTest, TestMediaContentDirection) { | 2140 TEST_F(VoiceChannelSingleThreadTest, TestMediaContentDirection) { |
2112 Base::TestMediaContentDirection(); | 2141 Base::TestMediaContentDirection(); |
2113 } | 2142 } |
2114 | 2143 |
2115 TEST_F(VoiceChannelTest, TestNetworkRouteChanges) { | 2144 TEST_F(VoiceChannelSingleThreadTest, TestNetworkRouteChanges) { |
2116 Base::TestNetworkRouteChanges(); | 2145 Base::TestNetworkRouteChanges(); |
2117 } | 2146 } |
2118 | 2147 |
2119 TEST_F(VoiceChannelTest, TestCallSetup) { | 2148 TEST_F(VoiceChannelSingleThreadTest, TestCallSetup) { |
2120 Base::TestCallSetup(); | 2149 Base::TestCallSetup(); |
2121 } | 2150 } |
2122 | 2151 |
2123 TEST_F(VoiceChannelTest, TestCallTeardownRtcpMux) { | 2152 TEST_F(VoiceChannelSingleThreadTest, TestCallTeardownRtcpMux) { |
2124 Base::TestCallTeardownRtcpMux(); | 2153 Base::TestCallTeardownRtcpMux(); |
2125 } | 2154 } |
2126 | 2155 |
2127 TEST_F(VoiceChannelTest, SendRtpToRtp) { | 2156 TEST_F(VoiceChannelSingleThreadTest, SendRtpToRtp) { |
2128 Base::SendRtpToRtp(); | 2157 Base::SendRtpToRtp(); |
2129 } | 2158 } |
2130 | 2159 |
2131 TEST_F(VoiceChannelTest, SendNoRtcpToNoRtcp) { | 2160 TEST_F(VoiceChannelSingleThreadTest, SendNoRtcpToNoRtcp) { |
2132 Base::SendNoRtcpToNoRtcp(); | 2161 Base::SendNoRtcpToNoRtcp(); |
2133 } | 2162 } |
2134 | 2163 |
2135 TEST_F(VoiceChannelTest, SendNoRtcpToRtcp) { | 2164 TEST_F(VoiceChannelSingleThreadTest, SendNoRtcpToRtcp) { |
2136 Base::SendNoRtcpToRtcp(); | 2165 Base::SendNoRtcpToRtcp(); |
2137 } | 2166 } |
2138 | 2167 |
2139 TEST_F(VoiceChannelTest, SendRtcpToNoRtcp) { | 2168 TEST_F(VoiceChannelSingleThreadTest, SendRtcpToNoRtcp) { |
2140 Base::SendRtcpToNoRtcp(); | 2169 Base::SendRtcpToNoRtcp(); |
2141 } | 2170 } |
2142 | 2171 |
2143 TEST_F(VoiceChannelTest, SendRtcpToRtcp) { | 2172 TEST_F(VoiceChannelSingleThreadTest, SendRtcpToRtcp) { |
2144 Base::SendRtcpToRtcp(); | 2173 Base::SendRtcpToRtcp(); |
2145 } | 2174 } |
2146 | 2175 |
2147 TEST_F(VoiceChannelTest, SendRtcpMuxToRtcp) { | 2176 TEST_F(VoiceChannelSingleThreadTest, SendRtcpMuxToRtcp) { |
2148 Base::SendRtcpMuxToRtcp(); | 2177 Base::SendRtcpMuxToRtcp(); |
2149 } | 2178 } |
2150 | 2179 |
2151 TEST_F(VoiceChannelTest, SendRtcpMuxToRtcpMux) { | 2180 TEST_F(VoiceChannelSingleThreadTest, SendRtcpMuxToRtcpMux) { |
2152 Base::SendRtcpMuxToRtcpMux(); | 2181 Base::SendRtcpMuxToRtcpMux(); |
2153 } | 2182 } |
2154 | 2183 |
2155 TEST_F(VoiceChannelTest, SendRequireRtcpMuxToRtcpMux) { | 2184 TEST_F(VoiceChannelSingleThreadTest, SendRequireRtcpMuxToRtcpMux) { |
2156 Base::SendRequireRtcpMuxToRtcpMux(); | 2185 Base::SendRequireRtcpMuxToRtcpMux(); |
2157 } | 2186 } |
2158 | 2187 |
2159 TEST_F(VoiceChannelTest, SendRtcpMuxToRequireRtcpMux) { | 2188 TEST_F(VoiceChannelSingleThreadTest, SendRtcpMuxToRequireRtcpMux) { |
2160 Base::SendRtcpMuxToRequireRtcpMux(); | 2189 Base::SendRtcpMuxToRequireRtcpMux(); |
2161 } | 2190 } |
2162 | 2191 |
2163 TEST_F(VoiceChannelTest, SendRequireRtcpMuxToRequireRtcpMux) { | 2192 TEST_F(VoiceChannelSingleThreadTest, SendRequireRtcpMuxToRequireRtcpMux) { |
2164 Base::SendRequireRtcpMuxToRequireRtcpMux(); | 2193 Base::SendRequireRtcpMuxToRequireRtcpMux(); |
2165 } | 2194 } |
2166 | 2195 |
2167 TEST_F(VoiceChannelTest, SendRequireRtcpMuxToNoRtcpMux) { | 2196 TEST_F(VoiceChannelSingleThreadTest, SendRequireRtcpMuxToNoRtcpMux) { |
2168 Base::SendRequireRtcpMuxToNoRtcpMux(); | 2197 Base::SendRequireRtcpMuxToNoRtcpMux(); |
2169 } | 2198 } |
2170 | 2199 |
2171 TEST_F(VoiceChannelTest, SendEarlyRtcpMuxToRtcp) { | 2200 TEST_F(VoiceChannelSingleThreadTest, SendEarlyRtcpMuxToRtcp) { |
2172 Base::SendEarlyRtcpMuxToRtcp(); | 2201 Base::SendEarlyRtcpMuxToRtcp(); |
2173 } | 2202 } |
2174 | 2203 |
2175 TEST_F(VoiceChannelTest, SendEarlyRtcpMuxToRtcpMux) { | 2204 TEST_F(VoiceChannelSingleThreadTest, SendEarlyRtcpMuxToRtcpMux) { |
2176 Base::SendEarlyRtcpMuxToRtcpMux(); | 2205 Base::SendEarlyRtcpMuxToRtcpMux(); |
2177 } | 2206 } |
2178 | 2207 |
2179 TEST_F(VoiceChannelTest, SendSrtpToSrtpRtcpMux) { | 2208 TEST_F(VoiceChannelSingleThreadTest, SendSrtpToSrtpRtcpMux) { |
2180 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX); | 2209 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX); |
2181 } | 2210 } |
2182 | 2211 |
2183 TEST_F(VoiceChannelTest, SendSrtpToRtp) { | 2212 TEST_F(VoiceChannelSingleThreadTest, SendSrtpToRtp) { |
2184 Base::SendSrtpToSrtp(); | 2213 Base::SendSrtpToSrtp(); |
2185 } | 2214 } |
2186 | 2215 |
2187 TEST_F(VoiceChannelTest, SendSrtcpMux) { | 2216 TEST_F(VoiceChannelSingleThreadTest, SendSrtcpMux) { |
2188 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX); | 2217 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX); |
2189 } | 2218 } |
2190 | 2219 |
2191 TEST_F(VoiceChannelTest, SendDtlsSrtpToSrtp) { | 2220 TEST_F(VoiceChannelSingleThreadTest, SendDtlsSrtpToSrtp) { |
2192 MAYBE_SKIP_TEST(HaveDtlsSrtp); | 2221 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
2193 Base::SendSrtpToSrtp(DTLS, 0); | 2222 Base::SendSrtpToSrtp(DTLS, 0); |
2194 } | 2223 } |
2195 | 2224 |
2196 TEST_F(VoiceChannelTest, SendDtlsSrtpToDtlsSrtp) { | 2225 TEST_F(VoiceChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtp) { |
2197 MAYBE_SKIP_TEST(HaveDtlsSrtp); | 2226 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
2198 Base::SendSrtpToSrtp(DTLS, DTLS); | 2227 Base::SendSrtpToSrtp(DTLS, DTLS); |
2199 } | 2228 } |
2200 | 2229 |
2201 TEST_F(VoiceChannelTest, SendDtlsSrtpToDtlsSrtpRtcpMux) { | 2230 TEST_F(VoiceChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) { |
2202 MAYBE_SKIP_TEST(HaveDtlsSrtp); | 2231 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
2203 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX); | 2232 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX); |
2204 } | 2233 } |
2205 | 2234 |
2206 TEST_F(VoiceChannelTest, SendEarlyMediaUsingRtcpMuxSrtp) { | 2235 TEST_F(VoiceChannelSingleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) { |
2207 Base::SendEarlyMediaUsingRtcpMuxSrtp(); | 2236 Base::SendEarlyMediaUsingRtcpMuxSrtp(); |
2208 } | 2237 } |
2209 | 2238 |
2210 TEST_F(VoiceChannelTest, SendRtpToRtpOnThread) { | 2239 TEST_F(VoiceChannelSingleThreadTest, SendRtpToRtpOnThread) { |
2211 Base::SendRtpToRtpOnThread(); | 2240 Base::SendRtpToRtpOnThread(); |
2212 } | 2241 } |
2213 | 2242 |
2214 TEST_F(VoiceChannelTest, SendSrtpToSrtpOnThread) { | 2243 TEST_F(VoiceChannelSingleThreadTest, SendSrtpToSrtpOnThread) { |
2215 Base::SendSrtpToSrtpOnThread(); | 2244 Base::SendSrtpToSrtpOnThread(); |
2216 } | 2245 } |
2217 | 2246 |
2218 TEST_F(VoiceChannelTest, SendWithWritabilityLoss) { | 2247 TEST_F(VoiceChannelSingleThreadTest, SendWithWritabilityLoss) { |
2219 Base::SendWithWritabilityLoss(); | 2248 Base::SendWithWritabilityLoss(); |
2220 } | 2249 } |
2221 | 2250 |
2222 TEST_F(VoiceChannelTest, TestMediaMonitor) { | 2251 TEST_F(VoiceChannelSingleThreadTest, TestMediaMonitor) { |
2223 Base::TestMediaMonitor(); | 2252 Base::TestMediaMonitor(); |
2224 } | 2253 } |
2225 | 2254 |
2226 // Test that InsertDtmf properly forwards to the media channel. | 2255 // Test that InsertDtmf properly forwards to the media channel. |
2227 TEST_F(VoiceChannelTest, TestInsertDtmf) { | 2256 TEST_F(VoiceChannelSingleThreadTest, TestInsertDtmf) { |
2228 CreateChannels(0, 0); | 2257 CreateChannels(0, 0); |
2229 EXPECT_TRUE(SendInitiate()); | 2258 EXPECT_TRUE(SendInitiate()); |
2230 EXPECT_TRUE(SendAccept()); | 2259 EXPECT_TRUE(SendAccept()); |
2231 EXPECT_EQ(0U, media_channel1_->dtmf_info_queue().size()); | 2260 EXPECT_EQ(0U, media_channel1_->dtmf_info_queue().size()); |
2232 | 2261 |
2233 EXPECT_TRUE(channel1_->InsertDtmf(1, 3, 100)); | 2262 EXPECT_TRUE(channel1_->InsertDtmf(1, 3, 100)); |
2234 EXPECT_TRUE(channel1_->InsertDtmf(2, 5, 110)); | 2263 EXPECT_TRUE(channel1_->InsertDtmf(2, 5, 110)); |
2235 EXPECT_TRUE(channel1_->InsertDtmf(3, 7, 120)); | 2264 EXPECT_TRUE(channel1_->InsertDtmf(3, 7, 120)); |
2236 | 2265 |
2237 ASSERT_EQ(3U, media_channel1_->dtmf_info_queue().size()); | 2266 ASSERT_EQ(3U, media_channel1_->dtmf_info_queue().size()); |
2238 EXPECT_TRUE(CompareDtmfInfo(media_channel1_->dtmf_info_queue()[0], | 2267 EXPECT_TRUE(CompareDtmfInfo(media_channel1_->dtmf_info_queue()[0], |
2239 1, 3, 100)); | 2268 1, 3, 100)); |
2240 EXPECT_TRUE(CompareDtmfInfo(media_channel1_->dtmf_info_queue()[1], | 2269 EXPECT_TRUE(CompareDtmfInfo(media_channel1_->dtmf_info_queue()[1], |
2241 2, 5, 110)); | 2270 2, 5, 110)); |
2242 EXPECT_TRUE(CompareDtmfInfo(media_channel1_->dtmf_info_queue()[2], | 2271 EXPECT_TRUE(CompareDtmfInfo(media_channel1_->dtmf_info_queue()[2], |
2243 3, 7, 120)); | 2272 3, 7, 120)); |
2244 } | 2273 } |
2245 | 2274 |
2246 TEST_F(VoiceChannelTest, TestSetContentFailure) { | 2275 TEST_F(VoiceChannelSingleThreadTest, TestSetContentFailure) { |
2247 Base::TestSetContentFailure(); | 2276 Base::TestSetContentFailure(); |
2248 } | 2277 } |
2249 | 2278 |
2250 TEST_F(VoiceChannelTest, TestSendTwoOffers) { | 2279 TEST_F(VoiceChannelSingleThreadTest, TestSendTwoOffers) { |
2251 Base::TestSendTwoOffers(); | 2280 Base::TestSendTwoOffers(); |
2252 } | 2281 } |
2253 | 2282 |
2254 TEST_F(VoiceChannelTest, TestReceiveTwoOffers) { | 2283 TEST_F(VoiceChannelSingleThreadTest, TestReceiveTwoOffers) { |
2255 Base::TestReceiveTwoOffers(); | 2284 Base::TestReceiveTwoOffers(); |
2256 } | 2285 } |
2257 | 2286 |
2258 TEST_F(VoiceChannelTest, TestSendPrAnswer) { | 2287 TEST_F(VoiceChannelSingleThreadTest, TestSendPrAnswer) { |
2259 Base::TestSendPrAnswer(); | 2288 Base::TestSendPrAnswer(); |
2260 } | 2289 } |
2261 | 2290 |
2262 TEST_F(VoiceChannelTest, TestReceivePrAnswer) { | 2291 TEST_F(VoiceChannelSingleThreadTest, TestReceivePrAnswer) { |
2263 Base::TestReceivePrAnswer(); | 2292 Base::TestReceivePrAnswer(); |
2264 } | 2293 } |
2265 | 2294 |
2266 TEST_F(VoiceChannelTest, TestFlushRtcp) { | 2295 TEST_F(VoiceChannelSingleThreadTest, TestFlushRtcp) { |
2267 Base::TestFlushRtcp(); | 2296 Base::TestFlushRtcp(); |
2268 } | 2297 } |
2269 | 2298 |
2270 TEST_F(VoiceChannelTest, TestSrtpError) { | 2299 TEST_F(VoiceChannelSingleThreadTest, TestSrtpError) { |
2271 Base::TestSrtpError(kAudioPts[0]); | 2300 Base::TestSrtpError(kAudioPts[0]); |
2272 } | 2301 } |
2273 | 2302 |
2274 TEST_F(VoiceChannelTest, TestOnReadyToSend) { | 2303 TEST_F(VoiceChannelSingleThreadTest, TestOnReadyToSend) { |
2275 Base::TestOnReadyToSend(); | 2304 Base::TestOnReadyToSend(); |
2276 } | 2305 } |
2277 | 2306 |
2278 TEST_F(VoiceChannelTest, TestOnReadyToSendWithRtcpMux) { | 2307 TEST_F(VoiceChannelSingleThreadTest, TestOnReadyToSendWithRtcpMux) { |
2279 Base::TestOnReadyToSendWithRtcpMux(); | 2308 Base::TestOnReadyToSendWithRtcpMux(); |
2280 } | 2309 } |
2281 | 2310 |
2282 // Test that we can scale the output volume properly for 1:1 calls. | 2311 // Test that we can scale the output volume properly for 1:1 calls. |
2283 TEST_F(VoiceChannelTest, TestScaleVolume1to1Call) { | 2312 TEST_F(VoiceChannelSingleThreadTest, TestScaleVolume1to1Call) { |
2284 CreateChannels(RTCP, RTCP); | 2313 CreateChannels(RTCP, RTCP); |
2285 EXPECT_TRUE(SendInitiate()); | 2314 EXPECT_TRUE(SendInitiate()); |
2286 EXPECT_TRUE(SendAccept()); | 2315 EXPECT_TRUE(SendAccept()); |
2287 double volume; | 2316 double volume; |
2288 | 2317 |
2289 // Default is (1.0). | 2318 // Default is (1.0). |
2290 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume)); | 2319 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume)); |
2291 EXPECT_DOUBLE_EQ(1.0, volume); | 2320 EXPECT_DOUBLE_EQ(1.0, volume); |
2292 // invalid ssrc. | 2321 // invalid ssrc. |
2293 EXPECT_FALSE(media_channel1_->GetOutputVolume(3, &volume)); | 2322 EXPECT_FALSE(media_channel1_->GetOutputVolume(3, &volume)); |
2294 | 2323 |
2295 // Set scale to (1.5). | 2324 // Set scale to (1.5). |
2296 EXPECT_TRUE(channel1_->SetOutputVolume(0, 1.5)); | 2325 EXPECT_TRUE(channel1_->SetOutputVolume(0, 1.5)); |
2297 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume)); | 2326 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume)); |
2298 EXPECT_DOUBLE_EQ(1.5, volume); | 2327 EXPECT_DOUBLE_EQ(1.5, volume); |
2299 | 2328 |
2300 // Set scale to (0). | 2329 // Set scale to (0). |
2301 EXPECT_TRUE(channel1_->SetOutputVolume(0, 0.0)); | 2330 EXPECT_TRUE(channel1_->SetOutputVolume(0, 0.0)); |
2302 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume)); | 2331 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume)); |
2303 EXPECT_DOUBLE_EQ(0.0, volume); | 2332 EXPECT_DOUBLE_EQ(0.0, volume); |
2304 } | 2333 } |
2305 | 2334 |
2306 // Test that we can scale the output volume properly for multiway calls. | 2335 // Test that we can scale the output volume properly for multiway calls. |
2307 TEST_F(VoiceChannelTest, TestScaleVolumeMultiwayCall) { | 2336 TEST_F(VoiceChannelSingleThreadTest, TestScaleVolumeMultiwayCall) { |
2308 CreateChannels(RTCP, RTCP); | 2337 CreateChannels(RTCP, RTCP); |
2309 EXPECT_TRUE(SendInitiate()); | 2338 EXPECT_TRUE(SendInitiate()); |
2310 EXPECT_TRUE(SendAccept()); | 2339 EXPECT_TRUE(SendAccept()); |
2311 EXPECT_TRUE(AddStream1(1)); | 2340 EXPECT_TRUE(AddStream1(1)); |
2312 EXPECT_TRUE(AddStream1(2)); | 2341 EXPECT_TRUE(AddStream1(2)); |
2313 | 2342 |
2314 double volume; | 2343 double volume; |
2315 // Default is (1.0). | 2344 // Default is (1.0). |
2316 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume)); | 2345 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume)); |
2317 EXPECT_DOUBLE_EQ(1.0, volume); | 2346 EXPECT_DOUBLE_EQ(1.0, volume); |
(...skipping 16 matching lines...) Expand all Loading... |
2334 // Set scale to (0) for all ssrcs. | 2363 // Set scale to (0) for all ssrcs. |
2335 EXPECT_TRUE(channel1_->SetOutputVolume(0, 0.0)); | 2364 EXPECT_TRUE(channel1_->SetOutputVolume(0, 0.0)); |
2336 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume)); | 2365 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume)); |
2337 EXPECT_DOUBLE_EQ(0.0, volume); | 2366 EXPECT_DOUBLE_EQ(0.0, volume); |
2338 EXPECT_TRUE(media_channel1_->GetOutputVolume(1, &volume)); | 2367 EXPECT_TRUE(media_channel1_->GetOutputVolume(1, &volume)); |
2339 EXPECT_DOUBLE_EQ(0.0, volume); | 2368 EXPECT_DOUBLE_EQ(0.0, volume); |
2340 EXPECT_TRUE(media_channel1_->GetOutputVolume(2, &volume)); | 2369 EXPECT_TRUE(media_channel1_->GetOutputVolume(2, &volume)); |
2341 EXPECT_DOUBLE_EQ(0.0, volume); | 2370 EXPECT_DOUBLE_EQ(0.0, volume); |
2342 } | 2371 } |
2343 | 2372 |
2344 TEST_F(VoiceChannelTest, SendBundleToBundle) { | 2373 TEST_F(VoiceChannelSingleThreadTest, SendBundleToBundle) { |
2345 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, false); | 2374 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, false); |
2346 } | 2375 } |
2347 | 2376 |
2348 TEST_F(VoiceChannelTest, SendBundleToBundleSecure) { | 2377 TEST_F(VoiceChannelSingleThreadTest, SendBundleToBundleSecure) { |
2349 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, true); | 2378 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, true); |
2350 } | 2379 } |
2351 | 2380 |
2352 TEST_F(VoiceChannelTest, SendBundleToBundleWithRtcpMux) { | 2381 TEST_F(VoiceChannelSingleThreadTest, SendBundleToBundleWithRtcpMux) { |
2353 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, false); | 2382 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, false); |
2354 } | 2383 } |
2355 | 2384 |
2356 TEST_F(VoiceChannelTest, SendBundleToBundleWithRtcpMuxSecure) { | 2385 TEST_F(VoiceChannelSingleThreadTest, SendBundleToBundleWithRtcpMuxSecure) { |
2357 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, true); | 2386 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, true); |
2358 } | 2387 } |
2359 | 2388 |
2360 TEST_F(VoiceChannelTest, DefaultMaxBitrateIsUnlimited) { | 2389 TEST_F(VoiceChannelSingleThreadTest, DefaultMaxBitrateIsUnlimited) { |
2361 Base::DefaultMaxBitrateIsUnlimited(); | 2390 Base::DefaultMaxBitrateIsUnlimited(); |
2362 } | 2391 } |
2363 | 2392 |
2364 TEST_F(VoiceChannelTest, CanChangeMaxBitrate) { | 2393 TEST_F(VoiceChannelSingleThreadTest, CanChangeMaxBitrate) { |
2365 Base::CanChangeMaxBitrate(); | 2394 Base::CanChangeMaxBitrate(); |
2366 } | 2395 } |
2367 | 2396 |
2368 // VideoChannelTest | 2397 // VoiceChannelDoubleThreadTest |
2369 TEST_F(VideoChannelTest, TestInit) { | 2398 TEST_F(VoiceChannelDoubleThreadTest, TestInit) { |
2370 Base::TestInit(); | 2399 Base::TestInit(); |
2371 } | 2400 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); |
2372 | 2401 EXPECT_TRUE(media_channel1_->dtmf_info_queue().empty()); |
2373 TEST_F(VideoChannelTest, TestSetContents) { | 2402 } |
| 2403 |
| 2404 TEST_F(VoiceChannelDoubleThreadTest, TestSetContents) { |
2374 Base::TestSetContents(); | 2405 Base::TestSetContents(); |
2375 } | 2406 } |
2376 | 2407 |
2377 TEST_F(VideoChannelTest, TestSetContentsNullOffer) { | 2408 TEST_F(VoiceChannelDoubleThreadTest, TestSetContentsNullOffer) { |
2378 Base::TestSetContentsNullOffer(); | 2409 Base::TestSetContentsNullOffer(); |
2379 } | 2410 } |
2380 | 2411 |
2381 TEST_F(VideoChannelTest, TestSetContentsRtcpMux) { | 2412 TEST_F(VoiceChannelDoubleThreadTest, TestSetContentsRtcpMux) { |
2382 Base::TestSetContentsRtcpMux(); | 2413 Base::TestSetContentsRtcpMux(); |
2383 } | 2414 } |
2384 | 2415 |
2385 TEST_F(VideoChannelTest, TestSetContentsRtcpMuxWithPrAnswer) { | 2416 TEST_F(VoiceChannelDoubleThreadTest, TestSetContentsRtcpMuxWithPrAnswer) { |
2386 Base::TestSetContentsRtcpMux(); | 2417 Base::TestSetContentsRtcpMux(); |
2387 } | 2418 } |
2388 | 2419 |
2389 TEST_F(VideoChannelTest, TestSetRemoteContentUpdate) { | 2420 TEST_F(VoiceChannelDoubleThreadTest, TestSetRemoteContentUpdate) { |
2390 Base::TestSetRemoteContentUpdate(); | 2421 Base::TestSetRemoteContentUpdate(); |
2391 } | 2422 } |
2392 | 2423 |
2393 TEST_F(VideoChannelTest, TestStreams) { | 2424 TEST_F(VoiceChannelDoubleThreadTest, TestStreams) { |
2394 Base::TestStreams(); | 2425 Base::TestStreams(); |
2395 } | 2426 } |
2396 | 2427 |
2397 TEST_F(VideoChannelTest, TestUpdateStreamsInLocalContent) { | 2428 TEST_F(VoiceChannelDoubleThreadTest, TestUpdateStreamsInLocalContent) { |
2398 Base::TestUpdateStreamsInLocalContent(); | 2429 Base::TestUpdateStreamsInLocalContent(); |
2399 } | 2430 } |
2400 | 2431 |
2401 TEST_F(VideoChannelTest, TestUpdateRemoteStreamsInContent) { | 2432 TEST_F(VoiceChannelDoubleThreadTest, TestUpdateRemoteStreamsInContent) { |
2402 Base::TestUpdateStreamsInRemoteContent(); | 2433 Base::TestUpdateStreamsInRemoteContent(); |
2403 } | 2434 } |
2404 | 2435 |
2405 TEST_F(VideoChannelTest, TestChangeStreamParamsInContent) { | 2436 TEST_F(VoiceChannelDoubleThreadTest, TestChangeStreamParamsInContent) { |
2406 Base::TestChangeStreamParamsInContent(); | 2437 Base::TestChangeStreamParamsInContent(); |
2407 } | 2438 } |
2408 | 2439 |
2409 TEST_F(VideoChannelTest, TestPlayoutAndSendingStates) { | 2440 TEST_F(VoiceChannelDoubleThreadTest, TestPlayoutAndSendingStates) { |
2410 Base::TestPlayoutAndSendingStates(); | 2441 Base::TestPlayoutAndSendingStates(); |
2411 } | 2442 } |
2412 | 2443 |
2413 TEST_F(VideoChannelTest, TestMuteStream) { | 2444 TEST_F(VoiceChannelDoubleThreadTest, TestMuteStream) { |
| 2445 CreateChannels(0, 0); |
| 2446 // Test that we can Mute the default channel even though the sending SSRC |
| 2447 // is unknown. |
| 2448 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); |
| 2449 EXPECT_TRUE(channel1_->SetAudioSend(0, false, nullptr, nullptr)); |
| 2450 EXPECT_TRUE(media_channel1_->IsStreamMuted(0)); |
| 2451 EXPECT_TRUE(channel1_->SetAudioSend(0, true, nullptr, nullptr)); |
| 2452 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); |
| 2453 |
| 2454 // Test that we can not mute an unknown SSRC. |
| 2455 EXPECT_FALSE(channel1_->SetAudioSend(kSsrc1, false, nullptr, nullptr)); |
| 2456 |
| 2457 SendInitiate(); |
| 2458 // After the local session description has been set, we can mute a stream |
| 2459 // with its SSRC. |
| 2460 EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, false, nullptr, nullptr)); |
| 2461 EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1)); |
| 2462 EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, true, nullptr, nullptr)); |
| 2463 EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1)); |
| 2464 } |
| 2465 |
| 2466 TEST_F(VoiceChannelDoubleThreadTest, TestMediaContentDirection) { |
| 2467 Base::TestMediaContentDirection(); |
| 2468 } |
| 2469 |
| 2470 TEST_F(VoiceChannelDoubleThreadTest, TestNetworkRouteChanges) { |
| 2471 Base::TestNetworkRouteChanges(); |
| 2472 } |
| 2473 |
| 2474 TEST_F(VoiceChannelDoubleThreadTest, TestCallSetup) { |
| 2475 Base::TestCallSetup(); |
| 2476 } |
| 2477 |
| 2478 TEST_F(VoiceChannelDoubleThreadTest, TestCallTeardownRtcpMux) { |
| 2479 Base::TestCallTeardownRtcpMux(); |
| 2480 } |
| 2481 |
| 2482 TEST_F(VoiceChannelDoubleThreadTest, SendRtpToRtp) { |
| 2483 Base::SendRtpToRtp(); |
| 2484 } |
| 2485 |
| 2486 TEST_F(VoiceChannelDoubleThreadTest, SendNoRtcpToNoRtcp) { |
| 2487 Base::SendNoRtcpToNoRtcp(); |
| 2488 } |
| 2489 |
| 2490 TEST_F(VoiceChannelDoubleThreadTest, SendNoRtcpToRtcp) { |
| 2491 Base::SendNoRtcpToRtcp(); |
| 2492 } |
| 2493 |
| 2494 TEST_F(VoiceChannelDoubleThreadTest, SendRtcpToNoRtcp) { |
| 2495 Base::SendRtcpToNoRtcp(); |
| 2496 } |
| 2497 |
| 2498 TEST_F(VoiceChannelDoubleThreadTest, SendRtcpToRtcp) { |
| 2499 Base::SendRtcpToRtcp(); |
| 2500 } |
| 2501 |
| 2502 TEST_F(VoiceChannelDoubleThreadTest, SendRtcpMuxToRtcp) { |
| 2503 Base::SendRtcpMuxToRtcp(); |
| 2504 } |
| 2505 |
| 2506 TEST_F(VoiceChannelDoubleThreadTest, SendRtcpMuxToRtcpMux) { |
| 2507 Base::SendRtcpMuxToRtcpMux(); |
| 2508 } |
| 2509 |
| 2510 TEST_F(VoiceChannelDoubleThreadTest, SendRequireRtcpMuxToRtcpMux) { |
| 2511 Base::SendRequireRtcpMuxToRtcpMux(); |
| 2512 } |
| 2513 |
| 2514 TEST_F(VoiceChannelDoubleThreadTest, SendRtcpMuxToRequireRtcpMux) { |
| 2515 Base::SendRtcpMuxToRequireRtcpMux(); |
| 2516 } |
| 2517 |
| 2518 TEST_F(VoiceChannelDoubleThreadTest, SendRequireRtcpMuxToRequireRtcpMux) { |
| 2519 Base::SendRequireRtcpMuxToRequireRtcpMux(); |
| 2520 } |
| 2521 |
| 2522 TEST_F(VoiceChannelDoubleThreadTest, SendRequireRtcpMuxToNoRtcpMux) { |
| 2523 Base::SendRequireRtcpMuxToNoRtcpMux(); |
| 2524 } |
| 2525 |
| 2526 TEST_F(VoiceChannelDoubleThreadTest, SendEarlyRtcpMuxToRtcp) { |
| 2527 Base::SendEarlyRtcpMuxToRtcp(); |
| 2528 } |
| 2529 |
| 2530 TEST_F(VoiceChannelDoubleThreadTest, SendEarlyRtcpMuxToRtcpMux) { |
| 2531 Base::SendEarlyRtcpMuxToRtcpMux(); |
| 2532 } |
| 2533 |
| 2534 TEST_F(VoiceChannelDoubleThreadTest, SendSrtpToSrtpRtcpMux) { |
| 2535 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX); |
| 2536 } |
| 2537 |
| 2538 TEST_F(VoiceChannelDoubleThreadTest, SendSrtpToRtp) { |
| 2539 Base::SendSrtpToSrtp(); |
| 2540 } |
| 2541 |
| 2542 TEST_F(VoiceChannelDoubleThreadTest, SendSrtcpMux) { |
| 2543 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX); |
| 2544 } |
| 2545 |
| 2546 TEST_F(VoiceChannelDoubleThreadTest, SendDtlsSrtpToSrtp) { |
| 2547 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 2548 Base::SendSrtpToSrtp(DTLS, 0); |
| 2549 } |
| 2550 |
| 2551 TEST_F(VoiceChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtp) { |
| 2552 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 2553 Base::SendSrtpToSrtp(DTLS, DTLS); |
| 2554 } |
| 2555 |
| 2556 TEST_F(VoiceChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) { |
| 2557 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 2558 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX); |
| 2559 } |
| 2560 |
| 2561 TEST_F(VoiceChannelDoubleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) { |
| 2562 Base::SendEarlyMediaUsingRtcpMuxSrtp(); |
| 2563 } |
| 2564 |
| 2565 TEST_F(VoiceChannelDoubleThreadTest, SendRtpToRtpOnThread) { |
| 2566 Base::SendRtpToRtpOnThread(); |
| 2567 } |
| 2568 |
| 2569 TEST_F(VoiceChannelDoubleThreadTest, SendSrtpToSrtpOnThread) { |
| 2570 Base::SendSrtpToSrtpOnThread(); |
| 2571 } |
| 2572 |
| 2573 TEST_F(VoiceChannelDoubleThreadTest, SendWithWritabilityLoss) { |
| 2574 Base::SendWithWritabilityLoss(); |
| 2575 } |
| 2576 |
| 2577 TEST_F(VoiceChannelDoubleThreadTest, TestMediaMonitor) { |
| 2578 Base::TestMediaMonitor(); |
| 2579 } |
| 2580 |
| 2581 // Test that InsertDtmf properly forwards to the media channel. |
| 2582 TEST_F(VoiceChannelDoubleThreadTest, TestInsertDtmf) { |
| 2583 CreateChannels(0, 0); |
| 2584 EXPECT_TRUE(SendInitiate()); |
| 2585 EXPECT_TRUE(SendAccept()); |
| 2586 EXPECT_EQ(0U, media_channel1_->dtmf_info_queue().size()); |
| 2587 |
| 2588 EXPECT_TRUE(channel1_->InsertDtmf(1, 3, 100)); |
| 2589 EXPECT_TRUE(channel1_->InsertDtmf(2, 5, 110)); |
| 2590 EXPECT_TRUE(channel1_->InsertDtmf(3, 7, 120)); |
| 2591 |
| 2592 ASSERT_EQ(3U, media_channel1_->dtmf_info_queue().size()); |
| 2593 EXPECT_TRUE( |
| 2594 CompareDtmfInfo(media_channel1_->dtmf_info_queue()[0], 1, 3, 100)); |
| 2595 EXPECT_TRUE( |
| 2596 CompareDtmfInfo(media_channel1_->dtmf_info_queue()[1], 2, 5, 110)); |
| 2597 EXPECT_TRUE( |
| 2598 CompareDtmfInfo(media_channel1_->dtmf_info_queue()[2], 3, 7, 120)); |
| 2599 } |
| 2600 |
| 2601 TEST_F(VoiceChannelDoubleThreadTest, TestSetContentFailure) { |
| 2602 Base::TestSetContentFailure(); |
| 2603 } |
| 2604 |
| 2605 TEST_F(VoiceChannelDoubleThreadTest, TestSendTwoOffers) { |
| 2606 Base::TestSendTwoOffers(); |
| 2607 } |
| 2608 |
| 2609 TEST_F(VoiceChannelDoubleThreadTest, TestReceiveTwoOffers) { |
| 2610 Base::TestReceiveTwoOffers(); |
| 2611 } |
| 2612 |
| 2613 TEST_F(VoiceChannelDoubleThreadTest, TestSendPrAnswer) { |
| 2614 Base::TestSendPrAnswer(); |
| 2615 } |
| 2616 |
| 2617 TEST_F(VoiceChannelDoubleThreadTest, TestReceivePrAnswer) { |
| 2618 Base::TestReceivePrAnswer(); |
| 2619 } |
| 2620 |
| 2621 TEST_F(VoiceChannelDoubleThreadTest, TestFlushRtcp) { |
| 2622 Base::TestFlushRtcp(); |
| 2623 } |
| 2624 |
| 2625 TEST_F(VoiceChannelDoubleThreadTest, TestSrtpError) { |
| 2626 Base::TestSrtpError(kAudioPts[0]); |
| 2627 } |
| 2628 |
| 2629 TEST_F(VoiceChannelDoubleThreadTest, TestOnReadyToSend) { |
| 2630 Base::TestOnReadyToSend(); |
| 2631 } |
| 2632 |
| 2633 TEST_F(VoiceChannelDoubleThreadTest, TestOnReadyToSendWithRtcpMux) { |
| 2634 Base::TestOnReadyToSendWithRtcpMux(); |
| 2635 } |
| 2636 |
| 2637 // Test that we can scale the output volume properly for 1:1 calls. |
| 2638 TEST_F(VoiceChannelDoubleThreadTest, TestScaleVolume1to1Call) { |
| 2639 CreateChannels(RTCP, RTCP); |
| 2640 EXPECT_TRUE(SendInitiate()); |
| 2641 EXPECT_TRUE(SendAccept()); |
| 2642 double volume; |
| 2643 |
| 2644 // Default is (1.0). |
| 2645 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume)); |
| 2646 EXPECT_DOUBLE_EQ(1.0, volume); |
| 2647 // invalid ssrc. |
| 2648 EXPECT_FALSE(media_channel1_->GetOutputVolume(3, &volume)); |
| 2649 |
| 2650 // Set scale to (1.5). |
| 2651 EXPECT_TRUE(channel1_->SetOutputVolume(0, 1.5)); |
| 2652 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume)); |
| 2653 EXPECT_DOUBLE_EQ(1.5, volume); |
| 2654 |
| 2655 // Set scale to (0). |
| 2656 EXPECT_TRUE(channel1_->SetOutputVolume(0, 0.0)); |
| 2657 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume)); |
| 2658 EXPECT_DOUBLE_EQ(0.0, volume); |
| 2659 } |
| 2660 |
| 2661 // Test that we can scale the output volume properly for multiway calls. |
| 2662 TEST_F(VoiceChannelDoubleThreadTest, TestScaleVolumeMultiwayCall) { |
| 2663 CreateChannels(RTCP, RTCP); |
| 2664 EXPECT_TRUE(SendInitiate()); |
| 2665 EXPECT_TRUE(SendAccept()); |
| 2666 EXPECT_TRUE(AddStream1(1)); |
| 2667 EXPECT_TRUE(AddStream1(2)); |
| 2668 |
| 2669 double volume; |
| 2670 // Default is (1.0). |
| 2671 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume)); |
| 2672 EXPECT_DOUBLE_EQ(1.0, volume); |
| 2673 EXPECT_TRUE(media_channel1_->GetOutputVolume(1, &volume)); |
| 2674 EXPECT_DOUBLE_EQ(1.0, volume); |
| 2675 EXPECT_TRUE(media_channel1_->GetOutputVolume(2, &volume)); |
| 2676 EXPECT_DOUBLE_EQ(1.0, volume); |
| 2677 // invalid ssrc. |
| 2678 EXPECT_FALSE(media_channel1_->GetOutputVolume(3, &volume)); |
| 2679 |
| 2680 // Set scale to (1.5) for ssrc = 1. |
| 2681 EXPECT_TRUE(channel1_->SetOutputVolume(1, 1.5)); |
| 2682 EXPECT_TRUE(media_channel1_->GetOutputVolume(1, &volume)); |
| 2683 EXPECT_DOUBLE_EQ(1.5, volume); |
| 2684 EXPECT_TRUE(media_channel1_->GetOutputVolume(2, &volume)); |
| 2685 EXPECT_DOUBLE_EQ(1.0, volume); |
| 2686 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume)); |
| 2687 EXPECT_DOUBLE_EQ(1.0, volume); |
| 2688 |
| 2689 // Set scale to (0) for all ssrcs. |
| 2690 EXPECT_TRUE(channel1_->SetOutputVolume(0, 0.0)); |
| 2691 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume)); |
| 2692 EXPECT_DOUBLE_EQ(0.0, volume); |
| 2693 EXPECT_TRUE(media_channel1_->GetOutputVolume(1, &volume)); |
| 2694 EXPECT_DOUBLE_EQ(0.0, volume); |
| 2695 EXPECT_TRUE(media_channel1_->GetOutputVolume(2, &volume)); |
| 2696 EXPECT_DOUBLE_EQ(0.0, volume); |
| 2697 } |
| 2698 |
| 2699 TEST_F(VoiceChannelDoubleThreadTest, SendBundleToBundle) { |
| 2700 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, false); |
| 2701 } |
| 2702 |
| 2703 TEST_F(VoiceChannelDoubleThreadTest, SendBundleToBundleSecure) { |
| 2704 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, true); |
| 2705 } |
| 2706 |
| 2707 TEST_F(VoiceChannelDoubleThreadTest, SendBundleToBundleWithRtcpMux) { |
| 2708 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, false); |
| 2709 } |
| 2710 |
| 2711 TEST_F(VoiceChannelDoubleThreadTest, SendBundleToBundleWithRtcpMuxSecure) { |
| 2712 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, true); |
| 2713 } |
| 2714 |
| 2715 TEST_F(VoiceChannelDoubleThreadTest, DefaultMaxBitrateIsUnlimited) { |
| 2716 Base::DefaultMaxBitrateIsUnlimited(); |
| 2717 } |
| 2718 |
| 2719 TEST_F(VoiceChannelDoubleThreadTest, CanChangeMaxBitrate) { |
| 2720 Base::CanChangeMaxBitrate(); |
| 2721 } |
| 2722 |
| 2723 // VideoChannelSingleThreadTest |
| 2724 TEST_F(VideoChannelSingleThreadTest, TestInit) { |
| 2725 Base::TestInit(); |
| 2726 } |
| 2727 |
| 2728 TEST_F(VideoChannelSingleThreadTest, TestSetContents) { |
| 2729 Base::TestSetContents(); |
| 2730 } |
| 2731 |
| 2732 TEST_F(VideoChannelSingleThreadTest, TestSetContentsNullOffer) { |
| 2733 Base::TestSetContentsNullOffer(); |
| 2734 } |
| 2735 |
| 2736 TEST_F(VideoChannelSingleThreadTest, TestSetContentsRtcpMux) { |
| 2737 Base::TestSetContentsRtcpMux(); |
| 2738 } |
| 2739 |
| 2740 TEST_F(VideoChannelSingleThreadTest, TestSetContentsRtcpMuxWithPrAnswer) { |
| 2741 Base::TestSetContentsRtcpMux(); |
| 2742 } |
| 2743 |
| 2744 TEST_F(VideoChannelSingleThreadTest, TestSetRemoteContentUpdate) { |
| 2745 Base::TestSetRemoteContentUpdate(); |
| 2746 } |
| 2747 |
| 2748 TEST_F(VideoChannelSingleThreadTest, TestStreams) { |
| 2749 Base::TestStreams(); |
| 2750 } |
| 2751 |
| 2752 TEST_F(VideoChannelSingleThreadTest, TestUpdateStreamsInLocalContent) { |
| 2753 Base::TestUpdateStreamsInLocalContent(); |
| 2754 } |
| 2755 |
| 2756 TEST_F(VideoChannelSingleThreadTest, TestUpdateRemoteStreamsInContent) { |
| 2757 Base::TestUpdateStreamsInRemoteContent(); |
| 2758 } |
| 2759 |
| 2760 TEST_F(VideoChannelSingleThreadTest, TestChangeStreamParamsInContent) { |
| 2761 Base::TestChangeStreamParamsInContent(); |
| 2762 } |
| 2763 |
| 2764 TEST_F(VideoChannelSingleThreadTest, TestPlayoutAndSendingStates) { |
| 2765 Base::TestPlayoutAndSendingStates(); |
| 2766 } |
| 2767 |
| 2768 TEST_F(VideoChannelSingleThreadTest, TestMuteStream) { |
2414 CreateChannels(0, 0); | 2769 CreateChannels(0, 0); |
2415 // Test that we can Mute the default channel even though the sending SSRC | 2770 // Test that we can Mute the default channel even though the sending SSRC |
2416 // is unknown. | 2771 // is unknown. |
2417 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); | 2772 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); |
2418 EXPECT_TRUE(channel1_->SetVideoSend(0, false, nullptr)); | 2773 EXPECT_TRUE(channel1_->SetVideoSend(0, false, nullptr)); |
2419 EXPECT_TRUE(media_channel1_->IsStreamMuted(0)); | 2774 EXPECT_TRUE(media_channel1_->IsStreamMuted(0)); |
2420 EXPECT_TRUE(channel1_->SetVideoSend(0, true, nullptr)); | 2775 EXPECT_TRUE(channel1_->SetVideoSend(0, true, nullptr)); |
2421 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); | 2776 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); |
2422 // Test that we can not mute an unknown SSRC. | 2777 // Test that we can not mute an unknown SSRC. |
2423 EXPECT_FALSE(channel1_->SetVideoSend(kSsrc1, false, nullptr)); | 2778 EXPECT_FALSE(channel1_->SetVideoSend(kSsrc1, false, nullptr)); |
2424 SendInitiate(); | 2779 SendInitiate(); |
2425 // After the local session description has been set, we can mute a stream | 2780 // After the local session description has been set, we can mute a stream |
2426 // with its SSRC. | 2781 // with its SSRC. |
2427 EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, false, nullptr)); | 2782 EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, false, nullptr)); |
2428 EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1)); | 2783 EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1)); |
2429 EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, true, nullptr)); | 2784 EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, true, nullptr)); |
2430 EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1)); | 2785 EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1)); |
2431 } | 2786 } |
2432 | 2787 |
2433 TEST_F(VideoChannelTest, TestMediaContentDirection) { | 2788 TEST_F(VideoChannelSingleThreadTest, TestMediaContentDirection) { |
2434 Base::TestMediaContentDirection(); | 2789 Base::TestMediaContentDirection(); |
2435 } | 2790 } |
2436 | 2791 |
2437 TEST_F(VideoChannelTest, TestNetworkRouteChanges) { | 2792 TEST_F(VideoChannelSingleThreadTest, TestNetworkRouteChanges) { |
2438 Base::TestNetworkRouteChanges(); | 2793 Base::TestNetworkRouteChanges(); |
2439 } | 2794 } |
2440 | 2795 |
2441 TEST_F(VideoChannelTest, TestCallSetup) { | 2796 TEST_F(VideoChannelSingleThreadTest, TestCallSetup) { |
2442 Base::TestCallSetup(); | 2797 Base::TestCallSetup(); |
2443 } | 2798 } |
2444 | 2799 |
2445 TEST_F(VideoChannelTest, TestCallTeardownRtcpMux) { | 2800 TEST_F(VideoChannelSingleThreadTest, TestCallTeardownRtcpMux) { |
2446 Base::TestCallTeardownRtcpMux(); | 2801 Base::TestCallTeardownRtcpMux(); |
2447 } | 2802 } |
2448 | 2803 |
2449 TEST_F(VideoChannelTest, SendRtpToRtp) { | 2804 TEST_F(VideoChannelSingleThreadTest, SendRtpToRtp) { |
2450 Base::SendRtpToRtp(); | 2805 Base::SendRtpToRtp(); |
2451 } | 2806 } |
2452 | 2807 |
2453 TEST_F(VideoChannelTest, SendNoRtcpToNoRtcp) { | 2808 TEST_F(VideoChannelSingleThreadTest, SendNoRtcpToNoRtcp) { |
2454 Base::SendNoRtcpToNoRtcp(); | 2809 Base::SendNoRtcpToNoRtcp(); |
2455 } | 2810 } |
2456 | 2811 |
2457 TEST_F(VideoChannelTest, SendNoRtcpToRtcp) { | 2812 TEST_F(VideoChannelSingleThreadTest, SendNoRtcpToRtcp) { |
2458 Base::SendNoRtcpToRtcp(); | 2813 Base::SendNoRtcpToRtcp(); |
2459 } | 2814 } |
2460 | 2815 |
2461 TEST_F(VideoChannelTest, SendRtcpToNoRtcp) { | 2816 TEST_F(VideoChannelSingleThreadTest, SendRtcpToNoRtcp) { |
2462 Base::SendRtcpToNoRtcp(); | 2817 Base::SendRtcpToNoRtcp(); |
2463 } | 2818 } |
2464 | 2819 |
2465 TEST_F(VideoChannelTest, SendRtcpToRtcp) { | 2820 TEST_F(VideoChannelSingleThreadTest, SendRtcpToRtcp) { |
2466 Base::SendRtcpToRtcp(); | 2821 Base::SendRtcpToRtcp(); |
2467 } | 2822 } |
2468 | 2823 |
2469 TEST_F(VideoChannelTest, SendRtcpMuxToRtcp) { | 2824 TEST_F(VideoChannelSingleThreadTest, SendRtcpMuxToRtcp) { |
2470 Base::SendRtcpMuxToRtcp(); | 2825 Base::SendRtcpMuxToRtcp(); |
2471 } | 2826 } |
2472 | 2827 |
2473 TEST_F(VideoChannelTest, SendRtcpMuxToRtcpMux) { | 2828 TEST_F(VideoChannelSingleThreadTest, SendRtcpMuxToRtcpMux) { |
2474 Base::SendRtcpMuxToRtcpMux(); | 2829 Base::SendRtcpMuxToRtcpMux(); |
2475 } | 2830 } |
2476 | 2831 |
2477 TEST_F(VideoChannelTest, SendRequireRtcpMuxToRtcpMux) { | 2832 TEST_F(VideoChannelSingleThreadTest, SendRequireRtcpMuxToRtcpMux) { |
2478 Base::SendRequireRtcpMuxToRtcpMux(); | 2833 Base::SendRequireRtcpMuxToRtcpMux(); |
2479 } | 2834 } |
2480 | 2835 |
2481 TEST_F(VideoChannelTest, SendRtcpMuxToRequireRtcpMux) { | 2836 TEST_F(VideoChannelSingleThreadTest, SendRtcpMuxToRequireRtcpMux) { |
2482 Base::SendRtcpMuxToRequireRtcpMux(); | 2837 Base::SendRtcpMuxToRequireRtcpMux(); |
2483 } | 2838 } |
2484 | 2839 |
2485 TEST_F(VideoChannelTest, SendRequireRtcpMuxToRequireRtcpMux) { | 2840 TEST_F(VideoChannelSingleThreadTest, SendRequireRtcpMuxToRequireRtcpMux) { |
2486 Base::SendRequireRtcpMuxToRequireRtcpMux(); | 2841 Base::SendRequireRtcpMuxToRequireRtcpMux(); |
2487 } | 2842 } |
2488 | 2843 |
2489 TEST_F(VideoChannelTest, SendRequireRtcpMuxToNoRtcpMux) { | 2844 TEST_F(VideoChannelSingleThreadTest, SendRequireRtcpMuxToNoRtcpMux) { |
2490 Base::SendRequireRtcpMuxToNoRtcpMux(); | 2845 Base::SendRequireRtcpMuxToNoRtcpMux(); |
2491 } | 2846 } |
2492 | 2847 |
2493 TEST_F(VideoChannelTest, SendEarlyRtcpMuxToRtcp) { | 2848 TEST_F(VideoChannelSingleThreadTest, SendEarlyRtcpMuxToRtcp) { |
2494 Base::SendEarlyRtcpMuxToRtcp(); | 2849 Base::SendEarlyRtcpMuxToRtcp(); |
2495 } | 2850 } |
2496 | 2851 |
2497 TEST_F(VideoChannelTest, SendEarlyRtcpMuxToRtcpMux) { | 2852 TEST_F(VideoChannelSingleThreadTest, SendEarlyRtcpMuxToRtcpMux) { |
2498 Base::SendEarlyRtcpMuxToRtcpMux(); | 2853 Base::SendEarlyRtcpMuxToRtcpMux(); |
2499 } | 2854 } |
2500 | 2855 |
2501 TEST_F(VideoChannelTest, SendSrtpToSrtp) { | 2856 TEST_F(VideoChannelSingleThreadTest, SendSrtpToSrtp) { |
2502 Base::SendSrtpToSrtp(); | 2857 Base::SendSrtpToSrtp(); |
2503 } | 2858 } |
2504 | 2859 |
2505 TEST_F(VideoChannelTest, SendSrtpToRtp) { | 2860 TEST_F(VideoChannelSingleThreadTest, SendSrtpToRtp) { |
2506 Base::SendSrtpToSrtp(); | 2861 Base::SendSrtpToSrtp(); |
2507 } | 2862 } |
2508 | 2863 |
2509 TEST_F(VideoChannelTest, SendDtlsSrtpToSrtp) { | 2864 TEST_F(VideoChannelSingleThreadTest, SendDtlsSrtpToSrtp) { |
2510 MAYBE_SKIP_TEST(HaveDtlsSrtp); | 2865 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
2511 Base::SendSrtpToSrtp(DTLS, 0); | 2866 Base::SendSrtpToSrtp(DTLS, 0); |
2512 } | 2867 } |
2513 | 2868 |
2514 TEST_F(VideoChannelTest, SendDtlsSrtpToDtlsSrtp) { | 2869 TEST_F(VideoChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtp) { |
2515 MAYBE_SKIP_TEST(HaveDtlsSrtp); | 2870 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
2516 Base::SendSrtpToSrtp(DTLS, DTLS); | 2871 Base::SendSrtpToSrtp(DTLS, DTLS); |
2517 } | 2872 } |
2518 | 2873 |
2519 TEST_F(VideoChannelTest, SendDtlsSrtpToDtlsSrtpRtcpMux) { | 2874 TEST_F(VideoChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) { |
2520 MAYBE_SKIP_TEST(HaveDtlsSrtp); | 2875 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
2521 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX); | 2876 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX); |
2522 } | 2877 } |
2523 | 2878 |
2524 TEST_F(VideoChannelTest, SendSrtcpMux) { | 2879 TEST_F(VideoChannelSingleThreadTest, SendSrtcpMux) { |
2525 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX); | 2880 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX); |
2526 } | 2881 } |
2527 | 2882 |
2528 TEST_F(VideoChannelTest, SendEarlyMediaUsingRtcpMuxSrtp) { | 2883 TEST_F(VideoChannelSingleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) { |
2529 Base::SendEarlyMediaUsingRtcpMuxSrtp(); | 2884 Base::SendEarlyMediaUsingRtcpMuxSrtp(); |
2530 } | 2885 } |
2531 | 2886 |
2532 TEST_F(VideoChannelTest, SendRtpToRtpOnThread) { | 2887 TEST_F(VideoChannelSingleThreadTest, SendRtpToRtpOnThread) { |
2533 Base::SendRtpToRtpOnThread(); | 2888 Base::SendRtpToRtpOnThread(); |
2534 } | 2889 } |
2535 | 2890 |
2536 TEST_F(VideoChannelTest, SendSrtpToSrtpOnThread) { | 2891 TEST_F(VideoChannelSingleThreadTest, SendSrtpToSrtpOnThread) { |
2537 Base::SendSrtpToSrtpOnThread(); | 2892 Base::SendSrtpToSrtpOnThread(); |
2538 } | 2893 } |
2539 | 2894 |
2540 TEST_F(VideoChannelTest, SendWithWritabilityLoss) { | 2895 TEST_F(VideoChannelSingleThreadTest, SendWithWritabilityLoss) { |
2541 Base::SendWithWritabilityLoss(); | 2896 Base::SendWithWritabilityLoss(); |
2542 } | 2897 } |
2543 | 2898 |
2544 TEST_F(VideoChannelTest, TestMediaMonitor) { | 2899 TEST_F(VideoChannelSingleThreadTest, TestMediaMonitor) { |
2545 Base::TestMediaMonitor(); | 2900 Base::TestMediaMonitor(); |
2546 } | 2901 } |
2547 | 2902 |
2548 TEST_F(VideoChannelTest, TestSetContentFailure) { | 2903 TEST_F(VideoChannelSingleThreadTest, TestSetContentFailure) { |
2549 Base::TestSetContentFailure(); | 2904 Base::TestSetContentFailure(); |
2550 } | 2905 } |
2551 | 2906 |
2552 TEST_F(VideoChannelTest, TestSendTwoOffers) { | 2907 TEST_F(VideoChannelSingleThreadTest, TestSendTwoOffers) { |
2553 Base::TestSendTwoOffers(); | 2908 Base::TestSendTwoOffers(); |
2554 } | 2909 } |
2555 | 2910 |
2556 TEST_F(VideoChannelTest, TestReceiveTwoOffers) { | 2911 TEST_F(VideoChannelSingleThreadTest, TestReceiveTwoOffers) { |
2557 Base::TestReceiveTwoOffers(); | 2912 Base::TestReceiveTwoOffers(); |
2558 } | 2913 } |
2559 | 2914 |
2560 TEST_F(VideoChannelTest, TestSendPrAnswer) { | 2915 TEST_F(VideoChannelSingleThreadTest, TestSendPrAnswer) { |
2561 Base::TestSendPrAnswer(); | 2916 Base::TestSendPrAnswer(); |
2562 } | 2917 } |
2563 | 2918 |
2564 TEST_F(VideoChannelTest, TestReceivePrAnswer) { | 2919 TEST_F(VideoChannelSingleThreadTest, TestReceivePrAnswer) { |
2565 Base::TestReceivePrAnswer(); | 2920 Base::TestReceivePrAnswer(); |
2566 } | 2921 } |
2567 | 2922 |
2568 TEST_F(VideoChannelTest, TestFlushRtcp) { | 2923 TEST_F(VideoChannelSingleThreadTest, TestFlushRtcp) { |
2569 Base::TestFlushRtcp(); | 2924 Base::TestFlushRtcp(); |
2570 } | 2925 } |
2571 | 2926 |
2572 TEST_F(VideoChannelTest, SendBundleToBundle) { | 2927 TEST_F(VideoChannelSingleThreadTest, SendBundleToBundle) { |
2573 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, false); | 2928 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, false); |
2574 } | 2929 } |
2575 | 2930 |
2576 TEST_F(VideoChannelTest, SendBundleToBundleSecure) { | 2931 TEST_F(VideoChannelSingleThreadTest, SendBundleToBundleSecure) { |
2577 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, true); | 2932 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, true); |
2578 } | 2933 } |
2579 | 2934 |
2580 TEST_F(VideoChannelTest, SendBundleToBundleWithRtcpMux) { | 2935 TEST_F(VideoChannelSingleThreadTest, SendBundleToBundleWithRtcpMux) { |
2581 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, false); | 2936 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, false); |
2582 } | 2937 } |
2583 | 2938 |
2584 TEST_F(VideoChannelTest, SendBundleToBundleWithRtcpMuxSecure) { | 2939 TEST_F(VideoChannelSingleThreadTest, SendBundleToBundleWithRtcpMuxSecure) { |
2585 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, true); | 2940 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, true); |
2586 } | 2941 } |
2587 | 2942 |
2588 TEST_F(VideoChannelTest, TestSrtpError) { | 2943 TEST_F(VideoChannelSingleThreadTest, TestSrtpError) { |
2589 Base::TestSrtpError(kVideoPts[0]); | 2944 Base::TestSrtpError(kVideoPts[0]); |
2590 } | 2945 } |
2591 | 2946 |
2592 TEST_F(VideoChannelTest, TestOnReadyToSend) { | 2947 TEST_F(VideoChannelSingleThreadTest, TestOnReadyToSend) { |
2593 Base::TestOnReadyToSend(); | 2948 Base::TestOnReadyToSend(); |
2594 } | 2949 } |
2595 | 2950 |
2596 TEST_F(VideoChannelTest, TestOnReadyToSendWithRtcpMux) { | 2951 TEST_F(VideoChannelSingleThreadTest, TestOnReadyToSendWithRtcpMux) { |
2597 Base::TestOnReadyToSendWithRtcpMux(); | 2952 Base::TestOnReadyToSendWithRtcpMux(); |
2598 } | 2953 } |
2599 | 2954 |
2600 TEST_F(VideoChannelTest, DefaultMaxBitrateIsUnlimited) { | 2955 TEST_F(VideoChannelSingleThreadTest, DefaultMaxBitrateIsUnlimited) { |
2601 Base::DefaultMaxBitrateIsUnlimited(); | 2956 Base::DefaultMaxBitrateIsUnlimited(); |
2602 } | 2957 } |
2603 | 2958 |
2604 TEST_F(VideoChannelTest, CanChangeMaxBitrate) { | 2959 TEST_F(VideoChannelSingleThreadTest, CanChangeMaxBitrate) { |
2605 Base::CanChangeMaxBitrate(); | 2960 Base::CanChangeMaxBitrate(); |
2606 } | 2961 } |
2607 | 2962 |
2608 // DataChannelTest | 2963 // VideoChannelDoubleThreadTest |
2609 | 2964 TEST_F(VideoChannelDoubleThreadTest, TestInit) { |
2610 class DataChannelTest | 2965 Base::TestInit(); |
2611 : public ChannelTest<DataTraits> { | 2966 } |
| 2967 |
| 2968 TEST_F(VideoChannelDoubleThreadTest, TestSetContents) { |
| 2969 Base::TestSetContents(); |
| 2970 } |
| 2971 |
| 2972 TEST_F(VideoChannelDoubleThreadTest, TestSetContentsNullOffer) { |
| 2973 Base::TestSetContentsNullOffer(); |
| 2974 } |
| 2975 |
| 2976 TEST_F(VideoChannelDoubleThreadTest, TestSetContentsRtcpMux) { |
| 2977 Base::TestSetContentsRtcpMux(); |
| 2978 } |
| 2979 |
| 2980 TEST_F(VideoChannelDoubleThreadTest, TestSetContentsRtcpMuxWithPrAnswer) { |
| 2981 Base::TestSetContentsRtcpMux(); |
| 2982 } |
| 2983 |
| 2984 TEST_F(VideoChannelDoubleThreadTest, TestSetRemoteContentUpdate) { |
| 2985 Base::TestSetRemoteContentUpdate(); |
| 2986 } |
| 2987 |
| 2988 TEST_F(VideoChannelDoubleThreadTest, TestStreams) { |
| 2989 Base::TestStreams(); |
| 2990 } |
| 2991 |
| 2992 TEST_F(VideoChannelDoubleThreadTest, TestUpdateStreamsInLocalContent) { |
| 2993 Base::TestUpdateStreamsInLocalContent(); |
| 2994 } |
| 2995 |
| 2996 TEST_F(VideoChannelDoubleThreadTest, TestUpdateRemoteStreamsInContent) { |
| 2997 Base::TestUpdateStreamsInRemoteContent(); |
| 2998 } |
| 2999 |
| 3000 TEST_F(VideoChannelDoubleThreadTest, TestChangeStreamParamsInContent) { |
| 3001 Base::TestChangeStreamParamsInContent(); |
| 3002 } |
| 3003 |
| 3004 TEST_F(VideoChannelDoubleThreadTest, TestPlayoutAndSendingStates) { |
| 3005 Base::TestPlayoutAndSendingStates(); |
| 3006 } |
| 3007 |
| 3008 TEST_F(VideoChannelDoubleThreadTest, TestMuteStream) { |
| 3009 CreateChannels(0, 0); |
| 3010 // Test that we can Mute the default channel even though the sending SSRC |
| 3011 // is unknown. |
| 3012 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); |
| 3013 EXPECT_TRUE(channel1_->SetVideoSend(0, false, nullptr)); |
| 3014 EXPECT_TRUE(media_channel1_->IsStreamMuted(0)); |
| 3015 EXPECT_TRUE(channel1_->SetVideoSend(0, true, nullptr)); |
| 3016 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); |
| 3017 // Test that we can not mute an unknown SSRC. |
| 3018 EXPECT_FALSE(channel1_->SetVideoSend(kSsrc1, false, nullptr)); |
| 3019 SendInitiate(); |
| 3020 // After the local session description has been set, we can mute a stream |
| 3021 // with its SSRC. |
| 3022 EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, false, nullptr)); |
| 3023 EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1)); |
| 3024 EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, true, nullptr)); |
| 3025 EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1)); |
| 3026 } |
| 3027 |
| 3028 TEST_F(VideoChannelDoubleThreadTest, TestMediaContentDirection) { |
| 3029 Base::TestMediaContentDirection(); |
| 3030 } |
| 3031 |
| 3032 TEST_F(VideoChannelDoubleThreadTest, TestNetworkRouteChanges) { |
| 3033 Base::TestNetworkRouteChanges(); |
| 3034 } |
| 3035 |
| 3036 TEST_F(VideoChannelDoubleThreadTest, TestCallSetup) { |
| 3037 Base::TestCallSetup(); |
| 3038 } |
| 3039 |
| 3040 TEST_F(VideoChannelDoubleThreadTest, TestCallTeardownRtcpMux) { |
| 3041 Base::TestCallTeardownRtcpMux(); |
| 3042 } |
| 3043 |
| 3044 TEST_F(VideoChannelDoubleThreadTest, SendRtpToRtp) { |
| 3045 Base::SendRtpToRtp(); |
| 3046 } |
| 3047 |
| 3048 TEST_F(VideoChannelDoubleThreadTest, SendNoRtcpToNoRtcp) { |
| 3049 Base::SendNoRtcpToNoRtcp(); |
| 3050 } |
| 3051 |
| 3052 TEST_F(VideoChannelDoubleThreadTest, SendNoRtcpToRtcp) { |
| 3053 Base::SendNoRtcpToRtcp(); |
| 3054 } |
| 3055 |
| 3056 TEST_F(VideoChannelDoubleThreadTest, SendRtcpToNoRtcp) { |
| 3057 Base::SendRtcpToNoRtcp(); |
| 3058 } |
| 3059 |
| 3060 TEST_F(VideoChannelDoubleThreadTest, SendRtcpToRtcp) { |
| 3061 Base::SendRtcpToRtcp(); |
| 3062 } |
| 3063 |
| 3064 TEST_F(VideoChannelDoubleThreadTest, SendRtcpMuxToRtcp) { |
| 3065 Base::SendRtcpMuxToRtcp(); |
| 3066 } |
| 3067 |
| 3068 TEST_F(VideoChannelDoubleThreadTest, SendRtcpMuxToRtcpMux) { |
| 3069 Base::SendRtcpMuxToRtcpMux(); |
| 3070 } |
| 3071 |
| 3072 TEST_F(VideoChannelDoubleThreadTest, SendRequireRtcpMuxToRtcpMux) { |
| 3073 Base::SendRequireRtcpMuxToRtcpMux(); |
| 3074 } |
| 3075 |
| 3076 TEST_F(VideoChannelDoubleThreadTest, SendRtcpMuxToRequireRtcpMux) { |
| 3077 Base::SendRtcpMuxToRequireRtcpMux(); |
| 3078 } |
| 3079 |
| 3080 TEST_F(VideoChannelDoubleThreadTest, SendRequireRtcpMuxToRequireRtcpMux) { |
| 3081 Base::SendRequireRtcpMuxToRequireRtcpMux(); |
| 3082 } |
| 3083 |
| 3084 TEST_F(VideoChannelDoubleThreadTest, SendRequireRtcpMuxToNoRtcpMux) { |
| 3085 Base::SendRequireRtcpMuxToNoRtcpMux(); |
| 3086 } |
| 3087 |
| 3088 TEST_F(VideoChannelDoubleThreadTest, SendEarlyRtcpMuxToRtcp) { |
| 3089 Base::SendEarlyRtcpMuxToRtcp(); |
| 3090 } |
| 3091 |
| 3092 TEST_F(VideoChannelDoubleThreadTest, SendEarlyRtcpMuxToRtcpMux) { |
| 3093 Base::SendEarlyRtcpMuxToRtcpMux(); |
| 3094 } |
| 3095 |
| 3096 TEST_F(VideoChannelDoubleThreadTest, SendSrtpToSrtp) { |
| 3097 Base::SendSrtpToSrtp(); |
| 3098 } |
| 3099 |
| 3100 TEST_F(VideoChannelDoubleThreadTest, SendSrtpToRtp) { |
| 3101 Base::SendSrtpToSrtp(); |
| 3102 } |
| 3103 |
| 3104 TEST_F(VideoChannelDoubleThreadTest, SendDtlsSrtpToSrtp) { |
| 3105 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 3106 Base::SendSrtpToSrtp(DTLS, 0); |
| 3107 } |
| 3108 |
| 3109 TEST_F(VideoChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtp) { |
| 3110 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 3111 Base::SendSrtpToSrtp(DTLS, DTLS); |
| 3112 } |
| 3113 |
| 3114 TEST_F(VideoChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) { |
| 3115 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 3116 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX); |
| 3117 } |
| 3118 |
| 3119 TEST_F(VideoChannelDoubleThreadTest, SendSrtcpMux) { |
| 3120 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX); |
| 3121 } |
| 3122 |
| 3123 TEST_F(VideoChannelDoubleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) { |
| 3124 Base::SendEarlyMediaUsingRtcpMuxSrtp(); |
| 3125 } |
| 3126 |
| 3127 TEST_F(VideoChannelDoubleThreadTest, SendRtpToRtpOnThread) { |
| 3128 Base::SendRtpToRtpOnThread(); |
| 3129 } |
| 3130 |
| 3131 TEST_F(VideoChannelDoubleThreadTest, SendSrtpToSrtpOnThread) { |
| 3132 Base::SendSrtpToSrtpOnThread(); |
| 3133 } |
| 3134 |
| 3135 TEST_F(VideoChannelDoubleThreadTest, SendWithWritabilityLoss) { |
| 3136 Base::SendWithWritabilityLoss(); |
| 3137 } |
| 3138 |
| 3139 TEST_F(VideoChannelDoubleThreadTest, TestMediaMonitor) { |
| 3140 Base::TestMediaMonitor(); |
| 3141 } |
| 3142 |
| 3143 TEST_F(VideoChannelDoubleThreadTest, TestSetContentFailure) { |
| 3144 Base::TestSetContentFailure(); |
| 3145 } |
| 3146 |
| 3147 TEST_F(VideoChannelDoubleThreadTest, TestSendTwoOffers) { |
| 3148 Base::TestSendTwoOffers(); |
| 3149 } |
| 3150 |
| 3151 TEST_F(VideoChannelDoubleThreadTest, TestReceiveTwoOffers) { |
| 3152 Base::TestReceiveTwoOffers(); |
| 3153 } |
| 3154 |
| 3155 TEST_F(VideoChannelDoubleThreadTest, TestSendPrAnswer) { |
| 3156 Base::TestSendPrAnswer(); |
| 3157 } |
| 3158 |
| 3159 TEST_F(VideoChannelDoubleThreadTest, TestReceivePrAnswer) { |
| 3160 Base::TestReceivePrAnswer(); |
| 3161 } |
| 3162 |
| 3163 TEST_F(VideoChannelDoubleThreadTest, TestFlushRtcp) { |
| 3164 Base::TestFlushRtcp(); |
| 3165 } |
| 3166 |
| 3167 TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundle) { |
| 3168 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, false); |
| 3169 } |
| 3170 |
| 3171 TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundleSecure) { |
| 3172 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, true); |
| 3173 } |
| 3174 |
| 3175 TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundleWithRtcpMux) { |
| 3176 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, false); |
| 3177 } |
| 3178 |
| 3179 TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundleWithRtcpMuxSecure) { |
| 3180 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, true); |
| 3181 } |
| 3182 |
| 3183 TEST_F(VideoChannelDoubleThreadTest, TestSrtpError) { |
| 3184 Base::TestSrtpError(kVideoPts[0]); |
| 3185 } |
| 3186 |
| 3187 TEST_F(VideoChannelDoubleThreadTest, TestOnReadyToSend) { |
| 3188 Base::TestOnReadyToSend(); |
| 3189 } |
| 3190 |
| 3191 TEST_F(VideoChannelDoubleThreadTest, TestOnReadyToSendWithRtcpMux) { |
| 3192 Base::TestOnReadyToSendWithRtcpMux(); |
| 3193 } |
| 3194 |
| 3195 TEST_F(VideoChannelDoubleThreadTest, DefaultMaxBitrateIsUnlimited) { |
| 3196 Base::DefaultMaxBitrateIsUnlimited(); |
| 3197 } |
| 3198 |
| 3199 TEST_F(VideoChannelDoubleThreadTest, CanChangeMaxBitrate) { |
| 3200 Base::CanChangeMaxBitrate(); |
| 3201 } |
| 3202 |
| 3203 // DataChannelSingleThreadTest |
| 3204 class DataChannelSingleThreadTest : public ChannelTest<DataTraits> { |
2612 public: | 3205 public: |
2613 typedef ChannelTest<DataTraits> | 3206 typedef ChannelTest<DataTraits> Base; |
2614 Base; | 3207 DataChannelSingleThreadTest() |
2615 DataChannelTest() | 3208 : Base(true, kDataPacket, kRtcpReport, NetworkIsWorker::Yes) {} |
2616 : Base(true, | 3209 }; |
2617 kDataPacket, | 3210 |
2618 sizeof(kDataPacket), | 3211 // DataChannelDoubleThreadTest |
2619 kRtcpReport, | 3212 class DataChannelDoubleThreadTest : public ChannelTest<DataTraits> { |
2620 sizeof(kRtcpReport)) {} | 3213 public: |
| 3214 typedef ChannelTest<DataTraits> Base; |
| 3215 DataChannelDoubleThreadTest() |
| 3216 : Base(true, kDataPacket, kRtcpReport, NetworkIsWorker::No) {} |
2621 }; | 3217 }; |
2622 | 3218 |
2623 // Override to avoid engine channel parameter. | 3219 // Override to avoid engine channel parameter. |
2624 template <> | 3220 template <> |
2625 cricket::DataChannel* ChannelTest<DataTraits>::CreateChannel( | 3221 cricket::DataChannel* ChannelTest<DataTraits>::CreateChannel( |
2626 rtc::Thread* thread, | 3222 rtc::Thread* worker_thread, |
| 3223 rtc::Thread* network_thread, |
2627 cricket::MediaEngineInterface* engine, | 3224 cricket::MediaEngineInterface* engine, |
2628 cricket::FakeDataMediaChannel* ch, | 3225 cricket::FakeDataMediaChannel* ch, |
2629 cricket::TransportController* transport_controller, | 3226 cricket::TransportController* transport_controller, |
2630 bool rtcp) { | 3227 bool rtcp) { |
2631 cricket::DataChannel* channel = new cricket::DataChannel( | 3228 cricket::DataChannel* channel = |
2632 thread, ch, transport_controller, cricket::CN_DATA, rtcp); | 3229 new cricket::DataChannel(worker_thread, network_thread, ch, |
| 3230 transport_controller, cricket::CN_DATA, rtcp); |
2633 if (!channel->Init()) { | 3231 if (!channel->Init()) { |
2634 delete channel; | 3232 delete channel; |
2635 channel = NULL; | 3233 channel = NULL; |
2636 } | 3234 } |
2637 return channel; | 3235 return channel; |
2638 } | 3236 } |
2639 | 3237 |
2640 template<> | 3238 template <> |
2641 void ChannelTest<DataTraits>::CreateContent( | 3239 void ChannelTest<DataTraits>::CreateContent( |
2642 int flags, | 3240 int flags, |
2643 const cricket::AudioCodec& audio_codec, | 3241 const cricket::AudioCodec& audio_codec, |
2644 const cricket::VideoCodec& video_codec, | 3242 const cricket::VideoCodec& video_codec, |
2645 cricket::DataContentDescription* data) { | 3243 cricket::DataContentDescription* data) { |
2646 data->AddCodec(kGoogleDataCodec); | 3244 data->AddCodec(kGoogleDataCodec); |
2647 data->set_rtcp_mux((flags & RTCP_MUX) != 0); | 3245 data->set_rtcp_mux((flags & RTCP_MUX) != 0); |
2648 if (flags & SECURE) { | 3246 if (flags & SECURE) { |
2649 data->AddCrypto(cricket::CryptoParams( | 3247 data->AddCrypto(cricket::CryptoParams( |
2650 1, rtc::CS_AES_CM_128_HMAC_SHA1_32, | 3248 1, rtc::CS_AES_CM_128_HMAC_SHA1_32, |
2651 "inline:" + rtc::CreateRandomString(40), std::string())); | 3249 "inline:" + rtc::CreateRandomString(40), std::string())); |
2652 } | 3250 } |
2653 } | 3251 } |
2654 | 3252 |
2655 template<> | 3253 template <> |
2656 void ChannelTest<DataTraits>::CopyContent( | 3254 void ChannelTest<DataTraits>::CopyContent( |
2657 const cricket::DataContentDescription& source, | 3255 const cricket::DataContentDescription& source, |
2658 cricket::DataContentDescription* data) { | 3256 cricket::DataContentDescription* data) { |
2659 *data = source; | 3257 *data = source; |
2660 } | 3258 } |
2661 | 3259 |
2662 template<> | 3260 template <> |
2663 bool ChannelTest<DataTraits>::CodecMatches(const cricket::DataCodec& c1, | 3261 bool ChannelTest<DataTraits>::CodecMatches(const cricket::DataCodec& c1, |
2664 const cricket::DataCodec& c2) { | 3262 const cricket::DataCodec& c2) { |
2665 return c1.name == c2.name; | 3263 return c1.name == c2.name; |
2666 } | 3264 } |
2667 | 3265 |
2668 template <> | 3266 template <> |
2669 void ChannelTest<DataTraits>::AddLegacyStreamInContent( | 3267 void ChannelTest<DataTraits>::AddLegacyStreamInContent( |
2670 uint32_t ssrc, | 3268 uint32_t ssrc, |
2671 int flags, | 3269 int flags, |
2672 cricket::DataContentDescription* data) { | 3270 cricket::DataContentDescription* data) { |
2673 data->AddLegacyStream(ssrc); | 3271 data->AddLegacyStream(ssrc); |
2674 } | 3272 } |
2675 | 3273 |
2676 TEST_F(DataChannelTest, TestInit) { | 3274 TEST_F(DataChannelSingleThreadTest, TestInit) { |
2677 Base::TestInit(); | 3275 Base::TestInit(); |
2678 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); | 3276 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); |
2679 } | 3277 } |
2680 | 3278 |
2681 TEST_F(DataChannelTest, TestSetContents) { | 3279 TEST_F(DataChannelSingleThreadTest, TestSetContents) { |
2682 Base::TestSetContents(); | 3280 Base::TestSetContents(); |
2683 } | 3281 } |
2684 | 3282 |
2685 TEST_F(DataChannelTest, TestSetContentsNullOffer) { | 3283 TEST_F(DataChannelSingleThreadTest, TestSetContentsNullOffer) { |
2686 Base::TestSetContentsNullOffer(); | 3284 Base::TestSetContentsNullOffer(); |
2687 } | 3285 } |
2688 | 3286 |
2689 TEST_F(DataChannelTest, TestSetContentsRtcpMux) { | 3287 TEST_F(DataChannelSingleThreadTest, TestSetContentsRtcpMux) { |
2690 Base::TestSetContentsRtcpMux(); | 3288 Base::TestSetContentsRtcpMux(); |
2691 } | 3289 } |
2692 | 3290 |
2693 TEST_F(DataChannelTest, TestSetRemoteContentUpdate) { | 3291 TEST_F(DataChannelSingleThreadTest, TestSetRemoteContentUpdate) { |
2694 Base::TestSetRemoteContentUpdate(); | 3292 Base::TestSetRemoteContentUpdate(); |
2695 } | 3293 } |
2696 | 3294 |
2697 TEST_F(DataChannelTest, TestStreams) { | 3295 TEST_F(DataChannelSingleThreadTest, TestStreams) { |
2698 Base::TestStreams(); | 3296 Base::TestStreams(); |
2699 } | 3297 } |
2700 | 3298 |
2701 TEST_F(DataChannelTest, TestUpdateStreamsInLocalContent) { | 3299 TEST_F(DataChannelSingleThreadTest, TestUpdateStreamsInLocalContent) { |
2702 Base::TestUpdateStreamsInLocalContent(); | 3300 Base::TestUpdateStreamsInLocalContent(); |
2703 } | 3301 } |
2704 | 3302 |
2705 TEST_F(DataChannelTest, TestUpdateRemoteStreamsInContent) { | 3303 TEST_F(DataChannelSingleThreadTest, TestUpdateRemoteStreamsInContent) { |
2706 Base::TestUpdateStreamsInRemoteContent(); | 3304 Base::TestUpdateStreamsInRemoteContent(); |
2707 } | 3305 } |
2708 | 3306 |
2709 TEST_F(DataChannelTest, TestChangeStreamParamsInContent) { | 3307 TEST_F(DataChannelSingleThreadTest, TestChangeStreamParamsInContent) { |
2710 Base::TestChangeStreamParamsInContent(); | 3308 Base::TestChangeStreamParamsInContent(); |
2711 } | 3309 } |
2712 | 3310 |
2713 TEST_F(DataChannelTest, TestPlayoutAndSendingStates) { | 3311 TEST_F(DataChannelSingleThreadTest, TestPlayoutAndSendingStates) { |
2714 Base::TestPlayoutAndSendingStates(); | 3312 Base::TestPlayoutAndSendingStates(); |
2715 } | 3313 } |
2716 | 3314 |
2717 TEST_F(DataChannelTest, TestMediaContentDirection) { | 3315 TEST_F(DataChannelSingleThreadTest, TestMediaContentDirection) { |
2718 Base::TestMediaContentDirection(); | 3316 Base::TestMediaContentDirection(); |
2719 } | 3317 } |
2720 | 3318 |
2721 TEST_F(DataChannelTest, TestCallSetup) { | 3319 TEST_F(DataChannelSingleThreadTest, TestCallSetup) { |
2722 Base::TestCallSetup(); | 3320 Base::TestCallSetup(); |
2723 } | 3321 } |
2724 | 3322 |
2725 TEST_F(DataChannelTest, TestCallTeardownRtcpMux) { | 3323 TEST_F(DataChannelSingleThreadTest, TestCallTeardownRtcpMux) { |
2726 Base::TestCallTeardownRtcpMux(); | 3324 Base::TestCallTeardownRtcpMux(); |
2727 } | 3325 } |
2728 | 3326 |
2729 TEST_F(DataChannelTest, TestOnReadyToSend) { | 3327 TEST_F(DataChannelSingleThreadTest, TestOnReadyToSend) { |
2730 Base::TestOnReadyToSend(); | 3328 Base::TestOnReadyToSend(); |
2731 } | 3329 } |
2732 | 3330 |
2733 TEST_F(DataChannelTest, TestOnReadyToSendWithRtcpMux) { | 3331 TEST_F(DataChannelSingleThreadTest, TestOnReadyToSendWithRtcpMux) { |
2734 Base::TestOnReadyToSendWithRtcpMux(); | 3332 Base::TestOnReadyToSendWithRtcpMux(); |
2735 } | 3333 } |
2736 | 3334 |
2737 TEST_F(DataChannelTest, SendRtpToRtp) { | 3335 TEST_F(DataChannelSingleThreadTest, SendRtpToRtp) { |
2738 Base::SendRtpToRtp(); | 3336 Base::SendRtpToRtp(); |
2739 } | 3337 } |
2740 | 3338 |
2741 TEST_F(DataChannelTest, SendNoRtcpToNoRtcp) { | 3339 TEST_F(DataChannelSingleThreadTest, SendNoRtcpToNoRtcp) { |
2742 Base::SendNoRtcpToNoRtcp(); | 3340 Base::SendNoRtcpToNoRtcp(); |
2743 } | 3341 } |
2744 | 3342 |
2745 TEST_F(DataChannelTest, SendNoRtcpToRtcp) { | 3343 TEST_F(DataChannelSingleThreadTest, SendNoRtcpToRtcp) { |
2746 Base::SendNoRtcpToRtcp(); | 3344 Base::SendNoRtcpToRtcp(); |
2747 } | 3345 } |
2748 | 3346 |
2749 TEST_F(DataChannelTest, SendRtcpToNoRtcp) { | 3347 TEST_F(DataChannelSingleThreadTest, SendRtcpToNoRtcp) { |
2750 Base::SendRtcpToNoRtcp(); | 3348 Base::SendRtcpToNoRtcp(); |
2751 } | 3349 } |
2752 | 3350 |
2753 TEST_F(DataChannelTest, SendRtcpToRtcp) { | 3351 TEST_F(DataChannelSingleThreadTest, SendRtcpToRtcp) { |
2754 Base::SendRtcpToRtcp(); | 3352 Base::SendRtcpToRtcp(); |
2755 } | 3353 } |
2756 | 3354 |
2757 TEST_F(DataChannelTest, SendRtcpMuxToRtcp) { | 3355 TEST_F(DataChannelSingleThreadTest, SendRtcpMuxToRtcp) { |
2758 Base::SendRtcpMuxToRtcp(); | 3356 Base::SendRtcpMuxToRtcp(); |
2759 } | 3357 } |
2760 | 3358 |
2761 TEST_F(DataChannelTest, SendRtcpMuxToRtcpMux) { | 3359 TEST_F(DataChannelSingleThreadTest, SendRtcpMuxToRtcpMux) { |
2762 Base::SendRtcpMuxToRtcpMux(); | 3360 Base::SendRtcpMuxToRtcpMux(); |
2763 } | 3361 } |
2764 | 3362 |
2765 TEST_F(DataChannelTest, SendEarlyRtcpMuxToRtcp) { | 3363 TEST_F(DataChannelSingleThreadTest, SendEarlyRtcpMuxToRtcp) { |
2766 Base::SendEarlyRtcpMuxToRtcp(); | 3364 Base::SendEarlyRtcpMuxToRtcp(); |
2767 } | 3365 } |
2768 | 3366 |
2769 TEST_F(DataChannelTest, SendEarlyRtcpMuxToRtcpMux) { | 3367 TEST_F(DataChannelSingleThreadTest, SendEarlyRtcpMuxToRtcpMux) { |
2770 Base::SendEarlyRtcpMuxToRtcpMux(); | 3368 Base::SendEarlyRtcpMuxToRtcpMux(); |
2771 } | 3369 } |
2772 | 3370 |
2773 TEST_F(DataChannelTest, SendSrtpToSrtp) { | 3371 TEST_F(DataChannelSingleThreadTest, SendSrtpToSrtp) { |
2774 Base::SendSrtpToSrtp(); | 3372 Base::SendSrtpToSrtp(); |
2775 } | 3373 } |
2776 | 3374 |
2777 TEST_F(DataChannelTest, SendSrtpToRtp) { | 3375 TEST_F(DataChannelSingleThreadTest, SendSrtpToRtp) { |
2778 Base::SendSrtpToSrtp(); | 3376 Base::SendSrtpToSrtp(); |
2779 } | 3377 } |
2780 | 3378 |
2781 TEST_F(DataChannelTest, SendSrtcpMux) { | 3379 TEST_F(DataChannelSingleThreadTest, SendSrtcpMux) { |
2782 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX); | 3380 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX); |
2783 } | 3381 } |
2784 | 3382 |
2785 TEST_F(DataChannelTest, SendRtpToRtpOnThread) { | 3383 TEST_F(DataChannelSingleThreadTest, SendRtpToRtpOnThread) { |
2786 Base::SendRtpToRtpOnThread(); | 3384 Base::SendRtpToRtpOnThread(); |
2787 } | 3385 } |
2788 | 3386 |
2789 TEST_F(DataChannelTest, SendSrtpToSrtpOnThread) { | 3387 TEST_F(DataChannelSingleThreadTest, SendSrtpToSrtpOnThread) { |
2790 Base::SendSrtpToSrtpOnThread(); | 3388 Base::SendSrtpToSrtpOnThread(); |
2791 } | 3389 } |
2792 | 3390 |
2793 TEST_F(DataChannelTest, SendWithWritabilityLoss) { | 3391 TEST_F(DataChannelSingleThreadTest, SendWithWritabilityLoss) { |
2794 Base::SendWithWritabilityLoss(); | 3392 Base::SendWithWritabilityLoss(); |
2795 } | 3393 } |
2796 | 3394 |
2797 TEST_F(DataChannelTest, TestMediaMonitor) { | 3395 TEST_F(DataChannelSingleThreadTest, TestMediaMonitor) { |
2798 Base::TestMediaMonitor(); | 3396 Base::TestMediaMonitor(); |
2799 } | 3397 } |
2800 | 3398 |
2801 TEST_F(DataChannelTest, TestSendData) { | 3399 TEST_F(DataChannelSingleThreadTest, TestSendData) { |
2802 CreateChannels(0, 0); | 3400 CreateChannels(0, 0); |
2803 EXPECT_TRUE(SendInitiate()); | 3401 EXPECT_TRUE(SendInitiate()); |
2804 EXPECT_TRUE(SendAccept()); | 3402 EXPECT_TRUE(SendAccept()); |
| 3403 |
| 3404 cricket::SendDataParams params; |
| 3405 params.ssrc = 42; |
| 3406 unsigned char data[] = {'f', 'o', 'o'}; |
| 3407 rtc::CopyOnWriteBuffer payload(data, 3); |
| 3408 cricket::SendDataResult result; |
| 3409 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); |
| 3410 EXPECT_EQ(params.ssrc, media_channel1_->last_sent_data_params().ssrc); |
| 3411 EXPECT_EQ("foo", media_channel1_->last_sent_data()); |
| 3412 } |
| 3413 |
| 3414 TEST_F(DataChannelDoubleThreadTest, TestInit) { |
| 3415 Base::TestInit(); |
| 3416 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); |
| 3417 } |
| 3418 |
| 3419 TEST_F(DataChannelDoubleThreadTest, TestSetContents) { |
| 3420 Base::TestSetContents(); |
| 3421 } |
| 3422 |
| 3423 TEST_F(DataChannelDoubleThreadTest, TestSetContentsNullOffer) { |
| 3424 Base::TestSetContentsNullOffer(); |
| 3425 } |
| 3426 |
| 3427 TEST_F(DataChannelDoubleThreadTest, TestSetContentsRtcpMux) { |
| 3428 Base::TestSetContentsRtcpMux(); |
| 3429 } |
| 3430 |
| 3431 TEST_F(DataChannelDoubleThreadTest, TestSetRemoteContentUpdate) { |
| 3432 Base::TestSetRemoteContentUpdate(); |
| 3433 } |
| 3434 |
| 3435 TEST_F(DataChannelDoubleThreadTest, TestStreams) { |
| 3436 Base::TestStreams(); |
| 3437 } |
| 3438 |
| 3439 TEST_F(DataChannelDoubleThreadTest, TestUpdateStreamsInLocalContent) { |
| 3440 Base::TestUpdateStreamsInLocalContent(); |
| 3441 } |
| 3442 |
| 3443 TEST_F(DataChannelDoubleThreadTest, TestUpdateRemoteStreamsInContent) { |
| 3444 Base::TestUpdateStreamsInRemoteContent(); |
| 3445 } |
| 3446 |
| 3447 TEST_F(DataChannelDoubleThreadTest, TestChangeStreamParamsInContent) { |
| 3448 Base::TestChangeStreamParamsInContent(); |
| 3449 } |
| 3450 |
| 3451 TEST_F(DataChannelDoubleThreadTest, TestPlayoutAndSendingStates) { |
| 3452 Base::TestPlayoutAndSendingStates(); |
| 3453 } |
| 3454 |
| 3455 TEST_F(DataChannelDoubleThreadTest, TestMediaContentDirection) { |
| 3456 Base::TestMediaContentDirection(); |
| 3457 } |
| 3458 |
| 3459 TEST_F(DataChannelDoubleThreadTest, TestCallSetup) { |
| 3460 Base::TestCallSetup(); |
| 3461 } |
| 3462 |
| 3463 TEST_F(DataChannelDoubleThreadTest, TestCallTeardownRtcpMux) { |
| 3464 Base::TestCallTeardownRtcpMux(); |
| 3465 } |
| 3466 |
| 3467 TEST_F(DataChannelDoubleThreadTest, TestOnReadyToSend) { |
| 3468 Base::TestOnReadyToSend(); |
| 3469 } |
| 3470 |
| 3471 TEST_F(DataChannelDoubleThreadTest, TestOnReadyToSendWithRtcpMux) { |
| 3472 Base::TestOnReadyToSendWithRtcpMux(); |
| 3473 } |
| 3474 |
| 3475 TEST_F(DataChannelDoubleThreadTest, SendRtpToRtp) { |
| 3476 Base::SendRtpToRtp(); |
| 3477 } |
| 3478 |
| 3479 TEST_F(DataChannelDoubleThreadTest, SendNoRtcpToNoRtcp) { |
| 3480 Base::SendNoRtcpToNoRtcp(); |
| 3481 } |
| 3482 |
| 3483 TEST_F(DataChannelDoubleThreadTest, SendNoRtcpToRtcp) { |
| 3484 Base::SendNoRtcpToRtcp(); |
| 3485 } |
| 3486 |
| 3487 TEST_F(DataChannelDoubleThreadTest, SendRtcpToNoRtcp) { |
| 3488 Base::SendRtcpToNoRtcp(); |
| 3489 } |
| 3490 |
| 3491 TEST_F(DataChannelDoubleThreadTest, SendRtcpToRtcp) { |
| 3492 Base::SendRtcpToRtcp(); |
| 3493 } |
| 3494 |
| 3495 TEST_F(DataChannelDoubleThreadTest, SendRtcpMuxToRtcp) { |
| 3496 Base::SendRtcpMuxToRtcp(); |
| 3497 } |
| 3498 |
| 3499 TEST_F(DataChannelDoubleThreadTest, SendRtcpMuxToRtcpMux) { |
| 3500 Base::SendRtcpMuxToRtcpMux(); |
| 3501 } |
| 3502 |
| 3503 TEST_F(DataChannelDoubleThreadTest, SendEarlyRtcpMuxToRtcp) { |
| 3504 Base::SendEarlyRtcpMuxToRtcp(); |
| 3505 } |
| 3506 |
| 3507 TEST_F(DataChannelDoubleThreadTest, SendEarlyRtcpMuxToRtcpMux) { |
| 3508 Base::SendEarlyRtcpMuxToRtcpMux(); |
| 3509 } |
| 3510 |
| 3511 TEST_F(DataChannelDoubleThreadTest, SendSrtpToSrtp) { |
| 3512 Base::SendSrtpToSrtp(); |
| 3513 } |
| 3514 |
| 3515 TEST_F(DataChannelDoubleThreadTest, SendSrtpToRtp) { |
| 3516 Base::SendSrtpToSrtp(); |
| 3517 } |
| 3518 |
| 3519 TEST_F(DataChannelDoubleThreadTest, SendSrtcpMux) { |
| 3520 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX); |
| 3521 } |
| 3522 |
| 3523 TEST_F(DataChannelDoubleThreadTest, SendRtpToRtpOnThread) { |
| 3524 Base::SendRtpToRtpOnThread(); |
| 3525 } |
| 3526 |
| 3527 TEST_F(DataChannelDoubleThreadTest, SendSrtpToSrtpOnThread) { |
| 3528 Base::SendSrtpToSrtpOnThread(); |
| 3529 } |
| 3530 |
| 3531 TEST_F(DataChannelDoubleThreadTest, SendWithWritabilityLoss) { |
| 3532 Base::SendWithWritabilityLoss(); |
| 3533 } |
| 3534 |
| 3535 TEST_F(DataChannelDoubleThreadTest, TestMediaMonitor) { |
| 3536 Base::TestMediaMonitor(); |
| 3537 } |
| 3538 |
| 3539 TEST_F(DataChannelDoubleThreadTest, TestSendData) { |
| 3540 CreateChannels(0, 0); |
| 3541 EXPECT_TRUE(SendInitiate()); |
| 3542 EXPECT_TRUE(SendAccept()); |
2805 | 3543 |
2806 cricket::SendDataParams params; | 3544 cricket::SendDataParams params; |
2807 params.ssrc = 42; | 3545 params.ssrc = 42; |
2808 unsigned char data[] = { | 3546 unsigned char data[] = { |
2809 'f', 'o', 'o' | 3547 'f', 'o', 'o' |
2810 }; | 3548 }; |
2811 rtc::CopyOnWriteBuffer payload(data, 3); | 3549 rtc::CopyOnWriteBuffer payload(data, 3); |
2812 cricket::SendDataResult result; | 3550 cricket::SendDataResult result; |
2813 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); | 3551 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); |
2814 EXPECT_EQ(params.ssrc, | 3552 EXPECT_EQ(params.ssrc, |
2815 media_channel1_->last_sent_data_params().ssrc); | 3553 media_channel1_->last_sent_data_params().ssrc); |
2816 EXPECT_EQ("foo", media_channel1_->last_sent_data()); | 3554 EXPECT_EQ("foo", media_channel1_->last_sent_data()); |
2817 } | 3555 } |
2818 | 3556 |
2819 // TODO(pthatcher): TestSetReceiver? | 3557 // TODO(pthatcher): TestSetReceiver? |
OLD | NEW |