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 |
| 11 #include <algorithm> |
11 #include <memory> | 12 #include <memory> |
12 #include <sstream> | 13 #include <sstream> |
13 #include <string> | 14 #include <string> |
14 #include <utility> | 15 #include <utility> |
15 | 16 |
16 #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" | 17 #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" |
17 #include "webrtc/api/audio_codecs/builtin_audio_encoder_factory.h" | 18 #include "webrtc/api/audio_codecs/builtin_audio_encoder_factory.h" |
18 #include "webrtc/api/jsepsessiondescription.h" | 19 #include "webrtc/api/jsepsessiondescription.h" |
19 #include "webrtc/api/mediastreaminterface.h" | 20 #include "webrtc/api/mediastreaminterface.h" |
20 #include "webrtc/api/peerconnectioninterface.h" | 21 #include "webrtc/api/peerconnectioninterface.h" |
(...skipping 3803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3824 CreatePeerConnection(); | 3825 CreatePeerConnection(); |
3825 // Creating answer fails because the remote description is unset. | 3826 // Creating answer fails because the remote description is unset. |
3826 std::unique_ptr<SessionDescriptionInterface> answer; | 3827 std::unique_ptr<SessionDescriptionInterface> answer; |
3827 EXPECT_FALSE(DoCreateAnswer(&answer, nullptr)); | 3828 EXPECT_FALSE(DoCreateAnswer(&answer, nullptr)); |
3828 | 3829 |
3829 // Createing answer succeeds when the remote description is set. | 3830 // Createing answer succeeds when the remote description is set. |
3830 CreateOfferAsRemoteDescription(); | 3831 CreateOfferAsRemoteDescription(); |
3831 EXPECT_TRUE(DoCreateAnswer(&answer, nullptr)); | 3832 EXPECT_TRUE(DoCreateAnswer(&answer, nullptr)); |
3832 } | 3833 } |
3833 | 3834 |
| 3835 // Test that an error is returned if a description is applied that doesn't |
| 3836 // respect the order of existing media sections. |
| 3837 TEST_F(PeerConnectionInterfaceTest, |
| 3838 MediaSectionOrderEnforcedForSubsequentOffers) { |
| 3839 CreatePeerConnection(); |
| 3840 FakeConstraints constraints; |
| 3841 constraints.SetMandatoryReceiveAudio(true); |
| 3842 constraints.SetMandatoryReceiveVideo(true); |
| 3843 std::unique_ptr<SessionDescriptionInterface> offer; |
| 3844 ASSERT_TRUE(DoCreateOffer(&offer, &constraints)); |
| 3845 EXPECT_TRUE(DoSetRemoteDescription(std::move(offer))); |
| 3846 |
| 3847 std::unique_ptr<SessionDescriptionInterface> answer; |
| 3848 ASSERT_TRUE(DoCreateAnswer(&answer, nullptr)); |
| 3849 EXPECT_TRUE(DoSetLocalDescription(std::move(answer))); |
| 3850 |
| 3851 // A remote offer with different m=line order should be rejected. |
| 3852 ASSERT_TRUE(DoCreateOffer(&offer, &constraints)); |
| 3853 std::reverse(offer->description()->contents().begin(), |
| 3854 offer->description()->contents().end()); |
| 3855 std::reverse(offer->description()->transport_infos().begin(), |
| 3856 offer->description()->transport_infos().end()); |
| 3857 EXPECT_FALSE(DoSetRemoteDescription(std::move(offer))); |
| 3858 |
| 3859 // A subsequent local offer with different m=line order should be rejected. |
| 3860 ASSERT_TRUE(DoCreateOffer(&offer, &constraints)); |
| 3861 std::reverse(offer->description()->contents().begin(), |
| 3862 offer->description()->contents().end()); |
| 3863 std::reverse(offer->description()->transport_infos().begin(), |
| 3864 offer->description()->transport_infos().end()); |
| 3865 EXPECT_FALSE(DoSetLocalDescription(std::move(offer))); |
| 3866 } |
| 3867 |
3834 class PeerConnectionMediaConfigTest : public testing::Test { | 3868 class PeerConnectionMediaConfigTest : public testing::Test { |
3835 protected: | 3869 protected: |
3836 void SetUp() override { | 3870 void SetUp() override { |
3837 pcf_ = PeerConnectionFactoryForTest::CreatePeerConnectionFactoryForTest(); | 3871 pcf_ = PeerConnectionFactoryForTest::CreatePeerConnectionFactoryForTest(); |
3838 pcf_->Initialize(); | 3872 pcf_->Initialize(); |
3839 } | 3873 } |
3840 const cricket::MediaConfig TestCreatePeerConnection( | 3874 const cricket::MediaConfig TestCreatePeerConnection( |
3841 const PeerConnectionInterface::RTCConfiguration& config, | 3875 const PeerConnectionInterface::RTCConfiguration& config, |
3842 const MediaConstraintsInterface* constraints) { | 3876 const MediaConstraintsInterface* constraints) { |
3843 rtc::scoped_refptr<PeerConnectionInterface> pc(pcf_->CreatePeerConnection( | 3877 rtc::scoped_refptr<PeerConnectionInterface> pc(pcf_->CreatePeerConnection( |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3944 EXPECT_NE(a, f); | 3978 EXPECT_NE(a, f); |
3945 | 3979 |
3946 PeerConnectionInterface::RTCConfiguration g; | 3980 PeerConnectionInterface::RTCConfiguration g; |
3947 g.disable_ipv6 = true; | 3981 g.disable_ipv6 = true; |
3948 EXPECT_NE(a, g); | 3982 EXPECT_NE(a, g); |
3949 | 3983 |
3950 PeerConnectionInterface::RTCConfiguration h( | 3984 PeerConnectionInterface::RTCConfiguration h( |
3951 PeerConnectionInterface::RTCConfigurationType::kAggressive); | 3985 PeerConnectionInterface::RTCConfigurationType::kAggressive); |
3952 EXPECT_NE(a, h); | 3986 EXPECT_NE(a, h); |
3953 } | 3987 } |
OLD | NEW |