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 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 } | 510 } |
511 | 511 |
512 void RemoveMsidFromReceivedSdp(bool remove) { remove_msid_ = remove; } | 512 void RemoveMsidFromReceivedSdp(bool remove) { remove_msid_ = remove; } |
513 | 513 |
514 void RemoveSdesCryptoFromReceivedSdp(bool remove) { remove_sdes_ = remove; } | 514 void RemoveSdesCryptoFromReceivedSdp(bool remove) { remove_sdes_ = remove; } |
515 | 515 |
516 void RemoveBundleFromReceivedSdp(bool remove) { remove_bundle_ = remove; } | 516 void RemoveBundleFromReceivedSdp(bool remove) { remove_bundle_ = remove; } |
517 | 517 |
518 void RemoveCvoFromReceivedSdp(bool remove) { remove_cvo_ = remove; } | 518 void RemoveCvoFromReceivedSdp(bool remove) { remove_cvo_ = remove; } |
519 | 519 |
| 520 void MakeSpecCompliantMaxBundleOfferFromReceivedSdp(bool real) { |
| 521 make_spec_compliant_max_bundle_offer_ = real; |
| 522 } |
| 523 |
520 bool can_receive_audio() { | 524 bool can_receive_audio() { |
521 bool value; | 525 bool value; |
522 if (prefer_constraint_apis_) { | 526 if (prefer_constraint_apis_) { |
523 if (webrtc::FindConstraint( | 527 if (webrtc::FindConstraint( |
524 &offer_answer_constraints_, | 528 &offer_answer_constraints_, |
525 MediaConstraintsInterface::kOfferToReceiveAudio, &value, | 529 MediaConstraintsInterface::kOfferToReceiveAudio, &value, |
526 nullptr)) { | 530 nullptr)) { |
527 return value; | 531 return value; |
528 } | 532 } |
529 return true; | 533 return true; |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1042 } | 1046 } |
1043 | 1047 |
1044 void HandleIncomingOffer(const std::string& msg) { | 1048 void HandleIncomingOffer(const std::string& msg) { |
1045 LOG(INFO) << id_ << "HandleIncomingOffer "; | 1049 LOG(INFO) << id_ << "HandleIncomingOffer "; |
1046 if (NumberOfLocalMediaStreams() == 0 && auto_add_stream_) { | 1050 if (NumberOfLocalMediaStreams() == 0 && auto_add_stream_) { |
1047 // If we are not sending any streams ourselves it is time to add some. | 1051 // If we are not sending any streams ourselves it is time to add some. |
1048 AddMediaStream(true, true); | 1052 AddMediaStream(true, true); |
1049 } | 1053 } |
1050 std::unique_ptr<SessionDescriptionInterface> desc( | 1054 std::unique_ptr<SessionDescriptionInterface> desc( |
1051 webrtc::CreateSessionDescription("offer", msg, nullptr)); | 1055 webrtc::CreateSessionDescription("offer", msg, nullptr)); |
| 1056 |
| 1057 // Do the equivalent of setting the port to 0, adding a=bundle-only, and |
| 1058 // removing a=ice-ufrag, a=ice-pwd, a=fingerprint and a=setup from all but |
| 1059 // the first m= section. |
| 1060 if (make_spec_compliant_max_bundle_offer_) { |
| 1061 bool first = true; |
| 1062 for (cricket::ContentInfo& content : desc->description()->contents()) { |
| 1063 if (first) { |
| 1064 first = false; |
| 1065 continue; |
| 1066 } |
| 1067 content.bundle_only = true; |
| 1068 } |
| 1069 first = true; |
| 1070 for (cricket::TransportInfo& transport : |
| 1071 desc->description()->transport_infos()) { |
| 1072 if (first) { |
| 1073 first = false; |
| 1074 continue; |
| 1075 } |
| 1076 transport.description.ice_ufrag.clear(); |
| 1077 transport.description.ice_pwd.clear(); |
| 1078 transport.description.connection_role = cricket::CONNECTIONROLE_NONE; |
| 1079 transport.description.identity_fingerprint.reset(nullptr); |
| 1080 } |
| 1081 } |
| 1082 |
1052 EXPECT_TRUE(DoSetRemoteDescription(desc.release())); | 1083 EXPECT_TRUE(DoSetRemoteDescription(desc.release())); |
1053 // Set the RtpReceiverObserver after receivers are created. | 1084 // Set the RtpReceiverObserver after receivers are created. |
1054 SetRtpReceiverObservers(); | 1085 SetRtpReceiverObservers(); |
1055 std::unique_ptr<SessionDescriptionInterface> answer; | 1086 std::unique_ptr<SessionDescriptionInterface> answer; |
1056 EXPECT_TRUE(DoCreateAnswer(&answer)); | 1087 EXPECT_TRUE(DoCreateAnswer(&answer)); |
1057 std::string sdp; | 1088 std::string sdp; |
1058 EXPECT_TRUE(answer->ToString(&sdp)); | 1089 EXPECT_TRUE(answer->ToString(&sdp)); |
1059 EXPECT_TRUE(DoSetLocalDescription(answer.release())); | 1090 EXPECT_TRUE(DoSetLocalDescription(answer.release())); |
1060 SendSdpMessage(webrtc::SessionDescriptionInterface::kAnswer, sdp); | 1091 SendSdpMessage(webrtc::SessionDescriptionInterface::kAnswer, sdp); |
1061 } | 1092 } |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1202 webrtc::FakeConstraints offer_answer_constraints_; | 1233 webrtc::FakeConstraints offer_answer_constraints_; |
1203 PeerConnectionInterface::RTCOfferAnswerOptions offer_answer_options_; | 1234 PeerConnectionInterface::RTCOfferAnswerOptions offer_answer_options_; |
1204 bool remove_msid_ = false; // True if MSID should be removed in received SDP. | 1235 bool remove_msid_ = false; // True if MSID should be removed in received SDP. |
1205 bool remove_bundle_ = | 1236 bool remove_bundle_ = |
1206 false; // True if bundle should be removed in received SDP. | 1237 false; // True if bundle should be removed in received SDP. |
1207 bool remove_sdes_ = | 1238 bool remove_sdes_ = |
1208 false; // True if a=crypto should be removed in received SDP. | 1239 false; // True if a=crypto should be removed in received SDP. |
1209 // |remove_cvo_| is true if extension urn:3gpp:video-orientation should be | 1240 // |remove_cvo_| is true if extension urn:3gpp:video-orientation should be |
1210 // removed in the received SDP. | 1241 // removed in the received SDP. |
1211 bool remove_cvo_ = false; | 1242 bool remove_cvo_ = false; |
| 1243 // See LocalP2PTestWithSpecCompliantMaxBundleOffer. |
| 1244 bool make_spec_compliant_max_bundle_offer_ = false; |
1212 | 1245 |
1213 rtc::scoped_refptr<DataChannelInterface> data_channel_; | 1246 rtc::scoped_refptr<DataChannelInterface> data_channel_; |
1214 std::unique_ptr<MockDataChannelObserver> data_observer_; | 1247 std::unique_ptr<MockDataChannelObserver> data_observer_; |
1215 | 1248 |
1216 std::vector<std::unique_ptr<MockRtpReceiverObserver>> rtp_receiver_observers_; | 1249 std::vector<std::unique_ptr<MockRtpReceiverObserver>> rtp_receiver_observers_; |
1217 }; | 1250 }; |
1218 | 1251 |
1219 class P2PTestConductor : public testing::Test { | 1252 class P2PTestConductor : public testing::Test { |
1220 public: | 1253 public: |
1221 P2PTestConductor() | 1254 P2PTestConductor() |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1842 FakeConstraints constraint; | 1875 FakeConstraints constraint; |
1843 constraint.SetOptionalMaxWidth(320); | 1876 constraint.SetOptionalMaxWidth(320); |
1844 SetVideoConstraints(constraint, constraint); | 1877 SetVideoConstraints(constraint, constraint); |
1845 initializing_client()->AddMediaStream(true, true); | 1878 initializing_client()->AddMediaStream(true, true); |
1846 initializing_client()->AddMediaStream(false, true); | 1879 initializing_client()->AddMediaStream(false, true); |
1847 ASSERT_EQ(2u, initializing_client()->NumberOfLocalMediaStreams()); | 1880 ASSERT_EQ(2u, initializing_client()->NumberOfLocalMediaStreams()); |
1848 LocalP2PTest(); | 1881 LocalP2PTest(); |
1849 EXPECT_EQ(2u, receiving_client()->number_of_remote_streams()); | 1882 EXPECT_EQ(2u, receiving_client()->number_of_remote_streams()); |
1850 } | 1883 } |
1851 | 1884 |
| 1885 // Test that if applying a true "max bundle" offer, which uses ports of 0, |
| 1886 // "a=bundle-only", omitting "a=fingerprint", "a=setup", "a=ice-ufrag" and |
| 1887 // "a=ice-pwd" for all but the audio "m=" section, negotiation still completes |
| 1888 // successfully and media flows. |
| 1889 // TODO(deadbeef): Update this test to also omit "a=rtcp-mux", once that works. |
| 1890 // TODO(deadbeef): Won't need this test once we start generating actual |
| 1891 // standards-compliant SDP. |
| 1892 TEST_F(P2PTestConductor, LocalP2PTestWithSpecCompliantMaxBundleOffer) { |
| 1893 ASSERT_TRUE(CreateTestClients()); |
| 1894 receiving_client()->MakeSpecCompliantMaxBundleOfferFromReceivedSdp(true); |
| 1895 LocalP2PTest(); |
| 1896 } |
| 1897 |
1852 // Test that we can receive the audio output level from a remote audio track. | 1898 // Test that we can receive the audio output level from a remote audio track. |
1853 TEST_F(P2PTestConductor, GetAudioOutputLevelStats) { | 1899 TEST_F(P2PTestConductor, GetAudioOutputLevelStats) { |
1854 ASSERT_TRUE(CreateTestClients()); | 1900 ASSERT_TRUE(CreateTestClients()); |
1855 LocalP2PTest(); | 1901 LocalP2PTest(); |
1856 | 1902 |
1857 StreamCollectionInterface* remote_streams = | 1903 StreamCollectionInterface* remote_streams = |
1858 initializing_client()->remote_streams(); | 1904 initializing_client()->remote_streams(); |
1859 ASSERT_GT(remote_streams->count(), 0u); | 1905 ASSERT_GT(remote_streams->count(), 0u); |
1860 ASSERT_GT(remote_streams->at(0)->GetAudioTracks().size(), 0u); | 1906 ASSERT_GT(remote_streams->at(0)->GetAudioTracks().size(), 0u); |
1861 MediaStreamTrackInterface* remote_audio_track = | 1907 MediaStreamTrackInterface* remote_audio_track = |
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2821 servers.push_back(server); | 2867 servers.push_back(server); |
2822 EXPECT_EQ(webrtc::RTCErrorType::NONE, | 2868 EXPECT_EQ(webrtc::RTCErrorType::NONE, |
2823 webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_)); | 2869 webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_)); |
2824 EXPECT_EQ(2U, turn_servers_.size()); | 2870 EXPECT_EQ(2U, turn_servers_.size()); |
2825 EXPECT_NE(turn_servers_[0].priority, turn_servers_[1].priority); | 2871 EXPECT_NE(turn_servers_[0].priority, turn_servers_[1].priority); |
2826 } | 2872 } |
2827 | 2873 |
2828 #endif // if !defined(THREAD_SANITIZER) | 2874 #endif // if !defined(THREAD_SANITIZER) |
2829 | 2875 |
2830 } // namespace | 2876 } // namespace |
OLD | NEW |