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 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1234 const cricket::AudioContentDescription* audio_content_desc = | 1234 const cricket::AudioContentDescription* audio_content_desc = |
1235 static_cast<const cricket::AudioContentDescription*>(description); | 1235 static_cast<const cricket::AudioContentDescription*>(description); |
1236 RTC_DCHECK(audio_content_desc); | 1236 RTC_DCHECK(audio_content_desc); |
1237 for (size_t i = 0; i < audio_content_desc->codecs().size(); ++i) { | 1237 for (size_t i = 0; i < audio_content_desc->codecs().size(); ++i) { |
1238 if (audio_content_desc->codecs()[i].name == "CN") | 1238 if (audio_content_desc->codecs()[i].name == "CN") |
1239 return true; | 1239 return true; |
1240 } | 1240 } |
1241 return false; | 1241 return false; |
1242 } | 1242 } |
1243 | 1243 |
1244 void ReorderMediaSections(SessionDescriptionInterface* session_description) { | |
Taylor Brandstetter
2017/09/14 00:41:47
nit: This could be simplified by using std::revers
| |
1245 if (!session_description) { | |
1246 return; | |
1247 } | |
1248 auto desc = session_description->description(); | |
1249 RTC_DCHECK(desc); | |
1250 RTC_DCHECK(desc->contents().size() == desc->transport_infos().size()); | |
1251 // Reorder the ContentInfo. | |
1252 if (desc->contents().empty()) { | |
1253 return; | |
1254 } | |
1255 size_t num_msections = desc->contents().size(); | |
1256 auto first_content_info = desc->contents()[0]; | |
1257 for (size_t i = 1; i < num_msections; ++i) { | |
1258 desc->contents()[i - 1] = desc->contents()[i]; | |
1259 } | |
1260 desc->contents()[num_msections - 1] = first_content_info; | |
1261 | |
1262 // Reorder the TransportInfo. | |
1263 if (desc->transport_infos().empty()) { | |
1264 return; | |
1265 } | |
1266 auto first_transport_info = desc->transport_infos()[0]; | |
1267 for (size_t i = 1; i < num_msections; ++i) { | |
1268 desc->transport_infos()[i - 1] = desc->transport_infos()[i]; | |
1269 } | |
1270 desc->transport_infos()[num_msections - 1] = first_transport_info; | |
1271 } | |
1272 | |
1244 std::unique_ptr<rtc::VirtualSocketServer> vss_; | 1273 std::unique_ptr<rtc::VirtualSocketServer> vss_; |
1245 rtc::AutoSocketServerThread main_; | 1274 rtc::AutoSocketServerThread main_; |
1246 rtc::scoped_refptr<FakeAudioCaptureModule> fake_audio_capture_module_; | 1275 rtc::scoped_refptr<FakeAudioCaptureModule> fake_audio_capture_module_; |
1247 cricket::FakePortAllocator* port_allocator_ = nullptr; | 1276 cricket::FakePortAllocator* port_allocator_ = nullptr; |
1248 FakeRTCCertificateGenerator* fake_certificate_generator_ = nullptr; | 1277 FakeRTCCertificateGenerator* fake_certificate_generator_ = nullptr; |
1249 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory_; | 1278 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory_; |
1250 rtc::scoped_refptr<PeerConnectionFactoryForTest> pc_factory_for_test_; | 1279 rtc::scoped_refptr<PeerConnectionFactoryForTest> pc_factory_for_test_; |
1251 rtc::scoped_refptr<PeerConnectionInterface> pc_; | 1280 rtc::scoped_refptr<PeerConnectionInterface> pc_; |
1252 MockPeerConnectionObserver observer_; | 1281 MockPeerConnectionObserver observer_; |
1253 rtc::scoped_refptr<StreamCollection> reference_collection_; | 1282 rtc::scoped_refptr<StreamCollection> reference_collection_; |
(...skipping 2557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3811 CreatePeerConnection(); | 3840 CreatePeerConnection(); |
3812 // Creating answer fails because the remote description is unset. | 3841 // Creating answer fails because the remote description is unset. |
3813 std::unique_ptr<SessionDescriptionInterface> answer; | 3842 std::unique_ptr<SessionDescriptionInterface> answer; |
3814 EXPECT_FALSE(DoCreateAnswer(&answer, nullptr)); | 3843 EXPECT_FALSE(DoCreateAnswer(&answer, nullptr)); |
3815 | 3844 |
3816 // Createing answer succeeds when the remote description is set. | 3845 // Createing answer succeeds when the remote description is set. |
3817 CreateOfferAsRemoteDescription(); | 3846 CreateOfferAsRemoteDescription(); |
3818 EXPECT_TRUE(DoCreateAnswer(&answer, nullptr)); | 3847 EXPECT_TRUE(DoCreateAnswer(&answer, nullptr)); |
3819 } | 3848 } |
3820 | 3849 |
3850 // Test that an error is returned if a description is applied that doesn't | |
3851 // respect the order of existing media sections. | |
3852 TEST_F(PeerConnectionInterfaceTest, | |
3853 MediaSectionOrderEnforcedForSubsequentOffers) { | |
3854 CreatePeerConnection(); | |
3855 FakeConstraints constraints; | |
3856 constraints.SetMandatoryReceiveAudio(true); | |
3857 constraints.SetMandatoryReceiveVideo(true); | |
3858 std::unique_ptr<SessionDescriptionInterface> offer; | |
3859 ASSERT_TRUE(DoCreateOffer(&offer, &constraints)); | |
3860 EXPECT_TRUE(DoSetRemoteDescription(offer.release())); | |
3861 | |
3862 std::unique_ptr<SessionDescriptionInterface> answer; | |
3863 ASSERT_TRUE(DoCreateAnswer(&answer, nullptr)); | |
3864 EXPECT_TRUE(DoSetLocalDescription(answer.release())); | |
3865 | |
3866 // An remote offer with different m=line order would be rejected. | |
Taylor Brandstetter
2017/09/14 00:41:47
nit: "A" instead of "An", and "should" instead of
| |
3867 ASSERT_TRUE(DoCreateOffer(&offer, &constraints)); | |
3868 ReorderMediaSections(offer.get()); | |
3869 EXPECT_FALSE(DoSetRemoteDescription(offer.release())); | |
3870 | |
3871 // A subsequent local offer with different m=line order would be rejected. | |
3872 ASSERT_TRUE(DoCreateOffer(&offer, &constraints)); | |
3873 ReorderMediaSections(offer.get()); | |
3874 EXPECT_FALSE(DoSetLocalDescription(offer.release())); | |
3875 } | |
3876 | |
3821 class PeerConnectionMediaConfigTest : public testing::Test { | 3877 class PeerConnectionMediaConfigTest : public testing::Test { |
3822 protected: | 3878 protected: |
3823 void SetUp() override { | 3879 void SetUp() override { |
3824 pcf_ = PeerConnectionFactoryForTest::CreatePeerConnectionFactoryForTest(); | 3880 pcf_ = PeerConnectionFactoryForTest::CreatePeerConnectionFactoryForTest(); |
3825 pcf_->Initialize(); | 3881 pcf_->Initialize(); |
3826 } | 3882 } |
3827 const cricket::MediaConfig TestCreatePeerConnection( | 3883 const cricket::MediaConfig TestCreatePeerConnection( |
3828 const PeerConnectionInterface::RTCConfiguration& config, | 3884 const PeerConnectionInterface::RTCConfiguration& config, |
3829 const MediaConstraintsInterface* constraints) { | 3885 const MediaConstraintsInterface* constraints) { |
3830 rtc::scoped_refptr<PeerConnectionInterface> pc(pcf_->CreatePeerConnection( | 3886 rtc::scoped_refptr<PeerConnectionInterface> pc(pcf_->CreatePeerConnection( |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3931 EXPECT_NE(a, f); | 3987 EXPECT_NE(a, f); |
3932 | 3988 |
3933 PeerConnectionInterface::RTCConfiguration g; | 3989 PeerConnectionInterface::RTCConfiguration g; |
3934 g.disable_ipv6 = true; | 3990 g.disable_ipv6 = true; |
3935 EXPECT_NE(a, g); | 3991 EXPECT_NE(a, g); |
3936 | 3992 |
3937 PeerConnectionInterface::RTCConfiguration h( | 3993 PeerConnectionInterface::RTCConfiguration h( |
3938 PeerConnectionInterface::RTCConfigurationType::kAggressive); | 3994 PeerConnectionInterface::RTCConfigurationType::kAggressive); |
3939 EXPECT_NE(a, h); | 3995 EXPECT_NE(a, h); |
3940 } | 3996 } |
OLD | NEW |