| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 #include "webrtc/base/stringutils.h" | 63 #include "webrtc/base/stringutils.h" |
| 64 #include "webrtc/base/thread.h" | 64 #include "webrtc/base/thread.h" |
| 65 #include "webrtc/base/virtualsocketserver.h" | 65 #include "webrtc/base/virtualsocketserver.h" |
| 66 | 66 |
| 67 #define MAYBE_SKIP_TEST(feature) \ | 67 #define MAYBE_SKIP_TEST(feature) \ |
| 68 if (!(feature())) { \ | 68 if (!(feature())) { \ |
| 69 LOG(LS_INFO) << "Feature disabled... skipping"; \ | 69 LOG(LS_INFO) << "Feature disabled... skipping"; \ |
| 70 return; \ | 70 return; \ |
| 71 } | 71 } |
| 72 | 72 |
| 73 using cricket::BaseSession; | |
| 74 using cricket::DF_PLAY; | 73 using cricket::DF_PLAY; |
| 75 using cricket::DF_SEND; | 74 using cricket::DF_SEND; |
| 76 using cricket::FakeVoiceMediaChannel; | 75 using cricket::FakeVoiceMediaChannel; |
| 77 using cricket::TransportInfo; | 76 using cricket::TransportInfo; |
| 78 using rtc::SocketAddress; | 77 using rtc::SocketAddress; |
| 79 using rtc::scoped_ptr; | 78 using rtc::scoped_ptr; |
| 80 using rtc::Thread; | 79 using rtc::Thread; |
| 81 using webrtc::CreateSessionDescription; | 80 using webrtc::CreateSessionDescription; |
| 82 using webrtc::CreateSessionDescriptionObserver; | 81 using webrtc::CreateSessionDescriptionObserver; |
| 83 using webrtc::CreateSessionDescriptionRequest; | 82 using webrtc::CreateSessionDescriptionRequest; |
| 84 using webrtc::DataChannel; | 83 using webrtc::DataChannel; |
| 85 using webrtc::DtlsIdentityStoreInterface; | 84 using webrtc::DtlsIdentityStoreInterface; |
| 86 using webrtc::FakeConstraints; | 85 using webrtc::FakeConstraints; |
| 87 using webrtc::FakeMetricsObserver; | 86 using webrtc::FakeMetricsObserver; |
| 88 using webrtc::IceCandidateCollection; | 87 using webrtc::IceCandidateCollection; |
| 89 using webrtc::InternalDataChannelInit; | 88 using webrtc::InternalDataChannelInit; |
| 90 using webrtc::JsepIceCandidate; | 89 using webrtc::JsepIceCandidate; |
| 91 using webrtc::JsepSessionDescription; | 90 using webrtc::JsepSessionDescription; |
| 92 using webrtc::PeerConnectionFactoryInterface; | 91 using webrtc::PeerConnectionFactoryInterface; |
| 93 using webrtc::PeerConnectionInterface; | 92 using webrtc::PeerConnectionInterface; |
| 94 using webrtc::SessionDescriptionInterface; | 93 using webrtc::SessionDescriptionInterface; |
| 94 using webrtc::SessionStats; |
| 95 using webrtc::StreamCollection; | 95 using webrtc::StreamCollection; |
| 96 using webrtc::WebRtcSession; | 96 using webrtc::WebRtcSession; |
| 97 using webrtc::kBundleWithoutRtcpMux; | 97 using webrtc::kBundleWithoutRtcpMux; |
| 98 using webrtc::kCreateChannelFailed; | 98 using webrtc::kCreateChannelFailed; |
| 99 using webrtc::kInvalidSdp; | 99 using webrtc::kInvalidSdp; |
| 100 using webrtc::kMlineMismatch; | 100 using webrtc::kMlineMismatch; |
| 101 using webrtc::kPushDownTDFailed; | 101 using webrtc::kPushDownTDFailed; |
| 102 using webrtc::kSdpWithoutIceUfragPwd; | 102 using webrtc::kSdpWithoutIceUfragPwd; |
| 103 using webrtc::kSdpWithoutDtlsFingerprint; | 103 using webrtc::kSdpWithoutDtlsFingerprint; |
| 104 using webrtc::kSdpWithoutSdesCrypto; | 104 using webrtc::kSdpWithoutSdesCrypto; |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 SessionDescriptionInterface* offer = CreateRemoteOffer(); | 850 SessionDescriptionInterface* offer = CreateRemoteOffer(); |
| 851 SetRemoteDescriptionWithoutError(offer); | 851 SetRemoteDescriptionWithoutError(offer); |
| 852 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 852 SessionDescriptionInterface* answer = CreateAnswer(NULL); |
| 853 SetLocalDescriptionWithoutError(answer); | 853 SetLocalDescriptionWithoutError(answer); |
| 854 } | 854 } |
| 855 void SetLocalDescriptionWithoutError(SessionDescriptionInterface* desc) { | 855 void SetLocalDescriptionWithoutError(SessionDescriptionInterface* desc) { |
| 856 EXPECT_TRUE(session_->SetLocalDescription(desc, NULL)); | 856 EXPECT_TRUE(session_->SetLocalDescription(desc, NULL)); |
| 857 session_->MaybeStartGathering(); | 857 session_->MaybeStartGathering(); |
| 858 } | 858 } |
| 859 void SetLocalDescriptionExpectState(SessionDescriptionInterface* desc, | 859 void SetLocalDescriptionExpectState(SessionDescriptionInterface* desc, |
| 860 BaseSession::State expected_state) { | 860 WebRtcSession::State expected_state) { |
| 861 SetLocalDescriptionWithoutError(desc); | 861 SetLocalDescriptionWithoutError(desc); |
| 862 EXPECT_EQ(expected_state, session_->state()); | 862 EXPECT_EQ(expected_state, session_->state()); |
| 863 } | 863 } |
| 864 void SetLocalDescriptionExpectError(const std::string& action, | 864 void SetLocalDescriptionExpectError(const std::string& action, |
| 865 const std::string& expected_error, | 865 const std::string& expected_error, |
| 866 SessionDescriptionInterface* desc) { | 866 SessionDescriptionInterface* desc) { |
| 867 std::string error; | 867 std::string error; |
| 868 EXPECT_FALSE(session_->SetLocalDescription(desc, &error)); | 868 EXPECT_FALSE(session_->SetLocalDescription(desc, &error)); |
| 869 std::string sdp_type = "local "; | 869 std::string sdp_type = "local "; |
| 870 sdp_type.append(action); | 870 sdp_type.append(action); |
| 871 EXPECT_NE(std::string::npos, error.find(sdp_type)); | 871 EXPECT_NE(std::string::npos, error.find(sdp_type)); |
| 872 EXPECT_NE(std::string::npos, error.find(expected_error)); | 872 EXPECT_NE(std::string::npos, error.find(expected_error)); |
| 873 } | 873 } |
| 874 void SetLocalDescriptionOfferExpectError(const std::string& expected_error, | 874 void SetLocalDescriptionOfferExpectError(const std::string& expected_error, |
| 875 SessionDescriptionInterface* desc) { | 875 SessionDescriptionInterface* desc) { |
| 876 SetLocalDescriptionExpectError(SessionDescriptionInterface::kOffer, | 876 SetLocalDescriptionExpectError(SessionDescriptionInterface::kOffer, |
| 877 expected_error, desc); | 877 expected_error, desc); |
| 878 } | 878 } |
| 879 void SetLocalDescriptionAnswerExpectError(const std::string& expected_error, | 879 void SetLocalDescriptionAnswerExpectError(const std::string& expected_error, |
| 880 SessionDescriptionInterface* desc) { | 880 SessionDescriptionInterface* desc) { |
| 881 SetLocalDescriptionExpectError(SessionDescriptionInterface::kAnswer, | 881 SetLocalDescriptionExpectError(SessionDescriptionInterface::kAnswer, |
| 882 expected_error, desc); | 882 expected_error, desc); |
| 883 } | 883 } |
| 884 void SetRemoteDescriptionWithoutError(SessionDescriptionInterface* desc) { | 884 void SetRemoteDescriptionWithoutError(SessionDescriptionInterface* desc) { |
| 885 EXPECT_TRUE(session_->SetRemoteDescription(desc, NULL)); | 885 EXPECT_TRUE(session_->SetRemoteDescription(desc, NULL)); |
| 886 } | 886 } |
| 887 void SetRemoteDescriptionExpectState(SessionDescriptionInterface* desc, | 887 void SetRemoteDescriptionExpectState(SessionDescriptionInterface* desc, |
| 888 BaseSession::State expected_state) { | 888 WebRtcSession::State expected_state) { |
| 889 SetRemoteDescriptionWithoutError(desc); | 889 SetRemoteDescriptionWithoutError(desc); |
| 890 EXPECT_EQ(expected_state, session_->state()); | 890 EXPECT_EQ(expected_state, session_->state()); |
| 891 } | 891 } |
| 892 void SetRemoteDescriptionExpectError(const std::string& action, | 892 void SetRemoteDescriptionExpectError(const std::string& action, |
| 893 const std::string& expected_error, | 893 const std::string& expected_error, |
| 894 SessionDescriptionInterface* desc) { | 894 SessionDescriptionInterface* desc) { |
| 895 std::string error; | 895 std::string error; |
| 896 EXPECT_FALSE(session_->SetRemoteDescription(desc, &error)); | 896 EXPECT_FALSE(session_->SetRemoteDescription(desc, &error)); |
| 897 std::string sdp_type = "remote "; | 897 std::string sdp_type = "remote "; |
| 898 sdp_type.append(action); | 898 sdp_type.append(action); |
| (...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1939 SessionDescriptionInterface* offer2 = CreateOffer(); | 1939 SessionDescriptionInterface* offer2 = CreateOffer(); |
| 1940 SetRemoteDescriptionWithoutError(offer2); | 1940 SetRemoteDescriptionWithoutError(offer2); |
| 1941 } | 1941 } |
| 1942 | 1942 |
| 1943 TEST_F(WebRtcSessionTest, TestSetLocalAndRemoteOffer) { | 1943 TEST_F(WebRtcSessionTest, TestSetLocalAndRemoteOffer) { |
| 1944 Init(); | 1944 Init(); |
| 1945 SendNothing(); | 1945 SendNothing(); |
| 1946 SessionDescriptionInterface* offer = CreateOffer(); | 1946 SessionDescriptionInterface* offer = CreateOffer(); |
| 1947 SetLocalDescriptionWithoutError(offer); | 1947 SetLocalDescriptionWithoutError(offer); |
| 1948 offer = CreateOffer(); | 1948 offer = CreateOffer(); |
| 1949 SetRemoteDescriptionOfferExpectError( | 1949 SetRemoteDescriptionOfferExpectError("Called in wrong state: STATE_SENTOFFER", |
| 1950 "Called in wrong state: STATE_SENTINITIATE", offer); | 1950 offer); |
| 1951 } | 1951 } |
| 1952 | 1952 |
| 1953 TEST_F(WebRtcSessionTest, TestSetRemoteAndLocalOffer) { | 1953 TEST_F(WebRtcSessionTest, TestSetRemoteAndLocalOffer) { |
| 1954 Init(); | 1954 Init(); |
| 1955 SendNothing(); | 1955 SendNothing(); |
| 1956 SessionDescriptionInterface* offer = CreateOffer(); | 1956 SessionDescriptionInterface* offer = CreateOffer(); |
| 1957 SetRemoteDescriptionWithoutError(offer); | 1957 SetRemoteDescriptionWithoutError(offer); |
| 1958 offer = CreateOffer(); | 1958 offer = CreateOffer(); |
| 1959 SetLocalDescriptionOfferExpectError( | 1959 SetLocalDescriptionOfferExpectError( |
| 1960 "Called in wrong state: STATE_RECEIVEDINITIATE", offer); | 1960 "Called in wrong state: STATE_RECEIVEDOFFER", offer); |
| 1961 } | 1961 } |
| 1962 | 1962 |
| 1963 TEST_F(WebRtcSessionTest, TestSetLocalPrAnswer) { | 1963 TEST_F(WebRtcSessionTest, TestSetLocalPrAnswer) { |
| 1964 Init(); | 1964 Init(); |
| 1965 SendNothing(); | 1965 SendNothing(); |
| 1966 SessionDescriptionInterface* offer = CreateRemoteOffer(); | 1966 SessionDescriptionInterface* offer = CreateRemoteOffer(); |
| 1967 SetRemoteDescriptionExpectState(offer, BaseSession::STATE_RECEIVEDINITIATE); | 1967 SetRemoteDescriptionExpectState(offer, WebRtcSession::STATE_RECEIVEDOFFER); |
| 1968 | 1968 |
| 1969 JsepSessionDescription* pranswer = static_cast<JsepSessionDescription*>( | 1969 JsepSessionDescription* pranswer = static_cast<JsepSessionDescription*>( |
| 1970 CreateAnswer(NULL)); | 1970 CreateAnswer(NULL)); |
| 1971 pranswer->set_type(SessionDescriptionInterface::kPrAnswer); | 1971 pranswer->set_type(SessionDescriptionInterface::kPrAnswer); |
| 1972 SetLocalDescriptionExpectState(pranswer, BaseSession::STATE_SENTPRACCEPT); | 1972 SetLocalDescriptionExpectState(pranswer, WebRtcSession::STATE_SENTPRANSWER); |
| 1973 | 1973 |
| 1974 SendAudioVideoStream1(); | 1974 SendAudioVideoStream1(); |
| 1975 JsepSessionDescription* pranswer2 = static_cast<JsepSessionDescription*>( | 1975 JsepSessionDescription* pranswer2 = static_cast<JsepSessionDescription*>( |
| 1976 CreateAnswer(NULL)); | 1976 CreateAnswer(NULL)); |
| 1977 pranswer2->set_type(SessionDescriptionInterface::kPrAnswer); | 1977 pranswer2->set_type(SessionDescriptionInterface::kPrAnswer); |
| 1978 | 1978 |
| 1979 SetLocalDescriptionExpectState(pranswer2, BaseSession::STATE_SENTPRACCEPT); | 1979 SetLocalDescriptionExpectState(pranswer2, WebRtcSession::STATE_SENTPRANSWER); |
| 1980 | 1980 |
| 1981 SendAudioVideoStream2(); | 1981 SendAudioVideoStream2(); |
| 1982 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 1982 SessionDescriptionInterface* answer = CreateAnswer(NULL); |
| 1983 SetLocalDescriptionExpectState(answer, BaseSession::STATE_SENTACCEPT); | 1983 SetLocalDescriptionExpectState(answer, WebRtcSession::STATE_INPROGRESS); |
| 1984 } | 1984 } |
| 1985 | 1985 |
| 1986 TEST_F(WebRtcSessionTest, TestSetRemotePrAnswer) { | 1986 TEST_F(WebRtcSessionTest, TestSetRemotePrAnswer) { |
| 1987 Init(); | 1987 Init(); |
| 1988 SendNothing(); | 1988 SendNothing(); |
| 1989 SessionDescriptionInterface* offer = CreateOffer(); | 1989 SessionDescriptionInterface* offer = CreateOffer(); |
| 1990 SetLocalDescriptionExpectState(offer, BaseSession::STATE_SENTINITIATE); | 1990 SetLocalDescriptionExpectState(offer, WebRtcSession::STATE_SENTOFFER); |
| 1991 | 1991 |
| 1992 JsepSessionDescription* pranswer = | 1992 JsepSessionDescription* pranswer = |
| 1993 CreateRemoteAnswer(session_->local_description()); | 1993 CreateRemoteAnswer(session_->local_description()); |
| 1994 pranswer->set_type(SessionDescriptionInterface::kPrAnswer); | 1994 pranswer->set_type(SessionDescriptionInterface::kPrAnswer); |
| 1995 | 1995 |
| 1996 SetRemoteDescriptionExpectState(pranswer, | 1996 SetRemoteDescriptionExpectState(pranswer, |
| 1997 BaseSession::STATE_RECEIVEDPRACCEPT); | 1997 WebRtcSession::STATE_RECEIVEDPRANSWER); |
| 1998 | 1998 |
| 1999 SendAudioVideoStream1(); | 1999 SendAudioVideoStream1(); |
| 2000 JsepSessionDescription* pranswer2 = | 2000 JsepSessionDescription* pranswer2 = |
| 2001 CreateRemoteAnswer(session_->local_description()); | 2001 CreateRemoteAnswer(session_->local_description()); |
| 2002 pranswer2->set_type(SessionDescriptionInterface::kPrAnswer); | 2002 pranswer2->set_type(SessionDescriptionInterface::kPrAnswer); |
| 2003 | 2003 |
| 2004 SetRemoteDescriptionExpectState(pranswer2, | 2004 SetRemoteDescriptionExpectState(pranswer2, |
| 2005 BaseSession::STATE_RECEIVEDPRACCEPT); | 2005 WebRtcSession::STATE_RECEIVEDPRANSWER); |
| 2006 | 2006 |
| 2007 SendAudioVideoStream2(); | 2007 SendAudioVideoStream2(); |
| 2008 SessionDescriptionInterface* answer = | 2008 SessionDescriptionInterface* answer = |
| 2009 CreateRemoteAnswer(session_->local_description()); | 2009 CreateRemoteAnswer(session_->local_description()); |
| 2010 SetRemoteDescriptionExpectState(answer, BaseSession::STATE_RECEIVEDACCEPT); | 2010 SetRemoteDescriptionExpectState(answer, WebRtcSession::STATE_INPROGRESS); |
| 2011 } | 2011 } |
| 2012 | 2012 |
| 2013 TEST_F(WebRtcSessionTest, TestSetLocalAnswerWithoutOffer) { | 2013 TEST_F(WebRtcSessionTest, TestSetLocalAnswerWithoutOffer) { |
| 2014 Init(); | 2014 Init(); |
| 2015 SendNothing(); | 2015 SendNothing(); |
| 2016 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 2016 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 2017 | 2017 |
| 2018 SessionDescriptionInterface* answer = | 2018 SessionDescriptionInterface* answer = |
| 2019 CreateRemoteAnswer(offer.get()); | 2019 CreateRemoteAnswer(offer.get()); |
| 2020 SetLocalDescriptionAnswerExpectError("Called in wrong state: STATE_INIT", | 2020 SetLocalDescriptionAnswerExpectError("Called in wrong state: STATE_INIT", |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2033 } | 2033 } |
| 2034 | 2034 |
| 2035 TEST_F(WebRtcSessionTest, TestAddRemoteCandidate) { | 2035 TEST_F(WebRtcSessionTest, TestAddRemoteCandidate) { |
| 2036 Init(); | 2036 Init(); |
| 2037 SendAudioVideoStream1(); | 2037 SendAudioVideoStream1(); |
| 2038 | 2038 |
| 2039 cricket::Candidate candidate; | 2039 cricket::Candidate candidate; |
| 2040 candidate.set_component(1); | 2040 candidate.set_component(1); |
| 2041 JsepIceCandidate ice_candidate1(kMediaContentName0, 0, candidate); | 2041 JsepIceCandidate ice_candidate1(kMediaContentName0, 0, candidate); |
| 2042 | 2042 |
| 2043 // Fail since we have not set a offer description. | 2043 // Fail since we have not set a remote description. |
| 2044 EXPECT_FALSE(session_->ProcessIceMessage(&ice_candidate1)); | 2044 EXPECT_FALSE(session_->ProcessIceMessage(&ice_candidate1)); |
| 2045 | 2045 |
| 2046 SessionDescriptionInterface* offer = CreateOffer(); | 2046 SessionDescriptionInterface* offer = CreateOffer(); |
| 2047 SetLocalDescriptionWithoutError(offer); | 2047 SetLocalDescriptionWithoutError(offer); |
| 2048 // Candidate should be allowed to add before remote description. | 2048 |
| 2049 // Fail since we have not set a remote description. |
| 2050 EXPECT_FALSE(session_->ProcessIceMessage(&ice_candidate1)); |
| 2051 |
| 2052 SessionDescriptionInterface* answer = CreateRemoteAnswer( |
| 2053 session_->local_description()); |
| 2054 SetRemoteDescriptionWithoutError(answer); |
| 2055 |
| 2049 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate1)); | 2056 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate1)); |
| 2050 candidate.set_component(2); | 2057 candidate.set_component(2); |
| 2051 JsepIceCandidate ice_candidate2(kMediaContentName0, 0, candidate); | 2058 JsepIceCandidate ice_candidate2(kMediaContentName0, 0, candidate); |
| 2052 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate2)); | 2059 EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate2)); |
| 2053 | 2060 |
| 2054 SessionDescriptionInterface* answer = CreateRemoteAnswer( | |
| 2055 session_->local_description()); | |
| 2056 SetRemoteDescriptionWithoutError(answer); | |
| 2057 | |
| 2058 // Verifying the candidates are copied properly from internal vector. | 2061 // Verifying the candidates are copied properly from internal vector. |
| 2059 const SessionDescriptionInterface* remote_desc = | 2062 const SessionDescriptionInterface* remote_desc = |
| 2060 session_->remote_description(); | 2063 session_->remote_description(); |
| 2061 ASSERT_TRUE(remote_desc != NULL); | 2064 ASSERT_TRUE(remote_desc != NULL); |
| 2062 ASSERT_EQ(2u, remote_desc->number_of_mediasections()); | 2065 ASSERT_EQ(2u, remote_desc->number_of_mediasections()); |
| 2063 const IceCandidateCollection* candidates = | 2066 const IceCandidateCollection* candidates = |
| 2064 remote_desc->candidates(kMediaContentIndex0); | 2067 remote_desc->candidates(kMediaContentIndex0); |
| 2065 ASSERT_EQ(2u, candidates->count()); | 2068 ASSERT_EQ(2u, candidates->count()); |
| 2066 EXPECT_EQ(kMediaContentIndex0, candidates->at(0)->sdp_mline_index()); | 2069 EXPECT_EQ(kMediaContentIndex0, candidates->at(0)->sdp_mline_index()); |
| 2067 EXPECT_EQ(kMediaContentName0, candidates->at(0)->sdp_mid()); | 2070 EXPECT_EQ(kMediaContentName0, candidates->at(0)->sdp_mid()); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2224 } | 2227 } |
| 2225 | 2228 |
| 2226 // Verifies TransportProxy and media channels are created with content names | 2229 // Verifies TransportProxy and media channels are created with content names |
| 2227 // present in the SessionDescription. | 2230 // present in the SessionDescription. |
| 2228 TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) { | 2231 TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) { |
| 2229 Init(); | 2232 Init(); |
| 2230 SendAudioVideoStream1(); | 2233 SendAudioVideoStream1(); |
| 2231 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 2234 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 2232 | 2235 |
| 2233 // CreateOffer creates session description with the content names "audio" and | 2236 // CreateOffer creates session description with the content names "audio" and |
| 2234 // "video". Goal is to modify these content names and verify transport channel | 2237 // "video". Goal is to modify these content names and verify transport |
| 2235 // proxy in the BaseSession, as proxies are created with the content names | 2238 // channels |
| 2239 // in the WebRtcSession, as channels are created with the content names |
| 2236 // present in SDP. | 2240 // present in SDP. |
| 2237 std::string sdp; | 2241 std::string sdp; |
| 2238 EXPECT_TRUE(offer->ToString(&sdp)); | 2242 EXPECT_TRUE(offer->ToString(&sdp)); |
| 2239 const std::string kAudioMid = "a=mid:audio"; | 2243 const std::string kAudioMid = "a=mid:audio"; |
| 2240 const std::string kAudioMidReplaceStr = "a=mid:audio_content_name"; | 2244 const std::string kAudioMidReplaceStr = "a=mid:audio_content_name"; |
| 2241 const std::string kVideoMid = "a=mid:video"; | 2245 const std::string kVideoMid = "a=mid:video"; |
| 2242 const std::string kVideoMidReplaceStr = "a=mid:video_content_name"; | 2246 const std::string kVideoMidReplaceStr = "a=mid:video_content_name"; |
| 2243 | 2247 |
| 2244 // Replacing |audio| with |audio_content_name|. | 2248 // Replacing |audio| with |audio_content_name|. |
| 2245 rtc::replace_substrs(kAudioMid.c_str(), kAudioMid.length(), | 2249 rtc::replace_substrs(kAudioMid.c_str(), kAudioMid.length(), |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2805 sdp.clear(); | 2809 sdp.clear(); |
| 2806 ModifyIceUfragPwdLines(offer.get(), "0123456789012444", | 2810 ModifyIceUfragPwdLines(offer.get(), "0123456789012444", |
| 2807 "abcdefghijklmnopqrstuvyz", &sdp); | 2811 "abcdefghijklmnopqrstuvyz", &sdp); |
| 2808 SessionDescriptionInterface* offer4 = | 2812 SessionDescriptionInterface* offer4 = |
| 2809 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); | 2813 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); |
| 2810 SetRemoteDescriptionWithoutError(offer4); | 2814 SetRemoteDescriptionWithoutError(offer4); |
| 2811 EXPECT_EQ(0, session_->remote_description()->candidates(0)->count()); | 2815 EXPECT_EQ(0, session_->remote_description()->candidates(0)->count()); |
| 2812 } | 2816 } |
| 2813 | 2817 |
| 2814 // Test that candidates sent to the "video" transport do not get pushed down to | 2818 // Test that candidates sent to the "video" transport do not get pushed down to |
| 2815 // the "audio" transport channel when bundling using TransportProxy. | 2819 // the "audio" transport channel when bundling. |
| 2816 TEST_F(WebRtcSessionTest, TestIgnoreCandidatesForUnusedTransportWhenBundling) { | 2820 TEST_F(WebRtcSessionTest, TestIgnoreCandidatesForUnusedTransportWhenBundling) { |
| 2817 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); | 2821 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
| 2818 | 2822 |
| 2819 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); | 2823 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); |
| 2820 SendAudioVideoStream1(); | 2824 SendAudioVideoStream1(); |
| 2821 | 2825 |
| 2822 PeerConnectionInterface::RTCOfferAnswerOptions options; | 2826 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2823 options.use_rtp_mux = true; | 2827 options.use_rtp_mux = true; |
| 2824 | 2828 |
| 2825 SessionDescriptionInterface* offer = CreateRemoteOffer(); | 2829 SessionDescriptionInterface* offer = CreateRemoteOffer(); |
| 2826 SetRemoteDescriptionWithoutError(offer); | 2830 SetRemoteDescriptionWithoutError(offer); |
| 2827 | 2831 |
| 2828 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 2832 SessionDescriptionInterface* answer = CreateAnswer(NULL); |
| 2829 SetLocalDescriptionWithoutError(answer); | 2833 SetLocalDescriptionWithoutError(answer); |
| 2830 | 2834 |
| 2831 EXPECT_EQ(session_->voice_rtp_transport_channel(), | 2835 EXPECT_EQ(session_->voice_rtp_transport_channel(), |
| 2832 session_->video_rtp_transport_channel()); | 2836 session_->video_rtp_transport_channel()); |
| 2833 | 2837 |
| 2834 cricket::BaseChannel* voice_channel = session_->voice_channel(); | 2838 cricket::BaseChannel* voice_channel = session_->voice_channel(); |
| 2835 ASSERT(voice_channel != NULL); | 2839 ASSERT(voice_channel != NULL); |
| 2836 | 2840 |
| 2837 // Checks if one of the transport channels contains a connection using a given | 2841 // Checks if one of the transport channels contains a connection using a given |
| 2838 // port. | 2842 // port. |
| 2839 auto connection_with_remote_port = [this, voice_channel](int port) { | 2843 auto connection_with_remote_port = [this, voice_channel](int port) { |
| 2840 cricket::SessionStats stats; | 2844 SessionStats stats; |
| 2841 session_->GetChannelTransportStats(voice_channel, &stats); | 2845 session_->GetChannelTransportStats(voice_channel, &stats); |
| 2842 for (auto& kv : stats.transport_stats) { | 2846 for (auto& kv : stats.transport_stats) { |
| 2843 for (auto& chan_stat : kv.second.channel_stats) { | 2847 for (auto& chan_stat : kv.second.channel_stats) { |
| 2844 for (auto& conn_info : chan_stat.connection_infos) { | 2848 for (auto& conn_info : chan_stat.connection_infos) { |
| 2845 if (conn_info.remote_candidate.address().port() == port) { | 2849 if (conn_info.remote_candidate.address().port() == port) { |
| 2846 return true; | 2850 return true; |
| 2847 } | 2851 } |
| 2848 } | 2852 } |
| 2849 } | 2853 } |
| 2850 } | 2854 } |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2989 session_->video_rtp_transport_channel()); | 2993 session_->video_rtp_transport_channel()); |
| 2990 | 2994 |
| 2991 SendAudioVideoStream2(); | 2995 SendAudioVideoStream2(); |
| 2992 cricket::MediaSessionOptions recv_options; | 2996 cricket::MediaSessionOptions recv_options; |
| 2993 recv_options.recv_audio = false; | 2997 recv_options.recv_audio = false; |
| 2994 recv_options.recv_video = true; | 2998 recv_options.recv_video = true; |
| 2995 SessionDescriptionInterface* answer = | 2999 SessionDescriptionInterface* answer = |
| 2996 CreateRemoteAnswer(session_->local_description(), recv_options); | 3000 CreateRemoteAnswer(session_->local_description(), recv_options); |
| 2997 SetRemoteDescriptionWithoutError(answer); | 3001 SetRemoteDescriptionWithoutError(answer); |
| 2998 | 3002 |
| 2999 EXPECT_TRUE(NULL == session_->voice_channel()); | 3003 EXPECT_TRUE(nullptr == session_->voice_channel()); |
| 3000 EXPECT_TRUE(NULL != session_->video_rtp_transport_channel()); | 3004 EXPECT_TRUE(nullptr != session_->video_rtp_transport_channel()); |
| 3001 | 3005 |
| 3002 session_->Terminate(); | 3006 session_->Close(); |
| 3003 EXPECT_TRUE(NULL == session_->voice_rtp_transport_channel()); | 3007 EXPECT_TRUE(nullptr == session_->voice_rtp_transport_channel()); |
| 3004 EXPECT_TRUE(NULL == session_->voice_rtcp_transport_channel()); | 3008 EXPECT_TRUE(nullptr == session_->voice_rtcp_transport_channel()); |
| 3005 EXPECT_TRUE(NULL == session_->video_rtp_transport_channel()); | 3009 EXPECT_TRUE(nullptr == session_->video_rtp_transport_channel()); |
| 3006 EXPECT_TRUE(NULL == session_->video_rtcp_transport_channel()); | 3010 EXPECT_TRUE(nullptr == session_->video_rtcp_transport_channel()); |
| 3007 } | 3011 } |
| 3008 | 3012 |
| 3009 // kBundlePolicyMaxBundle policy but no BUNDLE in the answer. | 3013 // kBundlePolicyMaxBundle policy but no BUNDLE in the answer. |
| 3010 TEST_F(WebRtcSessionTest, TestMaxBundleNoBundleInAnswer) { | 3014 TEST_F(WebRtcSessionTest, TestMaxBundleNoBundleInAnswer) { |
| 3011 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); | 3015 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); |
| 3012 SendAudioVideoStream1(); | 3016 SendAudioVideoStream1(); |
| 3013 | 3017 |
| 3014 PeerConnectionInterface::RTCOfferAnswerOptions options; | 3018 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 3015 options.use_rtp_mux = true; | 3019 options.use_rtp_mux = true; |
| 3016 | 3020 |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3342 ASSERT_EQ(3U, channel->dtmf_info_queue().size()); | 3346 ASSERT_EQ(3U, channel->dtmf_info_queue().size()); |
| 3343 const uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); | 3347 const uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); |
| 3344 EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[0], send_ssrc, 0, | 3348 EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[0], send_ssrc, 0, |
| 3345 expected_duration, expected_flags)); | 3349 expected_duration, expected_flags)); |
| 3346 EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[1], send_ssrc, 1, | 3350 EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[1], send_ssrc, 1, |
| 3347 expected_duration, expected_flags)); | 3351 expected_duration, expected_flags)); |
| 3348 EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[2], send_ssrc, 2, | 3352 EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[2], send_ssrc, 2, |
| 3349 expected_duration, expected_flags)); | 3353 expected_duration, expected_flags)); |
| 3350 } | 3354 } |
| 3351 | 3355 |
| 3352 // This test verifies the |initiator| flag when session initiates the call. | 3356 // This test verifies the |initial_offerer| flag when session initiates the |
| 3357 // call. |
| 3353 TEST_F(WebRtcSessionTest, TestInitiatorFlagAsOriginator) { | 3358 TEST_F(WebRtcSessionTest, TestInitiatorFlagAsOriginator) { |
| 3354 Init(); | 3359 Init(); |
| 3355 EXPECT_FALSE(session_->initiator()); | 3360 EXPECT_FALSE(session_->initial_offerer()); |
| 3356 SessionDescriptionInterface* offer = CreateOffer(); | 3361 SessionDescriptionInterface* offer = CreateOffer(); |
| 3357 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); | 3362 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); |
| 3358 SetLocalDescriptionWithoutError(offer); | 3363 SetLocalDescriptionWithoutError(offer); |
| 3359 EXPECT_TRUE(session_->initiator()); | 3364 EXPECT_TRUE(session_->initial_offerer()); |
| 3360 SetRemoteDescriptionWithoutError(answer); | 3365 SetRemoteDescriptionWithoutError(answer); |
| 3361 EXPECT_TRUE(session_->initiator()); | 3366 EXPECT_TRUE(session_->initial_offerer()); |
| 3362 } | 3367 } |
| 3363 | 3368 |
| 3364 // This test verifies the |initiator| flag when session receives the call. | 3369 // This test verifies the |initial_offerer| flag when session receives the call. |
| 3365 TEST_F(WebRtcSessionTest, TestInitiatorFlagAsReceiver) { | 3370 TEST_F(WebRtcSessionTest, TestInitiatorFlagAsReceiver) { |
| 3366 Init(); | 3371 Init(); |
| 3367 EXPECT_FALSE(session_->initiator()); | 3372 EXPECT_FALSE(session_->initial_offerer()); |
| 3368 SessionDescriptionInterface* offer = CreateRemoteOffer(); | 3373 SessionDescriptionInterface* offer = CreateRemoteOffer(); |
| 3369 SetRemoteDescriptionWithoutError(offer); | 3374 SetRemoteDescriptionWithoutError(offer); |
| 3370 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 3375 SessionDescriptionInterface* answer = CreateAnswer(NULL); |
| 3371 | 3376 |
| 3372 EXPECT_FALSE(session_->initiator()); | 3377 EXPECT_FALSE(session_->initial_offerer()); |
| 3373 SetLocalDescriptionWithoutError(answer); | 3378 SetLocalDescriptionWithoutError(answer); |
| 3374 EXPECT_FALSE(session_->initiator()); | 3379 EXPECT_FALSE(session_->initial_offerer()); |
| 3375 } | 3380 } |
| 3376 | 3381 |
| 3377 // Verifing local offer and remote answer have matching m-lines as per RFC 3264. | 3382 // Verifing local offer and remote answer have matching m-lines as per RFC 3264. |
| 3378 TEST_F(WebRtcSessionTest, TestIncorrectMLinesInRemoteAnswer) { | 3383 TEST_F(WebRtcSessionTest, TestIncorrectMLinesInRemoteAnswer) { |
| 3379 Init(); | 3384 Init(); |
| 3380 SendAudioVideoStream1(); | 3385 SendAudioVideoStream1(); |
| 3381 SessionDescriptionInterface* offer = CreateOffer(); | 3386 SessionDescriptionInterface* offer = CreateOffer(); |
| 3382 SetLocalDescriptionWithoutError(offer); | 3387 SetLocalDescriptionWithoutError(offer); |
| 3383 rtc::scoped_ptr<SessionDescriptionInterface> answer( | 3388 rtc::scoped_ptr<SessionDescriptionInterface> answer( |
| 3384 CreateRemoteAnswer(session_->local_description())); | 3389 CreateRemoteAnswer(session_->local_description())); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3576 Init(); | 3581 Init(); |
| 3577 SendAudioVideoStream1(); | 3582 SendAudioVideoStream1(); |
| 3578 SessionDescriptionInterface* offer = CreateOffer(); | 3583 SessionDescriptionInterface* offer = CreateOffer(); |
| 3579 const std::string session_id_orig = offer->session_id(); | 3584 const std::string session_id_orig = offer->session_id(); |
| 3580 const std::string session_version_orig = offer->session_version(); | 3585 const std::string session_version_orig = offer->session_version(); |
| 3581 SetLocalDescriptionWithoutError(offer); | 3586 SetLocalDescriptionWithoutError(offer); |
| 3582 | 3587 |
| 3583 video_channel_ = media_engine_->GetVideoChannel(0); | 3588 video_channel_ = media_engine_->GetVideoChannel(0); |
| 3584 video_channel_->set_fail_set_send_codecs(true); | 3589 video_channel_->set_fail_set_send_codecs(true); |
| 3585 | 3590 |
| 3586 SendAudioVideoStream2(); | |
| 3587 SessionDescriptionInterface* answer = | 3591 SessionDescriptionInterface* answer = |
| 3588 CreateRemoteAnswer(session_->local_description()); | 3592 CreateRemoteAnswer(session_->local_description()); |
| 3589 SetRemoteDescriptionAnswerExpectError("ERROR_CONTENT", answer); | 3593 SetRemoteDescriptionAnswerExpectError("ERROR_CONTENT", answer); |
| 3594 |
| 3595 // Test that after a content error, setting any description will |
| 3596 // result in an error. |
| 3597 video_channel_->set_fail_set_send_codecs(false); |
| 3598 answer = CreateRemoteAnswer(session_->local_description()); |
| 3599 SetRemoteDescriptionExpectError("", "ERROR_CONTENT", answer); |
| 3600 offer = CreateRemoteOffer(); |
| 3601 SetLocalDescriptionExpectError("", "ERROR_CONTENT", offer); |
| 3590 } | 3602 } |
| 3591 | 3603 |
| 3592 // Runs the loopback call test with BUNDLE and STUN disabled. | 3604 // Runs the loopback call test with BUNDLE and STUN disabled. |
| 3593 TEST_F(WebRtcSessionTest, TestIceStatesBasic) { | 3605 TEST_F(WebRtcSessionTest, TestIceStatesBasic) { |
| 3594 // Lets try with only UDP ports. | 3606 // Lets try with only UDP ports. |
| 3595 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | | 3607 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | |
| 3596 cricket::PORTALLOCATOR_DISABLE_STUN | | 3608 cricket::PORTALLOCATOR_DISABLE_STUN | |
| 3597 cricket::PORTALLOCATOR_DISABLE_RELAY); | 3609 cricket::PORTALLOCATOR_DISABLE_RELAY); |
| 3598 TestLoopbackCall(); | 3610 TestLoopbackCall(); |
| 3599 } | 3611 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3613 TestLoopbackCall(config); | 3625 TestLoopbackCall(config); |
| 3614 } | 3626 } |
| 3615 | 3627 |
| 3616 // Runs the loopback call test with BUNDLE and STUN enabled. | 3628 // Runs the loopback call test with BUNDLE and STUN enabled. |
| 3617 TEST_F(WebRtcSessionTest, TestIceStatesBundle) { | 3629 TEST_F(WebRtcSessionTest, TestIceStatesBundle) { |
| 3618 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | | 3630 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | |
| 3619 cricket::PORTALLOCATOR_DISABLE_RELAY); | 3631 cricket::PORTALLOCATOR_DISABLE_RELAY); |
| 3620 TestLoopbackCall(); | 3632 TestLoopbackCall(); |
| 3621 } | 3633 } |
| 3622 | 3634 |
| 3623 TEST_F(WebRtcSessionTest, SetSdpFailedOnSessionError) { | |
| 3624 Init(); | |
| 3625 cricket::MediaSessionOptions options; | |
| 3626 options.recv_video = true; | |
| 3627 | |
| 3628 cricket::BaseSession::Error error_code = cricket::BaseSession::ERROR_CONTENT; | |
| 3629 std::string error_code_str = "ERROR_CONTENT"; | |
| 3630 std::string error_desc = "Fake session error description."; | |
| 3631 session_->SetError(error_code, error_desc); | |
| 3632 | |
| 3633 SessionDescriptionInterface* offer = CreateRemoteOffer(options); | |
| 3634 SessionDescriptionInterface* answer = | |
| 3635 CreateRemoteAnswer(offer, options); | |
| 3636 | |
| 3637 std::string action; | |
| 3638 std::ostringstream session_error_msg; | |
| 3639 session_error_msg << kSessionError << error_code_str << ". "; | |
| 3640 session_error_msg << kSessionErrorDesc << error_desc << "."; | |
| 3641 SetRemoteDescriptionExpectError(action, session_error_msg.str(), offer); | |
| 3642 SetLocalDescriptionExpectError(action, session_error_msg.str(), answer); | |
| 3643 } | |
| 3644 | |
| 3645 TEST_F(WebRtcSessionTest, TestRtpDataChannel) { | 3635 TEST_F(WebRtcSessionTest, TestRtpDataChannel) { |
| 3646 constraints_.reset(new FakeConstraints()); | 3636 constraints_.reset(new FakeConstraints()); |
| 3647 constraints_->AddOptional( | 3637 constraints_->AddOptional( |
| 3648 webrtc::MediaConstraintsInterface::kEnableRtpDataChannels, true); | 3638 webrtc::MediaConstraintsInterface::kEnableRtpDataChannels, true); |
| 3649 Init(); | 3639 Init(); |
| 3650 | 3640 |
| 3651 SetLocalDescriptionWithDataChannel(); | 3641 SetLocalDescriptionWithDataChannel(); |
| 3652 EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type()); | 3642 EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type()); |
| 3653 } | 3643 } |
| 3654 | 3644 |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4165 } | 4155 } |
| 4166 | 4156 |
| 4167 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 4157 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
| 4168 // currently fails because upon disconnection and reconnection OnIceComplete is | 4158 // currently fails because upon disconnection and reconnection OnIceComplete is |
| 4169 // called more than once without returning to IceGatheringGathering. | 4159 // called more than once without returning to IceGatheringGathering. |
| 4170 | 4160 |
| 4171 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, | 4161 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, |
| 4172 WebRtcSessionTest, | 4162 WebRtcSessionTest, |
| 4173 testing::Values(ALREADY_GENERATED, | 4163 testing::Values(ALREADY_GENERATED, |
| 4174 DTLS_IDENTITY_STORE)); | 4164 DTLS_IDENTITY_STORE)); |
| OLD | NEW |