Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: webrtc/pc/channel_unittest.cc

Issue 1903393004: Added network thread to rtc::BaseChannel (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: fix flakiness of WebRtcSessionTest.TestPacketOptionsAndOnPacketSent Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/pc/channel.cc ('k') | webrtc/pc/channelmanager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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,
197 if (!channel->Init()) { 192 transport_controller, cricket::CN_AUDIO, rtcp);
193 if (!channel->Init_w()) {
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
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
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
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
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
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
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 kLocalNetId, kRemoteNetId, kLastPacketId] {
979 rtc::SocketAddress local_address("192.168.1.1", 1000 /* port number */); 926 // The transport channel becomes connected.
980 rtc::SocketAddress remote_address("192.168.1.2", 2000 /* port number */); 927 rtc::SocketAddress local_address("192.168.1.1", 1000 /* port number */);
981 uint16_t local_net_id = 1; 928 rtc::SocketAddress remote_address("192.168.1.2", 2000 /* port number */);
982 uint16_t remote_net_id = 2; 929 std::unique_ptr<cricket::CandidatePairInterface> candidate_pair(
983 int last_packet_id = 100; 930 transport_controller1_->CreateFakeCandidatePair(
984 std::unique_ptr<cricket::CandidatePairInterface> candidate_pair( 931 local_address, kLocalNetId, remote_address, kRemoteNetId));
985 transport_controller1_.CreateFakeCandidatePair( 932 transport_channel1->SignalSelectedCandidatePairChanged(
986 local_address, local_net_id, remote_address, remote_net_id)); 933 transport_channel1, candidate_pair.get(), kLastPacketId);
987 transport_channel1->SignalSelectedCandidatePairChanged( 934 });
988 transport_channel1, candidate_pair.get(), last_packet_id); 935 WaitForThreads();
989 EXPECT_EQ(1, media_channel1_->num_network_route_changes()); 936 EXPECT_EQ(1, media_channel1->num_network_route_changes());
990 rtc::NetworkRoute expected_network_route(local_net_id, remote_net_id, 937 rtc::NetworkRoute expected_network_route(kLocalNetId, kRemoteNetId,
991 last_packet_id); 938 kLastPacketId);
992 EXPECT_EQ(expected_network_route, media_channel1->last_network_route()); 939 EXPECT_EQ(expected_network_route, media_channel1->last_network_route());
993 EXPECT_EQ(last_packet_id, 940 EXPECT_EQ(kLastPacketId,
994 media_channel1->last_network_route().last_sent_packet_id); 941 media_channel1->last_network_route().last_sent_packet_id);
995 } 942 }
996 943
997 // Test setting up a call. 944 // Test setting up a call.
998 void TestCallSetup() { 945 void TestCallSetup() {
999 CreateChannels(0, 0); 946 CreateChannels(0, 0);
1000 EXPECT_FALSE(channel1_->secure()); 947 EXPECT_FALSE(channel1_->secure());
1001 EXPECT_TRUE(SendInitiate()); 948 EXPECT_TRUE(SendInitiate());
1002 if (verify_playout_) { 949 if (verify_playout_) {
1003 EXPECT_TRUE(media_channel1_->playout()); 950 EXPECT_TRUE(media_channel1_->playout());
(...skipping 18 matching lines...) Expand all
1022 class LastWordMediaChannel : public T::MediaChannel { 969 class LastWordMediaChannel : public T::MediaChannel {
1023 public: 970 public:
1024 LastWordMediaChannel() : T::MediaChannel(NULL, typename T::Options()) {} 971 LastWordMediaChannel() : T::MediaChannel(NULL, typename T::Options()) {}
1025 ~LastWordMediaChannel() { 972 ~LastWordMediaChannel() {
1026 T::MediaChannel::SendRtp(kPcmuFrame, sizeof(kPcmuFrame), 973 T::MediaChannel::SendRtp(kPcmuFrame, sizeof(kPcmuFrame),
1027 rtc::PacketOptions()); 974 rtc::PacketOptions());
1028 T::MediaChannel::SendRtcp(kRtcpReport, sizeof(kRtcpReport)); 975 T::MediaChannel::SendRtcp(kRtcpReport, sizeof(kRtcpReport));
1029 } 976 }
1030 }; 977 };
1031 CreateChannels(new LastWordMediaChannel(), new LastWordMediaChannel(), 978 CreateChannels(new LastWordMediaChannel(), new LastWordMediaChannel(),
1032 RTCP | RTCP_MUX, RTCP | RTCP_MUX, 979 RTCP | RTCP_MUX, RTCP | RTCP_MUX);
1033 rtc::Thread::Current());
1034 EXPECT_TRUE(SendInitiate()); 980 EXPECT_TRUE(SendInitiate());
1035 EXPECT_TRUE(SendAccept()); 981 EXPECT_TRUE(SendAccept());
1036 EXPECT_TRUE(SendTerminate()); 982 EXPECT_TRUE(SendTerminate());
1037 } 983 }
1038 984
1039 // Send voice RTP data to the other side and ensure it gets there. 985 // Send voice RTP data to the other side and ensure it gets there.
1040 void SendRtpToRtp() { 986 void SendRtpToRtp() {
1041 CreateChannels(0, 0); 987 CreateChannels(0, 0);
1042 EXPECT_TRUE(SendInitiate()); 988 EXPECT_TRUE(SendInitiate());
1043 EXPECT_TRUE(SendAccept()); 989 EXPECT_TRUE(SendAccept());
1044 ASSERT_TRUE(GetTransport1()); 990 ASSERT_TRUE(GetTransport1());
1045 ASSERT_TRUE(GetTransport2()); 991 ASSERT_TRUE(GetTransport2());
1046 EXPECT_EQ(1U, GetTransport1()->channels().size()); 992 EXPECT_EQ(1U, GetTransport1()->channels().size());
1047 EXPECT_EQ(1U, GetTransport2()->channels().size()); 993 EXPECT_EQ(1U, GetTransport2()->channels().size());
1048 EXPECT_TRUE(SendRtp1()); 994 SendRtp1();
1049 EXPECT_TRUE(SendRtp2()); 995 SendRtp2();
996 WaitForThreads();
1050 EXPECT_TRUE(CheckRtp1()); 997 EXPECT_TRUE(CheckRtp1());
1051 EXPECT_TRUE(CheckRtp2()); 998 EXPECT_TRUE(CheckRtp2());
1052 EXPECT_TRUE(CheckNoRtp1()); 999 EXPECT_TRUE(CheckNoRtp1());
1053 EXPECT_TRUE(CheckNoRtp2()); 1000 EXPECT_TRUE(CheckNoRtp2());
1054 } 1001 }
1055 1002
1056 // Check that RTCP is not transmitted if both sides don't support RTCP. 1003 // Check that RTCP is not transmitted if both sides don't support RTCP.
1057 void SendNoRtcpToNoRtcp() { 1004 void SendNoRtcpToNoRtcp() {
1058 CreateChannels(0, 0); 1005 CreateChannels(0, 0);
1059 EXPECT_TRUE(SendInitiate()); 1006 EXPECT_TRUE(SendInitiate());
1060 EXPECT_TRUE(SendAccept()); 1007 EXPECT_TRUE(SendAccept());
1061 ASSERT_TRUE(GetTransport1()); 1008 ASSERT_TRUE(GetTransport1());
1062 ASSERT_TRUE(GetTransport2()); 1009 ASSERT_TRUE(GetTransport2());
1063 EXPECT_EQ(1U, GetTransport1()->channels().size()); 1010 EXPECT_EQ(1U, GetTransport1()->channels().size());
1064 EXPECT_EQ(1U, GetTransport2()->channels().size()); 1011 EXPECT_EQ(1U, GetTransport2()->channels().size());
1065 EXPECT_FALSE(SendRtcp1()); 1012 SendRtcp1();
1066 EXPECT_FALSE(SendRtcp2()); 1013 SendRtcp2();
1014 WaitForThreads();
1067 EXPECT_TRUE(CheckNoRtcp1()); 1015 EXPECT_TRUE(CheckNoRtcp1());
1068 EXPECT_TRUE(CheckNoRtcp2()); 1016 EXPECT_TRUE(CheckNoRtcp2());
1069 } 1017 }
1070 1018
1071 // Check that RTCP is not transmitted if the callee doesn't support RTCP. 1019 // Check that RTCP is not transmitted if the callee doesn't support RTCP.
1072 void SendNoRtcpToRtcp() { 1020 void SendNoRtcpToRtcp() {
1073 CreateChannels(0, RTCP); 1021 CreateChannels(0, RTCP);
1074 EXPECT_TRUE(SendInitiate()); 1022 EXPECT_TRUE(SendInitiate());
1075 EXPECT_TRUE(SendAccept()); 1023 EXPECT_TRUE(SendAccept());
1076 ASSERT_TRUE(GetTransport1()); 1024 ASSERT_TRUE(GetTransport1());
1077 ASSERT_TRUE(GetTransport2()); 1025 ASSERT_TRUE(GetTransport2());
1078 EXPECT_EQ(1U, GetTransport1()->channels().size()); 1026 EXPECT_EQ(1U, GetTransport1()->channels().size());
1079 EXPECT_EQ(2U, GetTransport2()->channels().size()); 1027 EXPECT_EQ(2U, GetTransport2()->channels().size());
1080 EXPECT_FALSE(SendRtcp1()); 1028 SendRtcp1();
1081 EXPECT_FALSE(SendRtcp2()); 1029 SendRtcp2();
1030 WaitForThreads();
1082 EXPECT_TRUE(CheckNoRtcp1()); 1031 EXPECT_TRUE(CheckNoRtcp1());
1083 EXPECT_TRUE(CheckNoRtcp2()); 1032 EXPECT_TRUE(CheckNoRtcp2());
1084 } 1033 }
1085 1034
1086 // Check that RTCP is not transmitted if the caller doesn't support RTCP. 1035 // Check that RTCP is not transmitted if the caller doesn't support RTCP.
1087 void SendRtcpToNoRtcp() { 1036 void SendRtcpToNoRtcp() {
1088 CreateChannels(RTCP, 0); 1037 CreateChannels(RTCP, 0);
1089 EXPECT_TRUE(SendInitiate()); 1038 EXPECT_TRUE(SendInitiate());
1090 EXPECT_TRUE(SendAccept()); 1039 EXPECT_TRUE(SendAccept());
1091 ASSERT_TRUE(GetTransport1()); 1040 ASSERT_TRUE(GetTransport1());
1092 ASSERT_TRUE(GetTransport2()); 1041 ASSERT_TRUE(GetTransport2());
1093 EXPECT_EQ(2U, GetTransport1()->channels().size()); 1042 EXPECT_EQ(2U, GetTransport1()->channels().size());
1094 EXPECT_EQ(1U, GetTransport2()->channels().size()); 1043 EXPECT_EQ(1U, GetTransport2()->channels().size());
1095 EXPECT_FALSE(SendRtcp1()); 1044 SendRtcp1();
1096 EXPECT_FALSE(SendRtcp2()); 1045 SendRtcp2();
1046 WaitForThreads();
1097 EXPECT_TRUE(CheckNoRtcp1()); 1047 EXPECT_TRUE(CheckNoRtcp1());
1098 EXPECT_TRUE(CheckNoRtcp2()); 1048 EXPECT_TRUE(CheckNoRtcp2());
1099 } 1049 }
1100 1050
1101 // Check that RTCP is transmitted if both sides support RTCP. 1051 // Check that RTCP is transmitted if both sides support RTCP.
1102 void SendRtcpToRtcp() { 1052 void SendRtcpToRtcp() {
1103 CreateChannels(RTCP, RTCP); 1053 CreateChannels(RTCP, RTCP);
1104 EXPECT_TRUE(SendInitiate()); 1054 EXPECT_TRUE(SendInitiate());
1105 EXPECT_TRUE(SendAccept()); 1055 EXPECT_TRUE(SendAccept());
1106 ASSERT_TRUE(GetTransport1()); 1056 ASSERT_TRUE(GetTransport1());
1107 ASSERT_TRUE(GetTransport2()); 1057 ASSERT_TRUE(GetTransport2());
1108 EXPECT_EQ(2U, GetTransport1()->channels().size()); 1058 EXPECT_EQ(2U, GetTransport1()->channels().size());
1109 EXPECT_EQ(2U, GetTransport2()->channels().size()); 1059 EXPECT_EQ(2U, GetTransport2()->channels().size());
1110 EXPECT_TRUE(SendRtcp1()); 1060 SendRtcp1();
1111 EXPECT_TRUE(SendRtcp2()); 1061 SendRtcp2();
1062 WaitForThreads();
1112 EXPECT_TRUE(CheckRtcp1()); 1063 EXPECT_TRUE(CheckRtcp1());
1113 EXPECT_TRUE(CheckRtcp2()); 1064 EXPECT_TRUE(CheckRtcp2());
1114 EXPECT_TRUE(CheckNoRtcp1()); 1065 EXPECT_TRUE(CheckNoRtcp1());
1115 EXPECT_TRUE(CheckNoRtcp2()); 1066 EXPECT_TRUE(CheckNoRtcp2());
1116 } 1067 }
1117 1068
1118 // Check that RTCP is transmitted if only the initiator supports mux. 1069 // Check that RTCP is transmitted if only the initiator supports mux.
1119 void SendRtcpMuxToRtcp() { 1070 void SendRtcpMuxToRtcp() {
1120 CreateChannels(RTCP | RTCP_MUX, RTCP); 1071 CreateChannels(RTCP | RTCP_MUX, RTCP);
1121 EXPECT_TRUE(SendInitiate()); 1072 EXPECT_TRUE(SendInitiate());
1122 EXPECT_TRUE(SendAccept()); 1073 EXPECT_TRUE(SendAccept());
1123 ASSERT_TRUE(GetTransport1()); 1074 ASSERT_TRUE(GetTransport1());
1124 ASSERT_TRUE(GetTransport2()); 1075 ASSERT_TRUE(GetTransport2());
1125 EXPECT_EQ(2U, GetTransport1()->channels().size()); 1076 EXPECT_EQ(2U, GetTransport1()->channels().size());
1126 EXPECT_EQ(2U, GetTransport2()->channels().size()); 1077 EXPECT_EQ(2U, GetTransport2()->channels().size());
1127 EXPECT_TRUE(SendRtcp1()); 1078 SendRtcp1();
1128 EXPECT_TRUE(SendRtcp2()); 1079 SendRtcp2();
1080 WaitForThreads();
1129 EXPECT_TRUE(CheckRtcp1()); 1081 EXPECT_TRUE(CheckRtcp1());
1130 EXPECT_TRUE(CheckRtcp2()); 1082 EXPECT_TRUE(CheckRtcp2());
1131 EXPECT_TRUE(CheckNoRtcp1()); 1083 EXPECT_TRUE(CheckNoRtcp1());
1132 EXPECT_TRUE(CheckNoRtcp2()); 1084 EXPECT_TRUE(CheckNoRtcp2());
1133 } 1085 }
1134 1086
1135 // Check that RTP and RTCP are transmitted ok when both sides support mux. 1087 // Check that RTP and RTCP are transmitted ok when both sides support mux.
1136 void SendRtcpMuxToRtcpMux() { 1088 void SendRtcpMuxToRtcpMux() {
1137 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); 1089 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
1138 EXPECT_TRUE(SendInitiate()); 1090 EXPECT_TRUE(SendInitiate());
1139 ASSERT_TRUE(GetTransport1()); 1091 ASSERT_TRUE(GetTransport1());
1140 ASSERT_TRUE(GetTransport2()); 1092 ASSERT_TRUE(GetTransport2());
1141 EXPECT_EQ(2U, GetTransport1()->channels().size()); 1093 EXPECT_EQ(2U, GetTransport1()->channels().size());
1142 EXPECT_EQ(1U, GetTransport2()->channels().size()); 1094 EXPECT_EQ(1U, GetTransport2()->channels().size());
1143 EXPECT_TRUE(SendAccept()); 1095 EXPECT_TRUE(SendAccept());
1144 EXPECT_EQ(1U, GetTransport1()->channels().size()); 1096 EXPECT_EQ(1U, GetTransport1()->channels().size());
1145 EXPECT_TRUE(SendRtp1()); 1097 SendRtp1();
1146 EXPECT_TRUE(SendRtp2()); 1098 SendRtp2();
1147 EXPECT_TRUE(SendRtcp1()); 1099 SendRtcp1();
1148 EXPECT_TRUE(SendRtcp2()); 1100 SendRtcp2();
1101 WaitForThreads();
1149 EXPECT_TRUE(CheckRtp1()); 1102 EXPECT_TRUE(CheckRtp1());
1150 EXPECT_TRUE(CheckRtp2()); 1103 EXPECT_TRUE(CheckRtp2());
1151 EXPECT_TRUE(CheckNoRtp1()); 1104 EXPECT_TRUE(CheckNoRtp1());
1152 EXPECT_TRUE(CheckNoRtp2()); 1105 EXPECT_TRUE(CheckNoRtp2());
1153 EXPECT_TRUE(CheckRtcp1()); 1106 EXPECT_TRUE(CheckRtcp1());
1154 EXPECT_TRUE(CheckRtcp2()); 1107 EXPECT_TRUE(CheckRtcp2());
1155 EXPECT_TRUE(CheckNoRtcp1()); 1108 EXPECT_TRUE(CheckNoRtcp1());
1156 EXPECT_TRUE(CheckNoRtcp2()); 1109 EXPECT_TRUE(CheckNoRtcp2());
1157 } 1110 }
1158 1111
1159 // Check that RTP and RTCP are transmitted ok when both sides 1112 // Check that RTP and RTCP are transmitted ok when both sides
1160 // support mux and one the offerer requires mux. 1113 // support mux and one the offerer requires mux.
1161 void SendRequireRtcpMuxToRtcpMux() { 1114 void SendRequireRtcpMuxToRtcpMux() {
1162 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); 1115 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
1163 channel1_->ActivateRtcpMux(); 1116 channel1_->ActivateRtcpMux();
1164 EXPECT_TRUE(SendInitiate()); 1117 EXPECT_TRUE(SendInitiate());
1165 ASSERT_TRUE(GetTransport1()); 1118 ASSERT_TRUE(GetTransport1());
1166 ASSERT_TRUE(GetTransport2()); 1119 ASSERT_TRUE(GetTransport2());
1167 EXPECT_EQ(1U, GetTransport1()->channels().size()); 1120 EXPECT_EQ(1U, GetTransport1()->channels().size());
1168 EXPECT_EQ(1U, GetTransport2()->channels().size()); 1121 EXPECT_EQ(1U, GetTransport2()->channels().size());
1169 EXPECT_TRUE(SendAccept()); 1122 EXPECT_TRUE(SendAccept());
1170 EXPECT_TRUE(SendRtp1()); 1123 SendRtp1();
1171 EXPECT_TRUE(SendRtp2()); 1124 SendRtp2();
1172 EXPECT_TRUE(SendRtcp1()); 1125 SendRtcp1();
1173 EXPECT_TRUE(SendRtcp2()); 1126 SendRtcp2();
1127 WaitForThreads();
1174 EXPECT_TRUE(CheckRtp1()); 1128 EXPECT_TRUE(CheckRtp1());
1175 EXPECT_TRUE(CheckRtp2()); 1129 EXPECT_TRUE(CheckRtp2());
1176 EXPECT_TRUE(CheckNoRtp1()); 1130 EXPECT_TRUE(CheckNoRtp1());
1177 EXPECT_TRUE(CheckNoRtp2()); 1131 EXPECT_TRUE(CheckNoRtp2());
1178 EXPECT_TRUE(CheckRtcp1()); 1132 EXPECT_TRUE(CheckRtcp1());
1179 EXPECT_TRUE(CheckRtcp2()); 1133 EXPECT_TRUE(CheckRtcp2());
1180 EXPECT_TRUE(CheckNoRtcp1()); 1134 EXPECT_TRUE(CheckNoRtcp1());
1181 EXPECT_TRUE(CheckNoRtcp2()); 1135 EXPECT_TRUE(CheckNoRtcp2());
1182 } 1136 }
1183 1137
1184 // Check that RTP and RTCP are transmitted ok when both sides 1138 // Check that RTP and RTCP are transmitted ok when both sides
1185 // support mux and one the answerer requires rtcp mux. 1139 // support mux and one the answerer requires rtcp mux.
1186 void SendRtcpMuxToRequireRtcpMux() { 1140 void SendRtcpMuxToRequireRtcpMux() {
1187 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); 1141 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
1188 channel2_->ActivateRtcpMux(); 1142 channel2_->ActivateRtcpMux();
1189 EXPECT_TRUE(SendInitiate()); 1143 EXPECT_TRUE(SendInitiate());
1190 ASSERT_TRUE(GetTransport1()); 1144 ASSERT_TRUE(GetTransport1());
1191 ASSERT_TRUE(GetTransport2()); 1145 ASSERT_TRUE(GetTransport2());
1192 EXPECT_EQ(2U, GetTransport1()->channels().size()); 1146 EXPECT_EQ(2U, GetTransport1()->channels().size());
1193 EXPECT_EQ(1U, GetTransport2()->channels().size()); 1147 EXPECT_EQ(1U, GetTransport2()->channels().size());
1194 EXPECT_TRUE(SendAccept()); 1148 EXPECT_TRUE(SendAccept());
1195 EXPECT_EQ(1U, GetTransport1()->channels().size()); 1149 EXPECT_EQ(1U, GetTransport1()->channels().size());
1196 EXPECT_TRUE(SendRtp1()); 1150 SendRtp1();
1197 EXPECT_TRUE(SendRtp2()); 1151 SendRtp2();
1198 EXPECT_TRUE(SendRtcp1()); 1152 SendRtcp1();
1199 EXPECT_TRUE(SendRtcp2()); 1153 SendRtcp2();
1154 WaitForThreads();
1200 EXPECT_TRUE(CheckRtp1()); 1155 EXPECT_TRUE(CheckRtp1());
1201 EXPECT_TRUE(CheckRtp2()); 1156 EXPECT_TRUE(CheckRtp2());
1202 EXPECT_TRUE(CheckNoRtp1()); 1157 EXPECT_TRUE(CheckNoRtp1());
1203 EXPECT_TRUE(CheckNoRtp2()); 1158 EXPECT_TRUE(CheckNoRtp2());
1204 EXPECT_TRUE(CheckRtcp1()); 1159 EXPECT_TRUE(CheckRtcp1());
1205 EXPECT_TRUE(CheckRtcp2()); 1160 EXPECT_TRUE(CheckRtcp2());
1206 EXPECT_TRUE(CheckNoRtcp1()); 1161 EXPECT_TRUE(CheckNoRtcp1());
1207 EXPECT_TRUE(CheckNoRtcp2()); 1162 EXPECT_TRUE(CheckNoRtcp2());
1208 } 1163 }
1209 1164
1210 // Check that RTP and RTCP are transmitted ok when both sides 1165 // Check that RTP and RTCP are transmitted ok when both sides
1211 // require mux. 1166 // require mux.
1212 void SendRequireRtcpMuxToRequireRtcpMux() { 1167 void SendRequireRtcpMuxToRequireRtcpMux() {
1213 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); 1168 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
1214 channel1_->ActivateRtcpMux(); 1169 channel1_->ActivateRtcpMux();
1215 channel2_->ActivateRtcpMux(); 1170 channel2_->ActivateRtcpMux();
1216 EXPECT_TRUE(SendInitiate()); 1171 EXPECT_TRUE(SendInitiate());
1217 ASSERT_TRUE(GetTransport1()); 1172 ASSERT_TRUE(GetTransport1());
1218 ASSERT_TRUE(GetTransport2()); 1173 ASSERT_TRUE(GetTransport2());
1219 EXPECT_EQ(1U, GetTransport1()->channels().size()); 1174 EXPECT_EQ(1U, GetTransport1()->channels().size());
1220 EXPECT_EQ(1U, GetTransport2()->channels().size()); 1175 EXPECT_EQ(1U, GetTransport2()->channels().size());
1221 EXPECT_TRUE(SendAccept()); 1176 EXPECT_TRUE(SendAccept());
1222 EXPECT_EQ(1U, GetTransport1()->channels().size()); 1177 EXPECT_EQ(1U, GetTransport1()->channels().size());
1223 EXPECT_TRUE(SendRtp1()); 1178 SendRtp1();
1224 EXPECT_TRUE(SendRtp2()); 1179 SendRtp2();
1225 EXPECT_TRUE(SendRtcp1()); 1180 SendRtcp1();
1226 EXPECT_TRUE(SendRtcp2()); 1181 SendRtcp2();
1182 WaitForThreads();
1227 EXPECT_TRUE(CheckRtp1()); 1183 EXPECT_TRUE(CheckRtp1());
1228 EXPECT_TRUE(CheckRtp2()); 1184 EXPECT_TRUE(CheckRtp2());
1229 EXPECT_TRUE(CheckNoRtp1()); 1185 EXPECT_TRUE(CheckNoRtp1());
1230 EXPECT_TRUE(CheckNoRtp2()); 1186 EXPECT_TRUE(CheckNoRtp2());
1231 EXPECT_TRUE(CheckRtcp1()); 1187 EXPECT_TRUE(CheckRtcp1());
1232 EXPECT_TRUE(CheckRtcp2()); 1188 EXPECT_TRUE(CheckRtcp2());
1233 EXPECT_TRUE(CheckNoRtcp1()); 1189 EXPECT_TRUE(CheckNoRtcp1());
1234 EXPECT_TRUE(CheckNoRtcp2()); 1190 EXPECT_TRUE(CheckNoRtcp2());
1235 } 1191 }
1236 1192
(...skipping 14 matching lines...) Expand all
1251 void SendEarlyRtcpMuxToRtcp() { 1207 void SendEarlyRtcpMuxToRtcp() {
1252 CreateChannels(RTCP | RTCP_MUX, RTCP); 1208 CreateChannels(RTCP | RTCP_MUX, RTCP);
1253 EXPECT_TRUE(SendInitiate()); 1209 EXPECT_TRUE(SendInitiate());
1254 ASSERT_TRUE(GetTransport1()); 1210 ASSERT_TRUE(GetTransport1());
1255 ASSERT_TRUE(GetTransport2()); 1211 ASSERT_TRUE(GetTransport2());
1256 EXPECT_EQ(2U, GetTransport1()->channels().size()); 1212 EXPECT_EQ(2U, GetTransport1()->channels().size());
1257 EXPECT_EQ(2U, GetTransport2()->channels().size()); 1213 EXPECT_EQ(2U, GetTransport2()->channels().size());
1258 1214
1259 // RTCP can be sent before the call is accepted, if the transport is ready. 1215 // 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. 1216 // It should not be muxed though, as the remote side doesn't support mux.
1261 EXPECT_TRUE(SendRtcp1()); 1217 SendRtcp1();
1218 WaitForThreads();
1262 EXPECT_TRUE(CheckNoRtp2()); 1219 EXPECT_TRUE(CheckNoRtp2());
1263 EXPECT_TRUE(CheckRtcp2()); 1220 EXPECT_TRUE(CheckRtcp2());
1264 1221
1265 // Send RTCP packet from callee and verify that it is received. 1222 // Send RTCP packet from callee and verify that it is received.
1266 EXPECT_TRUE(SendRtcp2()); 1223 SendRtcp2();
1224 WaitForThreads();
1267 EXPECT_TRUE(CheckNoRtp1()); 1225 EXPECT_TRUE(CheckNoRtp1());
1268 EXPECT_TRUE(CheckRtcp1()); 1226 EXPECT_TRUE(CheckRtcp1());
1269 1227
1270 // Complete call setup and ensure everything is still OK. 1228 // Complete call setup and ensure everything is still OK.
1271 EXPECT_TRUE(SendAccept()); 1229 EXPECT_TRUE(SendAccept());
1272 EXPECT_EQ(2U, GetTransport1()->channels().size()); 1230 EXPECT_EQ(2U, GetTransport1()->channels().size());
1273 EXPECT_TRUE(SendRtcp1()); 1231 SendRtcp1();
1232 SendRtcp2();
1233 WaitForThreads();
1274 EXPECT_TRUE(CheckRtcp2()); 1234 EXPECT_TRUE(CheckRtcp2());
1275 EXPECT_TRUE(SendRtcp2());
1276 EXPECT_TRUE(CheckRtcp1()); 1235 EXPECT_TRUE(CheckRtcp1());
1277 } 1236 }
1278 1237
1279 1238
1280 // Check that RTCP data is not muxed until both sides have enabled muxing, 1239 // 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 1240 // but that we properly demux before we get the accept message, since there
1282 // is a race between RTP data and the jingle accept. 1241 // is a race between RTP data and the jingle accept.
1283 void SendEarlyRtcpMuxToRtcpMux() { 1242 void SendEarlyRtcpMuxToRtcpMux() {
1284 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX); 1243 CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
1285 EXPECT_TRUE(SendInitiate()); 1244 EXPECT_TRUE(SendInitiate());
1286 ASSERT_TRUE(GetTransport1()); 1245 ASSERT_TRUE(GetTransport1());
1287 ASSERT_TRUE(GetTransport2()); 1246 ASSERT_TRUE(GetTransport2());
1288 EXPECT_EQ(2U, GetTransport1()->channels().size()); 1247 EXPECT_EQ(2U, GetTransport1()->channels().size());
1289 EXPECT_EQ(1U, GetTransport2()->channels().size()); 1248 EXPECT_EQ(1U, GetTransport2()->channels().size());
1290 1249
1291 // RTCP can't be sent yet, since the RTCP transport isn't writable, and 1250 // 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. 1251 // we haven't yet received the accept that says we should mux.
1293 EXPECT_FALSE(SendRtcp1()); 1252 SendRtcp1();
1253 WaitForThreads();
1254 EXPECT_TRUE(CheckNoRtcp2());
1294 1255
1295 // Send muxed RTCP packet from callee and verify that it is received. 1256 // Send muxed RTCP packet from callee and verify that it is received.
1296 EXPECT_TRUE(SendRtcp2()); 1257 SendRtcp2();
1258 WaitForThreads();
1297 EXPECT_TRUE(CheckNoRtp1()); 1259 EXPECT_TRUE(CheckNoRtp1());
1298 EXPECT_TRUE(CheckRtcp1()); 1260 EXPECT_TRUE(CheckRtcp1());
1299 1261
1300 // Complete call setup and ensure everything is still OK. 1262 // Complete call setup and ensure everything is still OK.
1301 EXPECT_TRUE(SendAccept()); 1263 EXPECT_TRUE(SendAccept());
1302 EXPECT_EQ(1U, GetTransport1()->channels().size()); 1264 EXPECT_EQ(1U, GetTransport1()->channels().size());
1303 EXPECT_TRUE(SendRtcp1()); 1265 SendRtcp1();
1266 SendRtcp2();
1267 WaitForThreads();
1304 EXPECT_TRUE(CheckRtcp2()); 1268 EXPECT_TRUE(CheckRtcp2());
1305 EXPECT_TRUE(SendRtcp2());
1306 EXPECT_TRUE(CheckRtcp1()); 1269 EXPECT_TRUE(CheckRtcp1());
1307 } 1270 }
1308 1271
1309 // Test that we properly send SRTP with RTCP in both directions. 1272 // Test that we properly send SRTP with RTCP in both directions.
1310 // You can pass in DTLS and/or RTCP_MUX as flags. 1273 // You can pass in DTLS and/or RTCP_MUX as flags.
1311 void SendSrtpToSrtp(int flags1_in = 0, int flags2_in = 0) { 1274 void SendSrtpToSrtp(int flags1_in = 0, int flags2_in = 0) {
1312 ASSERT((flags1_in & ~(RTCP_MUX | DTLS)) == 0); 1275 ASSERT((flags1_in & ~(RTCP_MUX | DTLS)) == 0);
1313 ASSERT((flags2_in & ~(RTCP_MUX | DTLS)) == 0); 1276 ASSERT((flags2_in & ~(RTCP_MUX | DTLS)) == 0);
1314 1277
1315 int flags1 = RTCP | SECURE | flags1_in; 1278 int flags1 = RTCP | SECURE | flags1_in;
1316 int flags2 = RTCP | SECURE | flags2_in; 1279 int flags2 = RTCP | SECURE | flags2_in;
1317 bool dtls1 = !!(flags1_in & DTLS); 1280 bool dtls1 = !!(flags1_in & DTLS);
1318 bool dtls2 = !!(flags2_in & DTLS); 1281 bool dtls2 = !!(flags2_in & DTLS);
1319 CreateChannels(flags1, flags2); 1282 CreateChannels(flags1, flags2);
1320 EXPECT_FALSE(channel1_->secure()); 1283 EXPECT_FALSE(channel1_->secure());
1321 EXPECT_FALSE(channel2_->secure()); 1284 EXPECT_FALSE(channel2_->secure());
1322 EXPECT_TRUE(SendInitiate()); 1285 EXPECT_TRUE(SendInitiate());
1323 EXPECT_TRUE_WAIT(channel1_->writable(), kEventTimeout); 1286 WaitForThreads();
1324 EXPECT_TRUE_WAIT(channel2_->writable(), kEventTimeout); 1287 EXPECT_TRUE(channel1_->writable());
1288 EXPECT_TRUE(channel2_->writable());
1325 EXPECT_TRUE(SendAccept()); 1289 EXPECT_TRUE(SendAccept());
1326 EXPECT_TRUE(channel1_->secure()); 1290 EXPECT_TRUE(channel1_->secure());
1327 EXPECT_TRUE(channel2_->secure()); 1291 EXPECT_TRUE(channel2_->secure());
1328 EXPECT_EQ(dtls1 && dtls2, channel1_->secure_dtls()); 1292 EXPECT_EQ(dtls1 && dtls2, channel1_->secure_dtls());
1329 EXPECT_EQ(dtls1 && dtls2, channel2_->secure_dtls()); 1293 EXPECT_EQ(dtls1 && dtls2, channel2_->secure_dtls());
1330 EXPECT_TRUE(SendRtp1()); 1294 SendRtp1();
1331 EXPECT_TRUE(SendRtp2()); 1295 SendRtp2();
1332 EXPECT_TRUE(SendRtcp1()); 1296 SendRtcp1();
1333 EXPECT_TRUE(SendRtcp2()); 1297 SendRtcp2();
1298 WaitForThreads();
1334 EXPECT_TRUE(CheckRtp1()); 1299 EXPECT_TRUE(CheckRtp1());
1335 EXPECT_TRUE(CheckRtp2()); 1300 EXPECT_TRUE(CheckRtp2());
1336 EXPECT_TRUE(CheckNoRtp1()); 1301 EXPECT_TRUE(CheckNoRtp1());
1337 EXPECT_TRUE(CheckNoRtp2()); 1302 EXPECT_TRUE(CheckNoRtp2());
1338 EXPECT_TRUE(CheckRtcp1()); 1303 EXPECT_TRUE(CheckRtcp1());
1339 EXPECT_TRUE(CheckRtcp2()); 1304 EXPECT_TRUE(CheckRtcp2());
1340 EXPECT_TRUE(CheckNoRtcp1()); 1305 EXPECT_TRUE(CheckNoRtcp1());
1341 EXPECT_TRUE(CheckNoRtcp2()); 1306 EXPECT_TRUE(CheckNoRtcp2());
1342 } 1307 }
1343 1308
1344 // Test that we properly handling SRTP negotiating down to RTP. 1309 // Test that we properly handling SRTP negotiating down to RTP.
1345 void SendSrtpToRtp() { 1310 void SendSrtpToRtp() {
1346 CreateChannels(RTCP | SECURE, RTCP); 1311 CreateChannels(RTCP | SECURE, RTCP);
1347 EXPECT_FALSE(channel1_->secure()); 1312 EXPECT_FALSE(channel1_->secure());
1348 EXPECT_FALSE(channel2_->secure()); 1313 EXPECT_FALSE(channel2_->secure());
1349 EXPECT_TRUE(SendInitiate()); 1314 EXPECT_TRUE(SendInitiate());
1350 EXPECT_TRUE(SendAccept()); 1315 EXPECT_TRUE(SendAccept());
1351 EXPECT_FALSE(channel1_->secure()); 1316 EXPECT_FALSE(channel1_->secure());
1352 EXPECT_FALSE(channel2_->secure()); 1317 EXPECT_FALSE(channel2_->secure());
1353 EXPECT_TRUE(SendRtp1()); 1318 SendRtp1();
1354 EXPECT_TRUE(SendRtp2()); 1319 SendRtp2();
1355 EXPECT_TRUE(SendRtcp1()); 1320 SendRtcp1();
1356 EXPECT_TRUE(SendRtcp2()); 1321 SendRtcp2();
1322 WaitForThreads();
1357 EXPECT_TRUE(CheckRtp1()); 1323 EXPECT_TRUE(CheckRtp1());
1358 EXPECT_TRUE(CheckRtp2()); 1324 EXPECT_TRUE(CheckRtp2());
1359 EXPECT_TRUE(CheckNoRtp1()); 1325 EXPECT_TRUE(CheckNoRtp1());
1360 EXPECT_TRUE(CheckNoRtp2()); 1326 EXPECT_TRUE(CheckNoRtp2());
1361 EXPECT_TRUE(CheckRtcp1()); 1327 EXPECT_TRUE(CheckRtcp1());
1362 EXPECT_TRUE(CheckRtcp2()); 1328 EXPECT_TRUE(CheckRtcp2());
1363 EXPECT_TRUE(CheckNoRtcp1()); 1329 EXPECT_TRUE(CheckNoRtcp1());
1364 EXPECT_TRUE(CheckNoRtcp2()); 1330 EXPECT_TRUE(CheckNoRtcp2());
1365 } 1331 }
1366 1332
1367 // Test that we can send and receive early media when a provisional answer is 1333 // 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. 1334 // sent and received. The test uses SRTP, RTCP mux and SSRC mux.
1369 void SendEarlyMediaUsingRtcpMuxSrtp() { 1335 void SendEarlyMediaUsingRtcpMuxSrtp() {
1370 int sequence_number1_1 = 0, sequence_number2_2 = 0; 1336 int sequence_number1_1 = 0, sequence_number2_2 = 0;
1371 1337
1372 CreateChannels(SSRC_MUX | RTCP | RTCP_MUX | SECURE, 1338 CreateChannels(SSRC_MUX | RTCP | RTCP_MUX | SECURE,
1373 SSRC_MUX | RTCP | RTCP_MUX | SECURE); 1339 SSRC_MUX | RTCP | RTCP_MUX | SECURE);
1374 EXPECT_TRUE(SendOffer()); 1340 EXPECT_TRUE(SendOffer());
1375 EXPECT_TRUE(SendProvisionalAnswer()); 1341 EXPECT_TRUE(SendProvisionalAnswer());
1376 EXPECT_TRUE(channel1_->secure()); 1342 EXPECT_TRUE(channel1_->secure());
1377 EXPECT_TRUE(channel2_->secure()); 1343 EXPECT_TRUE(channel2_->secure());
1378 ASSERT_TRUE(GetTransport1()); 1344 ASSERT_TRUE(GetTransport1());
1379 ASSERT_TRUE(GetTransport2()); 1345 ASSERT_TRUE(GetTransport2());
1380 EXPECT_EQ(2U, GetTransport1()->channels().size()); 1346 EXPECT_EQ(2U, GetTransport1()->channels().size());
1381 EXPECT_EQ(2U, GetTransport2()->channels().size()); 1347 EXPECT_EQ(2U, GetTransport2()->channels().size());
1382 EXPECT_TRUE(SendCustomRtcp1(kSsrc1)); 1348 WaitForThreads(); // Wait for 'sending' flag go through network thread.
1349 SendCustomRtcp1(kSsrc1);
1350 SendCustomRtp1(kSsrc1, ++sequence_number1_1);
1351 WaitForThreads();
1383 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1)); 1352 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1));
1384 EXPECT_TRUE(SendCustomRtp1(kSsrc1, ++sequence_number1_1));
1385 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1)); 1353 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1));
1386 1354
1387 // Send packets from callee and verify that it is received. 1355 // Send packets from callee and verify that it is received.
1388 EXPECT_TRUE(SendCustomRtcp2(kSsrc2)); 1356 SendCustomRtcp2(kSsrc2);
1357 SendCustomRtp2(kSsrc2, ++sequence_number2_2);
1358 WaitForThreads();
1389 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2)); 1359 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2));
1390 EXPECT_TRUE(SendCustomRtp2(kSsrc2, ++sequence_number2_2));
1391 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2)); 1360 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2));
1392 1361
1393 // Complete call setup and ensure everything is still OK. 1362 // Complete call setup and ensure everything is still OK.
1394 EXPECT_TRUE(SendFinalAnswer()); 1363 EXPECT_TRUE(SendFinalAnswer());
1395 EXPECT_EQ(1U, GetTransport1()->channels().size()); 1364 EXPECT_EQ(1U, GetTransport1()->channels().size());
1396 EXPECT_EQ(1U, GetTransport2()->channels().size()); 1365 EXPECT_EQ(1U, GetTransport2()->channels().size());
1397 EXPECT_TRUE(channel1_->secure()); 1366 EXPECT_TRUE(channel1_->secure());
1398 EXPECT_TRUE(channel2_->secure()); 1367 EXPECT_TRUE(channel2_->secure());
1399 EXPECT_TRUE(SendCustomRtcp1(kSsrc1)); 1368 SendCustomRtcp1(kSsrc1);
1369 SendCustomRtp1(kSsrc1, ++sequence_number1_1);
1370 SendCustomRtcp2(kSsrc2);
1371 SendCustomRtp2(kSsrc2, ++sequence_number2_2);
1372 WaitForThreads();
1400 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1)); 1373 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1));
1401 EXPECT_TRUE(SendCustomRtp1(kSsrc1, ++sequence_number1_1));
1402 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1)); 1374 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1));
1403 EXPECT_TRUE(SendCustomRtcp2(kSsrc2));
1404 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2)); 1375 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2));
1405 EXPECT_TRUE(SendCustomRtp2(kSsrc2, ++sequence_number2_2));
1406 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2)); 1376 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2));
1407 } 1377 }
1408 1378
1409 // Test that we properly send RTP without SRTP from a thread. 1379 // Test that we properly send RTP without SRTP from a thread.
1410 void SendRtpToRtpOnThread() { 1380 void SendRtpToRtpOnThread() {
1411 CreateChannels(RTCP, RTCP); 1381 CreateChannels(RTCP, RTCP);
1412 EXPECT_TRUE(SendInitiate()); 1382 EXPECT_TRUE(SendInitiate());
1413 EXPECT_TRUE(SendAccept()); 1383 EXPECT_TRUE(SendAccept());
1414 ScopedCallThread send_rtp1(this, &ChannelTest<T>::SendRtp1); 1384 ScopedCallThread send_rtp1([this] { SendRtp1(); });
1415 ScopedCallThread send_rtp2(this, &ChannelTest<T>::SendRtp2); 1385 ScopedCallThread send_rtp2([this] { SendRtp2(); });
1416 ScopedCallThread send_rtcp1(this, &ChannelTest<T>::SendRtcp1); 1386 ScopedCallThread send_rtcp1([this] { SendRtcp1(); });
1417 ScopedCallThread send_rtcp2(this, &ChannelTest<T>::SendRtcp2); 1387 ScopedCallThread send_rtcp2([this] { SendRtcp2(); });
1418 EXPECT_TRUE_WAIT(CheckRtp1(), 1000); 1388 rtc::Thread* involved_threads[] = {send_rtp1.thread(), send_rtp2.thread(),
1419 EXPECT_TRUE_WAIT(CheckRtp2(), 1000); 1389 send_rtcp1.thread(),
1420 EXPECT_TRUE_WAIT(send_rtp1.result(), 1000); 1390 send_rtcp2.thread()};
1421 EXPECT_TRUE_WAIT(send_rtp2.result(), 1000); 1391 WaitForThreads(involved_threads);
1392 EXPECT_TRUE(CheckRtp1());
1393 EXPECT_TRUE(CheckRtp2());
1422 EXPECT_TRUE(CheckNoRtp1()); 1394 EXPECT_TRUE(CheckNoRtp1());
1423 EXPECT_TRUE(CheckNoRtp2()); 1395 EXPECT_TRUE(CheckNoRtp2());
1424 EXPECT_TRUE_WAIT(CheckRtcp1(), 1000); 1396 EXPECT_TRUE(CheckRtcp1());
1425 EXPECT_TRUE_WAIT(CheckRtcp2(), 1000); 1397 EXPECT_TRUE(CheckRtcp2());
1426 EXPECT_TRUE_WAIT(send_rtcp1.result(), 1000);
1427 EXPECT_TRUE_WAIT(send_rtcp2.result(), 1000);
1428 EXPECT_TRUE(CheckNoRtcp1()); 1398 EXPECT_TRUE(CheckNoRtcp1());
1429 EXPECT_TRUE(CheckNoRtcp2()); 1399 EXPECT_TRUE(CheckNoRtcp2());
1430 } 1400 }
1431 1401
1432 // Test that we properly send SRTP with RTCP from a thread. 1402 // Test that we properly send SRTP with RTCP from a thread.
1433 void SendSrtpToSrtpOnThread() { 1403 void SendSrtpToSrtpOnThread() {
1434 CreateChannels(RTCP | SECURE, RTCP | SECURE); 1404 CreateChannels(RTCP | SECURE, RTCP | SECURE);
1435 EXPECT_TRUE(SendInitiate()); 1405 EXPECT_TRUE(SendInitiate());
1436 EXPECT_TRUE(SendAccept()); 1406 EXPECT_TRUE(SendAccept());
1437 ScopedCallThread send_rtp1(this, &ChannelTest<T>::SendRtp1); 1407 ScopedCallThread send_rtp1([this] { SendRtp1(); });
1438 ScopedCallThread send_rtp2(this, &ChannelTest<T>::SendRtp2); 1408 ScopedCallThread send_rtp2([this] { SendRtp2(); });
1439 ScopedCallThread send_rtcp1(this, &ChannelTest<T>::SendRtcp1); 1409 ScopedCallThread send_rtcp1([this] { SendRtcp1(); });
1440 ScopedCallThread send_rtcp2(this, &ChannelTest<T>::SendRtcp2); 1410 ScopedCallThread send_rtcp2([this] { SendRtcp2(); });
1441 EXPECT_TRUE_WAIT(CheckRtp1(), 1000); 1411 rtc::Thread* involved_threads[] = {send_rtp1.thread(), send_rtp2.thread(),
1442 EXPECT_TRUE_WAIT(CheckRtp2(), 1000); 1412 send_rtcp1.thread(),
1443 EXPECT_TRUE_WAIT(send_rtp1.result(), 1000); 1413 send_rtcp2.thread()};
1444 EXPECT_TRUE_WAIT(send_rtp2.result(), 1000); 1414 WaitForThreads(involved_threads);
1415 EXPECT_TRUE(CheckRtp1());
1416 EXPECT_TRUE(CheckRtp2());
1445 EXPECT_TRUE(CheckNoRtp1()); 1417 EXPECT_TRUE(CheckNoRtp1());
1446 EXPECT_TRUE(CheckNoRtp2()); 1418 EXPECT_TRUE(CheckNoRtp2());
1447 EXPECT_TRUE_WAIT(CheckRtcp1(), 1000); 1419 EXPECT_TRUE(CheckRtcp1());
1448 EXPECT_TRUE_WAIT(CheckRtcp2(), 1000); 1420 EXPECT_TRUE(CheckRtcp2());
1449 EXPECT_TRUE_WAIT(send_rtcp1.result(), 1000);
1450 EXPECT_TRUE_WAIT(send_rtcp2.result(), 1000);
1451 EXPECT_TRUE(CheckNoRtcp1()); 1421 EXPECT_TRUE(CheckNoRtcp1());
1452 EXPECT_TRUE(CheckNoRtcp2()); 1422 EXPECT_TRUE(CheckNoRtcp2());
1453 } 1423 }
1454 1424
1455 // Test that the mediachannel retains its sending state after the transport 1425 // Test that the mediachannel retains its sending state after the transport
1456 // becomes non-writable. 1426 // becomes non-writable.
1457 void SendWithWritabilityLoss() { 1427 void SendWithWritabilityLoss() {
1458 CreateChannels(0, 0); 1428 CreateChannels(0, 0);
1459 EXPECT_TRUE(SendInitiate()); 1429 EXPECT_TRUE(SendInitiate());
1460 EXPECT_TRUE(SendAccept()); 1430 EXPECT_TRUE(SendAccept());
1461 ASSERT_TRUE(GetTransport1()); 1431 ASSERT_TRUE(GetTransport1());
1462 ASSERT_TRUE(GetTransport2()); 1432 ASSERT_TRUE(GetTransport2());
1463 EXPECT_EQ(1U, GetTransport1()->channels().size()); 1433 EXPECT_EQ(1U, GetTransport1()->channels().size());
1464 EXPECT_EQ(1U, GetTransport2()->channels().size()); 1434 EXPECT_EQ(1U, GetTransport2()->channels().size());
1465 EXPECT_TRUE(SendRtp1()); 1435 SendRtp1();
1466 EXPECT_TRUE(SendRtp2()); 1436 SendRtp2();
1437 WaitForThreads();
1467 EXPECT_TRUE(CheckRtp1()); 1438 EXPECT_TRUE(CheckRtp1());
1468 EXPECT_TRUE(CheckRtp2()); 1439 EXPECT_TRUE(CheckRtp2());
1469 EXPECT_TRUE(CheckNoRtp1()); 1440 EXPECT_TRUE(CheckNoRtp1());
1470 EXPECT_TRUE(CheckNoRtp2()); 1441 EXPECT_TRUE(CheckNoRtp2());
1471 1442
1472 // Lose writability, which should fail. 1443 // Lose writability, which should fail.
1473 GetTransport1()->SetWritable(false); 1444 network_thread_->Invoke<void>(
1474 EXPECT_FALSE(SendRtp1()); 1445 [this] { GetTransport1()->SetWritable(false); });
1475 EXPECT_TRUE(SendRtp2()); 1446 SendRtp1();
1447 SendRtp2();
1448 WaitForThreads();
1476 EXPECT_TRUE(CheckRtp1()); 1449 EXPECT_TRUE(CheckRtp1());
1477 EXPECT_TRUE(CheckNoRtp2()); 1450 EXPECT_TRUE(CheckNoRtp2());
1478 1451
1479 // Regain writability 1452 // Regain writability
1480 GetTransport1()->SetWritable(true); 1453 network_thread_->Invoke<void>(
1454 [this] { GetTransport1()->SetWritable(true); });
1481 EXPECT_TRUE(media_channel1_->sending()); 1455 EXPECT_TRUE(media_channel1_->sending());
1482 EXPECT_TRUE(SendRtp1()); 1456 SendRtp1();
1483 EXPECT_TRUE(SendRtp2()); 1457 SendRtp2();
1458 WaitForThreads();
1484 EXPECT_TRUE(CheckRtp1()); 1459 EXPECT_TRUE(CheckRtp1());
1485 EXPECT_TRUE(CheckRtp2()); 1460 EXPECT_TRUE(CheckRtp2());
1486 EXPECT_TRUE(CheckNoRtp1()); 1461 EXPECT_TRUE(CheckNoRtp1());
1487 EXPECT_TRUE(CheckNoRtp2()); 1462 EXPECT_TRUE(CheckNoRtp2());
1488 1463
1489 // Lose writability completely 1464 // Lose writability completely
1490 GetTransport1()->SetDestination(NULL); 1465 network_thread_->Invoke<void>(
1466 [this] { GetTransport1()->SetDestination(NULL); });
1491 EXPECT_TRUE(media_channel1_->sending()); 1467 EXPECT_TRUE(media_channel1_->sending());
1492 1468
1493 // Should fail also. 1469 // Should fail also.
1494 EXPECT_FALSE(SendRtp1()); 1470 SendRtp1();
1495 EXPECT_TRUE(SendRtp2()); 1471 SendRtp2();
1472 WaitForThreads();
1496 EXPECT_TRUE(CheckRtp1()); 1473 EXPECT_TRUE(CheckRtp1());
1497 EXPECT_TRUE(CheckNoRtp2()); 1474 EXPECT_TRUE(CheckNoRtp2());
1498 1475
1499 // Gain writability back 1476 // Gain writability back
1500 GetTransport1()->SetDestination(GetTransport2()); 1477 network_thread_->Invoke<void>(
1478 [this] { GetTransport1()->SetDestination(GetTransport2()); });
1501 EXPECT_TRUE(media_channel1_->sending()); 1479 EXPECT_TRUE(media_channel1_->sending());
1502 EXPECT_TRUE(SendRtp1()); 1480 SendRtp1();
1503 EXPECT_TRUE(SendRtp2()); 1481 SendRtp2();
1482 WaitForThreads();
1504 EXPECT_TRUE(CheckRtp1()); 1483 EXPECT_TRUE(CheckRtp1());
1505 EXPECT_TRUE(CheckRtp2()); 1484 EXPECT_TRUE(CheckRtp2());
1506 EXPECT_TRUE(CheckNoRtp1()); 1485 EXPECT_TRUE(CheckNoRtp1());
1507 EXPECT_TRUE(CheckNoRtp2()); 1486 EXPECT_TRUE(CheckNoRtp2());
1508 } 1487 }
1509 1488
1510 void SendBundleToBundle( 1489 void SendBundleToBundle(
1511 const int* pl_types, int len, bool rtcp_mux, bool secure) { 1490 const int* pl_types, int len, bool rtcp_mux, bool secure) {
1512 ASSERT_EQ(2, len); 1491 ASSERT_EQ(2, len);
1513 int sequence_number1_1 = 0, sequence_number2_2 = 0; 1492 int sequence_number1_1 = 0, sequence_number2_2 = 0;
(...skipping 16 matching lines...) Expand all
1530 EXPECT_EQ(expected_channels, GetTransport2()->channels().size()); 1509 EXPECT_EQ(expected_channels, GetTransport2()->channels().size());
1531 EXPECT_TRUE(SendAccept()); 1510 EXPECT_TRUE(SendAccept());
1532 EXPECT_EQ(expected_channels, GetTransport1()->channels().size()); 1511 EXPECT_EQ(expected_channels, GetTransport1()->channels().size());
1533 EXPECT_EQ(expected_channels, GetTransport2()->channels().size()); 1512 EXPECT_EQ(expected_channels, GetTransport2()->channels().size());
1534 EXPECT_TRUE(channel1_->bundle_filter()->FindPayloadType(pl_type1)); 1513 EXPECT_TRUE(channel1_->bundle_filter()->FindPayloadType(pl_type1));
1535 EXPECT_TRUE(channel2_->bundle_filter()->FindPayloadType(pl_type1)); 1514 EXPECT_TRUE(channel2_->bundle_filter()->FindPayloadType(pl_type1));
1536 EXPECT_FALSE(channel1_->bundle_filter()->FindPayloadType(pl_type2)); 1515 EXPECT_FALSE(channel1_->bundle_filter()->FindPayloadType(pl_type2));
1537 EXPECT_FALSE(channel2_->bundle_filter()->FindPayloadType(pl_type2)); 1516 EXPECT_FALSE(channel2_->bundle_filter()->FindPayloadType(pl_type2));
1538 1517
1539 // Both channels can receive pl_type1 only. 1518 // Both channels can receive pl_type1 only.
1540 EXPECT_TRUE(SendCustomRtp1(kSsrc1, ++sequence_number1_1, pl_type1)); 1519 SendCustomRtp1(kSsrc1, ++sequence_number1_1, pl_type1);
1520 SendCustomRtp2(kSsrc2, ++sequence_number2_2, pl_type1);
1521 WaitForThreads();
1541 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1, pl_type1)); 1522 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)); 1523 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2, pl_type1));
1544 EXPECT_TRUE(CheckNoRtp1()); 1524 EXPECT_TRUE(CheckNoRtp1());
1545 EXPECT_TRUE(CheckNoRtp2()); 1525 EXPECT_TRUE(CheckNoRtp2());
1546 1526
1547 // RTCP test 1527 // RTCP test
1548 EXPECT_TRUE(SendCustomRtp1(kSsrc1, ++sequence_number1_1, pl_type2)); 1528 SendCustomRtp1(kSsrc1, ++sequence_number1_1, pl_type2);
1529 SendCustomRtp2(kSsrc2, ++sequence_number2_2, pl_type2);
1530 WaitForThreads();
1549 EXPECT_FALSE(CheckCustomRtp2(kSsrc1, sequence_number1_1, pl_type2)); 1531 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)); 1532 EXPECT_FALSE(CheckCustomRtp1(kSsrc2, sequence_number2_2, pl_type2));
1552 1533
1553 EXPECT_TRUE(SendCustomRtcp1(kSsrc1)); 1534 SendCustomRtcp1(kSsrc1);
1554 EXPECT_TRUE(SendCustomRtcp2(kSsrc2)); 1535 SendCustomRtcp2(kSsrc2);
1536 WaitForThreads();
1555 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2)); 1537 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2));
1556 EXPECT_TRUE(CheckNoRtcp1()); 1538 EXPECT_TRUE(CheckNoRtcp1());
1557 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1)); 1539 EXPECT_TRUE(CheckCustomRtcp2(kSsrc1));
1558 EXPECT_TRUE(CheckNoRtcp2()); 1540 EXPECT_TRUE(CheckNoRtcp2());
1559 1541
1560 EXPECT_TRUE(SendCustomRtcp1(kSsrc2)); 1542 SendCustomRtcp1(kSsrc2);
1561 EXPECT_TRUE(SendCustomRtcp2(kSsrc1)); 1543 SendCustomRtcp2(kSsrc1);
1544 WaitForThreads();
1562 // Bundle filter shouldn't filter out any RTCP. 1545 // Bundle filter shouldn't filter out any RTCP.
1563 EXPECT_TRUE(CheckCustomRtcp1(kSsrc1)); 1546 EXPECT_TRUE(CheckCustomRtcp1(kSsrc1));
1564 EXPECT_TRUE(CheckCustomRtcp2(kSsrc2)); 1547 EXPECT_TRUE(CheckCustomRtcp2(kSsrc2));
1565 } 1548 }
1566 1549
1567 // Test that the media monitor can be run and gives timely callbacks. 1550 // Test that the media monitor can be run and gives timely callbacks.
1568 void TestMediaMonitor() { 1551 void TestMediaMonitor() {
1569 static const int kTimeout = 500; 1552 static const int kTimeout = 500;
1570 CreateChannels(0, 0); 1553 CreateChannels(0, 0);
1571 EXPECT_TRUE(SendInitiate()); 1554 EXPECT_TRUE(SendInitiate());
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1697 std::unique_ptr<cricket::SessionDescription> sdesc3( 1680 std::unique_ptr<cricket::SessionDescription> sdesc3(
1698 CreateSessionDescriptionWithStream(3)); 1681 CreateSessionDescriptionWithStream(3));
1699 EXPECT_TRUE(channel1_->PushdownRemoteDescription( 1682 EXPECT_TRUE(channel1_->PushdownRemoteDescription(
1700 sdesc3.get(), cricket::CA_ANSWER, &err)); 1683 sdesc3.get(), cricket::CA_ANSWER, &err));
1701 EXPECT_TRUE(media_channel1_->HasSendStream(1)); 1684 EXPECT_TRUE(media_channel1_->HasSendStream(1));
1702 EXPECT_FALSE(media_channel1_->HasRecvStream(2)); 1685 EXPECT_FALSE(media_channel1_->HasRecvStream(2));
1703 EXPECT_TRUE(media_channel1_->HasRecvStream(3)); 1686 EXPECT_TRUE(media_channel1_->HasRecvStream(3));
1704 } 1687 }
1705 1688
1706 void TestFlushRtcp() { 1689 void TestFlushRtcp() {
1707 bool send_rtcp1;
1708 CreateChannels(RTCP, RTCP); 1690 CreateChannels(RTCP, RTCP);
1709 EXPECT_TRUE(SendInitiate()); 1691 EXPECT_TRUE(SendInitiate());
1710 EXPECT_TRUE(SendAccept()); 1692 EXPECT_TRUE(SendAccept());
1711 ASSERT_TRUE(GetTransport1()); 1693 ASSERT_TRUE(GetTransport1());
1712 ASSERT_TRUE(GetTransport2()); 1694 ASSERT_TRUE(GetTransport2());
1713 EXPECT_EQ(2U, GetTransport1()->channels().size()); 1695 EXPECT_EQ(2U, GetTransport1()->channels().size());
1714 EXPECT_EQ(2U, GetTransport2()->channels().size()); 1696 EXPECT_EQ(2U, GetTransport2()->channels().size());
1715 1697
1716 // Send RTCP1 from a different thread. 1698 // Send RTCP1 from a different thread.
1717 CallOnThreadAndWaitForDone(&ChannelTest<T>::SendRtcp1, &send_rtcp1); 1699 ScopedCallThread send_rtcp([this] { SendRtcp1(); });
1718 EXPECT_TRUE(send_rtcp1);
1719 // The sending message is only posted. channel2_ should be empty. 1700 // The sending message is only posted. channel2_ should be empty.
1720 EXPECT_TRUE(CheckNoRtcp2()); 1701 EXPECT_TRUE(CheckNoRtcp2());
1702 rtc::Thread* wait_for[] = {send_rtcp.thread()};
1703 WaitForThreads(wait_for); // Ensure rtcp was posted
1721 1704
1722 // When channel1_ is deleted, the RTCP packet should be sent out to 1705 // When channel1_ is deleted, the RTCP packet should be sent out to
1723 // channel2_. 1706 // channel2_.
1724 channel1_.reset(); 1707 channel1_.reset();
1708 WaitForThreads();
1725 EXPECT_TRUE(CheckRtcp2()); 1709 EXPECT_TRUE(CheckRtcp2());
1726 } 1710 }
1727 1711
1728 void TestSrtpError(int pl_type) { 1712 void TestSrtpError(int pl_type) {
1729 struct SrtpErrorHandler : public sigslot::has_slots<> { 1713 struct SrtpErrorHandler : public sigslot::has_slots<> {
1730 SrtpErrorHandler() : 1714 SrtpErrorHandler() :
1731 mode_(cricket::SrtpFilter::UNPROTECT), 1715 mode_(cricket::SrtpFilter::UNPROTECT),
1732 error_(cricket::SrtpFilter::ERROR_NONE) {} 1716 error_(cricket::SrtpFilter::ERROR_NONE) {}
1733 void OnSrtpError(uint32 ssrc, cricket::SrtpFilter::Mode mode, 1717 void OnSrtpError(uint32 ssrc, cricket::SrtpFilter::Mode mode,
1734 cricket::SrtpFilter::Error error) { 1718 cricket::SrtpFilter::Error error) {
1735 mode_ = mode; 1719 mode_ = mode;
1736 error_ = error; 1720 error_ = error;
1737 } 1721 }
1738 cricket::SrtpFilter::Mode mode_; 1722 cricket::SrtpFilter::Mode mode_;
1739 cricket::SrtpFilter::Error error_; 1723 cricket::SrtpFilter::Error error_;
1740 } error_handler; 1724 } error_handler;
1741 1725
1742 // For Audio, only pl_type 0 is added to the bundle filter. 1726 // 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. 1727 // 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 1728 // 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. 1729 // 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. 1730 // The packet is not a valid srtp packet because it is too short.
1747 unsigned const char kBadPacket[] = {0x84, 1731 static unsigned const char kBadPacket[] = {
1748 static_cast<unsigned char>(pl_type), 1732 0x84, static_cast<unsigned char>(pl_type),
1749 0x00, 1733 0x00, 0x01,
1750 0x01, 1734 0x00, 0x00,
1751 0x00, 1735 0x00, 0x00,
1752 0x00, 1736 0x00, 0x00,
1753 0x00, 1737 0x00, 0x01};
1754 0x00,
1755 0x00,
1756 0x00,
1757 0x00,
1758 0x01};
1759 CreateChannels(RTCP | SECURE, RTCP | SECURE); 1738 CreateChannels(RTCP | SECURE, RTCP | SECURE);
1760 EXPECT_FALSE(channel1_->secure()); 1739 EXPECT_FALSE(channel1_->secure());
1761 EXPECT_FALSE(channel2_->secure()); 1740 EXPECT_FALSE(channel2_->secure());
1762 EXPECT_TRUE(SendInitiate()); 1741 EXPECT_TRUE(SendInitiate());
1763 EXPECT_TRUE(SendAccept()); 1742 EXPECT_TRUE(SendAccept());
1764 EXPECT_TRUE(channel1_->secure()); 1743 EXPECT_TRUE(channel1_->secure());
1765 EXPECT_TRUE(channel2_->secure()); 1744 EXPECT_TRUE(channel2_->secure());
1766 channel2_->srtp_filter()->set_signal_silent_time(250); 1745 channel2_->srtp_filter()->set_signal_silent_time(250);
1767 channel2_->srtp_filter()->SignalSrtpError.connect( 1746 channel2_->srtp_filter()->SignalSrtpError.connect(
1768 &error_handler, &SrtpErrorHandler::OnSrtpError); 1747 &error_handler, &SrtpErrorHandler::OnSrtpError);
1769 1748
1770 // Testing failures in sending packets. 1749 // Testing failures in sending packets.
1771 EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket), 1750 media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket),
1772 rtc::PacketOptions())); 1751 rtc::PacketOptions());
1752 WaitForThreads();
1773 // The first failure will trigger an error. 1753 // The first failure will trigger an error.
1774 EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500); 1754 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_);
1775 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_); 1755 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_);
1776 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE; 1756 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE;
1777 error_handler.mode_ = cricket::SrtpFilter::UNPROTECT; 1757 error_handler.mode_ = cricket::SrtpFilter::UNPROTECT;
1778 // The next 250 ms failures will not trigger an error. 1758 // The next 250 ms failures will not trigger an error.
1779 EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket), 1759 media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket),
1780 rtc::PacketOptions())); 1760 rtc::PacketOptions());
1781 // Wait for a while to ensure no message comes in. 1761 // Wait for a while to ensure no message comes in.
1762 WaitForThreads();
1782 rtc::Thread::Current()->ProcessMessages(200); 1763 rtc::Thread::Current()->ProcessMessages(200);
1783 EXPECT_EQ(cricket::SrtpFilter::ERROR_NONE, error_handler.error_); 1764 EXPECT_EQ(cricket::SrtpFilter::ERROR_NONE, error_handler.error_);
1784 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_); 1765 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_);
1785 // Wait for a little more - the error will be triggered again. 1766 // Wait for a little more - the error will be triggered again.
1786 rtc::Thread::Current()->ProcessMessages(200); 1767 rtc::Thread::Current()->ProcessMessages(200);
1787 EXPECT_FALSE(media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket), 1768 media_channel2_->SendRtp(kBadPacket, sizeof(kBadPacket),
1788 rtc::PacketOptions())); 1769 rtc::PacketOptions());
1789 EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500); 1770 WaitForThreads();
1771 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_);
1790 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_); 1772 EXPECT_EQ(cricket::SrtpFilter::PROTECT, error_handler.mode_);
1791 1773
1792 // Testing failures in receiving packets. 1774 // Testing failures in receiving packets.
1793 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE; 1775 error_handler.error_ = cricket::SrtpFilter::ERROR_NONE;
1794 error_handler.mode_ = cricket::SrtpFilter::UNPROTECT; 1776 error_handler.mode_ = cricket::SrtpFilter::UNPROTECT;
1795 1777
1796 cricket::TransportChannel* transport_channel = 1778 network_thread_->Invoke<void>([this] {
1797 channel2_->transport_channel(); 1779 cricket::TransportChannel* transport_channel =
1798 transport_channel->SignalReadPacket( 1780 channel2_->transport_channel();
1799 transport_channel, reinterpret_cast<const char*>(kBadPacket), 1781 transport_channel->SignalReadPacket(
1800 sizeof(kBadPacket), rtc::PacketTime(), 0); 1782 transport_channel, reinterpret_cast<const char*>(kBadPacket),
1801 EXPECT_EQ_WAIT(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_, 500); 1783 sizeof(kBadPacket), rtc::PacketTime(), 0);
1784 });
1785 EXPECT_EQ(cricket::SrtpFilter::ERROR_FAIL, error_handler.error_);
1802 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_); 1786 EXPECT_EQ(cricket::SrtpFilter::UNPROTECT, error_handler.mode_);
1803 } 1787 }
1804 1788
1805 void TestOnReadyToSend() { 1789 void TestOnReadyToSend() {
1806 CreateChannels(RTCP, RTCP); 1790 CreateChannels(RTCP, RTCP);
1807 TransportChannel* rtp = channel1_->transport_channel(); 1791 TransportChannel* rtp = channel1_->transport_channel();
1808 TransportChannel* rtcp = channel1_->rtcp_transport_channel(); 1792 TransportChannel* rtcp = channel1_->rtcp_transport_channel();
1809 EXPECT_FALSE(media_channel1_->ready_to_send()); 1793 EXPECT_FALSE(media_channel1_->ready_to_send());
1810 rtp->SignalReadyToSend(rtp); 1794
1795 network_thread_->Invoke<void>([rtp] { rtp->SignalReadyToSend(rtp); });
1796 WaitForThreads();
1811 EXPECT_FALSE(media_channel1_->ready_to_send()); 1797 EXPECT_FALSE(media_channel1_->ready_to_send());
1812 rtcp->SignalReadyToSend(rtcp); 1798
1799 network_thread_->Invoke<void>([rtcp] { rtcp->SignalReadyToSend(rtcp); });
1800 WaitForThreads();
1813 // MediaChannel::OnReadyToSend only be called when both rtp and rtcp 1801 // MediaChannel::OnReadyToSend only be called when both rtp and rtcp
1814 // channel are ready to send. 1802 // channel are ready to send.
1815 EXPECT_TRUE(media_channel1_->ready_to_send()); 1803 EXPECT_TRUE(media_channel1_->ready_to_send());
1816 1804
1817 // rtp channel becomes not ready to send will be propagated to mediachannel 1805 // rtp channel becomes not ready to send will be propagated to mediachannel
1818 channel1_->SetReadyToSend(false, false); 1806 network_thread_->Invoke<void>(
1807 [this] { channel1_->SetReadyToSend(false, false); });
1808 WaitForThreads();
1819 EXPECT_FALSE(media_channel1_->ready_to_send()); 1809 EXPECT_FALSE(media_channel1_->ready_to_send());
1820 channel1_->SetReadyToSend(false, true); 1810
1811 network_thread_->Invoke<void>(
1812 [this] { channel1_->SetReadyToSend(false, true); });
1813 WaitForThreads();
1821 EXPECT_TRUE(media_channel1_->ready_to_send()); 1814 EXPECT_TRUE(media_channel1_->ready_to_send());
1822 1815
1823 // rtcp channel becomes not ready to send will be propagated to mediachannel 1816 // rtcp channel becomes not ready to send will be propagated to mediachannel
1824 channel1_->SetReadyToSend(true, false); 1817 network_thread_->Invoke<void>(
1818 [this] { channel1_->SetReadyToSend(true, false); });
1819 WaitForThreads();
1825 EXPECT_FALSE(media_channel1_->ready_to_send()); 1820 EXPECT_FALSE(media_channel1_->ready_to_send());
1826 channel1_->SetReadyToSend(true, true); 1821
1822 network_thread_->Invoke<void>(
1823 [this] { channel1_->SetReadyToSend(true, true); });
1824 WaitForThreads();
1827 EXPECT_TRUE(media_channel1_->ready_to_send()); 1825 EXPECT_TRUE(media_channel1_->ready_to_send());
1828 } 1826 }
1829 1827
1830 void TestOnReadyToSendWithRtcpMux() { 1828 void TestOnReadyToSendWithRtcpMux() {
1831 CreateChannels(RTCP, RTCP); 1829 CreateChannels(RTCP, RTCP);
1832 typename T::Content content; 1830 typename T::Content content;
1833 CreateContent(0, kPcmuCodec, kH264Codec, &content); 1831 CreateContent(0, kPcmuCodec, kH264Codec, &content);
1834 // Both sides agree on mux. Should no longer be a separate RTCP channel. 1832 // Both sides agree on mux. Should no longer be a separate RTCP channel.
1835 content.set_rtcp_mux(true); 1833 content.set_rtcp_mux(true);
1836 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL)); 1834 EXPECT_TRUE(channel1_->SetLocalContent(&content, CA_OFFER, NULL));
1837 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL)); 1835 EXPECT_TRUE(channel1_->SetRemoteContent(&content, CA_ANSWER, NULL));
1838 EXPECT_TRUE(channel1_->rtcp_transport_channel() == NULL); 1836 EXPECT_TRUE(channel1_->rtcp_transport_channel() == NULL);
1839 TransportChannel* rtp = channel1_->transport_channel(); 1837 TransportChannel* rtp = channel1_->transport_channel();
1840 EXPECT_FALSE(media_channel1_->ready_to_send()); 1838 EXPECT_FALSE(media_channel1_->ready_to_send());
1841 // In the case of rtcp mux, the SignalReadyToSend() from rtp channel 1839 // In the case of rtcp mux, the SignalReadyToSend() from rtp channel
1842 // should trigger the MediaChannel's OnReadyToSend. 1840 // should trigger the MediaChannel's OnReadyToSend.
1843 rtp->SignalReadyToSend(rtp); 1841 network_thread_->Invoke<void>([rtp] { rtp->SignalReadyToSend(rtp); });
1842 WaitForThreads();
1844 EXPECT_TRUE(media_channel1_->ready_to_send()); 1843 EXPECT_TRUE(media_channel1_->ready_to_send());
1845 channel1_->SetReadyToSend(false, false); 1844
1845 network_thread_->Invoke<void>(
1846 [this] { channel1_->SetReadyToSend(false, false); });
1847 WaitForThreads();
1846 EXPECT_FALSE(media_channel1_->ready_to_send()); 1848 EXPECT_FALSE(media_channel1_->ready_to_send());
1847 } 1849 }
1848 1850
1849 bool SetRemoteContentWithBitrateLimit(int remote_limit) { 1851 bool SetRemoteContentWithBitrateLimit(int remote_limit) {
1850 typename T::Content content; 1852 typename T::Content content;
1851 CreateContent(0, kPcmuCodec, kH264Codec, &content); 1853 CreateContent(0, kPcmuCodec, kH264Codec, &content);
1852 content.set_bandwidth(remote_limit); 1854 content.set_bandwidth(remote_limit);
1853 return channel1_->SetRemoteContent(&content, CA_OFFER, NULL); 1855 return channel1_->SetRemoteContent(&content, CA_OFFER, NULL);
1854 } 1856 }
1855 1857
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1887 EXPECT_EQ(-1, media_channel1_->max_bps()); 1889 EXPECT_EQ(-1, media_channel1_->max_bps());
1888 1890
1889 EXPECT_TRUE( 1891 EXPECT_TRUE(
1890 channel1_->SetRtpParameters(kSsrc1, BitrateLimitedParameters(-1))); 1892 channel1_->SetRtpParameters(kSsrc1, BitrateLimitedParameters(-1)));
1891 VerifyMaxBitrate(channel1_->GetRtpParameters(kSsrc1), -1); 1893 VerifyMaxBitrate(channel1_->GetRtpParameters(kSsrc1), -1);
1892 VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), -1); 1894 VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), -1);
1893 EXPECT_EQ(-1, media_channel1_->max_bps()); 1895 EXPECT_EQ(-1, media_channel1_->max_bps());
1894 } 1896 }
1895 1897
1896 protected: 1898 protected:
1899 void WaitForThreads() { WaitForThreads(rtc::ArrayView<rtc::Thread*>()); }
1900 static void ProcessThreadQueue(rtc::Thread* thread) {
1901 RTC_DCHECK(thread->IsCurrent());
1902 while (!thread->empty()) {
1903 thread->ProcessMessages(0);
1904 }
1905 }
1906 void WaitForThreads(rtc::ArrayView<rtc::Thread*> threads) {
1907 // |threads| and current thread post packets to network thread.
1908 for (rtc::Thread* thread : threads) {
1909 thread->Invoke<void>([thread] { ProcessThreadQueue(thread); });
1910 }
1911 ProcessThreadQueue(rtc::Thread::Current());
1912 // Network thread move them around and post back to worker = current thread.
1913 if (!network_thread_->IsCurrent()) {
1914 network_thread_->Invoke<void>(
1915 [this] { ProcessThreadQueue(network_thread_); });
1916 }
1917 // Worker thread = current Thread process received messages.
1918 ProcessThreadQueue(rtc::Thread::Current());
1919 }
1897 // TODO(pbos): Remove playout from all media channels and let renderers mute 1920 // TODO(pbos): Remove playout from all media channels and let renderers mute
1898 // themselves. 1921 // themselves.
1899 const bool verify_playout_; 1922 const bool verify_playout_;
1900 cricket::FakeTransportController transport_controller1_; 1923 std::unique_ptr<rtc::Thread> network_thread_keeper_;
1901 cricket::FakeTransportController transport_controller2_; 1924 rtc::Thread* network_thread_;
1925 std::unique_ptr<cricket::FakeTransportController> transport_controller1_;
1926 std::unique_ptr<cricket::FakeTransportController> transport_controller2_;
1902 cricket::FakeMediaEngine media_engine_; 1927 cricket::FakeMediaEngine media_engine_;
1903 // The media channels are owned by the voice channel objects below. 1928 // The media channels are owned by the voice channel objects below.
1904 typename T::MediaChannel* media_channel1_; 1929 typename T::MediaChannel* media_channel1_;
1905 typename T::MediaChannel* media_channel2_; 1930 typename T::MediaChannel* media_channel2_;
1906 std::unique_ptr<typename T::Channel> channel1_; 1931 std::unique_ptr<typename T::Channel> channel1_;
1907 std::unique_ptr<typename T::Channel> channel2_; 1932 std::unique_ptr<typename T::Channel> channel2_;
1908 typename T::Content local_media_content1_; 1933 typename T::Content local_media_content1_;
1909 typename T::Content local_media_content2_; 1934 typename T::Content local_media_content2_;
1910 typename T::Content remote_media_content1_; 1935 typename T::Content remote_media_content1_;
1911 typename T::Content remote_media_content2_; 1936 typename T::Content remote_media_content2_;
1912 // The RTP and RTCP packets to send in the tests. 1937 // The RTP and RTCP packets to send in the tests.
1913 std::string rtp_packet_; 1938 rtc::Buffer rtp_packet_;
1914 std::string rtcp_packet_; 1939 rtc::Buffer rtcp_packet_;
1915 int media_info_callbacks1_; 1940 int media_info_callbacks1_;
1916 int media_info_callbacks2_; 1941 int media_info_callbacks2_;
1917 cricket::CandidatePairInterface* last_selected_candidate_pair_; 1942 cricket::CandidatePairInterface* last_selected_candidate_pair_;
1918 }; 1943 };
1919 1944
1920 template<> 1945 template<>
1921 void ChannelTest<VoiceTraits>::CreateContent( 1946 void ChannelTest<VoiceTraits>::CreateContent(
1922 int flags, 1947 int flags,
1923 const cricket::AudioCodec& audio_codec, 1948 const cricket::AudioCodec& audio_codec,
1924 const cricket::VideoCodec& video_codec, 1949 const cricket::VideoCodec& video_codec,
(...skipping 22 matching lines...) Expand all
1947 } 1972 }
1948 1973
1949 template <> 1974 template <>
1950 void ChannelTest<VoiceTraits>::AddLegacyStreamInContent( 1975 void ChannelTest<VoiceTraits>::AddLegacyStreamInContent(
1951 uint32_t ssrc, 1976 uint32_t ssrc,
1952 int flags, 1977 int flags,
1953 cricket::AudioContentDescription* audio) { 1978 cricket::AudioContentDescription* audio) {
1954 audio->AddLegacyStream(ssrc); 1979 audio->AddLegacyStream(ssrc);
1955 } 1980 }
1956 1981
1957 class VoiceChannelTest 1982 class VoiceChannelSingleThreadTest : public ChannelTest<VoiceTraits> {
1958 : public ChannelTest<VoiceTraits> {
1959 public: 1983 public:
1960 typedef ChannelTest<VoiceTraits> Base; 1984 typedef ChannelTest<VoiceTraits> Base;
1961 VoiceChannelTest() 1985 VoiceChannelSingleThreadTest()
1962 : Base(true, 1986 : Base(true, kPcmuFrame, kRtcpReport, NetworkIsWorker::Yes) {}
1963 kPcmuFrame, 1987 };
1964 sizeof(kPcmuFrame), 1988
1965 kRtcpReport, 1989 class VoiceChannelDoubleThreadTest : public ChannelTest<VoiceTraits> {
1966 sizeof(kRtcpReport)) {} 1990 public:
1991 typedef ChannelTest<VoiceTraits> Base;
1992 VoiceChannelDoubleThreadTest()
1993 : Base(true, kPcmuFrame, kRtcpReport, NetworkIsWorker::No) {}
1967 }; 1994 };
1968 1995
1969 // override to add NULL parameter 1996 // override to add NULL parameter
1970 template <> 1997 template <>
1971 cricket::VideoChannel* ChannelTest<VideoTraits>::CreateChannel( 1998 cricket::VideoChannel* ChannelTest<VideoTraits>::CreateChannel(
1972 rtc::Thread* thread, 1999 rtc::Thread* worker_thread,
2000 rtc::Thread* network_thread,
1973 cricket::MediaEngineInterface* engine, 2001 cricket::MediaEngineInterface* engine,
1974 cricket::FakeVideoMediaChannel* ch, 2002 cricket::FakeVideoMediaChannel* ch,
1975 cricket::TransportController* transport_controller, 2003 cricket::TransportController* transport_controller,
1976 bool rtcp) { 2004 bool rtcp) {
1977 cricket::VideoChannel* channel = new cricket::VideoChannel( 2005 cricket::VideoChannel* channel =
1978 thread, ch, transport_controller, cricket::CN_VIDEO, rtcp); 2006 new cricket::VideoChannel(worker_thread, network_thread, ch,
1979 if (!channel->Init()) { 2007 transport_controller, cricket::CN_VIDEO, rtcp);
2008 if (!channel->Init_w()) {
1980 delete channel; 2009 delete channel;
1981 channel = NULL; 2010 channel = NULL;
1982 } 2011 }
1983 return channel; 2012 return channel;
1984 } 2013 }
1985 2014
1986 // override to add 0 parameter 2015 // override to add 0 parameter
1987 template<> 2016 template<>
1988 bool ChannelTest<VideoTraits>::AddStream1(int id) { 2017 bool ChannelTest<VideoTraits>::AddStream1(int id) {
1989 return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id)); 2018 return channel1_->AddRecvStream(cricket::StreamParams::CreateLegacy(id));
(...skipping 29 matching lines...) Expand all
2019 } 2048 }
2020 2049
2021 template <> 2050 template <>
2022 void ChannelTest<VideoTraits>::AddLegacyStreamInContent( 2051 void ChannelTest<VideoTraits>::AddLegacyStreamInContent(
2023 uint32_t ssrc, 2052 uint32_t ssrc,
2024 int flags, 2053 int flags,
2025 cricket::VideoContentDescription* video) { 2054 cricket::VideoContentDescription* video) {
2026 video->AddLegacyStream(ssrc); 2055 video->AddLegacyStream(ssrc);
2027 } 2056 }
2028 2057
2029 class VideoChannelTest 2058 class VideoChannelSingleThreadTest : public ChannelTest<VideoTraits> {
2030 : public ChannelTest<VideoTraits> {
2031 public: 2059 public:
2032 typedef ChannelTest<VideoTraits> Base; 2060 typedef ChannelTest<VideoTraits> Base;
2033 VideoChannelTest() 2061 VideoChannelSingleThreadTest()
2034 : Base(false, 2062 : Base(false, kH264Packet, kRtcpReport, NetworkIsWorker::Yes) {}
2035 kH264Packet,
2036 sizeof(kH264Packet),
2037 kRtcpReport,
2038 sizeof(kRtcpReport)) {}
2039 }; 2063 };
2040 2064
2065 class VideoChannelDoubleThreadTest : public ChannelTest<VideoTraits> {
2066 public:
2067 typedef ChannelTest<VideoTraits> Base;
2068 VideoChannelDoubleThreadTest()
2069 : Base(false, kH264Packet, kRtcpReport, NetworkIsWorker::No) {}
2070 };
2041 2071
2042 // VoiceChannelTest 2072 // VoiceChannelSingleThreadTest
2043 TEST_F(VoiceChannelTest, TestInit) { 2073 TEST_F(VoiceChannelSingleThreadTest, TestInit) {
2044 Base::TestInit(); 2074 Base::TestInit();
2045 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); 2075 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
2046 EXPECT_TRUE(media_channel1_->dtmf_info_queue().empty()); 2076 EXPECT_TRUE(media_channel1_->dtmf_info_queue().empty());
2047 } 2077 }
2048 2078
2049 TEST_F(VoiceChannelTest, TestSetContents) { 2079 TEST_F(VoiceChannelSingleThreadTest, TestSetContents) {
2050 Base::TestSetContents(); 2080 Base::TestSetContents();
2051 } 2081 }
2052 2082
2053 TEST_F(VoiceChannelTest, TestSetContentsNullOffer) { 2083 TEST_F(VoiceChannelSingleThreadTest, TestSetContentsNullOffer) {
2054 Base::TestSetContentsNullOffer(); 2084 Base::TestSetContentsNullOffer();
2055 } 2085 }
2056 2086
2057 TEST_F(VoiceChannelTest, TestSetContentsRtcpMux) { 2087 TEST_F(VoiceChannelSingleThreadTest, TestSetContentsRtcpMux) {
2058 Base::TestSetContentsRtcpMux(); 2088 Base::TestSetContentsRtcpMux();
2059 } 2089 }
2060 2090
2061 TEST_F(VoiceChannelTest, TestSetContentsRtcpMuxWithPrAnswer) { 2091 TEST_F(VoiceChannelSingleThreadTest, TestSetContentsRtcpMuxWithPrAnswer) {
2062 Base::TestSetContentsRtcpMux(); 2092 Base::TestSetContentsRtcpMux();
2063 } 2093 }
2064 2094
2065 TEST_F(VoiceChannelTest, TestSetRemoteContentUpdate) { 2095 TEST_F(VoiceChannelSingleThreadTest, TestSetRemoteContentUpdate) {
2066 Base::TestSetRemoteContentUpdate(); 2096 Base::TestSetRemoteContentUpdate();
2067 } 2097 }
2068 2098
2069 TEST_F(VoiceChannelTest, TestStreams) { 2099 TEST_F(VoiceChannelSingleThreadTest, TestStreams) {
2070 Base::TestStreams(); 2100 Base::TestStreams();
2071 } 2101 }
2072 2102
2073 TEST_F(VoiceChannelTest, TestUpdateStreamsInLocalContent) { 2103 TEST_F(VoiceChannelSingleThreadTest, TestUpdateStreamsInLocalContent) {
2074 Base::TestUpdateStreamsInLocalContent(); 2104 Base::TestUpdateStreamsInLocalContent();
2075 } 2105 }
2076 2106
2077 TEST_F(VoiceChannelTest, TestUpdateRemoteStreamsInContent) { 2107 TEST_F(VoiceChannelSingleThreadTest, TestUpdateRemoteStreamsInContent) {
2078 Base::TestUpdateStreamsInRemoteContent(); 2108 Base::TestUpdateStreamsInRemoteContent();
2079 } 2109 }
2080 2110
2081 TEST_F(VoiceChannelTest, TestChangeStreamParamsInContent) { 2111 TEST_F(VoiceChannelSingleThreadTest, TestChangeStreamParamsInContent) {
2082 Base::TestChangeStreamParamsInContent(); 2112 Base::TestChangeStreamParamsInContent();
2083 } 2113 }
2084 2114
2085 TEST_F(VoiceChannelTest, TestPlayoutAndSendingStates) { 2115 TEST_F(VoiceChannelSingleThreadTest, TestPlayoutAndSendingStates) {
2086 Base::TestPlayoutAndSendingStates(); 2116 Base::TestPlayoutAndSendingStates();
2087 } 2117 }
2088 2118
2089 TEST_F(VoiceChannelTest, TestMuteStream) { 2119 TEST_F(VoiceChannelSingleThreadTest, TestMuteStream) {
2090 CreateChannels(0, 0); 2120 CreateChannels(0, 0);
2091 // Test that we can Mute the default channel even though the sending SSRC 2121 // Test that we can Mute the default channel even though the sending SSRC
2092 // is unknown. 2122 // is unknown.
2093 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); 2123 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
2094 EXPECT_TRUE(channel1_->SetAudioSend(0, false, nullptr, nullptr)); 2124 EXPECT_TRUE(channel1_->SetAudioSend(0, false, nullptr, nullptr));
2095 EXPECT_TRUE(media_channel1_->IsStreamMuted(0)); 2125 EXPECT_TRUE(media_channel1_->IsStreamMuted(0));
2096 EXPECT_TRUE(channel1_->SetAudioSend(0, true, nullptr, nullptr)); 2126 EXPECT_TRUE(channel1_->SetAudioSend(0, true, nullptr, nullptr));
2097 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); 2127 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
2098 2128
2099 // Test that we can not mute an unknown SSRC. 2129 // Test that we can not mute an unknown SSRC.
2100 EXPECT_FALSE(channel1_->SetAudioSend(kSsrc1, false, nullptr, nullptr)); 2130 EXPECT_FALSE(channel1_->SetAudioSend(kSsrc1, false, nullptr, nullptr));
2101 2131
2102 SendInitiate(); 2132 SendInitiate();
2103 // After the local session description has been set, we can mute a stream 2133 // After the local session description has been set, we can mute a stream
2104 // with its SSRC. 2134 // with its SSRC.
2105 EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, false, nullptr, nullptr)); 2135 EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, false, nullptr, nullptr));
2106 EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1)); 2136 EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1));
2107 EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, true, nullptr, nullptr)); 2137 EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, true, nullptr, nullptr));
2108 EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1)); 2138 EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1));
2109 } 2139 }
2110 2140
2111 TEST_F(VoiceChannelTest, TestMediaContentDirection) { 2141 TEST_F(VoiceChannelSingleThreadTest, TestMediaContentDirection) {
2112 Base::TestMediaContentDirection(); 2142 Base::TestMediaContentDirection();
2113 } 2143 }
2114 2144
2115 TEST_F(VoiceChannelTest, TestNetworkRouteChanges) { 2145 TEST_F(VoiceChannelSingleThreadTest, TestNetworkRouteChanges) {
2116 Base::TestNetworkRouteChanges(); 2146 Base::TestNetworkRouteChanges();
2117 } 2147 }
2118 2148
2119 TEST_F(VoiceChannelTest, TestCallSetup) { 2149 TEST_F(VoiceChannelSingleThreadTest, TestCallSetup) {
2120 Base::TestCallSetup(); 2150 Base::TestCallSetup();
2121 } 2151 }
2122 2152
2123 TEST_F(VoiceChannelTest, TestCallTeardownRtcpMux) { 2153 TEST_F(VoiceChannelSingleThreadTest, TestCallTeardownRtcpMux) {
2124 Base::TestCallTeardownRtcpMux(); 2154 Base::TestCallTeardownRtcpMux();
2125 } 2155 }
2126 2156
2127 TEST_F(VoiceChannelTest, SendRtpToRtp) { 2157 TEST_F(VoiceChannelSingleThreadTest, SendRtpToRtp) {
2128 Base::SendRtpToRtp(); 2158 Base::SendRtpToRtp();
2129 } 2159 }
2130 2160
2131 TEST_F(VoiceChannelTest, SendNoRtcpToNoRtcp) { 2161 TEST_F(VoiceChannelSingleThreadTest, SendNoRtcpToNoRtcp) {
2132 Base::SendNoRtcpToNoRtcp(); 2162 Base::SendNoRtcpToNoRtcp();
2133 } 2163 }
2134 2164
2135 TEST_F(VoiceChannelTest, SendNoRtcpToRtcp) { 2165 TEST_F(VoiceChannelSingleThreadTest, SendNoRtcpToRtcp) {
2136 Base::SendNoRtcpToRtcp(); 2166 Base::SendNoRtcpToRtcp();
2137 } 2167 }
2138 2168
2139 TEST_F(VoiceChannelTest, SendRtcpToNoRtcp) { 2169 TEST_F(VoiceChannelSingleThreadTest, SendRtcpToNoRtcp) {
2140 Base::SendRtcpToNoRtcp(); 2170 Base::SendRtcpToNoRtcp();
2141 } 2171 }
2142 2172
2143 TEST_F(VoiceChannelTest, SendRtcpToRtcp) { 2173 TEST_F(VoiceChannelSingleThreadTest, SendRtcpToRtcp) {
2144 Base::SendRtcpToRtcp(); 2174 Base::SendRtcpToRtcp();
2145 } 2175 }
2146 2176
2147 TEST_F(VoiceChannelTest, SendRtcpMuxToRtcp) { 2177 TEST_F(VoiceChannelSingleThreadTest, SendRtcpMuxToRtcp) {
2148 Base::SendRtcpMuxToRtcp(); 2178 Base::SendRtcpMuxToRtcp();
2149 } 2179 }
2150 2180
2151 TEST_F(VoiceChannelTest, SendRtcpMuxToRtcpMux) { 2181 TEST_F(VoiceChannelSingleThreadTest, SendRtcpMuxToRtcpMux) {
2152 Base::SendRtcpMuxToRtcpMux(); 2182 Base::SendRtcpMuxToRtcpMux();
2153 } 2183 }
2154 2184
2155 TEST_F(VoiceChannelTest, SendRequireRtcpMuxToRtcpMux) { 2185 TEST_F(VoiceChannelSingleThreadTest, SendRequireRtcpMuxToRtcpMux) {
2156 Base::SendRequireRtcpMuxToRtcpMux(); 2186 Base::SendRequireRtcpMuxToRtcpMux();
2157 } 2187 }
2158 2188
2159 TEST_F(VoiceChannelTest, SendRtcpMuxToRequireRtcpMux) { 2189 TEST_F(VoiceChannelSingleThreadTest, SendRtcpMuxToRequireRtcpMux) {
2160 Base::SendRtcpMuxToRequireRtcpMux(); 2190 Base::SendRtcpMuxToRequireRtcpMux();
2161 } 2191 }
2162 2192
2163 TEST_F(VoiceChannelTest, SendRequireRtcpMuxToRequireRtcpMux) { 2193 TEST_F(VoiceChannelSingleThreadTest, SendRequireRtcpMuxToRequireRtcpMux) {
2164 Base::SendRequireRtcpMuxToRequireRtcpMux(); 2194 Base::SendRequireRtcpMuxToRequireRtcpMux();
2165 } 2195 }
2166 2196
2167 TEST_F(VoiceChannelTest, SendRequireRtcpMuxToNoRtcpMux) { 2197 TEST_F(VoiceChannelSingleThreadTest, SendRequireRtcpMuxToNoRtcpMux) {
2168 Base::SendRequireRtcpMuxToNoRtcpMux(); 2198 Base::SendRequireRtcpMuxToNoRtcpMux();
2169 } 2199 }
2170 2200
2171 TEST_F(VoiceChannelTest, SendEarlyRtcpMuxToRtcp) { 2201 TEST_F(VoiceChannelSingleThreadTest, SendEarlyRtcpMuxToRtcp) {
2172 Base::SendEarlyRtcpMuxToRtcp(); 2202 Base::SendEarlyRtcpMuxToRtcp();
2173 } 2203 }
2174 2204
2175 TEST_F(VoiceChannelTest, SendEarlyRtcpMuxToRtcpMux) { 2205 TEST_F(VoiceChannelSingleThreadTest, SendEarlyRtcpMuxToRtcpMux) {
2176 Base::SendEarlyRtcpMuxToRtcpMux(); 2206 Base::SendEarlyRtcpMuxToRtcpMux();
2177 } 2207 }
2178 2208
2179 TEST_F(VoiceChannelTest, SendSrtpToSrtpRtcpMux) { 2209 TEST_F(VoiceChannelSingleThreadTest, SendSrtpToSrtpRtcpMux) {
2180 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX); 2210 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX);
2181 } 2211 }
2182 2212
2183 TEST_F(VoiceChannelTest, SendSrtpToRtp) { 2213 TEST_F(VoiceChannelSingleThreadTest, SendSrtpToRtp) {
2184 Base::SendSrtpToSrtp(); 2214 Base::SendSrtpToSrtp();
2185 } 2215 }
2186 2216
2187 TEST_F(VoiceChannelTest, SendSrtcpMux) { 2217 TEST_F(VoiceChannelSingleThreadTest, SendSrtcpMux) {
2188 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX); 2218 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX);
2189 } 2219 }
2190 2220
2191 TEST_F(VoiceChannelTest, SendDtlsSrtpToSrtp) { 2221 TEST_F(VoiceChannelSingleThreadTest, SendDtlsSrtpToSrtp) {
2192 MAYBE_SKIP_TEST(HaveDtlsSrtp); 2222 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2193 Base::SendSrtpToSrtp(DTLS, 0); 2223 Base::SendSrtpToSrtp(DTLS, 0);
2194 } 2224 }
2195 2225
2196 TEST_F(VoiceChannelTest, SendDtlsSrtpToDtlsSrtp) { 2226 TEST_F(VoiceChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtp) {
2197 MAYBE_SKIP_TEST(HaveDtlsSrtp); 2227 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2198 Base::SendSrtpToSrtp(DTLS, DTLS); 2228 Base::SendSrtpToSrtp(DTLS, DTLS);
2199 } 2229 }
2200 2230
2201 TEST_F(VoiceChannelTest, SendDtlsSrtpToDtlsSrtpRtcpMux) { 2231 TEST_F(VoiceChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) {
2202 MAYBE_SKIP_TEST(HaveDtlsSrtp); 2232 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2203 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX); 2233 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX);
2204 } 2234 }
2205 2235
2206 TEST_F(VoiceChannelTest, SendEarlyMediaUsingRtcpMuxSrtp) { 2236 TEST_F(VoiceChannelSingleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) {
2207 Base::SendEarlyMediaUsingRtcpMuxSrtp(); 2237 Base::SendEarlyMediaUsingRtcpMuxSrtp();
2208 } 2238 }
2209 2239
2210 TEST_F(VoiceChannelTest, SendRtpToRtpOnThread) { 2240 TEST_F(VoiceChannelSingleThreadTest, SendRtpToRtpOnThread) {
2211 Base::SendRtpToRtpOnThread(); 2241 Base::SendRtpToRtpOnThread();
2212 } 2242 }
2213 2243
2214 TEST_F(VoiceChannelTest, SendSrtpToSrtpOnThread) { 2244 TEST_F(VoiceChannelSingleThreadTest, SendSrtpToSrtpOnThread) {
2215 Base::SendSrtpToSrtpOnThread(); 2245 Base::SendSrtpToSrtpOnThread();
2216 } 2246 }
2217 2247
2218 TEST_F(VoiceChannelTest, SendWithWritabilityLoss) { 2248 TEST_F(VoiceChannelSingleThreadTest, SendWithWritabilityLoss) {
2219 Base::SendWithWritabilityLoss(); 2249 Base::SendWithWritabilityLoss();
2220 } 2250 }
2221 2251
2222 TEST_F(VoiceChannelTest, TestMediaMonitor) { 2252 TEST_F(VoiceChannelSingleThreadTest, TestMediaMonitor) {
2223 Base::TestMediaMonitor(); 2253 Base::TestMediaMonitor();
2224 } 2254 }
2225 2255
2226 // Test that InsertDtmf properly forwards to the media channel. 2256 // Test that InsertDtmf properly forwards to the media channel.
2227 TEST_F(VoiceChannelTest, TestInsertDtmf) { 2257 TEST_F(VoiceChannelSingleThreadTest, TestInsertDtmf) {
2228 CreateChannels(0, 0); 2258 CreateChannels(0, 0);
2229 EXPECT_TRUE(SendInitiate()); 2259 EXPECT_TRUE(SendInitiate());
2230 EXPECT_TRUE(SendAccept()); 2260 EXPECT_TRUE(SendAccept());
2231 EXPECT_EQ(0U, media_channel1_->dtmf_info_queue().size()); 2261 EXPECT_EQ(0U, media_channel1_->dtmf_info_queue().size());
2232 2262
2233 EXPECT_TRUE(channel1_->InsertDtmf(1, 3, 100)); 2263 EXPECT_TRUE(channel1_->InsertDtmf(1, 3, 100));
2234 EXPECT_TRUE(channel1_->InsertDtmf(2, 5, 110)); 2264 EXPECT_TRUE(channel1_->InsertDtmf(2, 5, 110));
2235 EXPECT_TRUE(channel1_->InsertDtmf(3, 7, 120)); 2265 EXPECT_TRUE(channel1_->InsertDtmf(3, 7, 120));
2236 2266
2237 ASSERT_EQ(3U, media_channel1_->dtmf_info_queue().size()); 2267 ASSERT_EQ(3U, media_channel1_->dtmf_info_queue().size());
2238 EXPECT_TRUE(CompareDtmfInfo(media_channel1_->dtmf_info_queue()[0], 2268 EXPECT_TRUE(CompareDtmfInfo(media_channel1_->dtmf_info_queue()[0],
2239 1, 3, 100)); 2269 1, 3, 100));
2240 EXPECT_TRUE(CompareDtmfInfo(media_channel1_->dtmf_info_queue()[1], 2270 EXPECT_TRUE(CompareDtmfInfo(media_channel1_->dtmf_info_queue()[1],
2241 2, 5, 110)); 2271 2, 5, 110));
2242 EXPECT_TRUE(CompareDtmfInfo(media_channel1_->dtmf_info_queue()[2], 2272 EXPECT_TRUE(CompareDtmfInfo(media_channel1_->dtmf_info_queue()[2],
2243 3, 7, 120)); 2273 3, 7, 120));
2244 } 2274 }
2245 2275
2246 TEST_F(VoiceChannelTest, TestSetContentFailure) { 2276 TEST_F(VoiceChannelSingleThreadTest, TestSetContentFailure) {
2247 Base::TestSetContentFailure(); 2277 Base::TestSetContentFailure();
2248 } 2278 }
2249 2279
2250 TEST_F(VoiceChannelTest, TestSendTwoOffers) { 2280 TEST_F(VoiceChannelSingleThreadTest, TestSendTwoOffers) {
2251 Base::TestSendTwoOffers(); 2281 Base::TestSendTwoOffers();
2252 } 2282 }
2253 2283
2254 TEST_F(VoiceChannelTest, TestReceiveTwoOffers) { 2284 TEST_F(VoiceChannelSingleThreadTest, TestReceiveTwoOffers) {
2255 Base::TestReceiveTwoOffers(); 2285 Base::TestReceiveTwoOffers();
2256 } 2286 }
2257 2287
2258 TEST_F(VoiceChannelTest, TestSendPrAnswer) { 2288 TEST_F(VoiceChannelSingleThreadTest, TestSendPrAnswer) {
2259 Base::TestSendPrAnswer(); 2289 Base::TestSendPrAnswer();
2260 } 2290 }
2261 2291
2262 TEST_F(VoiceChannelTest, TestReceivePrAnswer) { 2292 TEST_F(VoiceChannelSingleThreadTest, TestReceivePrAnswer) {
2263 Base::TestReceivePrAnswer(); 2293 Base::TestReceivePrAnswer();
2264 } 2294 }
2265 2295
2266 TEST_F(VoiceChannelTest, TestFlushRtcp) { 2296 TEST_F(VoiceChannelSingleThreadTest, TestFlushRtcp) {
2267 Base::TestFlushRtcp(); 2297 Base::TestFlushRtcp();
2268 } 2298 }
2269 2299
2270 TEST_F(VoiceChannelTest, TestSrtpError) { 2300 TEST_F(VoiceChannelSingleThreadTest, TestSrtpError) {
2271 Base::TestSrtpError(kAudioPts[0]); 2301 Base::TestSrtpError(kAudioPts[0]);
2272 } 2302 }
2273 2303
2274 TEST_F(VoiceChannelTest, TestOnReadyToSend) { 2304 TEST_F(VoiceChannelSingleThreadTest, TestOnReadyToSend) {
2275 Base::TestOnReadyToSend(); 2305 Base::TestOnReadyToSend();
2276 } 2306 }
2277 2307
2278 TEST_F(VoiceChannelTest, TestOnReadyToSendWithRtcpMux) { 2308 TEST_F(VoiceChannelSingleThreadTest, TestOnReadyToSendWithRtcpMux) {
2279 Base::TestOnReadyToSendWithRtcpMux(); 2309 Base::TestOnReadyToSendWithRtcpMux();
2280 } 2310 }
2281 2311
2282 // Test that we can scale the output volume properly for 1:1 calls. 2312 // Test that we can scale the output volume properly for 1:1 calls.
2283 TEST_F(VoiceChannelTest, TestScaleVolume1to1Call) { 2313 TEST_F(VoiceChannelSingleThreadTest, TestScaleVolume1to1Call) {
2284 CreateChannels(RTCP, RTCP); 2314 CreateChannels(RTCP, RTCP);
2285 EXPECT_TRUE(SendInitiate()); 2315 EXPECT_TRUE(SendInitiate());
2286 EXPECT_TRUE(SendAccept()); 2316 EXPECT_TRUE(SendAccept());
2287 double volume; 2317 double volume;
2288 2318
2289 // Default is (1.0). 2319 // Default is (1.0).
2290 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume)); 2320 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2291 EXPECT_DOUBLE_EQ(1.0, volume); 2321 EXPECT_DOUBLE_EQ(1.0, volume);
2292 // invalid ssrc. 2322 // invalid ssrc.
2293 EXPECT_FALSE(media_channel1_->GetOutputVolume(3, &volume)); 2323 EXPECT_FALSE(media_channel1_->GetOutputVolume(3, &volume));
2294 2324
2295 // Set scale to (1.5). 2325 // Set scale to (1.5).
2296 EXPECT_TRUE(channel1_->SetOutputVolume(0, 1.5)); 2326 EXPECT_TRUE(channel1_->SetOutputVolume(0, 1.5));
2297 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume)); 2327 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2298 EXPECT_DOUBLE_EQ(1.5, volume); 2328 EXPECT_DOUBLE_EQ(1.5, volume);
2299 2329
2300 // Set scale to (0). 2330 // Set scale to (0).
2301 EXPECT_TRUE(channel1_->SetOutputVolume(0, 0.0)); 2331 EXPECT_TRUE(channel1_->SetOutputVolume(0, 0.0));
2302 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume)); 2332 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2303 EXPECT_DOUBLE_EQ(0.0, volume); 2333 EXPECT_DOUBLE_EQ(0.0, volume);
2304 } 2334 }
2305 2335
2306 // Test that we can scale the output volume properly for multiway calls. 2336 // Test that we can scale the output volume properly for multiway calls.
2307 TEST_F(VoiceChannelTest, TestScaleVolumeMultiwayCall) { 2337 TEST_F(VoiceChannelSingleThreadTest, TestScaleVolumeMultiwayCall) {
2308 CreateChannels(RTCP, RTCP); 2338 CreateChannels(RTCP, RTCP);
2309 EXPECT_TRUE(SendInitiate()); 2339 EXPECT_TRUE(SendInitiate());
2310 EXPECT_TRUE(SendAccept()); 2340 EXPECT_TRUE(SendAccept());
2311 EXPECT_TRUE(AddStream1(1)); 2341 EXPECT_TRUE(AddStream1(1));
2312 EXPECT_TRUE(AddStream1(2)); 2342 EXPECT_TRUE(AddStream1(2));
2313 2343
2314 double volume; 2344 double volume;
2315 // Default is (1.0). 2345 // Default is (1.0).
2316 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume)); 2346 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2317 EXPECT_DOUBLE_EQ(1.0, volume); 2347 EXPECT_DOUBLE_EQ(1.0, volume);
(...skipping 16 matching lines...) Expand all
2334 // Set scale to (0) for all ssrcs. 2364 // Set scale to (0) for all ssrcs.
2335 EXPECT_TRUE(channel1_->SetOutputVolume(0, 0.0)); 2365 EXPECT_TRUE(channel1_->SetOutputVolume(0, 0.0));
2336 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume)); 2366 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2337 EXPECT_DOUBLE_EQ(0.0, volume); 2367 EXPECT_DOUBLE_EQ(0.0, volume);
2338 EXPECT_TRUE(media_channel1_->GetOutputVolume(1, &volume)); 2368 EXPECT_TRUE(media_channel1_->GetOutputVolume(1, &volume));
2339 EXPECT_DOUBLE_EQ(0.0, volume); 2369 EXPECT_DOUBLE_EQ(0.0, volume);
2340 EXPECT_TRUE(media_channel1_->GetOutputVolume(2, &volume)); 2370 EXPECT_TRUE(media_channel1_->GetOutputVolume(2, &volume));
2341 EXPECT_DOUBLE_EQ(0.0, volume); 2371 EXPECT_DOUBLE_EQ(0.0, volume);
2342 } 2372 }
2343 2373
2344 TEST_F(VoiceChannelTest, SendBundleToBundle) { 2374 TEST_F(VoiceChannelSingleThreadTest, SendBundleToBundle) {
2345 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, false); 2375 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, false);
2346 } 2376 }
2347 2377
2348 TEST_F(VoiceChannelTest, SendBundleToBundleSecure) { 2378 TEST_F(VoiceChannelSingleThreadTest, SendBundleToBundleSecure) {
2349 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, true); 2379 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, true);
2350 } 2380 }
2351 2381
2352 TEST_F(VoiceChannelTest, SendBundleToBundleWithRtcpMux) { 2382 TEST_F(VoiceChannelSingleThreadTest, SendBundleToBundleWithRtcpMux) {
2353 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, false); 2383 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, false);
2354 } 2384 }
2355 2385
2356 TEST_F(VoiceChannelTest, SendBundleToBundleWithRtcpMuxSecure) { 2386 TEST_F(VoiceChannelSingleThreadTest, SendBundleToBundleWithRtcpMuxSecure) {
2357 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, true); 2387 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, true);
2358 } 2388 }
2359 2389
2360 TEST_F(VoiceChannelTest, DefaultMaxBitrateIsUnlimited) { 2390 TEST_F(VoiceChannelSingleThreadTest, DefaultMaxBitrateIsUnlimited) {
2361 Base::DefaultMaxBitrateIsUnlimited(); 2391 Base::DefaultMaxBitrateIsUnlimited();
2362 } 2392 }
2363 2393
2364 TEST_F(VoiceChannelTest, CanChangeMaxBitrate) { 2394 TEST_F(VoiceChannelSingleThreadTest, CanChangeMaxBitrate) {
2365 Base::CanChangeMaxBitrate(); 2395 Base::CanChangeMaxBitrate();
2366 } 2396 }
2367 2397
2368 // VideoChannelTest 2398 // VoiceChannelDoubleThreadTest
2369 TEST_F(VideoChannelTest, TestInit) { 2399 TEST_F(VoiceChannelDoubleThreadTest, TestInit) {
2370 Base::TestInit(); 2400 Base::TestInit();
2371 } 2401 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
2372 2402 EXPECT_TRUE(media_channel1_->dtmf_info_queue().empty());
2373 TEST_F(VideoChannelTest, TestSetContents) { 2403 }
2404
2405 TEST_F(VoiceChannelDoubleThreadTest, TestSetContents) {
2374 Base::TestSetContents(); 2406 Base::TestSetContents();
2375 } 2407 }
2376 2408
2377 TEST_F(VideoChannelTest, TestSetContentsNullOffer) { 2409 TEST_F(VoiceChannelDoubleThreadTest, TestSetContentsNullOffer) {
2378 Base::TestSetContentsNullOffer(); 2410 Base::TestSetContentsNullOffer();
2379 } 2411 }
2380 2412
2381 TEST_F(VideoChannelTest, TestSetContentsRtcpMux) { 2413 TEST_F(VoiceChannelDoubleThreadTest, TestSetContentsRtcpMux) {
2382 Base::TestSetContentsRtcpMux(); 2414 Base::TestSetContentsRtcpMux();
2383 } 2415 }
2384 2416
2385 TEST_F(VideoChannelTest, TestSetContentsRtcpMuxWithPrAnswer) { 2417 TEST_F(VoiceChannelDoubleThreadTest, TestSetContentsRtcpMuxWithPrAnswer) {
2386 Base::TestSetContentsRtcpMux(); 2418 Base::TestSetContentsRtcpMux();
2387 } 2419 }
2388 2420
2389 TEST_F(VideoChannelTest, TestSetRemoteContentUpdate) { 2421 TEST_F(VoiceChannelDoubleThreadTest, TestSetRemoteContentUpdate) {
2390 Base::TestSetRemoteContentUpdate(); 2422 Base::TestSetRemoteContentUpdate();
2391 } 2423 }
2392 2424
2393 TEST_F(VideoChannelTest, TestStreams) { 2425 TEST_F(VoiceChannelDoubleThreadTest, TestStreams) {
2394 Base::TestStreams(); 2426 Base::TestStreams();
2395 } 2427 }
2396 2428
2397 TEST_F(VideoChannelTest, TestUpdateStreamsInLocalContent) { 2429 TEST_F(VoiceChannelDoubleThreadTest, TestUpdateStreamsInLocalContent) {
2398 Base::TestUpdateStreamsInLocalContent(); 2430 Base::TestUpdateStreamsInLocalContent();
2399 } 2431 }
2400 2432
2401 TEST_F(VideoChannelTest, TestUpdateRemoteStreamsInContent) { 2433 TEST_F(VoiceChannelDoubleThreadTest, TestUpdateRemoteStreamsInContent) {
2402 Base::TestUpdateStreamsInRemoteContent(); 2434 Base::TestUpdateStreamsInRemoteContent();
2403 } 2435 }
2404 2436
2405 TEST_F(VideoChannelTest, TestChangeStreamParamsInContent) { 2437 TEST_F(VoiceChannelDoubleThreadTest, TestChangeStreamParamsInContent) {
2406 Base::TestChangeStreamParamsInContent(); 2438 Base::TestChangeStreamParamsInContent();
2407 } 2439 }
2408 2440
2409 TEST_F(VideoChannelTest, TestPlayoutAndSendingStates) { 2441 TEST_F(VoiceChannelDoubleThreadTest, TestPlayoutAndSendingStates) {
2410 Base::TestPlayoutAndSendingStates(); 2442 Base::TestPlayoutAndSendingStates();
2411 } 2443 }
2412 2444
2413 TEST_F(VideoChannelTest, TestMuteStream) { 2445 TEST_F(VoiceChannelDoubleThreadTest, TestMuteStream) {
2446 CreateChannels(0, 0);
2447 // Test that we can Mute the default channel even though the sending SSRC
2448 // is unknown.
2449 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
2450 EXPECT_TRUE(channel1_->SetAudioSend(0, false, nullptr, nullptr));
2451 EXPECT_TRUE(media_channel1_->IsStreamMuted(0));
2452 EXPECT_TRUE(channel1_->SetAudioSend(0, true, nullptr, nullptr));
2453 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
2454
2455 // Test that we can not mute an unknown SSRC.
2456 EXPECT_FALSE(channel1_->SetAudioSend(kSsrc1, false, nullptr, nullptr));
2457
2458 SendInitiate();
2459 // After the local session description has been set, we can mute a stream
2460 // with its SSRC.
2461 EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, false, nullptr, nullptr));
2462 EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1));
2463 EXPECT_TRUE(channel1_->SetAudioSend(kSsrc1, true, nullptr, nullptr));
2464 EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1));
2465 }
2466
2467 TEST_F(VoiceChannelDoubleThreadTest, TestMediaContentDirection) {
2468 Base::TestMediaContentDirection();
2469 }
2470
2471 TEST_F(VoiceChannelDoubleThreadTest, TestNetworkRouteChanges) {
2472 Base::TestNetworkRouteChanges();
2473 }
2474
2475 TEST_F(VoiceChannelDoubleThreadTest, TestCallSetup) {
2476 Base::TestCallSetup();
2477 }
2478
2479 TEST_F(VoiceChannelDoubleThreadTest, TestCallTeardownRtcpMux) {
2480 Base::TestCallTeardownRtcpMux();
2481 }
2482
2483 TEST_F(VoiceChannelDoubleThreadTest, SendRtpToRtp) {
2484 Base::SendRtpToRtp();
2485 }
2486
2487 TEST_F(VoiceChannelDoubleThreadTest, SendNoRtcpToNoRtcp) {
2488 Base::SendNoRtcpToNoRtcp();
2489 }
2490
2491 TEST_F(VoiceChannelDoubleThreadTest, SendNoRtcpToRtcp) {
2492 Base::SendNoRtcpToRtcp();
2493 }
2494
2495 TEST_F(VoiceChannelDoubleThreadTest, SendRtcpToNoRtcp) {
2496 Base::SendRtcpToNoRtcp();
2497 }
2498
2499 TEST_F(VoiceChannelDoubleThreadTest, SendRtcpToRtcp) {
2500 Base::SendRtcpToRtcp();
2501 }
2502
2503 TEST_F(VoiceChannelDoubleThreadTest, SendRtcpMuxToRtcp) {
2504 Base::SendRtcpMuxToRtcp();
2505 }
2506
2507 TEST_F(VoiceChannelDoubleThreadTest, SendRtcpMuxToRtcpMux) {
2508 Base::SendRtcpMuxToRtcpMux();
2509 }
2510
2511 TEST_F(VoiceChannelDoubleThreadTest, SendRequireRtcpMuxToRtcpMux) {
2512 Base::SendRequireRtcpMuxToRtcpMux();
2513 }
2514
2515 TEST_F(VoiceChannelDoubleThreadTest, SendRtcpMuxToRequireRtcpMux) {
2516 Base::SendRtcpMuxToRequireRtcpMux();
2517 }
2518
2519 TEST_F(VoiceChannelDoubleThreadTest, SendRequireRtcpMuxToRequireRtcpMux) {
2520 Base::SendRequireRtcpMuxToRequireRtcpMux();
2521 }
2522
2523 TEST_F(VoiceChannelDoubleThreadTest, SendRequireRtcpMuxToNoRtcpMux) {
2524 Base::SendRequireRtcpMuxToNoRtcpMux();
2525 }
2526
2527 TEST_F(VoiceChannelDoubleThreadTest, SendEarlyRtcpMuxToRtcp) {
2528 Base::SendEarlyRtcpMuxToRtcp();
2529 }
2530
2531 TEST_F(VoiceChannelDoubleThreadTest, SendEarlyRtcpMuxToRtcpMux) {
2532 Base::SendEarlyRtcpMuxToRtcpMux();
2533 }
2534
2535 TEST_F(VoiceChannelDoubleThreadTest, SendSrtpToSrtpRtcpMux) {
2536 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX);
2537 }
2538
2539 TEST_F(VoiceChannelDoubleThreadTest, SendSrtpToRtp) {
2540 Base::SendSrtpToSrtp();
2541 }
2542
2543 TEST_F(VoiceChannelDoubleThreadTest, SendSrtcpMux) {
2544 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX);
2545 }
2546
2547 TEST_F(VoiceChannelDoubleThreadTest, SendDtlsSrtpToSrtp) {
2548 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2549 Base::SendSrtpToSrtp(DTLS, 0);
2550 }
2551
2552 TEST_F(VoiceChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtp) {
2553 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2554 Base::SendSrtpToSrtp(DTLS, DTLS);
2555 }
2556
2557 TEST_F(VoiceChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) {
2558 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2559 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX);
2560 }
2561
2562 TEST_F(VoiceChannelDoubleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) {
2563 Base::SendEarlyMediaUsingRtcpMuxSrtp();
2564 }
2565
2566 TEST_F(VoiceChannelDoubleThreadTest, SendRtpToRtpOnThread) {
2567 Base::SendRtpToRtpOnThread();
2568 }
2569
2570 TEST_F(VoiceChannelDoubleThreadTest, SendSrtpToSrtpOnThread) {
2571 Base::SendSrtpToSrtpOnThread();
2572 }
2573
2574 TEST_F(VoiceChannelDoubleThreadTest, SendWithWritabilityLoss) {
2575 Base::SendWithWritabilityLoss();
2576 }
2577
2578 TEST_F(VoiceChannelDoubleThreadTest, TestMediaMonitor) {
2579 Base::TestMediaMonitor();
2580 }
2581
2582 // Test that InsertDtmf properly forwards to the media channel.
2583 TEST_F(VoiceChannelDoubleThreadTest, TestInsertDtmf) {
2584 CreateChannels(0, 0);
2585 EXPECT_TRUE(SendInitiate());
2586 EXPECT_TRUE(SendAccept());
2587 EXPECT_EQ(0U, media_channel1_->dtmf_info_queue().size());
2588
2589 EXPECT_TRUE(channel1_->InsertDtmf(1, 3, 100));
2590 EXPECT_TRUE(channel1_->InsertDtmf(2, 5, 110));
2591 EXPECT_TRUE(channel1_->InsertDtmf(3, 7, 120));
2592
2593 ASSERT_EQ(3U, media_channel1_->dtmf_info_queue().size());
2594 EXPECT_TRUE(
2595 CompareDtmfInfo(media_channel1_->dtmf_info_queue()[0], 1, 3, 100));
2596 EXPECT_TRUE(
2597 CompareDtmfInfo(media_channel1_->dtmf_info_queue()[1], 2, 5, 110));
2598 EXPECT_TRUE(
2599 CompareDtmfInfo(media_channel1_->dtmf_info_queue()[2], 3, 7, 120));
2600 }
2601
2602 TEST_F(VoiceChannelDoubleThreadTest, TestSetContentFailure) {
2603 Base::TestSetContentFailure();
2604 }
2605
2606 TEST_F(VoiceChannelDoubleThreadTest, TestSendTwoOffers) {
2607 Base::TestSendTwoOffers();
2608 }
2609
2610 TEST_F(VoiceChannelDoubleThreadTest, TestReceiveTwoOffers) {
2611 Base::TestReceiveTwoOffers();
2612 }
2613
2614 TEST_F(VoiceChannelDoubleThreadTest, TestSendPrAnswer) {
2615 Base::TestSendPrAnswer();
2616 }
2617
2618 TEST_F(VoiceChannelDoubleThreadTest, TestReceivePrAnswer) {
2619 Base::TestReceivePrAnswer();
2620 }
2621
2622 TEST_F(VoiceChannelDoubleThreadTest, TestFlushRtcp) {
2623 Base::TestFlushRtcp();
2624 }
2625
2626 TEST_F(VoiceChannelDoubleThreadTest, TestSrtpError) {
2627 Base::TestSrtpError(kAudioPts[0]);
2628 }
2629
2630 TEST_F(VoiceChannelDoubleThreadTest, TestOnReadyToSend) {
2631 Base::TestOnReadyToSend();
2632 }
2633
2634 TEST_F(VoiceChannelDoubleThreadTest, TestOnReadyToSendWithRtcpMux) {
2635 Base::TestOnReadyToSendWithRtcpMux();
2636 }
2637
2638 // Test that we can scale the output volume properly for 1:1 calls.
2639 TEST_F(VoiceChannelDoubleThreadTest, TestScaleVolume1to1Call) {
2640 CreateChannels(RTCP, RTCP);
2641 EXPECT_TRUE(SendInitiate());
2642 EXPECT_TRUE(SendAccept());
2643 double volume;
2644
2645 // Default is (1.0).
2646 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2647 EXPECT_DOUBLE_EQ(1.0, volume);
2648 // invalid ssrc.
2649 EXPECT_FALSE(media_channel1_->GetOutputVolume(3, &volume));
2650
2651 // Set scale to (1.5).
2652 EXPECT_TRUE(channel1_->SetOutputVolume(0, 1.5));
2653 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2654 EXPECT_DOUBLE_EQ(1.5, volume);
2655
2656 // Set scale to (0).
2657 EXPECT_TRUE(channel1_->SetOutputVolume(0, 0.0));
2658 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2659 EXPECT_DOUBLE_EQ(0.0, volume);
2660 }
2661
2662 // Test that we can scale the output volume properly for multiway calls.
2663 TEST_F(VoiceChannelDoubleThreadTest, TestScaleVolumeMultiwayCall) {
2664 CreateChannels(RTCP, RTCP);
2665 EXPECT_TRUE(SendInitiate());
2666 EXPECT_TRUE(SendAccept());
2667 EXPECT_TRUE(AddStream1(1));
2668 EXPECT_TRUE(AddStream1(2));
2669
2670 double volume;
2671 // Default is (1.0).
2672 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2673 EXPECT_DOUBLE_EQ(1.0, volume);
2674 EXPECT_TRUE(media_channel1_->GetOutputVolume(1, &volume));
2675 EXPECT_DOUBLE_EQ(1.0, volume);
2676 EXPECT_TRUE(media_channel1_->GetOutputVolume(2, &volume));
2677 EXPECT_DOUBLE_EQ(1.0, volume);
2678 // invalid ssrc.
2679 EXPECT_FALSE(media_channel1_->GetOutputVolume(3, &volume));
2680
2681 // Set scale to (1.5) for ssrc = 1.
2682 EXPECT_TRUE(channel1_->SetOutputVolume(1, 1.5));
2683 EXPECT_TRUE(media_channel1_->GetOutputVolume(1, &volume));
2684 EXPECT_DOUBLE_EQ(1.5, volume);
2685 EXPECT_TRUE(media_channel1_->GetOutputVolume(2, &volume));
2686 EXPECT_DOUBLE_EQ(1.0, volume);
2687 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2688 EXPECT_DOUBLE_EQ(1.0, volume);
2689
2690 // Set scale to (0) for all ssrcs.
2691 EXPECT_TRUE(channel1_->SetOutputVolume(0, 0.0));
2692 EXPECT_TRUE(media_channel1_->GetOutputVolume(0, &volume));
2693 EXPECT_DOUBLE_EQ(0.0, volume);
2694 EXPECT_TRUE(media_channel1_->GetOutputVolume(1, &volume));
2695 EXPECT_DOUBLE_EQ(0.0, volume);
2696 EXPECT_TRUE(media_channel1_->GetOutputVolume(2, &volume));
2697 EXPECT_DOUBLE_EQ(0.0, volume);
2698 }
2699
2700 TEST_F(VoiceChannelDoubleThreadTest, SendBundleToBundle) {
2701 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, false);
2702 }
2703
2704 TEST_F(VoiceChannelDoubleThreadTest, SendBundleToBundleSecure) {
2705 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, true);
2706 }
2707
2708 TEST_F(VoiceChannelDoubleThreadTest, SendBundleToBundleWithRtcpMux) {
2709 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, false);
2710 }
2711
2712 TEST_F(VoiceChannelDoubleThreadTest, SendBundleToBundleWithRtcpMuxSecure) {
2713 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, true);
2714 }
2715
2716 TEST_F(VoiceChannelDoubleThreadTest, DefaultMaxBitrateIsUnlimited) {
2717 Base::DefaultMaxBitrateIsUnlimited();
2718 }
2719
2720 TEST_F(VoiceChannelDoubleThreadTest, CanChangeMaxBitrate) {
2721 Base::CanChangeMaxBitrate();
2722 }
2723
2724 // VideoChannelSingleThreadTest
2725 TEST_F(VideoChannelSingleThreadTest, TestInit) {
2726 Base::TestInit();
2727 }
2728
2729 TEST_F(VideoChannelSingleThreadTest, TestSetContents) {
2730 Base::TestSetContents();
2731 }
2732
2733 TEST_F(VideoChannelSingleThreadTest, TestSetContentsNullOffer) {
2734 Base::TestSetContentsNullOffer();
2735 }
2736
2737 TEST_F(VideoChannelSingleThreadTest, TestSetContentsRtcpMux) {
2738 Base::TestSetContentsRtcpMux();
2739 }
2740
2741 TEST_F(VideoChannelSingleThreadTest, TestSetContentsRtcpMuxWithPrAnswer) {
2742 Base::TestSetContentsRtcpMux();
2743 }
2744
2745 TEST_F(VideoChannelSingleThreadTest, TestSetRemoteContentUpdate) {
2746 Base::TestSetRemoteContentUpdate();
2747 }
2748
2749 TEST_F(VideoChannelSingleThreadTest, TestStreams) {
2750 Base::TestStreams();
2751 }
2752
2753 TEST_F(VideoChannelSingleThreadTest, TestUpdateStreamsInLocalContent) {
2754 Base::TestUpdateStreamsInLocalContent();
2755 }
2756
2757 TEST_F(VideoChannelSingleThreadTest, TestUpdateRemoteStreamsInContent) {
2758 Base::TestUpdateStreamsInRemoteContent();
2759 }
2760
2761 TEST_F(VideoChannelSingleThreadTest, TestChangeStreamParamsInContent) {
2762 Base::TestChangeStreamParamsInContent();
2763 }
2764
2765 TEST_F(VideoChannelSingleThreadTest, TestPlayoutAndSendingStates) {
2766 Base::TestPlayoutAndSendingStates();
2767 }
2768
2769 TEST_F(VideoChannelSingleThreadTest, TestMuteStream) {
2414 CreateChannels(0, 0); 2770 CreateChannels(0, 0);
2415 // Test that we can Mute the default channel even though the sending SSRC 2771 // Test that we can Mute the default channel even though the sending SSRC
2416 // is unknown. 2772 // is unknown.
2417 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); 2773 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
2418 EXPECT_TRUE(channel1_->SetVideoSend(0, false, nullptr)); 2774 EXPECT_TRUE(channel1_->SetVideoSend(0, false, nullptr));
2419 EXPECT_TRUE(media_channel1_->IsStreamMuted(0)); 2775 EXPECT_TRUE(media_channel1_->IsStreamMuted(0));
2420 EXPECT_TRUE(channel1_->SetVideoSend(0, true, nullptr)); 2776 EXPECT_TRUE(channel1_->SetVideoSend(0, true, nullptr));
2421 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); 2777 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
2422 // Test that we can not mute an unknown SSRC. 2778 // Test that we can not mute an unknown SSRC.
2423 EXPECT_FALSE(channel1_->SetVideoSend(kSsrc1, false, nullptr)); 2779 EXPECT_FALSE(channel1_->SetVideoSend(kSsrc1, false, nullptr));
2424 SendInitiate(); 2780 SendInitiate();
2425 // After the local session description has been set, we can mute a stream 2781 // After the local session description has been set, we can mute a stream
2426 // with its SSRC. 2782 // with its SSRC.
2427 EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, false, nullptr)); 2783 EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, false, nullptr));
2428 EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1)); 2784 EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1));
2429 EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, true, nullptr)); 2785 EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, true, nullptr));
2430 EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1)); 2786 EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1));
2431 } 2787 }
2432 2788
2433 TEST_F(VideoChannelTest, TestMediaContentDirection) { 2789 TEST_F(VideoChannelSingleThreadTest, TestMediaContentDirection) {
2434 Base::TestMediaContentDirection(); 2790 Base::TestMediaContentDirection();
2435 } 2791 }
2436 2792
2437 TEST_F(VideoChannelTest, TestNetworkRouteChanges) { 2793 TEST_F(VideoChannelSingleThreadTest, TestNetworkRouteChanges) {
2438 Base::TestNetworkRouteChanges(); 2794 Base::TestNetworkRouteChanges();
2439 } 2795 }
2440 2796
2441 TEST_F(VideoChannelTest, TestCallSetup) { 2797 TEST_F(VideoChannelSingleThreadTest, TestCallSetup) {
2442 Base::TestCallSetup(); 2798 Base::TestCallSetup();
2443 } 2799 }
2444 2800
2445 TEST_F(VideoChannelTest, TestCallTeardownRtcpMux) { 2801 TEST_F(VideoChannelSingleThreadTest, TestCallTeardownRtcpMux) {
2446 Base::TestCallTeardownRtcpMux(); 2802 Base::TestCallTeardownRtcpMux();
2447 } 2803 }
2448 2804
2449 TEST_F(VideoChannelTest, SendRtpToRtp) { 2805 TEST_F(VideoChannelSingleThreadTest, SendRtpToRtp) {
2450 Base::SendRtpToRtp(); 2806 Base::SendRtpToRtp();
2451 } 2807 }
2452 2808
2453 TEST_F(VideoChannelTest, SendNoRtcpToNoRtcp) { 2809 TEST_F(VideoChannelSingleThreadTest, SendNoRtcpToNoRtcp) {
2454 Base::SendNoRtcpToNoRtcp(); 2810 Base::SendNoRtcpToNoRtcp();
2455 } 2811 }
2456 2812
2457 TEST_F(VideoChannelTest, SendNoRtcpToRtcp) { 2813 TEST_F(VideoChannelSingleThreadTest, SendNoRtcpToRtcp) {
2458 Base::SendNoRtcpToRtcp(); 2814 Base::SendNoRtcpToRtcp();
2459 } 2815 }
2460 2816
2461 TEST_F(VideoChannelTest, SendRtcpToNoRtcp) { 2817 TEST_F(VideoChannelSingleThreadTest, SendRtcpToNoRtcp) {
2462 Base::SendRtcpToNoRtcp(); 2818 Base::SendRtcpToNoRtcp();
2463 } 2819 }
2464 2820
2465 TEST_F(VideoChannelTest, SendRtcpToRtcp) { 2821 TEST_F(VideoChannelSingleThreadTest, SendRtcpToRtcp) {
2466 Base::SendRtcpToRtcp(); 2822 Base::SendRtcpToRtcp();
2467 } 2823 }
2468 2824
2469 TEST_F(VideoChannelTest, SendRtcpMuxToRtcp) { 2825 TEST_F(VideoChannelSingleThreadTest, SendRtcpMuxToRtcp) {
2470 Base::SendRtcpMuxToRtcp(); 2826 Base::SendRtcpMuxToRtcp();
2471 } 2827 }
2472 2828
2473 TEST_F(VideoChannelTest, SendRtcpMuxToRtcpMux) { 2829 TEST_F(VideoChannelSingleThreadTest, SendRtcpMuxToRtcpMux) {
2474 Base::SendRtcpMuxToRtcpMux(); 2830 Base::SendRtcpMuxToRtcpMux();
2475 } 2831 }
2476 2832
2477 TEST_F(VideoChannelTest, SendRequireRtcpMuxToRtcpMux) { 2833 TEST_F(VideoChannelSingleThreadTest, SendRequireRtcpMuxToRtcpMux) {
2478 Base::SendRequireRtcpMuxToRtcpMux(); 2834 Base::SendRequireRtcpMuxToRtcpMux();
2479 } 2835 }
2480 2836
2481 TEST_F(VideoChannelTest, SendRtcpMuxToRequireRtcpMux) { 2837 TEST_F(VideoChannelSingleThreadTest, SendRtcpMuxToRequireRtcpMux) {
2482 Base::SendRtcpMuxToRequireRtcpMux(); 2838 Base::SendRtcpMuxToRequireRtcpMux();
2483 } 2839 }
2484 2840
2485 TEST_F(VideoChannelTest, SendRequireRtcpMuxToRequireRtcpMux) { 2841 TEST_F(VideoChannelSingleThreadTest, SendRequireRtcpMuxToRequireRtcpMux) {
2486 Base::SendRequireRtcpMuxToRequireRtcpMux(); 2842 Base::SendRequireRtcpMuxToRequireRtcpMux();
2487 } 2843 }
2488 2844
2489 TEST_F(VideoChannelTest, SendRequireRtcpMuxToNoRtcpMux) { 2845 TEST_F(VideoChannelSingleThreadTest, SendRequireRtcpMuxToNoRtcpMux) {
2490 Base::SendRequireRtcpMuxToNoRtcpMux(); 2846 Base::SendRequireRtcpMuxToNoRtcpMux();
2491 } 2847 }
2492 2848
2493 TEST_F(VideoChannelTest, SendEarlyRtcpMuxToRtcp) { 2849 TEST_F(VideoChannelSingleThreadTest, SendEarlyRtcpMuxToRtcp) {
2494 Base::SendEarlyRtcpMuxToRtcp(); 2850 Base::SendEarlyRtcpMuxToRtcp();
2495 } 2851 }
2496 2852
2497 TEST_F(VideoChannelTest, SendEarlyRtcpMuxToRtcpMux) { 2853 TEST_F(VideoChannelSingleThreadTest, SendEarlyRtcpMuxToRtcpMux) {
2498 Base::SendEarlyRtcpMuxToRtcpMux(); 2854 Base::SendEarlyRtcpMuxToRtcpMux();
2499 } 2855 }
2500 2856
2501 TEST_F(VideoChannelTest, SendSrtpToSrtp) { 2857 TEST_F(VideoChannelSingleThreadTest, SendSrtpToSrtp) {
2502 Base::SendSrtpToSrtp(); 2858 Base::SendSrtpToSrtp();
2503 } 2859 }
2504 2860
2505 TEST_F(VideoChannelTest, SendSrtpToRtp) { 2861 TEST_F(VideoChannelSingleThreadTest, SendSrtpToRtp) {
2506 Base::SendSrtpToSrtp(); 2862 Base::SendSrtpToSrtp();
2507 } 2863 }
2508 2864
2509 TEST_F(VideoChannelTest, SendDtlsSrtpToSrtp) { 2865 TEST_F(VideoChannelSingleThreadTest, SendDtlsSrtpToSrtp) {
2510 MAYBE_SKIP_TEST(HaveDtlsSrtp); 2866 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2511 Base::SendSrtpToSrtp(DTLS, 0); 2867 Base::SendSrtpToSrtp(DTLS, 0);
2512 } 2868 }
2513 2869
2514 TEST_F(VideoChannelTest, SendDtlsSrtpToDtlsSrtp) { 2870 TEST_F(VideoChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtp) {
2515 MAYBE_SKIP_TEST(HaveDtlsSrtp); 2871 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2516 Base::SendSrtpToSrtp(DTLS, DTLS); 2872 Base::SendSrtpToSrtp(DTLS, DTLS);
2517 } 2873 }
2518 2874
2519 TEST_F(VideoChannelTest, SendDtlsSrtpToDtlsSrtpRtcpMux) { 2875 TEST_F(VideoChannelSingleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) {
2520 MAYBE_SKIP_TEST(HaveDtlsSrtp); 2876 MAYBE_SKIP_TEST(HaveDtlsSrtp);
2521 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX); 2877 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX);
2522 } 2878 }
2523 2879
2524 TEST_F(VideoChannelTest, SendSrtcpMux) { 2880 TEST_F(VideoChannelSingleThreadTest, SendSrtcpMux) {
2525 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX); 2881 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX);
2526 } 2882 }
2527 2883
2528 TEST_F(VideoChannelTest, SendEarlyMediaUsingRtcpMuxSrtp) { 2884 TEST_F(VideoChannelSingleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) {
2529 Base::SendEarlyMediaUsingRtcpMuxSrtp(); 2885 Base::SendEarlyMediaUsingRtcpMuxSrtp();
2530 } 2886 }
2531 2887
2532 TEST_F(VideoChannelTest, SendRtpToRtpOnThread) { 2888 TEST_F(VideoChannelSingleThreadTest, SendRtpToRtpOnThread) {
2533 Base::SendRtpToRtpOnThread(); 2889 Base::SendRtpToRtpOnThread();
2534 } 2890 }
2535 2891
2536 TEST_F(VideoChannelTest, SendSrtpToSrtpOnThread) { 2892 TEST_F(VideoChannelSingleThreadTest, SendSrtpToSrtpOnThread) {
2537 Base::SendSrtpToSrtpOnThread(); 2893 Base::SendSrtpToSrtpOnThread();
2538 } 2894 }
2539 2895
2540 TEST_F(VideoChannelTest, SendWithWritabilityLoss) { 2896 TEST_F(VideoChannelSingleThreadTest, SendWithWritabilityLoss) {
2541 Base::SendWithWritabilityLoss(); 2897 Base::SendWithWritabilityLoss();
2542 } 2898 }
2543 2899
2544 TEST_F(VideoChannelTest, TestMediaMonitor) { 2900 TEST_F(VideoChannelSingleThreadTest, TestMediaMonitor) {
2545 Base::TestMediaMonitor(); 2901 Base::TestMediaMonitor();
2546 } 2902 }
2547 2903
2548 TEST_F(VideoChannelTest, TestSetContentFailure) { 2904 TEST_F(VideoChannelSingleThreadTest, TestSetContentFailure) {
2549 Base::TestSetContentFailure(); 2905 Base::TestSetContentFailure();
2550 } 2906 }
2551 2907
2552 TEST_F(VideoChannelTest, TestSendTwoOffers) { 2908 TEST_F(VideoChannelSingleThreadTest, TestSendTwoOffers) {
2553 Base::TestSendTwoOffers(); 2909 Base::TestSendTwoOffers();
2554 } 2910 }
2555 2911
2556 TEST_F(VideoChannelTest, TestReceiveTwoOffers) { 2912 TEST_F(VideoChannelSingleThreadTest, TestReceiveTwoOffers) {
2557 Base::TestReceiveTwoOffers(); 2913 Base::TestReceiveTwoOffers();
2558 } 2914 }
2559 2915
2560 TEST_F(VideoChannelTest, TestSendPrAnswer) { 2916 TEST_F(VideoChannelSingleThreadTest, TestSendPrAnswer) {
2561 Base::TestSendPrAnswer(); 2917 Base::TestSendPrAnswer();
2562 } 2918 }
2563 2919
2564 TEST_F(VideoChannelTest, TestReceivePrAnswer) { 2920 TEST_F(VideoChannelSingleThreadTest, TestReceivePrAnswer) {
2565 Base::TestReceivePrAnswer(); 2921 Base::TestReceivePrAnswer();
2566 } 2922 }
2567 2923
2568 TEST_F(VideoChannelTest, TestFlushRtcp) { 2924 TEST_F(VideoChannelSingleThreadTest, TestFlushRtcp) {
2569 Base::TestFlushRtcp(); 2925 Base::TestFlushRtcp();
2570 } 2926 }
2571 2927
2572 TEST_F(VideoChannelTest, SendBundleToBundle) { 2928 TEST_F(VideoChannelSingleThreadTest, SendBundleToBundle) {
2573 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, false); 2929 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, false);
2574 } 2930 }
2575 2931
2576 TEST_F(VideoChannelTest, SendBundleToBundleSecure) { 2932 TEST_F(VideoChannelSingleThreadTest, SendBundleToBundleSecure) {
2577 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, true); 2933 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, true);
2578 } 2934 }
2579 2935
2580 TEST_F(VideoChannelTest, SendBundleToBundleWithRtcpMux) { 2936 TEST_F(VideoChannelSingleThreadTest, SendBundleToBundleWithRtcpMux) {
2581 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, false); 2937 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, false);
2582 } 2938 }
2583 2939
2584 TEST_F(VideoChannelTest, SendBundleToBundleWithRtcpMuxSecure) { 2940 TEST_F(VideoChannelSingleThreadTest, SendBundleToBundleWithRtcpMuxSecure) {
2585 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, true); 2941 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, true);
2586 } 2942 }
2587 2943
2588 TEST_F(VideoChannelTest, TestSrtpError) { 2944 TEST_F(VideoChannelSingleThreadTest, TestSrtpError) {
2589 Base::TestSrtpError(kVideoPts[0]); 2945 Base::TestSrtpError(kVideoPts[0]);
2590 } 2946 }
2591 2947
2592 TEST_F(VideoChannelTest, TestOnReadyToSend) { 2948 TEST_F(VideoChannelSingleThreadTest, TestOnReadyToSend) {
2593 Base::TestOnReadyToSend(); 2949 Base::TestOnReadyToSend();
2594 } 2950 }
2595 2951
2596 TEST_F(VideoChannelTest, TestOnReadyToSendWithRtcpMux) { 2952 TEST_F(VideoChannelSingleThreadTest, TestOnReadyToSendWithRtcpMux) {
2597 Base::TestOnReadyToSendWithRtcpMux(); 2953 Base::TestOnReadyToSendWithRtcpMux();
2598 } 2954 }
2599 2955
2600 TEST_F(VideoChannelTest, DefaultMaxBitrateIsUnlimited) { 2956 TEST_F(VideoChannelSingleThreadTest, DefaultMaxBitrateIsUnlimited) {
2601 Base::DefaultMaxBitrateIsUnlimited(); 2957 Base::DefaultMaxBitrateIsUnlimited();
2602 } 2958 }
2603 2959
2604 TEST_F(VideoChannelTest, CanChangeMaxBitrate) { 2960 TEST_F(VideoChannelSingleThreadTest, CanChangeMaxBitrate) {
2605 Base::CanChangeMaxBitrate(); 2961 Base::CanChangeMaxBitrate();
2606 } 2962 }
2607 2963
2608 // DataChannelTest 2964 // VideoChannelDoubleThreadTest
2609 2965 TEST_F(VideoChannelDoubleThreadTest, TestInit) {
2610 class DataChannelTest 2966 Base::TestInit();
2611 : public ChannelTest<DataTraits> { 2967 }
2968
2969 TEST_F(VideoChannelDoubleThreadTest, TestSetContents) {
2970 Base::TestSetContents();
2971 }
2972
2973 TEST_F(VideoChannelDoubleThreadTest, TestSetContentsNullOffer) {
2974 Base::TestSetContentsNullOffer();
2975 }
2976
2977 TEST_F(VideoChannelDoubleThreadTest, TestSetContentsRtcpMux) {
2978 Base::TestSetContentsRtcpMux();
2979 }
2980
2981 TEST_F(VideoChannelDoubleThreadTest, TestSetContentsRtcpMuxWithPrAnswer) {
2982 Base::TestSetContentsRtcpMux();
2983 }
2984
2985 TEST_F(VideoChannelDoubleThreadTest, TestSetRemoteContentUpdate) {
2986 Base::TestSetRemoteContentUpdate();
2987 }
2988
2989 TEST_F(VideoChannelDoubleThreadTest, TestStreams) {
2990 Base::TestStreams();
2991 }
2992
2993 TEST_F(VideoChannelDoubleThreadTest, TestUpdateStreamsInLocalContent) {
2994 Base::TestUpdateStreamsInLocalContent();
2995 }
2996
2997 TEST_F(VideoChannelDoubleThreadTest, TestUpdateRemoteStreamsInContent) {
2998 Base::TestUpdateStreamsInRemoteContent();
2999 }
3000
3001 TEST_F(VideoChannelDoubleThreadTest, TestChangeStreamParamsInContent) {
3002 Base::TestChangeStreamParamsInContent();
3003 }
3004
3005 TEST_F(VideoChannelDoubleThreadTest, TestPlayoutAndSendingStates) {
3006 Base::TestPlayoutAndSendingStates();
3007 }
3008
3009 TEST_F(VideoChannelDoubleThreadTest, TestMuteStream) {
3010 CreateChannels(0, 0);
3011 // Test that we can Mute the default channel even though the sending SSRC
3012 // is unknown.
3013 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
3014 EXPECT_TRUE(channel1_->SetVideoSend(0, false, nullptr));
3015 EXPECT_TRUE(media_channel1_->IsStreamMuted(0));
3016 EXPECT_TRUE(channel1_->SetVideoSend(0, true, nullptr));
3017 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
3018 // Test that we can not mute an unknown SSRC.
3019 EXPECT_FALSE(channel1_->SetVideoSend(kSsrc1, false, nullptr));
3020 SendInitiate();
3021 // After the local session description has been set, we can mute a stream
3022 // with its SSRC.
3023 EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, false, nullptr));
3024 EXPECT_TRUE(media_channel1_->IsStreamMuted(kSsrc1));
3025 EXPECT_TRUE(channel1_->SetVideoSend(kSsrc1, true, nullptr));
3026 EXPECT_FALSE(media_channel1_->IsStreamMuted(kSsrc1));
3027 }
3028
3029 TEST_F(VideoChannelDoubleThreadTest, TestMediaContentDirection) {
3030 Base::TestMediaContentDirection();
3031 }
3032
3033 TEST_F(VideoChannelDoubleThreadTest, TestNetworkRouteChanges) {
3034 Base::TestNetworkRouteChanges();
3035 }
3036
3037 TEST_F(VideoChannelDoubleThreadTest, TestCallSetup) {
3038 Base::TestCallSetup();
3039 }
3040
3041 TEST_F(VideoChannelDoubleThreadTest, TestCallTeardownRtcpMux) {
3042 Base::TestCallTeardownRtcpMux();
3043 }
3044
3045 TEST_F(VideoChannelDoubleThreadTest, SendRtpToRtp) {
3046 Base::SendRtpToRtp();
3047 }
3048
3049 TEST_F(VideoChannelDoubleThreadTest, SendNoRtcpToNoRtcp) {
3050 Base::SendNoRtcpToNoRtcp();
3051 }
3052
3053 TEST_F(VideoChannelDoubleThreadTest, SendNoRtcpToRtcp) {
3054 Base::SendNoRtcpToRtcp();
3055 }
3056
3057 TEST_F(VideoChannelDoubleThreadTest, SendRtcpToNoRtcp) {
3058 Base::SendRtcpToNoRtcp();
3059 }
3060
3061 TEST_F(VideoChannelDoubleThreadTest, SendRtcpToRtcp) {
3062 Base::SendRtcpToRtcp();
3063 }
3064
3065 TEST_F(VideoChannelDoubleThreadTest, SendRtcpMuxToRtcp) {
3066 Base::SendRtcpMuxToRtcp();
3067 }
3068
3069 TEST_F(VideoChannelDoubleThreadTest, SendRtcpMuxToRtcpMux) {
3070 Base::SendRtcpMuxToRtcpMux();
3071 }
3072
3073 TEST_F(VideoChannelDoubleThreadTest, SendRequireRtcpMuxToRtcpMux) {
3074 Base::SendRequireRtcpMuxToRtcpMux();
3075 }
3076
3077 TEST_F(VideoChannelDoubleThreadTest, SendRtcpMuxToRequireRtcpMux) {
3078 Base::SendRtcpMuxToRequireRtcpMux();
3079 }
3080
3081 TEST_F(VideoChannelDoubleThreadTest, SendRequireRtcpMuxToRequireRtcpMux) {
3082 Base::SendRequireRtcpMuxToRequireRtcpMux();
3083 }
3084
3085 TEST_F(VideoChannelDoubleThreadTest, SendRequireRtcpMuxToNoRtcpMux) {
3086 Base::SendRequireRtcpMuxToNoRtcpMux();
3087 }
3088
3089 TEST_F(VideoChannelDoubleThreadTest, SendEarlyRtcpMuxToRtcp) {
3090 Base::SendEarlyRtcpMuxToRtcp();
3091 }
3092
3093 TEST_F(VideoChannelDoubleThreadTest, SendEarlyRtcpMuxToRtcpMux) {
3094 Base::SendEarlyRtcpMuxToRtcpMux();
3095 }
3096
3097 TEST_F(VideoChannelDoubleThreadTest, SendSrtpToSrtp) {
3098 Base::SendSrtpToSrtp();
3099 }
3100
3101 TEST_F(VideoChannelDoubleThreadTest, SendSrtpToRtp) {
3102 Base::SendSrtpToSrtp();
3103 }
3104
3105 TEST_F(VideoChannelDoubleThreadTest, SendDtlsSrtpToSrtp) {
3106 MAYBE_SKIP_TEST(HaveDtlsSrtp);
3107 Base::SendSrtpToSrtp(DTLS, 0);
3108 }
3109
3110 TEST_F(VideoChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtp) {
3111 MAYBE_SKIP_TEST(HaveDtlsSrtp);
3112 Base::SendSrtpToSrtp(DTLS, DTLS);
3113 }
3114
3115 TEST_F(VideoChannelDoubleThreadTest, SendDtlsSrtpToDtlsSrtpRtcpMux) {
3116 MAYBE_SKIP_TEST(HaveDtlsSrtp);
3117 Base::SendSrtpToSrtp(DTLS | RTCP_MUX, DTLS | RTCP_MUX);
3118 }
3119
3120 TEST_F(VideoChannelDoubleThreadTest, SendSrtcpMux) {
3121 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX);
3122 }
3123
3124 TEST_F(VideoChannelDoubleThreadTest, SendEarlyMediaUsingRtcpMuxSrtp) {
3125 Base::SendEarlyMediaUsingRtcpMuxSrtp();
3126 }
3127
3128 TEST_F(VideoChannelDoubleThreadTest, SendRtpToRtpOnThread) {
3129 Base::SendRtpToRtpOnThread();
3130 }
3131
3132 TEST_F(VideoChannelDoubleThreadTest, SendSrtpToSrtpOnThread) {
3133 Base::SendSrtpToSrtpOnThread();
3134 }
3135
3136 TEST_F(VideoChannelDoubleThreadTest, SendWithWritabilityLoss) {
3137 Base::SendWithWritabilityLoss();
3138 }
3139
3140 TEST_F(VideoChannelDoubleThreadTest, TestMediaMonitor) {
3141 Base::TestMediaMonitor();
3142 }
3143
3144 TEST_F(VideoChannelDoubleThreadTest, TestSetContentFailure) {
3145 Base::TestSetContentFailure();
3146 }
3147
3148 TEST_F(VideoChannelDoubleThreadTest, TestSendTwoOffers) {
3149 Base::TestSendTwoOffers();
3150 }
3151
3152 TEST_F(VideoChannelDoubleThreadTest, TestReceiveTwoOffers) {
3153 Base::TestReceiveTwoOffers();
3154 }
3155
3156 TEST_F(VideoChannelDoubleThreadTest, TestSendPrAnswer) {
3157 Base::TestSendPrAnswer();
3158 }
3159
3160 TEST_F(VideoChannelDoubleThreadTest, TestReceivePrAnswer) {
3161 Base::TestReceivePrAnswer();
3162 }
3163
3164 TEST_F(VideoChannelDoubleThreadTest, TestFlushRtcp) {
3165 Base::TestFlushRtcp();
3166 }
3167
3168 TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundle) {
3169 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, false);
3170 }
3171
3172 TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundleSecure) {
3173 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, true);
3174 }
3175
3176 TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundleWithRtcpMux) {
3177 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, false);
3178 }
3179
3180 TEST_F(VideoChannelDoubleThreadTest, SendBundleToBundleWithRtcpMuxSecure) {
3181 Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, true);
3182 }
3183
3184 TEST_F(VideoChannelDoubleThreadTest, TestSrtpError) {
3185 Base::TestSrtpError(kVideoPts[0]);
3186 }
3187
3188 TEST_F(VideoChannelDoubleThreadTest, TestOnReadyToSend) {
3189 Base::TestOnReadyToSend();
3190 }
3191
3192 TEST_F(VideoChannelDoubleThreadTest, TestOnReadyToSendWithRtcpMux) {
3193 Base::TestOnReadyToSendWithRtcpMux();
3194 }
3195
3196 TEST_F(VideoChannelDoubleThreadTest, DefaultMaxBitrateIsUnlimited) {
3197 Base::DefaultMaxBitrateIsUnlimited();
3198 }
3199
3200 TEST_F(VideoChannelDoubleThreadTest, CanChangeMaxBitrate) {
3201 Base::CanChangeMaxBitrate();
3202 }
3203
3204 // DataChannelSingleThreadTest
3205 class DataChannelSingleThreadTest : public ChannelTest<DataTraits> {
2612 public: 3206 public:
2613 typedef ChannelTest<DataTraits> 3207 typedef ChannelTest<DataTraits> Base;
2614 Base; 3208 DataChannelSingleThreadTest()
2615 DataChannelTest() 3209 : Base(true, kDataPacket, kRtcpReport, NetworkIsWorker::Yes) {}
2616 : Base(true, 3210 };
2617 kDataPacket, 3211
2618 sizeof(kDataPacket), 3212 // DataChannelDoubleThreadTest
2619 kRtcpReport, 3213 class DataChannelDoubleThreadTest : public ChannelTest<DataTraits> {
2620 sizeof(kRtcpReport)) {} 3214 public:
3215 typedef ChannelTest<DataTraits> Base;
3216 DataChannelDoubleThreadTest()
3217 : Base(true, kDataPacket, kRtcpReport, NetworkIsWorker::No) {}
2621 }; 3218 };
2622 3219
2623 // Override to avoid engine channel parameter. 3220 // Override to avoid engine channel parameter.
2624 template <> 3221 template <>
2625 cricket::DataChannel* ChannelTest<DataTraits>::CreateChannel( 3222 cricket::DataChannel* ChannelTest<DataTraits>::CreateChannel(
2626 rtc::Thread* thread, 3223 rtc::Thread* worker_thread,
3224 rtc::Thread* network_thread,
2627 cricket::MediaEngineInterface* engine, 3225 cricket::MediaEngineInterface* engine,
2628 cricket::FakeDataMediaChannel* ch, 3226 cricket::FakeDataMediaChannel* ch,
2629 cricket::TransportController* transport_controller, 3227 cricket::TransportController* transport_controller,
2630 bool rtcp) { 3228 bool rtcp) {
2631 cricket::DataChannel* channel = new cricket::DataChannel( 3229 cricket::DataChannel* channel =
2632 thread, ch, transport_controller, cricket::CN_DATA, rtcp); 3230 new cricket::DataChannel(worker_thread, network_thread, ch,
2633 if (!channel->Init()) { 3231 transport_controller, cricket::CN_DATA, rtcp);
3232 if (!channel->Init_w()) {
2634 delete channel; 3233 delete channel;
2635 channel = NULL; 3234 channel = NULL;
2636 } 3235 }
2637 return channel; 3236 return channel;
2638 } 3237 }
2639 3238
2640 template<> 3239 template <>
2641 void ChannelTest<DataTraits>::CreateContent( 3240 void ChannelTest<DataTraits>::CreateContent(
2642 int flags, 3241 int flags,
2643 const cricket::AudioCodec& audio_codec, 3242 const cricket::AudioCodec& audio_codec,
2644 const cricket::VideoCodec& video_codec, 3243 const cricket::VideoCodec& video_codec,
2645 cricket::DataContentDescription* data) { 3244 cricket::DataContentDescription* data) {
2646 data->AddCodec(kGoogleDataCodec); 3245 data->AddCodec(kGoogleDataCodec);
2647 data->set_rtcp_mux((flags & RTCP_MUX) != 0); 3246 data->set_rtcp_mux((flags & RTCP_MUX) != 0);
2648 if (flags & SECURE) { 3247 if (flags & SECURE) {
2649 data->AddCrypto(cricket::CryptoParams( 3248 data->AddCrypto(cricket::CryptoParams(
2650 1, rtc::CS_AES_CM_128_HMAC_SHA1_32, 3249 1, rtc::CS_AES_CM_128_HMAC_SHA1_32,
2651 "inline:" + rtc::CreateRandomString(40), std::string())); 3250 "inline:" + rtc::CreateRandomString(40), std::string()));
2652 } 3251 }
2653 } 3252 }
2654 3253
2655 template<> 3254 template <>
2656 void ChannelTest<DataTraits>::CopyContent( 3255 void ChannelTest<DataTraits>::CopyContent(
2657 const cricket::DataContentDescription& source, 3256 const cricket::DataContentDescription& source,
2658 cricket::DataContentDescription* data) { 3257 cricket::DataContentDescription* data) {
2659 *data = source; 3258 *data = source;
2660 } 3259 }
2661 3260
2662 template<> 3261 template <>
2663 bool ChannelTest<DataTraits>::CodecMatches(const cricket::DataCodec& c1, 3262 bool ChannelTest<DataTraits>::CodecMatches(const cricket::DataCodec& c1,
2664 const cricket::DataCodec& c2) { 3263 const cricket::DataCodec& c2) {
2665 return c1.name == c2.name; 3264 return c1.name == c2.name;
2666 } 3265 }
2667 3266
2668 template <> 3267 template <>
2669 void ChannelTest<DataTraits>::AddLegacyStreamInContent( 3268 void ChannelTest<DataTraits>::AddLegacyStreamInContent(
2670 uint32_t ssrc, 3269 uint32_t ssrc,
2671 int flags, 3270 int flags,
2672 cricket::DataContentDescription* data) { 3271 cricket::DataContentDescription* data) {
2673 data->AddLegacyStream(ssrc); 3272 data->AddLegacyStream(ssrc);
2674 } 3273 }
2675 3274
2676 TEST_F(DataChannelTest, TestInit) { 3275 TEST_F(DataChannelSingleThreadTest, TestInit) {
2677 Base::TestInit(); 3276 Base::TestInit();
2678 EXPECT_FALSE(media_channel1_->IsStreamMuted(0)); 3277 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
2679 } 3278 }
2680 3279
2681 TEST_F(DataChannelTest, TestSetContents) { 3280 TEST_F(DataChannelSingleThreadTest, TestSetContents) {
2682 Base::TestSetContents(); 3281 Base::TestSetContents();
2683 } 3282 }
2684 3283
2685 TEST_F(DataChannelTest, TestSetContentsNullOffer) { 3284 TEST_F(DataChannelSingleThreadTest, TestSetContentsNullOffer) {
2686 Base::TestSetContentsNullOffer(); 3285 Base::TestSetContentsNullOffer();
2687 } 3286 }
2688 3287
2689 TEST_F(DataChannelTest, TestSetContentsRtcpMux) { 3288 TEST_F(DataChannelSingleThreadTest, TestSetContentsRtcpMux) {
2690 Base::TestSetContentsRtcpMux(); 3289 Base::TestSetContentsRtcpMux();
2691 } 3290 }
2692 3291
2693 TEST_F(DataChannelTest, TestSetRemoteContentUpdate) { 3292 TEST_F(DataChannelSingleThreadTest, TestSetRemoteContentUpdate) {
2694 Base::TestSetRemoteContentUpdate(); 3293 Base::TestSetRemoteContentUpdate();
2695 } 3294 }
2696 3295
2697 TEST_F(DataChannelTest, TestStreams) { 3296 TEST_F(DataChannelSingleThreadTest, TestStreams) {
2698 Base::TestStreams(); 3297 Base::TestStreams();
2699 } 3298 }
2700 3299
2701 TEST_F(DataChannelTest, TestUpdateStreamsInLocalContent) { 3300 TEST_F(DataChannelSingleThreadTest, TestUpdateStreamsInLocalContent) {
2702 Base::TestUpdateStreamsInLocalContent(); 3301 Base::TestUpdateStreamsInLocalContent();
2703 } 3302 }
2704 3303
2705 TEST_F(DataChannelTest, TestUpdateRemoteStreamsInContent) { 3304 TEST_F(DataChannelSingleThreadTest, TestUpdateRemoteStreamsInContent) {
2706 Base::TestUpdateStreamsInRemoteContent(); 3305 Base::TestUpdateStreamsInRemoteContent();
2707 } 3306 }
2708 3307
2709 TEST_F(DataChannelTest, TestChangeStreamParamsInContent) { 3308 TEST_F(DataChannelSingleThreadTest, TestChangeStreamParamsInContent) {
2710 Base::TestChangeStreamParamsInContent(); 3309 Base::TestChangeStreamParamsInContent();
2711 } 3310 }
2712 3311
2713 TEST_F(DataChannelTest, TestPlayoutAndSendingStates) { 3312 TEST_F(DataChannelSingleThreadTest, TestPlayoutAndSendingStates) {
2714 Base::TestPlayoutAndSendingStates(); 3313 Base::TestPlayoutAndSendingStates();
2715 } 3314 }
2716 3315
2717 TEST_F(DataChannelTest, TestMediaContentDirection) { 3316 TEST_F(DataChannelSingleThreadTest, TestMediaContentDirection) {
2718 Base::TestMediaContentDirection(); 3317 Base::TestMediaContentDirection();
2719 } 3318 }
2720 3319
2721 TEST_F(DataChannelTest, TestCallSetup) { 3320 TEST_F(DataChannelSingleThreadTest, TestCallSetup) {
2722 Base::TestCallSetup(); 3321 Base::TestCallSetup();
2723 } 3322 }
2724 3323
2725 TEST_F(DataChannelTest, TestCallTeardownRtcpMux) { 3324 TEST_F(DataChannelSingleThreadTest, TestCallTeardownRtcpMux) {
2726 Base::TestCallTeardownRtcpMux(); 3325 Base::TestCallTeardownRtcpMux();
2727 } 3326 }
2728 3327
2729 TEST_F(DataChannelTest, TestOnReadyToSend) { 3328 TEST_F(DataChannelSingleThreadTest, TestOnReadyToSend) {
2730 Base::TestOnReadyToSend(); 3329 Base::TestOnReadyToSend();
2731 } 3330 }
2732 3331
2733 TEST_F(DataChannelTest, TestOnReadyToSendWithRtcpMux) { 3332 TEST_F(DataChannelSingleThreadTest, TestOnReadyToSendWithRtcpMux) {
2734 Base::TestOnReadyToSendWithRtcpMux(); 3333 Base::TestOnReadyToSendWithRtcpMux();
2735 } 3334 }
2736 3335
2737 TEST_F(DataChannelTest, SendRtpToRtp) { 3336 TEST_F(DataChannelSingleThreadTest, SendRtpToRtp) {
2738 Base::SendRtpToRtp(); 3337 Base::SendRtpToRtp();
2739 } 3338 }
2740 3339
2741 TEST_F(DataChannelTest, SendNoRtcpToNoRtcp) { 3340 TEST_F(DataChannelSingleThreadTest, SendNoRtcpToNoRtcp) {
2742 Base::SendNoRtcpToNoRtcp(); 3341 Base::SendNoRtcpToNoRtcp();
2743 } 3342 }
2744 3343
2745 TEST_F(DataChannelTest, SendNoRtcpToRtcp) { 3344 TEST_F(DataChannelSingleThreadTest, SendNoRtcpToRtcp) {
2746 Base::SendNoRtcpToRtcp(); 3345 Base::SendNoRtcpToRtcp();
2747 } 3346 }
2748 3347
2749 TEST_F(DataChannelTest, SendRtcpToNoRtcp) { 3348 TEST_F(DataChannelSingleThreadTest, SendRtcpToNoRtcp) {
2750 Base::SendRtcpToNoRtcp(); 3349 Base::SendRtcpToNoRtcp();
2751 } 3350 }
2752 3351
2753 TEST_F(DataChannelTest, SendRtcpToRtcp) { 3352 TEST_F(DataChannelSingleThreadTest, SendRtcpToRtcp) {
2754 Base::SendRtcpToRtcp(); 3353 Base::SendRtcpToRtcp();
2755 } 3354 }
2756 3355
2757 TEST_F(DataChannelTest, SendRtcpMuxToRtcp) { 3356 TEST_F(DataChannelSingleThreadTest, SendRtcpMuxToRtcp) {
2758 Base::SendRtcpMuxToRtcp(); 3357 Base::SendRtcpMuxToRtcp();
2759 } 3358 }
2760 3359
2761 TEST_F(DataChannelTest, SendRtcpMuxToRtcpMux) { 3360 TEST_F(DataChannelSingleThreadTest, SendRtcpMuxToRtcpMux) {
2762 Base::SendRtcpMuxToRtcpMux(); 3361 Base::SendRtcpMuxToRtcpMux();
2763 } 3362 }
2764 3363
2765 TEST_F(DataChannelTest, SendEarlyRtcpMuxToRtcp) { 3364 TEST_F(DataChannelSingleThreadTest, SendEarlyRtcpMuxToRtcp) {
2766 Base::SendEarlyRtcpMuxToRtcp(); 3365 Base::SendEarlyRtcpMuxToRtcp();
2767 } 3366 }
2768 3367
2769 TEST_F(DataChannelTest, SendEarlyRtcpMuxToRtcpMux) { 3368 TEST_F(DataChannelSingleThreadTest, SendEarlyRtcpMuxToRtcpMux) {
2770 Base::SendEarlyRtcpMuxToRtcpMux(); 3369 Base::SendEarlyRtcpMuxToRtcpMux();
2771 } 3370 }
2772 3371
2773 TEST_F(DataChannelTest, SendSrtpToSrtp) { 3372 TEST_F(DataChannelSingleThreadTest, SendSrtpToSrtp) {
2774 Base::SendSrtpToSrtp(); 3373 Base::SendSrtpToSrtp();
2775 } 3374 }
2776 3375
2777 TEST_F(DataChannelTest, SendSrtpToRtp) { 3376 TEST_F(DataChannelSingleThreadTest, SendSrtpToRtp) {
2778 Base::SendSrtpToSrtp(); 3377 Base::SendSrtpToSrtp();
2779 } 3378 }
2780 3379
2781 TEST_F(DataChannelTest, SendSrtcpMux) { 3380 TEST_F(DataChannelSingleThreadTest, SendSrtcpMux) {
2782 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX); 3381 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX);
2783 } 3382 }
2784 3383
2785 TEST_F(DataChannelTest, SendRtpToRtpOnThread) { 3384 TEST_F(DataChannelSingleThreadTest, SendRtpToRtpOnThread) {
2786 Base::SendRtpToRtpOnThread(); 3385 Base::SendRtpToRtpOnThread();
2787 } 3386 }
2788 3387
2789 TEST_F(DataChannelTest, SendSrtpToSrtpOnThread) { 3388 TEST_F(DataChannelSingleThreadTest, SendSrtpToSrtpOnThread) {
2790 Base::SendSrtpToSrtpOnThread(); 3389 Base::SendSrtpToSrtpOnThread();
2791 } 3390 }
2792 3391
2793 TEST_F(DataChannelTest, SendWithWritabilityLoss) { 3392 TEST_F(DataChannelSingleThreadTest, SendWithWritabilityLoss) {
2794 Base::SendWithWritabilityLoss(); 3393 Base::SendWithWritabilityLoss();
2795 } 3394 }
2796 3395
2797 TEST_F(DataChannelTest, TestMediaMonitor) { 3396 TEST_F(DataChannelSingleThreadTest, TestMediaMonitor) {
2798 Base::TestMediaMonitor(); 3397 Base::TestMediaMonitor();
2799 } 3398 }
2800 3399
2801 TEST_F(DataChannelTest, TestSendData) { 3400 TEST_F(DataChannelSingleThreadTest, TestSendData) {
2802 CreateChannels(0, 0); 3401 CreateChannels(0, 0);
2803 EXPECT_TRUE(SendInitiate()); 3402 EXPECT_TRUE(SendInitiate());
2804 EXPECT_TRUE(SendAccept()); 3403 EXPECT_TRUE(SendAccept());
3404
3405 cricket::SendDataParams params;
3406 params.ssrc = 42;
3407 unsigned char data[] = {'f', 'o', 'o'};
3408 rtc::CopyOnWriteBuffer payload(data, 3);
3409 cricket::SendDataResult result;
3410 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result));
3411 EXPECT_EQ(params.ssrc, media_channel1_->last_sent_data_params().ssrc);
3412 EXPECT_EQ("foo", media_channel1_->last_sent_data());
3413 }
3414
3415 TEST_F(DataChannelDoubleThreadTest, TestInit) {
3416 Base::TestInit();
3417 EXPECT_FALSE(media_channel1_->IsStreamMuted(0));
3418 }
3419
3420 TEST_F(DataChannelDoubleThreadTest, TestSetContents) {
3421 Base::TestSetContents();
3422 }
3423
3424 TEST_F(DataChannelDoubleThreadTest, TestSetContentsNullOffer) {
3425 Base::TestSetContentsNullOffer();
3426 }
3427
3428 TEST_F(DataChannelDoubleThreadTest, TestSetContentsRtcpMux) {
3429 Base::TestSetContentsRtcpMux();
3430 }
3431
3432 TEST_F(DataChannelDoubleThreadTest, TestSetRemoteContentUpdate) {
3433 Base::TestSetRemoteContentUpdate();
3434 }
3435
3436 TEST_F(DataChannelDoubleThreadTest, TestStreams) {
3437 Base::TestStreams();
3438 }
3439
3440 TEST_F(DataChannelDoubleThreadTest, TestUpdateStreamsInLocalContent) {
3441 Base::TestUpdateStreamsInLocalContent();
3442 }
3443
3444 TEST_F(DataChannelDoubleThreadTest, TestUpdateRemoteStreamsInContent) {
3445 Base::TestUpdateStreamsInRemoteContent();
3446 }
3447
3448 TEST_F(DataChannelDoubleThreadTest, TestChangeStreamParamsInContent) {
3449 Base::TestChangeStreamParamsInContent();
3450 }
3451
3452 TEST_F(DataChannelDoubleThreadTest, TestPlayoutAndSendingStates) {
3453 Base::TestPlayoutAndSendingStates();
3454 }
3455
3456 TEST_F(DataChannelDoubleThreadTest, TestMediaContentDirection) {
3457 Base::TestMediaContentDirection();
3458 }
3459
3460 TEST_F(DataChannelDoubleThreadTest, TestCallSetup) {
3461 Base::TestCallSetup();
3462 }
3463
3464 TEST_F(DataChannelDoubleThreadTest, TestCallTeardownRtcpMux) {
3465 Base::TestCallTeardownRtcpMux();
3466 }
3467
3468 TEST_F(DataChannelDoubleThreadTest, TestOnReadyToSend) {
3469 Base::TestOnReadyToSend();
3470 }
3471
3472 TEST_F(DataChannelDoubleThreadTest, TestOnReadyToSendWithRtcpMux) {
3473 Base::TestOnReadyToSendWithRtcpMux();
3474 }
3475
3476 TEST_F(DataChannelDoubleThreadTest, SendRtpToRtp) {
3477 Base::SendRtpToRtp();
3478 }
3479
3480 TEST_F(DataChannelDoubleThreadTest, SendNoRtcpToNoRtcp) {
3481 Base::SendNoRtcpToNoRtcp();
3482 }
3483
3484 TEST_F(DataChannelDoubleThreadTest, SendNoRtcpToRtcp) {
3485 Base::SendNoRtcpToRtcp();
3486 }
3487
3488 TEST_F(DataChannelDoubleThreadTest, SendRtcpToNoRtcp) {
3489 Base::SendRtcpToNoRtcp();
3490 }
3491
3492 TEST_F(DataChannelDoubleThreadTest, SendRtcpToRtcp) {
3493 Base::SendRtcpToRtcp();
3494 }
3495
3496 TEST_F(DataChannelDoubleThreadTest, SendRtcpMuxToRtcp) {
3497 Base::SendRtcpMuxToRtcp();
3498 }
3499
3500 TEST_F(DataChannelDoubleThreadTest, SendRtcpMuxToRtcpMux) {
3501 Base::SendRtcpMuxToRtcpMux();
3502 }
3503
3504 TEST_F(DataChannelDoubleThreadTest, SendEarlyRtcpMuxToRtcp) {
3505 Base::SendEarlyRtcpMuxToRtcp();
3506 }
3507
3508 TEST_F(DataChannelDoubleThreadTest, SendEarlyRtcpMuxToRtcpMux) {
3509 Base::SendEarlyRtcpMuxToRtcpMux();
3510 }
3511
3512 TEST_F(DataChannelDoubleThreadTest, SendSrtpToSrtp) {
3513 Base::SendSrtpToSrtp();
3514 }
3515
3516 TEST_F(DataChannelDoubleThreadTest, SendSrtpToRtp) {
3517 Base::SendSrtpToSrtp();
3518 }
3519
3520 TEST_F(DataChannelDoubleThreadTest, SendSrtcpMux) {
3521 Base::SendSrtpToSrtp(RTCP_MUX, RTCP_MUX);
3522 }
3523
3524 TEST_F(DataChannelDoubleThreadTest, SendRtpToRtpOnThread) {
3525 Base::SendRtpToRtpOnThread();
3526 }
3527
3528 TEST_F(DataChannelDoubleThreadTest, SendSrtpToSrtpOnThread) {
3529 Base::SendSrtpToSrtpOnThread();
3530 }
3531
3532 TEST_F(DataChannelDoubleThreadTest, SendWithWritabilityLoss) {
3533 Base::SendWithWritabilityLoss();
3534 }
3535
3536 TEST_F(DataChannelDoubleThreadTest, TestMediaMonitor) {
3537 Base::TestMediaMonitor();
3538 }
3539
3540 TEST_F(DataChannelDoubleThreadTest, TestSendData) {
3541 CreateChannels(0, 0);
3542 EXPECT_TRUE(SendInitiate());
3543 EXPECT_TRUE(SendAccept());
2805 3544
2806 cricket::SendDataParams params; 3545 cricket::SendDataParams params;
2807 params.ssrc = 42; 3546 params.ssrc = 42;
2808 unsigned char data[] = { 3547 unsigned char data[] = {
2809 'f', 'o', 'o' 3548 'f', 'o', 'o'
2810 }; 3549 };
2811 rtc::CopyOnWriteBuffer payload(data, 3); 3550 rtc::CopyOnWriteBuffer payload(data, 3);
2812 cricket::SendDataResult result; 3551 cricket::SendDataResult result;
2813 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); 3552 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result));
2814 EXPECT_EQ(params.ssrc, 3553 EXPECT_EQ(params.ssrc,
2815 media_channel1_->last_sent_data_params().ssrc); 3554 media_channel1_->last_sent_data_params().ssrc);
2816 EXPECT_EQ("foo", media_channel1_->last_sent_data()); 3555 EXPECT_EQ("foo", media_channel1_->last_sent_data());
2817 } 3556 }
2818 3557
2819 // TODO(pthatcher): TestSetReceiver? 3558 // TODO(pthatcher): TestSetReceiver?
OLDNEW
« no previous file with comments | « webrtc/pc/channel.cc ('k') | webrtc/pc/channelmanager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698