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 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1827 SessionDescriptionInterface* offer2 = CreateOffer(); | 1827 SessionDescriptionInterface* offer2 = CreateOffer(); |
| 1828 SetRemoteDescriptionWithoutError(offer2); | 1828 SetRemoteDescriptionWithoutError(offer2); |
| 1829 } | 1829 } |
| 1830 | 1830 |
| 1831 TEST_F(WebRtcSessionTest, TestSetLocalAndRemoteOffer) { | 1831 TEST_F(WebRtcSessionTest, TestSetLocalAndRemoteOffer) { |
| 1832 Init(); | 1832 Init(); |
| 1833 mediastream_signaling_.SendNothing(); | 1833 mediastream_signaling_.SendNothing(); |
| 1834 SessionDescriptionInterface* offer = CreateOffer(); | 1834 SessionDescriptionInterface* offer = CreateOffer(); |
| 1835 SetLocalDescriptionWithoutError(offer); | 1835 SetLocalDescriptionWithoutError(offer); |
| 1836 offer = CreateOffer(); | 1836 offer = CreateOffer(); |
| 1837 SetRemoteDescriptionOfferExpectError( | 1837 SetRemoteDescriptionOfferExpectError("Called in wrong state: STATE_SENTOFFER", |
| 1838 "Called in wrong state: STATE_SENTINITIATE", offer); | 1838 offer); |
| 1839 } | 1839 } |
| 1840 | 1840 |
| 1841 TEST_F(WebRtcSessionTest, TestSetRemoteAndLocalOffer) { | 1841 TEST_F(WebRtcSessionTest, TestSetRemoteAndLocalOffer) { |
| 1842 Init(); | 1842 Init(); |
| 1843 mediastream_signaling_.SendNothing(); | 1843 mediastream_signaling_.SendNothing(); |
| 1844 SessionDescriptionInterface* offer = CreateOffer(); | 1844 SessionDescriptionInterface* offer = CreateOffer(); |
| 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_RECEIVEDOFFER", 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_RECEIVEDOFFER); |
| 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_SENTPRANSWER); |
| 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_SENTPRANSWER); |
| 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_INPROGRESS); |
| 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_SENTOFFER); |
| 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_RECEIVEDPRANSWER); |
| 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_RECEIVEDPRANSWER); |
| 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_INPROGRESS); |
| 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 12 matching lines...) Expand all Loading... | |
| 1921 } | 1921 } |
| 1922 | 1922 |
| 1923 TEST_F(WebRtcSessionTest, TestAddRemoteCandidate) { | 1923 TEST_F(WebRtcSessionTest, TestAddRemoteCandidate) { |
| 1924 Init(); | 1924 Init(); |
| 1925 mediastream_signaling_.SendAudioVideoStream1(); | 1925 mediastream_signaling_.SendAudioVideoStream1(); |
| 1926 | 1926 |
| 1927 cricket::Candidate candidate; | 1927 cricket::Candidate candidate; |
| 1928 candidate.set_component(1); | 1928 candidate.set_component(1); |
| 1929 JsepIceCandidate ice_candidate1(kMediaContentName0, 0, candidate); | 1929 JsepIceCandidate ice_candidate1(kMediaContentName0, 0, candidate); |
| 1930 | 1930 |
| 1931 // Fail since we have not set a offer description. | 1931 // Fail since we have not set a remote description. |
| 1932 EXPECT_FALSE(session_->ProcessIceMessage(&ice_candidate1)); | 1932 EXPECT_FALSE(session_->ProcessIceMessage(&ice_candidate1)); |
| 1933 | 1933 |
| 1934 SessionDescriptionInterface* offer = CreateOffer(); | 1934 SessionDescriptionInterface* offer = CreateOffer(); |
| 1935 SetLocalDescriptionWithoutError(offer); | 1935 SetLocalDescriptionWithoutError(offer); |
| 1936 // Candidate should be allowed to add before remote description. | 1936 |
|
Taylor Brandstetter
2015/10/09 23:02:07
It's odd that this test says "candidate can be add
pthatcher1
2015/10/10 00:07:27
It's weird that we explicitly expected this behavi
Taylor Brandstetter
2015/10/10 00:30:15
Email sent; CC'd you.
| |
| 1937 // Fail since we have not set a remote description. | |
| 1938 EXPECT_FALSE(session_->ProcessIceMessage(&ice_candidate1)); | |
| 1939 | |
| 1940 SessionDescriptionInterface* answer = CreateRemoteAnswer( | |
| 1941 session_->local_description()); | |
| 1942 SetRemoteDescriptionWithoutError(answer); | |
| 1943 | |
| 1937 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate1)); | 1944 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate1)); |
| 1938 candidate.set_component(2); | 1945 candidate.set_component(2); |
| 1939 JsepIceCandidate ice_candidate2(kMediaContentName0, 0, candidate); | 1946 JsepIceCandidate ice_candidate2(kMediaContentName0, 0, candidate); |
| 1940 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate2)); | 1947 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate2)); |
| 1941 | 1948 |
| 1942 SessionDescriptionInterface* answer = CreateRemoteAnswer( | |
| 1943 session_->local_description()); | |
| 1944 SetRemoteDescriptionWithoutError(answer); | |
| 1945 | |
| 1946 // Verifying the candidates are copied properly from internal vector. | 1949 // Verifying the candidates are copied properly from internal vector. |
| 1947 const SessionDescriptionInterface* remote_desc = | 1950 const SessionDescriptionInterface* remote_desc = |
| 1948 session_->remote_description(); | 1951 session_->remote_description(); |
| 1949 ASSERT_TRUE(remote_desc != NULL); | 1952 ASSERT_TRUE(remote_desc != NULL); |
| 1950 ASSERT_EQ(2u, remote_desc->number_of_mediasections()); | 1953 ASSERT_EQ(2u, remote_desc->number_of_mediasections()); |
| 1951 const IceCandidateCollection* candidates = | 1954 const IceCandidateCollection* candidates = |
| 1952 remote_desc->candidates(kMediaContentIndex0); | 1955 remote_desc->candidates(kMediaContentIndex0); |
| 1953 ASSERT_EQ(2u, candidates->count()); | 1956 ASSERT_EQ(2u, candidates->count()); |
| 1954 EXPECT_EQ(kMediaContentIndex0, candidates->at(0)->sdp_mline_index()); | 1957 EXPECT_EQ(kMediaContentIndex0, candidates->at(0)->sdp_mline_index()); |
| 1955 EXPECT_EQ(kMediaContentName0, candidates->at(0)->sdp_mid()); | 1958 EXPECT_EQ(kMediaContentName0, candidates->at(0)->sdp_mid()); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2112 } | 2115 } |
| 2113 | 2116 |
| 2114 // Verifies TransportProxy and media channels are created with content names | 2117 // Verifies TransportProxy and media channels are created with content names |
| 2115 // present in the SessionDescription. | 2118 // present in the SessionDescription. |
| 2116 TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) { | 2119 TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) { |
| 2117 Init(); | 2120 Init(); |
| 2118 mediastream_signaling_.SendAudioVideoStream1(); | 2121 mediastream_signaling_.SendAudioVideoStream1(); |
| 2119 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 2122 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 2120 | 2123 |
| 2121 // CreateOffer creates session description with the content names "audio" and | 2124 // CreateOffer creates session description with the content names "audio" and |
| 2122 // "video". Goal is to modify these content names and verify transport channel | 2125 // "video". Goal is to modify these content names and verify transport |
| 2123 // proxy in the BaseSession, as proxies are created with the content names | 2126 // channels |
| 2127 // in the WebRtcSession, as channels are created with the content names | |
| 2124 // present in SDP. | 2128 // present in SDP. |
| 2125 std::string sdp; | 2129 std::string sdp; |
| 2126 EXPECT_TRUE(offer->ToString(&sdp)); | 2130 EXPECT_TRUE(offer->ToString(&sdp)); |
| 2127 const std::string kAudioMid = "a=mid:audio"; | 2131 const std::string kAudioMid = "a=mid:audio"; |
| 2128 const std::string kAudioMidReplaceStr = "a=mid:audio_content_name"; | 2132 const std::string kAudioMidReplaceStr = "a=mid:audio_content_name"; |
| 2129 const std::string kVideoMid = "a=mid:video"; | 2133 const std::string kVideoMid = "a=mid:video"; |
| 2130 const std::string kVideoMidReplaceStr = "a=mid:video_content_name"; | 2134 const std::string kVideoMidReplaceStr = "a=mid:video_content_name"; |
| 2131 | 2135 |
| 2132 // Replacing |audio| with |audio_content_name|. | 2136 // Replacing |audio| with |audio_content_name|. |
| 2133 rtc::replace_substrs(kAudioMid.c_str(), kAudioMid.length(), | 2137 rtc::replace_substrs(kAudioMid.c_str(), kAudioMid.length(), |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2693 sdp.clear(); | 2697 sdp.clear(); |
| 2694 ModifyIceUfragPwdLines(offer.get(), "0123456789012444", | 2698 ModifyIceUfragPwdLines(offer.get(), "0123456789012444", |
| 2695 "abcdefghijklmnopqrstuvyz", &sdp); | 2699 "abcdefghijklmnopqrstuvyz", &sdp); |
| 2696 SessionDescriptionInterface* offer4 = | 2700 SessionDescriptionInterface* offer4 = |
| 2697 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); | 2701 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); |
| 2698 SetRemoteDescriptionWithoutError(offer4); | 2702 SetRemoteDescriptionWithoutError(offer4); |
| 2699 EXPECT_EQ(0, session_->remote_description()->candidates(0)->count()); | 2703 EXPECT_EQ(0, session_->remote_description()->candidates(0)->count()); |
| 2700 } | 2704 } |
| 2701 | 2705 |
| 2702 // Test that candidates sent to the "video" transport do not get pushed down to | 2706 // Test that candidates sent to the "video" transport do not get pushed down to |
| 2703 // the "audio" transport channel when bundling using TransportProxy. | 2707 // the "audio" transport channel when bundling. |
| 2704 TEST_F(WebRtcSessionTest, TestIgnoreCandidatesForUnusedTransportWhenBundling) { | 2708 TEST_F(WebRtcSessionTest, TestIgnoreCandidatesForUnusedTransportWhenBundling) { |
| 2705 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); | 2709 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
| 2706 | 2710 |
| 2707 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); | 2711 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); |
| 2708 mediastream_signaling_.SendAudioVideoStream1(); | 2712 mediastream_signaling_.SendAudioVideoStream1(); |
| 2709 | 2713 |
| 2710 PeerConnectionInterface::RTCOfferAnswerOptions options; | 2714 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2711 options.use_rtp_mux = true; | 2715 options.use_rtp_mux = true; |
| 2712 | 2716 |
| 2713 SessionDescriptionInterface* offer = CreateRemoteOffer(); | 2717 SessionDescriptionInterface* offer = CreateRemoteOffer(); |
| 2714 SetRemoteDescriptionWithoutError(offer); | 2718 SetRemoteDescriptionWithoutError(offer); |
| 2715 | 2719 |
| 2716 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 2720 SessionDescriptionInterface* answer = CreateAnswer(NULL); |
| 2717 SetLocalDescriptionWithoutError(answer); | 2721 SetLocalDescriptionWithoutError(answer); |
| 2718 | 2722 |
| 2719 EXPECT_EQ(session_->voice_rtp_transport_channel(), | 2723 EXPECT_EQ(session_->voice_rtp_transport_channel(), |
| 2720 session_->video_rtp_transport_channel()); | 2724 session_->video_rtp_transport_channel()); |
| 2721 | 2725 |
| 2722 cricket::BaseChannel* voice_channel = session_->voice_channel(); | 2726 cricket::BaseChannel* voice_channel = session_->voice_channel(); |
| 2723 ASSERT(voice_channel != NULL); | 2727 ASSERT(voice_channel != NULL); |
| 2724 | 2728 |
| 2725 // Checks if one of the transport channels contains a connection using a given | 2729 // Checks if one of the transport channels contains a connection using a given |
| 2726 // port. | 2730 // port. |
| 2727 auto connection_with_remote_port = [this, voice_channel](int port) { | 2731 auto connection_with_remote_port = [this, voice_channel](int port) { |
| 2728 cricket::SessionStats stats; | 2732 SessionStats stats; |
| 2729 session_->GetChannelTransportStats(voice_channel, &stats); | 2733 session_->GetChannelTransportStats(voice_channel, &stats); |
| 2730 for (auto& kv : stats.transport_stats) { | 2734 for (auto& kv : stats.transport_stats) { |
| 2731 for (auto& chan_stat : kv.second.channel_stats) { | 2735 for (auto& chan_stat : kv.second.channel_stats) { |
| 2732 for (auto& conn_info : chan_stat.connection_infos) { | 2736 for (auto& conn_info : chan_stat.connection_infos) { |
| 2733 if (conn_info.remote_candidate.address().port() == port) { | 2737 if (conn_info.remote_candidate.address().port() == port) { |
| 2734 return true; | 2738 return true; |
| 2735 } | 2739 } |
| 2736 } | 2740 } |
| 2737 } | 2741 } |
| 2738 } | 2742 } |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3238 ASSERT_EQ(3U, channel->dtmf_info_queue().size()); | 3242 ASSERT_EQ(3U, channel->dtmf_info_queue().size()); |
| 3239 const uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); | 3243 const uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); |
| 3240 EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[0], send_ssrc, 0, | 3244 EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[0], send_ssrc, 0, |
| 3241 expected_duration, expected_flags)); | 3245 expected_duration, expected_flags)); |
| 3242 EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[1], send_ssrc, 1, | 3246 EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[1], send_ssrc, 1, |
| 3243 expected_duration, expected_flags)); | 3247 expected_duration, expected_flags)); |
| 3244 EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[2], send_ssrc, 2, | 3248 EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[2], send_ssrc, 2, |
| 3245 expected_duration, expected_flags)); | 3249 expected_duration, expected_flags)); |
| 3246 } | 3250 } |
| 3247 | 3251 |
| 3248 // This test verifies the |initiator| flag when session initiates the call. | 3252 // This test verifies the |initial_offerer| flag when session initiates the |
| 3253 // call. | |
| 3249 TEST_F(WebRtcSessionTest, TestInitiatorFlagAsOriginator) { | 3254 TEST_F(WebRtcSessionTest, TestInitiatorFlagAsOriginator) { |
| 3250 Init(); | 3255 Init(); |
| 3251 EXPECT_FALSE(session_->initiator()); | 3256 EXPECT_FALSE(session_->initial_offerer()); |
| 3252 SessionDescriptionInterface* offer = CreateOffer(); | 3257 SessionDescriptionInterface* offer = CreateOffer(); |
| 3253 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); | 3258 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); |
| 3254 SetLocalDescriptionWithoutError(offer); | 3259 SetLocalDescriptionWithoutError(offer); |
| 3255 EXPECT_TRUE(session_->initiator()); | 3260 EXPECT_TRUE(session_->initial_offerer()); |
| 3256 SetRemoteDescriptionWithoutError(answer); | 3261 SetRemoteDescriptionWithoutError(answer); |
| 3257 EXPECT_TRUE(session_->initiator()); | 3262 EXPECT_TRUE(session_->initial_offerer()); |
| 3258 } | 3263 } |
| 3259 | 3264 |
| 3260 // This test verifies the |initiator| flag when session receives the call. | 3265 // This test verifies the |initial_offerer| flag when session receives the call. |
| 3261 TEST_F(WebRtcSessionTest, TestInitiatorFlagAsReceiver) { | 3266 TEST_F(WebRtcSessionTest, TestInitiatorFlagAsReceiver) { |
| 3262 Init(); | 3267 Init(); |
| 3263 EXPECT_FALSE(session_->initiator()); | 3268 EXPECT_FALSE(session_->initial_offerer()); |
| 3264 SessionDescriptionInterface* offer = CreateRemoteOffer(); | 3269 SessionDescriptionInterface* offer = CreateRemoteOffer(); |
| 3265 SetRemoteDescriptionWithoutError(offer); | 3270 SetRemoteDescriptionWithoutError(offer); |
| 3266 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 3271 SessionDescriptionInterface* answer = CreateAnswer(NULL); |
| 3267 | 3272 |
| 3268 EXPECT_FALSE(session_->initiator()); | 3273 EXPECT_FALSE(session_->initial_offerer()); |
| 3269 SetLocalDescriptionWithoutError(answer); | 3274 SetLocalDescriptionWithoutError(answer); |
| 3270 EXPECT_FALSE(session_->initiator()); | 3275 EXPECT_FALSE(session_->initial_offerer()); |
| 3271 } | 3276 } |
| 3272 | 3277 |
| 3273 // Verifing local offer and remote answer have matching m-lines as per RFC 3264. | 3278 // Verifing local offer and remote answer have matching m-lines as per RFC 3264. |
| 3274 TEST_F(WebRtcSessionTest, TestIncorrectMLinesInRemoteAnswer) { | 3279 TEST_F(WebRtcSessionTest, TestIncorrectMLinesInRemoteAnswer) { |
| 3275 Init(); | 3280 Init(); |
| 3276 mediastream_signaling_.SendAudioVideoStream1(); | 3281 mediastream_signaling_.SendAudioVideoStream1(); |
| 3277 SessionDescriptionInterface* offer = CreateOffer(); | 3282 SessionDescriptionInterface* offer = CreateOffer(); |
| 3278 SetLocalDescriptionWithoutError(offer); | 3283 SetLocalDescriptionWithoutError(offer); |
| 3279 rtc::scoped_ptr<SessionDescriptionInterface> answer( | 3284 rtc::scoped_ptr<SessionDescriptionInterface> answer( |
| 3280 CreateRemoteAnswer(session_->local_description())); | 3285 CreateRemoteAnswer(session_->local_description())); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3472 Init(); | 3477 Init(); |
| 3473 mediastream_signaling_.SendAudioVideoStream1(); | 3478 mediastream_signaling_.SendAudioVideoStream1(); |
| 3474 SessionDescriptionInterface* offer = CreateOffer(); | 3479 SessionDescriptionInterface* offer = CreateOffer(); |
| 3475 const std::string session_id_orig = offer->session_id(); | 3480 const std::string session_id_orig = offer->session_id(); |
| 3476 const std::string session_version_orig = offer->session_version(); | 3481 const std::string session_version_orig = offer->session_version(); |
| 3477 SetLocalDescriptionWithoutError(offer); | 3482 SetLocalDescriptionWithoutError(offer); |
| 3478 | 3483 |
| 3479 video_channel_ = media_engine_->GetVideoChannel(0); | 3484 video_channel_ = media_engine_->GetVideoChannel(0); |
| 3480 video_channel_->set_fail_set_send_codecs(true); | 3485 video_channel_->set_fail_set_send_codecs(true); |
| 3481 | 3486 |
| 3482 mediastream_signaling_.SendAudioVideoStream2(); | |
| 3483 SessionDescriptionInterface* answer = | 3487 SessionDescriptionInterface* answer = |
| 3484 CreateRemoteAnswer(session_->local_description()); | 3488 CreateRemoteAnswer(session_->local_description()); |
| 3485 SetRemoteDescriptionAnswerExpectError("ERROR_CONTENT", answer); | 3489 SetRemoteDescriptionAnswerExpectError("ERROR_CONTENT", answer); |
| 3490 | |
| 3491 // Test that after a content error, setting any description will | |
| 3492 // result in an error. | |
| 3493 video_channel_->set_fail_set_send_codecs(false); | |
| 3494 answer = CreateRemoteAnswer(session_->local_description()); | |
| 3495 SetRemoteDescriptionExpectError("", "ERROR_CONTENT", answer); | |
| 3496 offer = CreateRemoteOffer(); | |
| 3497 SetLocalDescriptionExpectError("", "ERROR_CONTENT", offer); | |
| 3486 } | 3498 } |
| 3487 | 3499 |
| 3488 // Runs the loopback call test with BUNDLE and STUN disabled. | 3500 // Runs the loopback call test with BUNDLE and STUN disabled. |
| 3489 TEST_F(WebRtcSessionTest, TestIceStatesBasic) { | 3501 TEST_F(WebRtcSessionTest, TestIceStatesBasic) { |
| 3490 // Lets try with only UDP ports. | 3502 // Lets try with only UDP ports. |
| 3491 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | | 3503 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | |
| 3492 cricket::PORTALLOCATOR_DISABLE_STUN | | 3504 cricket::PORTALLOCATOR_DISABLE_STUN | |
| 3493 cricket::PORTALLOCATOR_DISABLE_RELAY); | 3505 cricket::PORTALLOCATOR_DISABLE_RELAY); |
| 3494 TestLoopbackCall(); | 3506 TestLoopbackCall(); |
| 3495 } | 3507 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 3509 TestLoopbackCall(config); | 3521 TestLoopbackCall(config); |
| 3510 } | 3522 } |
| 3511 | 3523 |
| 3512 // Runs the loopback call test with BUNDLE and STUN enabled. | 3524 // Runs the loopback call test with BUNDLE and STUN enabled. |
| 3513 TEST_F(WebRtcSessionTest, TestIceStatesBundle) { | 3525 TEST_F(WebRtcSessionTest, TestIceStatesBundle) { |
| 3514 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | | 3526 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | |
| 3515 cricket::PORTALLOCATOR_DISABLE_RELAY); | 3527 cricket::PORTALLOCATOR_DISABLE_RELAY); |
| 3516 TestLoopbackCall(); | 3528 TestLoopbackCall(); |
| 3517 } | 3529 } |
| 3518 | 3530 |
| 3519 TEST_F(WebRtcSessionTest, SetSdpFailedOnSessionError) { | |
| 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) { | 3531 TEST_F(WebRtcSessionTest, TestRtpDataChannel) { |
| 3542 constraints_.reset(new FakeConstraints()); | 3532 constraints_.reset(new FakeConstraints()); |
| 3543 constraints_->AddOptional( | 3533 constraints_->AddOptional( |
| 3544 webrtc::MediaConstraintsInterface::kEnableRtpDataChannels, true); | 3534 webrtc::MediaConstraintsInterface::kEnableRtpDataChannels, true); |
| 3545 Init(); | 3535 Init(); |
| 3546 | 3536 |
| 3547 SetLocalDescriptionWithDataChannel(); | 3537 SetLocalDescriptionWithDataChannel(); |
| 3548 EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type()); | 3538 EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type()); |
| 3549 } | 3539 } |
| 3550 | 3540 |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4033 } | 4023 } |
| 4034 | 4024 |
| 4035 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 4025 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
| 4036 // currently fails because upon disconnection and reconnection OnIceComplete is | 4026 // currently fails because upon disconnection and reconnection OnIceComplete is |
| 4037 // called more than once without returning to IceGatheringGathering. | 4027 // called more than once without returning to IceGatheringGathering. |
| 4038 | 4028 |
| 4039 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, | 4029 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, |
| 4040 WebRtcSessionTest, | 4030 WebRtcSessionTest, |
| 4041 testing::Values(ALREADY_GENERATED, | 4031 testing::Values(ALREADY_GENERATED, |
| 4042 DTLS_IDENTITY_STORE)); | 4032 DTLS_IDENTITY_STORE)); |
| OLD | NEW |