Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 #include "webrtc/base/stringutils.h" | 61 #include "webrtc/base/stringutils.h" |
| 62 #include "webrtc/base/thread.h" | 62 #include "webrtc/base/thread.h" |
| 63 #include "webrtc/base/virtualsocketserver.h" | 63 #include "webrtc/base/virtualsocketserver.h" |
| 64 | 64 |
| 65 #define MAYBE_SKIP_TEST(feature) \ | 65 #define MAYBE_SKIP_TEST(feature) \ |
| 66 if (!(feature())) { \ | 66 if (!(feature())) { \ |
| 67 LOG(LS_INFO) << "Feature disabled... skipping"; \ | 67 LOG(LS_INFO) << "Feature disabled... skipping"; \ |
| 68 return; \ | 68 return; \ |
| 69 } | 69 } |
| 70 | 70 |
| 71 using cricket::BaseSession; | |
| 72 using cricket::DF_PLAY; | 71 using cricket::DF_PLAY; |
| 73 using cricket::DF_SEND; | 72 using cricket::DF_SEND; |
| 74 using cricket::FakeVoiceMediaChannel; | 73 using cricket::FakeVoiceMediaChannel; |
| 75 using cricket::TransportInfo; | 74 using cricket::TransportInfo; |
| 76 using rtc::SocketAddress; | 75 using rtc::SocketAddress; |
| 77 using rtc::scoped_ptr; | 76 using rtc::scoped_ptr; |
| 78 using rtc::Thread; | 77 using rtc::Thread; |
| 79 using webrtc::CreateSessionDescription; | 78 using webrtc::CreateSessionDescription; |
| 80 using webrtc::CreateSessionDescriptionObserver; | 79 using webrtc::CreateSessionDescriptionObserver; |
| 81 using webrtc::CreateSessionDescriptionRequest; | 80 using webrtc::CreateSessionDescriptionRequest; |
| 82 using webrtc::DtlsIdentityStoreInterface; | 81 using webrtc::DtlsIdentityStoreInterface; |
| 83 using webrtc::FakeConstraints; | 82 using webrtc::FakeConstraints; |
| 84 using webrtc::FakeMetricsObserver; | 83 using webrtc::FakeMetricsObserver; |
| 85 using webrtc::IceCandidateCollection; | 84 using webrtc::IceCandidateCollection; |
| 86 using webrtc::JsepIceCandidate; | 85 using webrtc::JsepIceCandidate; |
| 87 using webrtc::JsepSessionDescription; | 86 using webrtc::JsepSessionDescription; |
| 88 using webrtc::PeerConnectionFactoryInterface; | 87 using webrtc::PeerConnectionFactoryInterface; |
| 89 using webrtc::PeerConnectionInterface; | 88 using webrtc::PeerConnectionInterface; |
| 90 using webrtc::SessionDescriptionInterface; | 89 using webrtc::SessionDescriptionInterface; |
| 90 using webrtc::SessionStats; | |
| 91 using webrtc::StreamCollection; | 91 using webrtc::StreamCollection; |
| 92 using webrtc::WebRtcSession; | 92 using webrtc::WebRtcSession; |
| 93 using webrtc::kBundleWithoutRtcpMux; | 93 using webrtc::kBundleWithoutRtcpMux; |
| 94 using webrtc::kCreateChannelFailed; | 94 using webrtc::kCreateChannelFailed; |
| 95 using webrtc::kInvalidSdp; | 95 using webrtc::kInvalidSdp; |
| 96 using webrtc::kMlineMismatch; | 96 using webrtc::kMlineMismatch; |
| 97 using webrtc::kPushDownTDFailed; | 97 using webrtc::kPushDownTDFailed; |
| 98 using webrtc::kSdpWithoutIceUfragPwd; | 98 using webrtc::kSdpWithoutIceUfragPwd; |
| 99 using webrtc::kSdpWithoutDtlsFingerprint; | 99 using webrtc::kSdpWithoutDtlsFingerprint; |
| 100 using webrtc::kSdpWithoutSdesCrypto; | 100 using webrtc::kSdpWithoutSdesCrypto; |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 751 SessionDescriptionInterface* offer = CreateRemoteOffer(); | 751 SessionDescriptionInterface* offer = CreateRemoteOffer(); |
| 752 SetRemoteDescriptionWithoutError(offer); | 752 SetRemoteDescriptionWithoutError(offer); |
| 753 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 753 SessionDescriptionInterface* answer = CreateAnswer(NULL); |
| 754 SetLocalDescriptionWithoutError(answer); | 754 SetLocalDescriptionWithoutError(answer); |
| 755 } | 755 } |
| 756 void SetLocalDescriptionWithoutError(SessionDescriptionInterface* desc) { | 756 void SetLocalDescriptionWithoutError(SessionDescriptionInterface* desc) { |
| 757 EXPECT_TRUE(session_->SetLocalDescription(desc, NULL)); | 757 EXPECT_TRUE(session_->SetLocalDescription(desc, NULL)); |
| 758 session_->MaybeStartGathering(); | 758 session_->MaybeStartGathering(); |
| 759 } | 759 } |
| 760 void SetLocalDescriptionExpectState(SessionDescriptionInterface* desc, | 760 void SetLocalDescriptionExpectState(SessionDescriptionInterface* desc, |
| 761 BaseSession::State expected_state) { | 761 WebRtcSession::State expected_state) { |
| 762 SetLocalDescriptionWithoutError(desc); | 762 SetLocalDescriptionWithoutError(desc); |
| 763 EXPECT_EQ(expected_state, session_->state()); | 763 EXPECT_EQ(expected_state, session_->state()); |
| 764 } | 764 } |
| 765 void SetLocalDescriptionExpectError(const std::string& action, | 765 void SetLocalDescriptionExpectError(const std::string& action, |
| 766 const std::string& expected_error, | 766 const std::string& expected_error, |
| 767 SessionDescriptionInterface* desc) { | 767 SessionDescriptionInterface* desc) { |
| 768 std::string error; | 768 std::string error; |
| 769 EXPECT_FALSE(session_->SetLocalDescription(desc, &error)); | 769 EXPECT_FALSE(session_->SetLocalDescription(desc, &error)); |
| 770 std::string sdp_type = "local "; | 770 std::string sdp_type = "local "; |
| 771 sdp_type.append(action); | 771 sdp_type.append(action); |
| 772 EXPECT_NE(std::string::npos, error.find(sdp_type)); | 772 EXPECT_NE(std::string::npos, error.find(sdp_type)); |
| 773 EXPECT_NE(std::string::npos, error.find(expected_error)); | 773 EXPECT_NE(std::string::npos, error.find(expected_error)); |
| 774 } | 774 } |
| 775 void SetLocalDescriptionOfferExpectError(const std::string& expected_error, | 775 void SetLocalDescriptionOfferExpectError(const std::string& expected_error, |
| 776 SessionDescriptionInterface* desc) { | 776 SessionDescriptionInterface* desc) { |
| 777 SetLocalDescriptionExpectError(SessionDescriptionInterface::kOffer, | 777 SetLocalDescriptionExpectError(SessionDescriptionInterface::kOffer, |
| 778 expected_error, desc); | 778 expected_error, desc); |
| 779 } | 779 } |
| 780 void SetLocalDescriptionAnswerExpectError(const std::string& expected_error, | 780 void SetLocalDescriptionAnswerExpectError(const std::string& expected_error, |
| 781 SessionDescriptionInterface* desc) { | 781 SessionDescriptionInterface* desc) { |
| 782 SetLocalDescriptionExpectError(SessionDescriptionInterface::kAnswer, | 782 SetLocalDescriptionExpectError(SessionDescriptionInterface::kAnswer, |
| 783 expected_error, desc); | 783 expected_error, desc); |
| 784 } | 784 } |
| 785 void SetRemoteDescriptionWithoutError(SessionDescriptionInterface* desc) { | 785 void SetRemoteDescriptionWithoutError(SessionDescriptionInterface* desc) { |
| 786 EXPECT_TRUE(session_->SetRemoteDescription(desc, NULL)); | 786 EXPECT_TRUE(session_->SetRemoteDescription(desc, NULL)); |
| 787 } | 787 } |
| 788 void SetRemoteDescriptionExpectState(SessionDescriptionInterface* desc, | 788 void SetRemoteDescriptionExpectState(SessionDescriptionInterface* desc, |
| 789 BaseSession::State expected_state) { | 789 WebRtcSession::State expected_state) { |
| 790 SetRemoteDescriptionWithoutError(desc); | 790 SetRemoteDescriptionWithoutError(desc); |
| 791 EXPECT_EQ(expected_state, session_->state()); | 791 EXPECT_EQ(expected_state, session_->state()); |
| 792 } | 792 } |
| 793 void SetRemoteDescriptionExpectError(const std::string& action, | 793 void SetRemoteDescriptionExpectError(const std::string& action, |
| 794 const std::string& expected_error, | 794 const std::string& expected_error, |
| 795 SessionDescriptionInterface* desc) { | 795 SessionDescriptionInterface* desc) { |
| 796 std::string error; | 796 std::string error; |
| 797 EXPECT_FALSE(session_->SetRemoteDescription(desc, &error)); | 797 EXPECT_FALSE(session_->SetRemoteDescription(desc, &error)); |
| 798 std::string sdp_type = "remote "; | 798 std::string sdp_type = "remote "; |
| 799 sdp_type.append(action); | 799 sdp_type.append(action); |
| (...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1845 SetRemoteDescriptionWithoutError(offer); | 1845 SetRemoteDescriptionWithoutError(offer); |
| 1846 offer = CreateOffer(); | 1846 offer = CreateOffer(); |
| 1847 SetLocalDescriptionOfferExpectError( | 1847 SetLocalDescriptionOfferExpectError( |
| 1848 "Called in wrong state: STATE_RECEIVEDINITIATE", offer); | 1848 "Called in wrong state: STATE_RECEIVEDINITIATE", offer); |
| 1849 } | 1849 } |
| 1850 | 1850 |
| 1851 TEST_F(WebRtcSessionTest, TestSetLocalPrAnswer) { | 1851 TEST_F(WebRtcSessionTest, TestSetLocalPrAnswer) { |
| 1852 Init(); | 1852 Init(); |
| 1853 mediastream_signaling_.SendNothing(); | 1853 mediastream_signaling_.SendNothing(); |
| 1854 SessionDescriptionInterface* offer = CreateRemoteOffer(); | 1854 SessionDescriptionInterface* offer = CreateRemoteOffer(); |
| 1855 SetRemoteDescriptionExpectState(offer, BaseSession::STATE_RECEIVEDINITIATE); | 1855 SetRemoteDescriptionExpectState(offer, WebRtcSession::STATE_RECEIVEDINITIATE); |
| 1856 | 1856 |
| 1857 JsepSessionDescription* pranswer = static_cast<JsepSessionDescription*>( | 1857 JsepSessionDescription* pranswer = static_cast<JsepSessionDescription*>( |
| 1858 CreateAnswer(NULL)); | 1858 CreateAnswer(NULL)); |
| 1859 pranswer->set_type(SessionDescriptionInterface::kPrAnswer); | 1859 pranswer->set_type(SessionDescriptionInterface::kPrAnswer); |
| 1860 SetLocalDescriptionExpectState(pranswer, BaseSession::STATE_SENTPRACCEPT); | 1860 SetLocalDescriptionExpectState(pranswer, WebRtcSession::STATE_SENTPRACCEPT); |
| 1861 | 1861 |
| 1862 mediastream_signaling_.SendAudioVideoStream1(); | 1862 mediastream_signaling_.SendAudioVideoStream1(); |
| 1863 JsepSessionDescription* pranswer2 = static_cast<JsepSessionDescription*>( | 1863 JsepSessionDescription* pranswer2 = static_cast<JsepSessionDescription*>( |
| 1864 CreateAnswer(NULL)); | 1864 CreateAnswer(NULL)); |
| 1865 pranswer2->set_type(SessionDescriptionInterface::kPrAnswer); | 1865 pranswer2->set_type(SessionDescriptionInterface::kPrAnswer); |
| 1866 | 1866 |
| 1867 SetLocalDescriptionExpectState(pranswer2, BaseSession::STATE_SENTPRACCEPT); | 1867 SetLocalDescriptionExpectState(pranswer2, WebRtcSession::STATE_SENTPRACCEPT); |
| 1868 | 1868 |
| 1869 mediastream_signaling_.SendAudioVideoStream2(); | 1869 mediastream_signaling_.SendAudioVideoStream2(); |
| 1870 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 1870 SessionDescriptionInterface* answer = CreateAnswer(NULL); |
| 1871 SetLocalDescriptionExpectState(answer, BaseSession::STATE_SENTACCEPT); | 1871 SetLocalDescriptionExpectState(answer, WebRtcSession::STATE_SENTACCEPT); |
| 1872 } | 1872 } |
| 1873 | 1873 |
| 1874 TEST_F(WebRtcSessionTest, TestSetRemotePrAnswer) { | 1874 TEST_F(WebRtcSessionTest, TestSetRemotePrAnswer) { |
| 1875 Init(); | 1875 Init(); |
| 1876 mediastream_signaling_.SendNothing(); | 1876 mediastream_signaling_.SendNothing(); |
| 1877 SessionDescriptionInterface* offer = CreateOffer(); | 1877 SessionDescriptionInterface* offer = CreateOffer(); |
| 1878 SetLocalDescriptionExpectState(offer, BaseSession::STATE_SENTINITIATE); | 1878 SetLocalDescriptionExpectState(offer, WebRtcSession::STATE_SENTINITIATE); |
| 1879 | 1879 |
| 1880 JsepSessionDescription* pranswer = | 1880 JsepSessionDescription* pranswer = |
| 1881 CreateRemoteAnswer(session_->local_description()); | 1881 CreateRemoteAnswer(session_->local_description()); |
| 1882 pranswer->set_type(SessionDescriptionInterface::kPrAnswer); | 1882 pranswer->set_type(SessionDescriptionInterface::kPrAnswer); |
| 1883 | 1883 |
| 1884 SetRemoteDescriptionExpectState(pranswer, | 1884 SetRemoteDescriptionExpectState(pranswer, |
| 1885 BaseSession::STATE_RECEIVEDPRACCEPT); | 1885 WebRtcSession::STATE_RECEIVEDPRACCEPT); |
| 1886 | 1886 |
| 1887 mediastream_signaling_.SendAudioVideoStream1(); | 1887 mediastream_signaling_.SendAudioVideoStream1(); |
| 1888 JsepSessionDescription* pranswer2 = | 1888 JsepSessionDescription* pranswer2 = |
| 1889 CreateRemoteAnswer(session_->local_description()); | 1889 CreateRemoteAnswer(session_->local_description()); |
| 1890 pranswer2->set_type(SessionDescriptionInterface::kPrAnswer); | 1890 pranswer2->set_type(SessionDescriptionInterface::kPrAnswer); |
| 1891 | 1891 |
| 1892 SetRemoteDescriptionExpectState(pranswer2, | 1892 SetRemoteDescriptionExpectState(pranswer2, |
| 1893 BaseSession::STATE_RECEIVEDPRACCEPT); | 1893 WebRtcSession::STATE_RECEIVEDPRACCEPT); |
| 1894 | 1894 |
| 1895 mediastream_signaling_.SendAudioVideoStream2(); | 1895 mediastream_signaling_.SendAudioVideoStream2(); |
| 1896 SessionDescriptionInterface* answer = | 1896 SessionDescriptionInterface* answer = |
| 1897 CreateRemoteAnswer(session_->local_description()); | 1897 CreateRemoteAnswer(session_->local_description()); |
| 1898 SetRemoteDescriptionExpectState(answer, BaseSession::STATE_RECEIVEDACCEPT); | 1898 SetRemoteDescriptionExpectState(answer, WebRtcSession::STATE_RECEIVEDACCEPT); |
| 1899 } | 1899 } |
| 1900 | 1900 |
| 1901 TEST_F(WebRtcSessionTest, TestSetLocalAnswerWithoutOffer) { | 1901 TEST_F(WebRtcSessionTest, TestSetLocalAnswerWithoutOffer) { |
| 1902 Init(); | 1902 Init(); |
| 1903 mediastream_signaling_.SendNothing(); | 1903 mediastream_signaling_.SendNothing(); |
| 1904 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 1904 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 1905 | 1905 |
| 1906 SessionDescriptionInterface* answer = | 1906 SessionDescriptionInterface* answer = |
| 1907 CreateRemoteAnswer(offer.get()); | 1907 CreateRemoteAnswer(offer.get()); |
| 1908 SetLocalDescriptionAnswerExpectError("Called in wrong state: STATE_INIT", | 1908 SetLocalDescriptionAnswerExpectError("Called in wrong state: STATE_INIT", |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2112 } | 2112 } |
| 2113 | 2113 |
| 2114 // Verifies TransportProxy and media channels are created with content names | 2114 // Verifies TransportProxy and media channels are created with content names |
| 2115 // present in the SessionDescription. | 2115 // present in the SessionDescription. |
| 2116 TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) { | 2116 TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) { |
| 2117 Init(); | 2117 Init(); |
| 2118 mediastream_signaling_.SendAudioVideoStream1(); | 2118 mediastream_signaling_.SendAudioVideoStream1(); |
| 2119 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 2119 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 2120 | 2120 |
| 2121 // CreateOffer creates session description with the content names "audio" and | 2121 // CreateOffer creates session description with the content names "audio" and |
| 2122 // "video". Goal is to modify these content names and verify transport channel | 2122 // "video". Goal is to modify these content names and verify transport |
| 2123 // proxy in the BaseSession, as proxies are created with the content names | 2123 // channels |
| 2124 // in the WebRtcSession, as channels are created with the content names | |
| 2124 // present in SDP. | 2125 // present in SDP. |
| 2125 std::string sdp; | 2126 std::string sdp; |
| 2126 EXPECT_TRUE(offer->ToString(&sdp)); | 2127 EXPECT_TRUE(offer->ToString(&sdp)); |
| 2127 const std::string kAudioMid = "a=mid:audio"; | 2128 const std::string kAudioMid = "a=mid:audio"; |
| 2128 const std::string kAudioMidReplaceStr = "a=mid:audio_content_name"; | 2129 const std::string kAudioMidReplaceStr = "a=mid:audio_content_name"; |
| 2129 const std::string kVideoMid = "a=mid:video"; | 2130 const std::string kVideoMid = "a=mid:video"; |
| 2130 const std::string kVideoMidReplaceStr = "a=mid:video_content_name"; | 2131 const std::string kVideoMidReplaceStr = "a=mid:video_content_name"; |
| 2131 | 2132 |
| 2132 // Replacing |audio| with |audio_content_name|. | 2133 // Replacing |audio| with |audio_content_name|. |
| 2133 rtc::replace_substrs(kAudioMid.c_str(), kAudioMid.length(), | 2134 rtc::replace_substrs(kAudioMid.c_str(), kAudioMid.length(), |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2693 sdp.clear(); | 2694 sdp.clear(); |
| 2694 ModifyIceUfragPwdLines(offer.get(), "0123456789012444", | 2695 ModifyIceUfragPwdLines(offer.get(), "0123456789012444", |
| 2695 "abcdefghijklmnopqrstuvyz", &sdp); | 2696 "abcdefghijklmnopqrstuvyz", &sdp); |
| 2696 SessionDescriptionInterface* offer4 = | 2697 SessionDescriptionInterface* offer4 = |
| 2697 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); | 2698 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); |
| 2698 SetRemoteDescriptionWithoutError(offer4); | 2699 SetRemoteDescriptionWithoutError(offer4); |
| 2699 EXPECT_EQ(0, session_->remote_description()->candidates(0)->count()); | 2700 EXPECT_EQ(0, session_->remote_description()->candidates(0)->count()); |
| 2700 } | 2701 } |
| 2701 | 2702 |
| 2702 // Test that candidates sent to the "video" transport do not get pushed down to | 2703 // Test that candidates sent to the "video" transport do not get pushed down to |
| 2703 // the "audio" transport channel when bundling using TransportProxy. | 2704 // the "audio" transport channel when bundling. |
| 2704 TEST_F(WebRtcSessionTest, TestIgnoreCandidatesForUnusedTransportWhenBundling) { | 2705 TEST_F(WebRtcSessionTest, TestIgnoreCandidatesForUnusedTransportWhenBundling) { |
| 2705 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); | 2706 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
| 2706 | 2707 |
| 2707 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); | 2708 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); |
| 2708 mediastream_signaling_.SendAudioVideoStream1(); | 2709 mediastream_signaling_.SendAudioVideoStream1(); |
| 2709 | 2710 |
| 2710 PeerConnectionInterface::RTCOfferAnswerOptions options; | 2711 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2711 options.use_rtp_mux = true; | 2712 options.use_rtp_mux = true; |
| 2712 | 2713 |
| 2713 SessionDescriptionInterface* offer = CreateRemoteOffer(); | 2714 SessionDescriptionInterface* offer = CreateRemoteOffer(); |
| 2714 SetRemoteDescriptionWithoutError(offer); | 2715 SetRemoteDescriptionWithoutError(offer); |
| 2715 | 2716 |
| 2716 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 2717 SessionDescriptionInterface* answer = CreateAnswer(NULL); |
| 2717 SetLocalDescriptionWithoutError(answer); | 2718 SetLocalDescriptionWithoutError(answer); |
| 2718 | 2719 |
| 2719 EXPECT_EQ(session_->voice_rtp_transport_channel(), | 2720 EXPECT_EQ(session_->voice_rtp_transport_channel(), |
| 2720 session_->video_rtp_transport_channel()); | 2721 session_->video_rtp_transport_channel()); |
| 2721 | 2722 |
| 2722 cricket::BaseChannel* voice_channel = session_->voice_channel(); | 2723 cricket::BaseChannel* voice_channel = session_->voice_channel(); |
| 2723 ASSERT(voice_channel != NULL); | 2724 ASSERT(voice_channel != NULL); |
| 2724 | 2725 |
| 2725 // Checks if one of the transport channels contains a connection using a given | 2726 // Checks if one of the transport channels contains a connection using a given |
| 2726 // port. | 2727 // port. |
| 2727 auto connection_with_remote_port = [this, voice_channel](int port) { | 2728 auto connection_with_remote_port = [this, voice_channel](int port) { |
| 2728 cricket::SessionStats stats; | 2729 SessionStats stats; |
| 2729 session_->GetChannelTransportStats(voice_channel, &stats); | 2730 session_->GetChannelTransportStats(voice_channel, &stats); |
| 2730 for (auto& kv : stats.transport_stats) { | 2731 for (auto& kv : stats.transport_stats) { |
| 2731 for (auto& chan_stat : kv.second.channel_stats) { | 2732 for (auto& chan_stat : kv.second.channel_stats) { |
| 2732 for (auto& conn_info : chan_stat.connection_infos) { | 2733 for (auto& conn_info : chan_stat.connection_infos) { |
| 2733 if (conn_info.remote_candidate.address().port() == port) { | 2734 if (conn_info.remote_candidate.address().port() == port) { |
| 2734 return true; | 2735 return true; |
| 2735 } | 2736 } |
| 2736 } | 2737 } |
| 2737 } | 2738 } |
| 2738 } | 2739 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2778 | 2779 |
| 2779 EXPECT_TRUE_WAIT(connection_with_remote_port(5000), 1000); | 2780 EXPECT_TRUE_WAIT(connection_with_remote_port(5000), 1000); |
| 2780 EXPECT_TRUE_WAIT(connection_with_remote_port(5001), 1000); | 2781 EXPECT_TRUE_WAIT(connection_with_remote_port(5001), 1000); |
| 2781 | 2782 |
| 2782 // No need here for a _WAIT check since we are checking that state hasn't | 2783 // No need here for a _WAIT check since we are checking that state hasn't |
| 2783 // changed: if this is false we would be doing waits for nothing and if this | 2784 // changed: if this is false we would be doing waits for nothing and if this |
| 2784 // is true then there will be no messages processed anyways. | 2785 // is true then there will be no messages processed anyways. |
| 2785 EXPECT_FALSE(connection_with_remote_port(6000)); | 2786 EXPECT_FALSE(connection_with_remote_port(6000)); |
| 2786 } | 2787 } |
| 2787 | 2788 |
| 2789 // Verifies that if a local offer is set, then remote candidates are received | |
|
Taylor Brandstetter
2015/10/09 02:48:50
This is a bug I found while working on the CL. In
| |
| 2790 // before the remote description is received, the candidates are used and the | |
| 2791 // connection completes. | |
| 2792 // This only works if the local description has been set; we don't accept any | |
| 2793 // candidates before we have an offer description. | |
| 2794 TEST_F(WebRtcSessionTest, ReceiveRemoteCandidateBeforeRemoteAnswer) { | |
| 2795 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); | |
| 2796 | |
| 2797 Init(); | |
| 2798 mediastream_signaling_.SendAudioVideoStream1(); | |
| 2799 | |
| 2800 PeerConnectionInterface::RTCOfferAnswerOptions options; | |
| 2801 options.use_rtp_mux = true; | |
| 2802 | |
| 2803 SessionDescriptionInterface* offer = CreateOffer(); | |
| 2804 SetLocalDescriptionWithoutError(offer); | |
| 2805 | |
| 2806 cricket::Candidate candidate; | |
| 2807 candidate.set_address(rtc::SocketAddress("1.1.1.1", 6000)); | |
| 2808 candidate.set_component(1); | |
| 2809 candidate.set_protocol("udp"); | |
| 2810 JsepIceCandidate ice_candidate(kMediaContentName0, kMediaContentIndex0, | |
| 2811 candidate); | |
| 2812 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate)); | |
|
pthatcher1
2015/10/09 03:28:57
I don't think that was what the copy of the candid
Taylor Brandstetter
2015/10/09 23:02:07
We discussed this and got rid of saved_candidates_
| |
| 2813 | |
| 2814 cricket::BaseChannel* voice_channel = session_->voice_channel(); | |
| 2815 ASSERT(voice_channel != nullptr); | |
| 2816 | |
| 2817 // Checks if a connection (pair of local/remote candidates) has been created. | |
| 2818 auto has_connection = [this, voice_channel]() { | |
| 2819 SessionStats stats; | |
| 2820 session_->GetChannelTransportStats(voice_channel, &stats); | |
| 2821 for (auto& kv : stats.transport_stats) { | |
| 2822 for (auto& chan_stat : kv.second.channel_stats) { | |
| 2823 if (!chan_stat.connection_infos.empty()) { | |
| 2824 return true; | |
| 2825 } | |
| 2826 } | |
| 2827 } | |
| 2828 return false; | |
| 2829 }; | |
| 2830 | |
| 2831 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); | |
| 2832 SetRemoteDescriptionWithoutError(answer); | |
| 2833 | |
| 2834 EXPECT_TRUE_WAIT(has_connection(), 1000); | |
| 2835 } | |
| 2836 | |
| 2788 // kBundlePolicyBalanced BUNDLE policy and answer contains BUNDLE. | 2837 // kBundlePolicyBalanced BUNDLE policy and answer contains BUNDLE. |
| 2789 TEST_F(WebRtcSessionTest, TestBalancedBundleInAnswer) { | 2838 TEST_F(WebRtcSessionTest, TestBalancedBundleInAnswer) { |
| 2790 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); | 2839 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); |
| 2791 mediastream_signaling_.SendAudioVideoStream1(); | 2840 mediastream_signaling_.SendAudioVideoStream1(); |
| 2792 | 2841 |
| 2793 PeerConnectionInterface::RTCOfferAnswerOptions options; | 2842 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2794 options.use_rtp_mux = true; | 2843 options.use_rtp_mux = true; |
| 2795 | 2844 |
| 2796 SessionDescriptionInterface* offer = CreateOffer(options); | 2845 SessionDescriptionInterface* offer = CreateOffer(options); |
| 2797 SetLocalDescriptionWithoutError(offer); | 2846 SetLocalDescriptionWithoutError(offer); |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3472 Init(); | 3521 Init(); |
| 3473 mediastream_signaling_.SendAudioVideoStream1(); | 3522 mediastream_signaling_.SendAudioVideoStream1(); |
| 3474 SessionDescriptionInterface* offer = CreateOffer(); | 3523 SessionDescriptionInterface* offer = CreateOffer(); |
| 3475 const std::string session_id_orig = offer->session_id(); | 3524 const std::string session_id_orig = offer->session_id(); |
| 3476 const std::string session_version_orig = offer->session_version(); | 3525 const std::string session_version_orig = offer->session_version(); |
| 3477 SetLocalDescriptionWithoutError(offer); | 3526 SetLocalDescriptionWithoutError(offer); |
| 3478 | 3527 |
| 3479 video_channel_ = media_engine_->GetVideoChannel(0); | 3528 video_channel_ = media_engine_->GetVideoChannel(0); |
| 3480 video_channel_->set_fail_set_send_codecs(true); | 3529 video_channel_->set_fail_set_send_codecs(true); |
| 3481 | 3530 |
| 3482 mediastream_signaling_.SendAudioVideoStream2(); | |
| 3483 SessionDescriptionInterface* answer = | 3531 SessionDescriptionInterface* answer = |
| 3484 CreateRemoteAnswer(session_->local_description()); | 3532 CreateRemoteAnswer(session_->local_description()); |
| 3485 SetRemoteDescriptionAnswerExpectError("ERROR_CONTENT", answer); | 3533 SetRemoteDescriptionAnswerExpectError("ERROR_CONTENT", answer); |
| 3534 | |
| 3535 // Test that after a content error, setting any description will | |
| 3536 // result in an error. | |
| 3537 video_channel_->set_fail_set_send_codecs(false); | |
| 3538 answer = CreateRemoteAnswer(session_->local_description()); | |
| 3539 SetRemoteDescriptionExpectError("", "ERROR_CONTENT", answer); | |
| 3540 offer = CreateRemoteOffer(); | |
| 3541 SetLocalDescriptionExpectError("", "ERROR_CONTENT", offer); | |
| 3486 } | 3542 } |
| 3487 | 3543 |
| 3488 // Runs the loopback call test with BUNDLE and STUN disabled. | 3544 // Runs the loopback call test with BUNDLE and STUN disabled. |
| 3489 TEST_F(WebRtcSessionTest, TestIceStatesBasic) { | 3545 TEST_F(WebRtcSessionTest, TestIceStatesBasic) { |
| 3490 // Lets try with only UDP ports. | 3546 // Lets try with only UDP ports. |
| 3491 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | | 3547 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | |
| 3492 cricket::PORTALLOCATOR_DISABLE_STUN | | 3548 cricket::PORTALLOCATOR_DISABLE_STUN | |
| 3493 cricket::PORTALLOCATOR_DISABLE_RELAY); | 3549 cricket::PORTALLOCATOR_DISABLE_RELAY); |
| 3494 TestLoopbackCall(); | 3550 TestLoopbackCall(); |
| 3495 } | 3551 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 3509 TestLoopbackCall(config); | 3565 TestLoopbackCall(config); |
| 3510 } | 3566 } |
| 3511 | 3567 |
| 3512 // Runs the loopback call test with BUNDLE and STUN enabled. | 3568 // Runs the loopback call test with BUNDLE and STUN enabled. |
| 3513 TEST_F(WebRtcSessionTest, TestIceStatesBundle) { | 3569 TEST_F(WebRtcSessionTest, TestIceStatesBundle) { |
| 3514 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | | 3570 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | |
| 3515 cricket::PORTALLOCATOR_DISABLE_RELAY); | 3571 cricket::PORTALLOCATOR_DISABLE_RELAY); |
| 3516 TestLoopbackCall(); | 3572 TestLoopbackCall(); |
| 3517 } | 3573 } |
| 3518 | 3574 |
| 3519 TEST_F(WebRtcSessionTest, SetSdpFailedOnSessionError) { | |
|
Taylor Brandstetter
2015/10/09 02:48:50
I moved this test into the end of TestSessionConte
| |
| 3520 Init(); | |
| 3521 cricket::MediaSessionOptions options; | |
| 3522 options.recv_video = true; | |
| 3523 | |
| 3524 cricket::BaseSession::Error error_code = cricket::BaseSession::ERROR_CONTENT; | |
| 3525 std::string error_code_str = "ERROR_CONTENT"; | |
| 3526 std::string error_desc = "Fake session error description."; | |
| 3527 session_->SetError(error_code, error_desc); | |
| 3528 | |
| 3529 SessionDescriptionInterface* offer = CreateRemoteOffer(options); | |
| 3530 SessionDescriptionInterface* answer = | |
| 3531 CreateRemoteAnswer(offer, options); | |
| 3532 | |
| 3533 std::string action; | |
| 3534 std::ostringstream session_error_msg; | |
| 3535 session_error_msg << kSessionError << error_code_str << ". "; | |
| 3536 session_error_msg << kSessionErrorDesc << error_desc << "."; | |
| 3537 SetRemoteDescriptionExpectError(action, session_error_msg.str(), offer); | |
| 3538 SetLocalDescriptionExpectError(action, session_error_msg.str(), answer); | |
| 3539 } | |
| 3540 | |
| 3541 TEST_F(WebRtcSessionTest, TestRtpDataChannel) { | 3575 TEST_F(WebRtcSessionTest, TestRtpDataChannel) { |
| 3542 constraints_.reset(new FakeConstraints()); | 3576 constraints_.reset(new FakeConstraints()); |
| 3543 constraints_->AddOptional( | 3577 constraints_->AddOptional( |
| 3544 webrtc::MediaConstraintsInterface::kEnableRtpDataChannels, true); | 3578 webrtc::MediaConstraintsInterface::kEnableRtpDataChannels, true); |
| 3545 Init(); | 3579 Init(); |
| 3546 | 3580 |
| 3547 SetLocalDescriptionWithDataChannel(); | 3581 SetLocalDescriptionWithDataChannel(); |
| 3548 EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type()); | 3582 EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type()); |
| 3549 } | 3583 } |
| 3550 | 3584 |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4033 } | 4067 } |
| 4034 | 4068 |
| 4035 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 4069 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
| 4036 // currently fails because upon disconnection and reconnection OnIceComplete is | 4070 // currently fails because upon disconnection and reconnection OnIceComplete is |
| 4037 // called more than once without returning to IceGatheringGathering. | 4071 // called more than once without returning to IceGatheringGathering. |
| 4038 | 4072 |
| 4039 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, | 4073 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, |
| 4040 WebRtcSessionTest, | 4074 WebRtcSessionTest, |
| 4041 testing::Values(ALREADY_GENERATED, | 4075 testing::Values(ALREADY_GENERATED, |
| 4042 DTLS_IDENTITY_STORE)); | 4076 DTLS_IDENTITY_STORE)); |
| OLD | NEW |