OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 rtc::PacketTransportInternal* rtcp_transport_channel( | 302 rtc::PacketTransportInternal* rtcp_transport_channel( |
303 cricket::BaseChannel* ch) { | 303 cricket::BaseChannel* ch) { |
304 if (!ch) { | 304 if (!ch) { |
305 return nullptr; | 305 return nullptr; |
306 } | 306 } |
307 return ch->rtcp_dtls_transport(); | 307 return ch->rtcp_dtls_transport(); |
308 } | 308 } |
309 }; | 309 }; |
310 | 310 |
311 class WebRtcSessionCreateSDPObserverForTest | 311 class WebRtcSessionCreateSDPObserverForTest |
312 : public rtc::RefCountedObject<CreateSessionDescriptionObserver> { | 312 : public CreateSessionDescriptionObserver { |
313 public: | 313 public: |
314 enum State { | 314 enum State { |
315 kInit, | 315 kInit, |
316 kFailed, | 316 kFailed, |
317 kSucceeded, | 317 kSucceeded, |
318 }; | 318 }; |
319 WebRtcSessionCreateSDPObserverForTest() : state_(kInit) {} | 319 WebRtcSessionCreateSDPObserverForTest() : state_(kInit) {} |
320 | 320 |
321 // CreateSessionDescriptionObserver implementation. | 321 // CreateSessionDescriptionObserver implementation. |
322 virtual void OnSuccess(SessionDescriptionInterface* desc) { | 322 virtual void OnSuccess(SessionDescriptionInterface* desc) { |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 | 781 |
782 SessionDescriptionInterface* CreateOffer() { | 782 SessionDescriptionInterface* CreateOffer() { |
783 PeerConnectionInterface::RTCOfferAnswerOptions options; | 783 PeerConnectionInterface::RTCOfferAnswerOptions options; |
784 options.offer_to_receive_audio = | 784 options.offer_to_receive_audio = |
785 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; | 785 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; |
786 return CreateOffer(options); | 786 return CreateOffer(options); |
787 } | 787 } |
788 | 788 |
789 SessionDescriptionInterface* CreateOffer( | 789 SessionDescriptionInterface* CreateOffer( |
790 const PeerConnectionInterface::RTCOfferAnswerOptions options) { | 790 const PeerConnectionInterface::RTCOfferAnswerOptions options) { |
791 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> | 791 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> observer = |
792 observer = new WebRtcSessionCreateSDPObserverForTest(); | 792 new rtc::RefCountedObject<WebRtcSessionCreateSDPObserverForTest>(); |
793 cricket::MediaSessionOptions session_options; | 793 cricket::MediaSessionOptions session_options; |
794 GetOptionsForOffer(options, &session_options); | 794 GetOptionsForOffer(options, &session_options); |
795 session_->CreateOffer(observer, options, session_options); | 795 session_->CreateOffer(observer, options, session_options); |
796 EXPECT_TRUE_WAIT( | 796 EXPECT_TRUE_WAIT( |
797 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit, | 797 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit, |
798 2000); | 798 2000); |
799 return observer->ReleaseDescription(); | 799 return observer->ReleaseDescription(); |
800 } | 800 } |
801 | 801 |
802 SessionDescriptionInterface* CreateAnswer( | 802 SessionDescriptionInterface* CreateAnswer( |
803 const cricket::MediaSessionOptions& options) { | 803 const cricket::MediaSessionOptions& options) { |
804 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> observer | 804 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> observer = |
805 = new WebRtcSessionCreateSDPObserverForTest(); | 805 new rtc::RefCountedObject<WebRtcSessionCreateSDPObserverForTest>(); |
806 cricket::MediaSessionOptions session_options = options; | 806 cricket::MediaSessionOptions session_options = options; |
807 GetOptionsForAnswer(&session_options); | 807 GetOptionsForAnswer(&session_options); |
808 session_->CreateAnswer(observer, session_options); | 808 session_->CreateAnswer(observer, session_options); |
809 EXPECT_TRUE_WAIT( | 809 EXPECT_TRUE_WAIT( |
810 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit, | 810 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit, |
811 2000); | 811 2000); |
812 return observer->ReleaseDescription(); | 812 return observer->ReleaseDescription(); |
813 } | 813 } |
814 | 814 |
815 SessionDescriptionInterface* CreateAnswer() { | 815 SessionDescriptionInterface* CreateAnswer() { |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1613 | 1613 |
1614 PeerConnectionInterface::RTCOfferAnswerOptions options; | 1614 PeerConnectionInterface::RTCOfferAnswerOptions options; |
1615 cricket::MediaSessionOptions offer_session_options; | 1615 cricket::MediaSessionOptions offer_session_options; |
1616 cricket::MediaSessionOptions answer_session_options; | 1616 cricket::MediaSessionOptions answer_session_options; |
1617 GetOptionsForOffer(options, &offer_session_options); | 1617 GetOptionsForOffer(options, &offer_session_options); |
1618 GetOptionsForAnswer(&answer_session_options); | 1618 GetOptionsForAnswer(&answer_session_options); |
1619 const int kNumber = 3; | 1619 const int kNumber = 3; |
1620 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> | 1620 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> |
1621 observers[kNumber]; | 1621 observers[kNumber]; |
1622 for (int i = 0; i < kNumber; ++i) { | 1622 for (int i = 0; i < kNumber; ++i) { |
1623 observers[i] = new WebRtcSessionCreateSDPObserverForTest(); | 1623 observers[i] = |
| 1624 new rtc::RefCountedObject<WebRtcSessionCreateSDPObserverForTest>(); |
1624 if (type == CreateSessionDescriptionRequest::kOffer) { | 1625 if (type == CreateSessionDescriptionRequest::kOffer) { |
1625 session_->CreateOffer(observers[i], options, offer_session_options); | 1626 session_->CreateOffer(observers[i], options, offer_session_options); |
1626 } else { | 1627 } else { |
1627 session_->CreateAnswer(observers[i], answer_session_options); | 1628 session_->CreateAnswer(observers[i], answer_session_options); |
1628 } | 1629 } |
1629 } | 1630 } |
1630 | 1631 |
1631 WebRtcSessionCreateSDPObserverForTest::State expected_state = | 1632 WebRtcSessionCreateSDPObserverForTest::State expected_state = |
1632 success ? WebRtcSessionCreateSDPObserverForTest::kSucceeded : | 1633 success ? WebRtcSessionCreateSDPObserverForTest::kSucceeded : |
1633 WebRtcSessionCreateSDPObserverForTest::kFailed; | 1634 WebRtcSessionCreateSDPObserverForTest::kFailed; |
(...skipping 2905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4539 TEST_F(WebRtcSessionTest, CreateOffersAndShutdown) { | 4540 TEST_F(WebRtcSessionTest, CreateOffersAndShutdown) { |
4540 Init(); | 4541 Init(); |
4541 | 4542 |
4542 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> observers[100]; | 4543 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> observers[100]; |
4543 PeerConnectionInterface::RTCOfferAnswerOptions options; | 4544 PeerConnectionInterface::RTCOfferAnswerOptions options; |
4544 options.offer_to_receive_audio = | 4545 options.offer_to_receive_audio = |
4545 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; | 4546 RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; |
4546 cricket::MediaSessionOptions session_options; | 4547 cricket::MediaSessionOptions session_options; |
4547 GetOptionsForOffer(options, &session_options); | 4548 GetOptionsForOffer(options, &session_options); |
4548 for (auto& o : observers) { | 4549 for (auto& o : observers) { |
4549 o = new WebRtcSessionCreateSDPObserverForTest(); | 4550 o = new rtc::RefCountedObject<WebRtcSessionCreateSDPObserverForTest>(); |
4550 session_->CreateOffer(o, options, session_options); | 4551 session_->CreateOffer(o, options, session_options); |
4551 } | 4552 } |
4552 | 4553 |
4553 session_.reset(); | 4554 session_.reset(); |
4554 | 4555 |
4555 for (auto& o : observers) { | 4556 for (auto& o : observers) { |
4556 // We expect to have received a notification now even if the session was | 4557 // We expect to have received a notification now even if the session was |
4557 // terminated. The offer creation may or may not have succeeded, but we | 4558 // terminated. The offer creation may or may not have succeeded, but we |
4558 // must have received a notification which, so the only invalid state | 4559 // must have received a notification which, so the only invalid state |
4559 // is kInit. | 4560 // is kInit. |
4560 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state()); | 4561 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state()); |
4561 } | 4562 } |
4562 } | 4563 } |
4563 | 4564 |
4564 TEST_F(WebRtcSessionTest, TestPacketOptionsAndOnPacketSent) { | 4565 TEST_F(WebRtcSessionTest, TestPacketOptionsAndOnPacketSent) { |
4565 TestPacketOptions(); | 4566 TestPacketOptions(); |
4566 } | 4567 } |
4567 | 4568 |
4568 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 4569 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
4569 // currently fails because upon disconnection and reconnection OnIceComplete is | 4570 // currently fails because upon disconnection and reconnection OnIceComplete is |
4570 // called more than once without returning to IceGatheringGathering. | 4571 // called more than once without returning to IceGatheringGathering. |
4571 | 4572 |
4572 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, | 4573 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, |
4573 WebRtcSessionTest, | 4574 WebRtcSessionTest, |
4574 testing::Values(ALREADY_GENERATED, | 4575 testing::Values(ALREADY_GENERATED, |
4575 DTLS_IDENTITY_STORE)); | 4576 DTLS_IDENTITY_STORE)); |
OLD | NEW |