OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2009 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2009 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... | |
22 #include "webrtc/media/base/fakertp.h" | 22 #include "webrtc/media/base/fakertp.h" |
23 #include "webrtc/media/base/fakescreencapturerfactory.h" | 23 #include "webrtc/media/base/fakescreencapturerfactory.h" |
24 #include "webrtc/media/base/fakevideocapturer.h" | 24 #include "webrtc/media/base/fakevideocapturer.h" |
25 #include "webrtc/media/base/mediachannel.h" | 25 #include "webrtc/media/base/mediachannel.h" |
26 #include "webrtc/media/base/rtpdump.h" | 26 #include "webrtc/media/base/rtpdump.h" |
27 #include "webrtc/media/base/screencastid.h" | 27 #include "webrtc/media/base/screencastid.h" |
28 #include "webrtc/media/base/testutils.h" | 28 #include "webrtc/media/base/testutils.h" |
29 #include "webrtc/p2p/base/faketransportcontroller.h" | 29 #include "webrtc/p2p/base/faketransportcontroller.h" |
30 #include "webrtc/pc/channel.h" | 30 #include "webrtc/pc/channel.h" |
31 | 31 |
32 #include <atomic> | |
33 | |
32 #define MAYBE_SKIP_TEST(feature) \ | 34 #define MAYBE_SKIP_TEST(feature) \ |
33 if (!(rtc::SSLStreamAdapter::feature())) { \ | 35 if (!(rtc::SSLStreamAdapter::feature())) { \ |
34 LOG(LS_INFO) << "Feature disabled... skipping"; \ | 36 LOG(LS_INFO) << "Feature disabled... skipping"; \ |
35 return; \ | 37 return; \ |
36 } | 38 } |
37 | 39 |
38 using cricket::CA_OFFER; | 40 using cricket::CA_OFFER; |
39 using cricket::CA_PRANSWER; | 41 using cricket::CA_PRANSWER; |
40 using cricket::CA_ANSWER; | 42 using cricket::CA_ANSWER; |
41 using cricket::CA_UPDATE; | 43 using cricket::CA_UPDATE; |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
401 CreateContent(SECURE, kPcmuCodec, kH264Codec, &content); | 403 CreateContent(SECURE, kPcmuCodec, kH264Codec, &content); |
402 AddLegacyStreamInContent(ssrc, 0, &content); | 404 AddLegacyStreamInContent(ssrc, 0, &content); |
403 sdesc->AddContent("DUMMY_CONTENT_NAME", | 405 sdesc->AddContent("DUMMY_CONTENT_NAME", |
404 cricket::NS_JINGLE_RTP, content.Copy()); | 406 cricket::NS_JINGLE_RTP, content.Copy()); |
405 return sdesc; | 407 return sdesc; |
406 } | 408 } |
407 | 409 |
408 class CallThread : public rtc::SignalThread { | 410 class CallThread : public rtc::SignalThread { |
409 public: | 411 public: |
410 typedef bool (ChannelTest<T>::*Method)(); | 412 typedef bool (ChannelTest<T>::*Method)(); |
411 CallThread(ChannelTest<T>* obj, Method method, bool* result) | 413 CallThread(ChannelTest<T>* obj, Method method, std::atomic<bool>* result) |
412 : obj_(obj), | 414 : obj_(obj), |
413 method_(method), | 415 method_(method), |
414 result_(result) { | 416 result_(result) { |
415 *result = false; | 417 *result = false; |
416 } | 418 } |
417 virtual void DoWork() { | 419 virtual void DoWork() { |
418 bool result = (*obj_.*method_)(); | 420 *result_ = (*obj_.*method_)(); |
ossu
2016/03/01 15:00:38
Since the pointer is always written to in the cons
Taylor Brandstetter
2016/03/01 20:03:42
I think the purpose of the check was so that you c
| |
419 if (result_) { | |
420 *result_ = result; | |
421 } | |
422 } | 421 } |
423 private: | 422 private: |
424 ChannelTest<T>* obj_; | 423 ChannelTest<T>* obj_; |
425 Method method_; | 424 Method method_; |
426 bool* result_; | 425 std::atomic<bool>* result_; |
427 }; | 426 }; |
428 void CallOnThread(typename CallThread::Method method, bool* result) { | 427 void CallOnThread(typename CallThread::Method method, |
428 std::atomic<bool>* result) { | |
429 CallThread* thread = new CallThread(this, method, result); | 429 CallThread* thread = new CallThread(this, method, result); |
430 thread->Start(); | 430 thread->Start(); |
431 thread->Release(); | 431 thread->Release(); |
432 } | 432 } |
433 | 433 |
434 void CallOnThreadAndWaitForDone(typename CallThread::Method method, | 434 void CallOnThreadAndWaitForDone(typename CallThread::Method method, |
435 bool* result) { | 435 std::atomic<bool>* result) { |
436 CallThread* thread = new CallThread(this, method, result); | 436 CallThread* thread = new CallThread(this, method, result); |
437 thread->Start(); | 437 thread->Start(); |
438 thread->Destroy(true); | 438 thread->Destroy(true); |
439 } | 439 } |
440 | 440 |
441 bool CodecMatches(const typename T::Codec& c1, const typename T::Codec& c2) { | 441 bool CodecMatches(const typename T::Codec& c1, const typename T::Codec& c2) { |
442 return false; // overridden in specialized classes | 442 return false; // overridden in specialized classes |
443 } | 443 } |
444 | 444 |
445 void OnMediaMonitor(typename T::Channel* channel, | 445 void OnMediaMonitor(typename T::Channel* channel, |
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1319 EXPECT_TRUE(SendCustomRtp1(kSsrc1, ++sequence_number1_1)); | 1319 EXPECT_TRUE(SendCustomRtp1(kSsrc1, ++sequence_number1_1)); |
1320 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1)); | 1320 EXPECT_TRUE(CheckCustomRtp2(kSsrc1, sequence_number1_1)); |
1321 EXPECT_TRUE(SendCustomRtcp2(kSsrc2)); | 1321 EXPECT_TRUE(SendCustomRtcp2(kSsrc2)); |
1322 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2)); | 1322 EXPECT_TRUE(CheckCustomRtcp1(kSsrc2)); |
1323 EXPECT_TRUE(SendCustomRtp2(kSsrc2, ++sequence_number2_2)); | 1323 EXPECT_TRUE(SendCustomRtp2(kSsrc2, ++sequence_number2_2)); |
1324 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2)); | 1324 EXPECT_TRUE(CheckCustomRtp1(kSsrc2, sequence_number2_2)); |
1325 } | 1325 } |
1326 | 1326 |
1327 // Test that we properly send RTP without SRTP from a thread. | 1327 // Test that we properly send RTP without SRTP from a thread. |
1328 void SendRtpToRtpOnThread() { | 1328 void SendRtpToRtpOnThread() { |
1329 bool sent_rtp1, sent_rtp2, sent_rtcp1, sent_rtcp2; | 1329 std::atomic<bool> sent_rtp1, sent_rtp2, sent_rtcp1, sent_rtcp2; |
1330 CreateChannels(RTCP, RTCP); | 1330 CreateChannels(RTCP, RTCP); |
1331 EXPECT_TRUE(SendInitiate()); | 1331 EXPECT_TRUE(SendInitiate()); |
1332 EXPECT_TRUE(SendAccept()); | 1332 EXPECT_TRUE(SendAccept()); |
1333 CallOnThread(&ChannelTest<T>::SendRtp1, &sent_rtp1); | 1333 CallOnThread(&ChannelTest<T>::SendRtp1, &sent_rtp1); |
1334 CallOnThread(&ChannelTest<T>::SendRtp2, &sent_rtp2); | 1334 CallOnThread(&ChannelTest<T>::SendRtp2, &sent_rtp2); |
1335 CallOnThread(&ChannelTest<T>::SendRtcp1, &sent_rtcp1); | 1335 CallOnThread(&ChannelTest<T>::SendRtcp1, &sent_rtcp1); |
1336 CallOnThread(&ChannelTest<T>::SendRtcp2, &sent_rtcp2); | 1336 CallOnThread(&ChannelTest<T>::SendRtcp2, &sent_rtcp2); |
1337 EXPECT_TRUE_WAIT(CheckRtp1(), 1000); | 1337 EXPECT_TRUE_WAIT(CheckRtp1(), 1000); |
1338 EXPECT_TRUE_WAIT(CheckRtp2(), 1000); | 1338 EXPECT_TRUE_WAIT(CheckRtp2(), 1000); |
1339 EXPECT_TRUE_WAIT(sent_rtp1, 1000); | 1339 EXPECT_TRUE_WAIT(sent_rtp1, 1000); |
1340 EXPECT_TRUE_WAIT(sent_rtp2, 1000); | 1340 EXPECT_TRUE_WAIT(sent_rtp2, 1000); |
1341 EXPECT_TRUE(CheckNoRtp1()); | 1341 EXPECT_TRUE(CheckNoRtp1()); |
1342 EXPECT_TRUE(CheckNoRtp2()); | 1342 EXPECT_TRUE(CheckNoRtp2()); |
1343 EXPECT_TRUE_WAIT(CheckRtcp1(), 1000); | 1343 EXPECT_TRUE_WAIT(CheckRtcp1(), 1000); |
1344 EXPECT_TRUE_WAIT(CheckRtcp2(), 1000); | 1344 EXPECT_TRUE_WAIT(CheckRtcp2(), 1000); |
1345 EXPECT_TRUE_WAIT(sent_rtcp1, 1000); | 1345 EXPECT_TRUE_WAIT(sent_rtcp1, 1000); |
1346 EXPECT_TRUE_WAIT(sent_rtcp2, 1000); | 1346 EXPECT_TRUE_WAIT(sent_rtcp2, 1000); |
1347 EXPECT_TRUE(CheckNoRtcp1()); | 1347 EXPECT_TRUE(CheckNoRtcp1()); |
1348 EXPECT_TRUE(CheckNoRtcp2()); | 1348 EXPECT_TRUE(CheckNoRtcp2()); |
1349 } | 1349 } |
1350 | 1350 |
1351 // Test that we properly send SRTP with RTCP from a thread. | 1351 // Test that we properly send SRTP with RTCP from a thread. |
1352 void SendSrtpToSrtpOnThread() { | 1352 void SendSrtpToSrtpOnThread() { |
1353 bool sent_rtp1, sent_rtp2, sent_rtcp1, sent_rtcp2; | 1353 std::atomic<bool> sent_rtp1, sent_rtp2, sent_rtcp1, sent_rtcp2; |
1354 CreateChannels(RTCP | SECURE, RTCP | SECURE); | 1354 CreateChannels(RTCP | SECURE, RTCP | SECURE); |
1355 EXPECT_TRUE(SendInitiate()); | 1355 EXPECT_TRUE(SendInitiate()); |
1356 EXPECT_TRUE(SendAccept()); | 1356 EXPECT_TRUE(SendAccept()); |
1357 CallOnThread(&ChannelTest<T>::SendRtp1, &sent_rtp1); | 1357 CallOnThread(&ChannelTest<T>::SendRtp1, &sent_rtp1); |
1358 CallOnThread(&ChannelTest<T>::SendRtp2, &sent_rtp2); | 1358 CallOnThread(&ChannelTest<T>::SendRtp2, &sent_rtp2); |
1359 CallOnThread(&ChannelTest<T>::SendRtcp1, &sent_rtcp1); | 1359 CallOnThread(&ChannelTest<T>::SendRtcp1, &sent_rtcp1); |
1360 CallOnThread(&ChannelTest<T>::SendRtcp2, &sent_rtcp2); | 1360 CallOnThread(&ChannelTest<T>::SendRtcp2, &sent_rtcp2); |
1361 EXPECT_TRUE_WAIT(CheckRtp1(), 1000); | 1361 EXPECT_TRUE_WAIT(CheckRtp1(), 1000); |
1362 EXPECT_TRUE_WAIT(CheckRtp2(), 1000); | 1362 EXPECT_TRUE_WAIT(CheckRtp2(), 1000); |
1363 EXPECT_TRUE_WAIT(sent_rtp1, 1000); | 1363 EXPECT_TRUE_WAIT(sent_rtp1, 1000); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1617 rtc::scoped_ptr<cricket::SessionDescription> sdesc3( | 1617 rtc::scoped_ptr<cricket::SessionDescription> sdesc3( |
1618 CreateSessionDescriptionWithStream(3)); | 1618 CreateSessionDescriptionWithStream(3)); |
1619 EXPECT_TRUE(channel1_->PushdownRemoteDescription( | 1619 EXPECT_TRUE(channel1_->PushdownRemoteDescription( |
1620 sdesc3.get(), cricket::CA_ANSWER, &err)); | 1620 sdesc3.get(), cricket::CA_ANSWER, &err)); |
1621 EXPECT_TRUE(media_channel1_->HasSendStream(1)); | 1621 EXPECT_TRUE(media_channel1_->HasSendStream(1)); |
1622 EXPECT_FALSE(media_channel1_->HasRecvStream(2)); | 1622 EXPECT_FALSE(media_channel1_->HasRecvStream(2)); |
1623 EXPECT_TRUE(media_channel1_->HasRecvStream(3)); | 1623 EXPECT_TRUE(media_channel1_->HasRecvStream(3)); |
1624 } | 1624 } |
1625 | 1625 |
1626 void TestFlushRtcp() { | 1626 void TestFlushRtcp() { |
1627 bool send_rtcp1; | 1627 std::atomic<bool> send_rtcp1; |
1628 | 1628 |
1629 CreateChannels(RTCP, RTCP); | 1629 CreateChannels(RTCP, RTCP); |
1630 EXPECT_TRUE(SendInitiate()); | 1630 EXPECT_TRUE(SendInitiate()); |
1631 EXPECT_TRUE(SendAccept()); | 1631 EXPECT_TRUE(SendAccept()); |
1632 ASSERT_TRUE(GetTransport1()); | 1632 ASSERT_TRUE(GetTransport1()); |
1633 ASSERT_TRUE(GetTransport2()); | 1633 ASSERT_TRUE(GetTransport2()); |
1634 EXPECT_EQ(2U, GetTransport1()->channels().size()); | 1634 EXPECT_EQ(2U, GetTransport1()->channels().size()); |
1635 EXPECT_EQ(2U, GetTransport2()->channels().size()); | 1635 EXPECT_EQ(2U, GetTransport2()->channels().size()); |
1636 | 1636 |
1637 // Send RTCP1 from a different thread. | 1637 // Send RTCP1 from a different thread. |
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2690 }; | 2690 }; |
2691 rtc::Buffer payload(data, 3); | 2691 rtc::Buffer payload(data, 3); |
2692 cricket::SendDataResult result; | 2692 cricket::SendDataResult result; |
2693 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); | 2693 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); |
2694 EXPECT_EQ(params.ssrc, | 2694 EXPECT_EQ(params.ssrc, |
2695 media_channel1_->last_sent_data_params().ssrc); | 2695 media_channel1_->last_sent_data_params().ssrc); |
2696 EXPECT_EQ("foo", media_channel1_->last_sent_data()); | 2696 EXPECT_EQ("foo", media_channel1_->last_sent_data()); |
2697 } | 2697 } |
2698 | 2698 |
2699 // TODO(pthatcher): TestSetReceiver? | 2699 // TODO(pthatcher): TestSetReceiver? |
OLD | NEW |