henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * libjingle |
jlmiller@webrtc.org | 5f93d0a | 2015-01-20 21:36:13 +0000 | [diff] [blame] | 3 | * Copyright 2012 Google Inc. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright notice, |
| 9 | * this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 12 | * and/or other materials provided with the distribution. |
| 13 | * 3. The name of the author may not be used to endorse or promote products |
| 14 | * derived from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 19 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 22 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 24 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 25 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
| 28 | #include "talk/app/webrtc/audiotrack.h" |
jbauch | ac8869e | 2015-07-03 01:36:14 -0700 | [diff] [blame] | 29 | #include "talk/app/webrtc/fakemetricsobserver.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 30 | #include "talk/app/webrtc/jsepicecandidate.h" |
| 31 | #include "talk/app/webrtc/jsepsessiondescription.h" |
| 32 | #include "talk/app/webrtc/mediastreamsignaling.h" |
| 33 | #include "talk/app/webrtc/streamcollection.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 34 | #include "talk/app/webrtc/test/fakeconstraints.h" |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 35 | #include "talk/app/webrtc/test/fakedtlsidentityservice.h" |
| 36 | #include "talk/app/webrtc/test/fakemediastreamsignaling.h" |
buildbot@webrtc.org | a09a999 | 2014-08-13 17:26:08 +0000 | [diff] [blame] | 37 | #include "talk/app/webrtc/videotrack.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 38 | #include "talk/app/webrtc/webrtcsession.h" |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 39 | #include "talk/app/webrtc/webrtcsessiondescriptionfactory.h" |
buildbot@webrtc.org | a09a999 | 2014-08-13 17:26:08 +0000 | [diff] [blame] | 40 | #include "talk/media/base/fakemediaengine.h" |
| 41 | #include "talk/media/base/fakevideorenderer.h" |
| 42 | #include "talk/media/base/mediachannel.h" |
| 43 | #include "talk/media/devices/fakedevicemanager.h" |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 44 | #include "webrtc/p2p/base/stunserver.h" |
| 45 | #include "webrtc/p2p/base/teststunserver.h" |
| 46 | #include "webrtc/p2p/base/testturnserver.h" |
pthatcher@webrtc.org | b4aac13 | 2015-03-13 18:25:21 +0000 | [diff] [blame] | 47 | #include "webrtc/p2p/base/transportchannel.h" |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 48 | #include "webrtc/p2p/client/basicportallocator.h" |
buildbot@webrtc.org | a09a999 | 2014-08-13 17:26:08 +0000 | [diff] [blame] | 49 | #include "talk/session/media/channelmanager.h" |
| 50 | #include "talk/session/media/mediasession.h" |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 51 | #include "webrtc/base/fakenetwork.h" |
| 52 | #include "webrtc/base/firewallsocketserver.h" |
| 53 | #include "webrtc/base/gunit.h" |
| 54 | #include "webrtc/base/logging.h" |
| 55 | #include "webrtc/base/network.h" |
| 56 | #include "webrtc/base/physicalsocketserver.h" |
| 57 | #include "webrtc/base/ssladapter.h" |
| 58 | #include "webrtc/base/sslstreamadapter.h" |
| 59 | #include "webrtc/base/stringutils.h" |
| 60 | #include "webrtc/base/thread.h" |
| 61 | #include "webrtc/base/virtualsocketserver.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 62 | |
| 63 | #define MAYBE_SKIP_TEST(feature) \ |
| 64 | if (!(feature())) { \ |
| 65 | LOG(LS_INFO) << "Feature disabled... skipping"; \ |
| 66 | return; \ |
| 67 | } |
| 68 | |
| 69 | using cricket::BaseSession; |
| 70 | using cricket::DF_PLAY; |
| 71 | using cricket::DF_SEND; |
| 72 | using cricket::FakeVoiceMediaChannel; |
| 73 | using cricket::NS_GINGLE_P2P; |
| 74 | using cricket::NS_JINGLE_ICE_UDP; |
| 75 | using cricket::TransportInfo; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 76 | using rtc::SocketAddress; |
| 77 | using rtc::scoped_ptr; |
| 78 | using rtc::Thread; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 79 | using webrtc::CreateSessionDescription; |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 80 | using webrtc::CreateSessionDescriptionObserver; |
| 81 | using webrtc::CreateSessionDescriptionRequest; |
| 82 | using webrtc::DTLSIdentityRequestObserver; |
| 83 | using webrtc::DTLSIdentityServiceInterface; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 84 | using webrtc::FakeConstraints; |
jbauch | ac8869e | 2015-07-03 01:36:14 -0700 | [diff] [blame] | 85 | using webrtc::FakeMetricsObserver; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 86 | using webrtc::IceCandidateCollection; |
| 87 | using webrtc::JsepIceCandidate; |
| 88 | using webrtc::JsepSessionDescription; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 89 | using webrtc::PeerConnectionFactoryInterface; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 90 | using webrtc::PeerConnectionInterface; |
| 91 | using webrtc::SessionDescriptionInterface; |
| 92 | using webrtc::StreamCollection; |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 93 | using webrtc::WebRtcSession; |
wu@webrtc.org | 364f204 | 2013-11-20 21:49:41 +0000 | [diff] [blame] | 94 | using webrtc::kBundleWithoutRtcpMux; |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 95 | using webrtc::kCreateChannelFailed; |
| 96 | using webrtc::kInvalidSdp; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 97 | using webrtc::kMlineMismatch; |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 98 | using webrtc::kPushDownTDFailed; |
mallinath@webrtc.org | 19f27e6 | 2013-10-13 17:18:27 +0000 | [diff] [blame] | 99 | using webrtc::kSdpWithoutIceUfragPwd; |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 100 | using webrtc::kSdpWithoutDtlsFingerprint; |
| 101 | using webrtc::kSdpWithoutSdesCrypto; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 102 | using webrtc::kSessionError; |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 103 | using webrtc::kSessionErrorDesc; |
buildbot@webrtc.org | 53df88c | 2014-08-07 22:46:01 +0000 | [diff] [blame] | 104 | using webrtc::kMaxUnsignalledRecvStreams; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 105 | |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 106 | typedef PeerConnectionInterface::RTCOfferAnswerOptions RTCOfferAnswerOptions; |
| 107 | |
wu@webrtc.org | 364f204 | 2013-11-20 21:49:41 +0000 | [diff] [blame] | 108 | static const int kClientAddrPort = 0; |
| 109 | static const char kClientAddrHost1[] = "11.11.11.11"; |
guoweis@webrtc.org | 7169afd | 2014-12-04 17:59:29 +0000 | [diff] [blame] | 110 | static const char kClientIPv6AddrHost1[] = |
| 111 | "2620:0:aaaa:bbbb:cccc:dddd:eeee:ffff"; |
wu@webrtc.org | 364f204 | 2013-11-20 21:49:41 +0000 | [diff] [blame] | 112 | static const char kClientAddrHost2[] = "22.22.22.22"; |
| 113 | static const char kStunAddrHost[] = "99.99.99.1"; |
buildbot@webrtc.org | 41451d4 | 2014-05-03 05:39:45 +0000 | [diff] [blame] | 114 | static const SocketAddress kTurnUdpIntAddr("99.99.99.4", 3478); |
| 115 | static const SocketAddress kTurnUdpExtAddr("99.99.99.6", 0); |
mallinath@webrtc.org | 3d81b1b | 2014-09-09 14:38:10 +0000 | [diff] [blame] | 116 | static const char kTurnUsername[] = "test"; |
| 117 | static const char kTurnPassword[] = "test"; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 118 | |
| 119 | static const char kSessionVersion[] = "1"; |
| 120 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 121 | // Media index of candidates belonging to the first media content. |
| 122 | static const int kMediaContentIndex0 = 0; |
| 123 | static const char kMediaContentName0[] = "audio"; |
| 124 | |
| 125 | // Media index of candidates belonging to the second media content. |
| 126 | static const int kMediaContentIndex1 = 1; |
| 127 | static const char kMediaContentName1[] = "video"; |
| 128 | |
| 129 | static const int kIceCandidatesTimeout = 10000; |
| 130 | |
mallinath@webrtc.org | a27be8e | 2013-09-27 23:04:10 +0000 | [diff] [blame] | 131 | static const char kFakeDtlsFingerprint[] = |
| 132 | "BB:CD:72:F7:2F:D0:BA:43:F3:68:B1:0C:23:72:B6:4A:" |
| 133 | "0F:DE:34:06:BC:E0:FE:01:BC:73:C8:6D:F4:65:D5:24"; |
| 134 | |
buildbot@webrtc.org | 7aa1a47 | 2014-05-23 17:33:05 +0000 | [diff] [blame] | 135 | static const char kTooLongIceUfragPwd[] = |
| 136 | "IceUfragIceUfragIceUfragIceUfragIceUfragIceUfragIceUfragIceUfragIceUfrag" |
| 137 | "IceUfragIceUfragIceUfragIceUfragIceUfragIceUfragIceUfragIceUfragIceUfrag" |
| 138 | "IceUfragIceUfragIceUfragIceUfragIceUfragIceUfragIceUfragIceUfragIceUfrag" |
| 139 | "IceUfragIceUfragIceUfragIceUfragIceUfragIceUfragIceUfragIceUfragIceUfrag"; |
| 140 | |
changbin.shao@webrtc.org | 2d25b44 | 2015-03-16 04:14:34 +0000 | [diff] [blame] | 141 | static const char kSdpWithRtx[] = |
| 142 | "v=0\r\n" |
| 143 | "o=- 4104004319237231850 2 IN IP4 127.0.0.1\r\n" |
| 144 | "s=-\r\n" |
| 145 | "t=0 0\r\n" |
| 146 | "a=msid-semantic: WMS stream1\r\n" |
| 147 | "m=video 9 RTP/SAVPF 0 96\r\n" |
| 148 | "c=IN IP4 0.0.0.0\r\n" |
| 149 | "a=rtcp:9 IN IP4 0.0.0.0\r\n" |
| 150 | "a=ice-ufrag:CerjGp19G7wpXwl7\r\n" |
| 151 | "a=ice-pwd:cMvOlFvQ6ochez1ZOoC2uBEC\r\n" |
| 152 | "a=mid:video\r\n" |
| 153 | "a=sendrecv\r\n" |
| 154 | "a=rtcp-mux\r\n" |
| 155 | "a=crypto:1 AES_CM_128_HMAC_SHA1_80 " |
| 156 | "inline:5/4N5CDvMiyDArHtBByUM71VIkguH17ZNoX60GrA\r\n" |
| 157 | "a=rtpmap:0 fake_video_codec/90000\r\n" |
| 158 | "a=rtpmap:96 rtx/90000\r\n" |
| 159 | "a=fmtp:96 apt=0\r\n"; |
| 160 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 161 | // Add some extra |newlines| to the |message| after |line|. |
| 162 | static void InjectAfter(const std::string& line, |
| 163 | const std::string& newlines, |
| 164 | std::string* message) { |
| 165 | const std::string tmp = line + newlines; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 166 | rtc::replace_substrs(line.c_str(), line.length(), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 167 | tmp.c_str(), tmp.length(), message); |
| 168 | } |
| 169 | |
| 170 | class MockIceObserver : public webrtc::IceObserver { |
| 171 | public: |
| 172 | MockIceObserver() |
| 173 | : oncandidatesready_(false), |
| 174 | ice_connection_state_(PeerConnectionInterface::kIceConnectionNew), |
| 175 | ice_gathering_state_(PeerConnectionInterface::kIceGatheringNew) { |
| 176 | } |
| 177 | |
| 178 | virtual void OnIceConnectionChange( |
| 179 | PeerConnectionInterface::IceConnectionState new_state) { |
| 180 | ice_connection_state_ = new_state; |
| 181 | } |
| 182 | virtual void OnIceGatheringChange( |
| 183 | PeerConnectionInterface::IceGatheringState new_state) { |
| 184 | // We can never transition back to "new". |
| 185 | EXPECT_NE(PeerConnectionInterface::kIceGatheringNew, new_state); |
| 186 | ice_gathering_state_ = new_state; |
| 187 | |
| 188 | // oncandidatesready_ really means "ICE gathering is complete". |
| 189 | // This if statement ensures that this value remains correct when we |
| 190 | // transition from kIceGatheringComplete to kIceGatheringGathering. |
| 191 | if (new_state == PeerConnectionInterface::kIceGatheringGathering) { |
| 192 | oncandidatesready_ = false; |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | // Found a new candidate. |
| 197 | virtual void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) { |
wu@webrtc.org | 364f204 | 2013-11-20 21:49:41 +0000 | [diff] [blame] | 198 | switch (candidate->sdp_mline_index()) { |
| 199 | case kMediaContentIndex0: |
| 200 | mline_0_candidates_.push_back(candidate->candidate()); |
| 201 | break; |
| 202 | case kMediaContentIndex1: |
| 203 | mline_1_candidates_.push_back(candidate->candidate()); |
| 204 | break; |
| 205 | default: |
| 206 | ASSERT(false); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 207 | } |
wu@webrtc.org | 364f204 | 2013-11-20 21:49:41 +0000 | [diff] [blame] | 208 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 209 | // The ICE gathering state should always be Gathering when a candidate is |
| 210 | // received (or possibly Completed in the case of the final candidate). |
| 211 | EXPECT_NE(PeerConnectionInterface::kIceGatheringNew, ice_gathering_state_); |
| 212 | } |
| 213 | |
| 214 | // TODO(bemasc): Remove this once callers transition to OnIceGatheringChange. |
| 215 | virtual void OnIceComplete() { |
| 216 | EXPECT_FALSE(oncandidatesready_); |
| 217 | oncandidatesready_ = true; |
| 218 | |
| 219 | // OnIceGatheringChange(IceGatheringCompleted) and OnIceComplete() should |
| 220 | // be called approximately simultaneously. For ease of testing, this |
| 221 | // check additionally requires that they be called in the above order. |
| 222 | EXPECT_EQ(PeerConnectionInterface::kIceGatheringComplete, |
| 223 | ice_gathering_state_); |
| 224 | } |
| 225 | |
| 226 | bool oncandidatesready_; |
| 227 | std::vector<cricket::Candidate> mline_0_candidates_; |
| 228 | std::vector<cricket::Candidate> mline_1_candidates_; |
| 229 | PeerConnectionInterface::IceConnectionState ice_connection_state_; |
| 230 | PeerConnectionInterface::IceGatheringState ice_gathering_state_; |
| 231 | }; |
| 232 | |
| 233 | class WebRtcSessionForTest : public webrtc::WebRtcSession { |
| 234 | public: |
| 235 | WebRtcSessionForTest(cricket::ChannelManager* cmgr, |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 236 | rtc::Thread* signaling_thread, |
| 237 | rtc::Thread* worker_thread, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 238 | cricket::PortAllocator* port_allocator, |
| 239 | webrtc::IceObserver* ice_observer, |
| 240 | webrtc::MediaStreamSignaling* mediastream_signaling) |
| 241 | : WebRtcSession(cmgr, signaling_thread, worker_thread, port_allocator, |
| 242 | mediastream_signaling) { |
| 243 | RegisterIceObserver(ice_observer); |
| 244 | } |
| 245 | virtual ~WebRtcSessionForTest() {} |
| 246 | |
| 247 | using cricket::BaseSession::GetTransportProxy; |
| 248 | using webrtc::WebRtcSession::SetAudioPlayout; |
| 249 | using webrtc::WebRtcSession::SetAudioSend; |
| 250 | using webrtc::WebRtcSession::SetCaptureDevice; |
| 251 | using webrtc::WebRtcSession::SetVideoPlayout; |
| 252 | using webrtc::WebRtcSession::SetVideoSend; |
| 253 | }; |
| 254 | |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 255 | class WebRtcSessionCreateSDPObserverForTest |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 256 | : public rtc::RefCountedObject<CreateSessionDescriptionObserver> { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 257 | public: |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 258 | enum State { |
| 259 | kInit, |
| 260 | kFailed, |
| 261 | kSucceeded, |
| 262 | }; |
mallinath@webrtc.org | a550669 | 2013-08-12 21:18:15 +0000 | [diff] [blame] | 263 | WebRtcSessionCreateSDPObserverForTest() : state_(kInit) {} |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 264 | |
| 265 | // CreateSessionDescriptionObserver implementation. |
| 266 | virtual void OnSuccess(SessionDescriptionInterface* desc) { |
mallinath@webrtc.org | a550669 | 2013-08-12 21:18:15 +0000 | [diff] [blame] | 267 | description_.reset(desc); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 268 | state_ = kSucceeded; |
| 269 | } |
| 270 | virtual void OnFailure(const std::string& error) { |
| 271 | state_ = kFailed; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 272 | } |
| 273 | |
mallinath@webrtc.org | a550669 | 2013-08-12 21:18:15 +0000 | [diff] [blame] | 274 | SessionDescriptionInterface* description() { return description_.get(); } |
| 275 | |
| 276 | SessionDescriptionInterface* ReleaseDescription() { |
| 277 | return description_.release(); |
| 278 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 279 | |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 280 | State state() const { return state_; } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 281 | |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 282 | protected: |
| 283 | ~WebRtcSessionCreateSDPObserverForTest() {} |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 284 | |
| 285 | private: |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 286 | rtc::scoped_ptr<SessionDescriptionInterface> description_; |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 287 | State state_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 288 | }; |
| 289 | |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 290 | class FakeAudioRenderer : public cricket::AudioRenderer { |
| 291 | public: |
henrike@webrtc.org | a7b9818 | 2014-02-21 15:51:43 +0000 | [diff] [blame] | 292 | FakeAudioRenderer() : channel_id_(-1), sink_(NULL) {} |
| 293 | virtual ~FakeAudioRenderer() { |
| 294 | if (sink_) |
| 295 | sink_->OnClose(); |
| 296 | } |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 297 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 298 | void AddChannel(int channel_id) override { |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 299 | ASSERT(channel_id_ == -1); |
| 300 | channel_id_ = channel_id; |
| 301 | } |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 302 | void RemoveChannel(int channel_id) override { |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 303 | ASSERT(channel_id == channel_id_); |
| 304 | channel_id_ = -1; |
| 305 | } |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 306 | void SetSink(Sink* sink) override { sink_ = sink; } |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 307 | |
| 308 | int channel_id() const { return channel_id_; } |
henrike@webrtc.org | a7b9818 | 2014-02-21 15:51:43 +0000 | [diff] [blame] | 309 | cricket::AudioRenderer::Sink* sink() const { return sink_; } |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 310 | private: |
| 311 | int channel_id_; |
henrike@webrtc.org | a7b9818 | 2014-02-21 15:51:43 +0000 | [diff] [blame] | 312 | cricket::AudioRenderer::Sink* sink_; |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 313 | }; |
| 314 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 315 | class WebRtcSessionTest : public testing::Test { |
| 316 | protected: |
| 317 | // TODO Investigate why ChannelManager crashes, if it's created |
| 318 | // after stun_server. |
| 319 | WebRtcSessionTest() |
| 320 | : media_engine_(new cricket::FakeMediaEngine()), |
| 321 | data_engine_(new cricket::FakeDataEngine()), |
| 322 | device_manager_(new cricket::FakeDeviceManager()), |
| 323 | channel_manager_(new cricket::ChannelManager( |
| 324 | media_engine_, data_engine_, device_manager_, |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 325 | new cricket::CaptureManager(), rtc::Thread::Current())), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 326 | tdesc_factory_(new cricket::TransportDescriptionFactory()), |
| 327 | desc_factory_(new cricket::MediaSessionDescriptionFactory( |
| 328 | channel_manager_.get(), tdesc_factory_.get())), |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 329 | pss_(new rtc::PhysicalSocketServer), |
| 330 | vss_(new rtc::VirtualSocketServer(pss_.get())), |
| 331 | fss_(new rtc::FirewallSocketServer(vss_.get())), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 332 | ss_scope_(fss_.get()), |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 333 | stun_socket_addr_(rtc::SocketAddress(kStunAddrHost, |
wu@webrtc.org | 364f204 | 2013-11-20 21:49:41 +0000 | [diff] [blame] | 334 | cricket::STUN_SERVER_PORT)), |
jiayl@webrtc.org | bebc75e | 2014-09-26 23:01:11 +0000 | [diff] [blame] | 335 | stun_server_(cricket::TestStunServer::Create(Thread::Current(), |
| 336 | stun_socket_addr_)), |
buildbot@webrtc.org | 41451d4 | 2014-05-03 05:39:45 +0000 | [diff] [blame] | 337 | turn_server_(Thread::Current(), kTurnUdpIntAddr, kTurnUdpExtAddr), |
jbauch | ac8869e | 2015-07-03 01:36:14 -0700 | [diff] [blame] | 338 | mediastream_signaling_(channel_manager_.get()), |
| 339 | metrics_observer_(new rtc::RefCountedObject<FakeMetricsObserver>()) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 340 | tdesc_factory_->set_protocol(cricket::ICEPROTO_HYBRID); |
buildbot@webrtc.org | 51c5508 | 2014-07-28 22:26:15 +0000 | [diff] [blame] | 341 | |
| 342 | cricket::ServerAddresses stun_servers; |
| 343 | stun_servers.insert(stun_socket_addr_); |
| 344 | allocator_.reset(new cricket::BasicPortAllocator( |
| 345 | &network_manager_, |
| 346 | stun_servers, |
| 347 | SocketAddress(), SocketAddress(), SocketAddress())); |
buildbot@webrtc.org | 41451d4 | 2014-05-03 05:39:45 +0000 | [diff] [blame] | 348 | allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 349 | cricket::PORTALLOCATOR_DISABLE_RELAY | |
jiayl@webrtc.org | dacdd94 | 2015-01-23 17:33:34 +0000 | [diff] [blame] | 350 | cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 351 | EXPECT_TRUE(channel_manager_->Init()); |
| 352 | desc_factory_->set_add_legacy_streams(false); |
buildbot@webrtc.org | 41451d4 | 2014-05-03 05:39:45 +0000 | [diff] [blame] | 353 | allocator_->set_step_delay(cricket::kMinimumStepDelay); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 354 | } |
| 355 | |
| 356 | void AddInterface(const SocketAddress& addr) { |
| 357 | network_manager_.AddInterface(addr); |
| 358 | } |
| 359 | |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 360 | void Init( |
| 361 | DTLSIdentityServiceInterface* identity_service, |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 362 | const PeerConnectionInterface::RTCConfiguration& rtc_configuration) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 363 | ASSERT_TRUE(session_.get() == NULL); |
| 364 | session_.reset(new WebRtcSessionForTest( |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 365 | channel_manager_.get(), rtc::Thread::Current(), |
| 366 | rtc::Thread::Current(), allocator_.get(), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 367 | &observer_, |
| 368 | &mediastream_signaling_)); |
| 369 | |
| 370 | EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, |
| 371 | observer_.ice_connection_state_); |
| 372 | EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, |
| 373 | observer_.ice_gathering_state_); |
| 374 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 375 | EXPECT_TRUE(session_->Initialize(options_, constraints_.get(), |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 376 | identity_service, rtc_configuration)); |
jbauch | ac8869e | 2015-07-03 01:36:14 -0700 | [diff] [blame] | 377 | session_->set_metrics_observer(metrics_observer_); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 378 | } |
| 379 | |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 380 | void Init() { |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 381 | PeerConnectionInterface::RTCConfiguration configuration; |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 382 | Init(NULL, configuration); |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | void InitWithIceTransport( |
| 386 | PeerConnectionInterface::IceTransportsType ice_transport_type) { |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 387 | PeerConnectionInterface::RTCConfiguration configuration; |
| 388 | configuration.type = ice_transport_type; |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 389 | Init(NULL, configuration); |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | void InitWithBundlePolicy( |
| 393 | PeerConnectionInterface::BundlePolicy bundle_policy) { |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 394 | PeerConnectionInterface::RTCConfiguration configuration; |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 395 | configuration.bundle_policy = bundle_policy; |
Peter Thatcher | af55ccc | 2015-05-21 07:48:41 -0700 | [diff] [blame] | 396 | Init(NULL, configuration); |
| 397 | } |
| 398 | |
| 399 | void InitWithRtcpMuxPolicy( |
| 400 | PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) { |
| 401 | PeerConnectionInterface::RTCConfiguration configuration; |
| 402 | configuration.rtcp_mux_policy = rtcp_mux_policy; |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 403 | Init(NULL, configuration); |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 404 | } |
| 405 | |
| 406 | void InitWithDtls(bool identity_request_should_fail = false) { |
| 407 | FakeIdentityService* identity_service = new FakeIdentityService(); |
| 408 | identity_service->set_should_fail(identity_request_should_fail); |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 409 | PeerConnectionInterface::RTCConfiguration configuration; |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 410 | Init(identity_service, configuration); |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 411 | } |
| 412 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 413 | void InitWithDtmfCodec() { |
| 414 | // Add kTelephoneEventCodec for dtmf test. |
wu@webrtc.org | 364f204 | 2013-11-20 21:49:41 +0000 | [diff] [blame] | 415 | const cricket::AudioCodec kTelephoneEventCodec( |
| 416 | 106, "telephone-event", 8000, 0, 1, 0); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 417 | std::vector<cricket::AudioCodec> codecs; |
| 418 | codecs.push_back(kTelephoneEventCodec); |
| 419 | media_engine_->SetAudioCodecs(codecs); |
| 420 | desc_factory_->set_audio_codecs(codecs); |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 421 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 422 | } |
| 423 | |
| 424 | // Creates a local offer and applies it. Starts ice. |
| 425 | // Call mediastream_signaling_.UseOptionsWithStreamX() before this function |
| 426 | // to decide which streams to create. |
| 427 | void InitiateCall() { |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 428 | SessionDescriptionInterface* offer = CreateOffer(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 429 | SetLocalDescriptionWithoutError(offer); |
| 430 | EXPECT_TRUE_WAIT(PeerConnectionInterface::kIceGatheringNew != |
| 431 | observer_.ice_gathering_state_, |
| 432 | kIceCandidatesTimeout); |
| 433 | } |
| 434 | |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 435 | SessionDescriptionInterface* CreateOffer() { |
| 436 | PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 437 | options.offer_to_receive_audio = |
| 438 | RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; |
| 439 | |
| 440 | return CreateOffer(options); |
| 441 | } |
| 442 | |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 443 | SessionDescriptionInterface* CreateOffer( |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 444 | const PeerConnectionInterface::RTCOfferAnswerOptions& options) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 445 | rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 446 | observer = new WebRtcSessionCreateSDPObserverForTest(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 447 | session_->CreateOffer(observer, options); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 448 | EXPECT_TRUE_WAIT( |
| 449 | observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit, |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 450 | 2000); |
mallinath@webrtc.org | a550669 | 2013-08-12 21:18:15 +0000 | [diff] [blame] | 451 | return observer->ReleaseDescription(); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 452 | } |
| 453 | |
| 454 | SessionDescriptionInterface* CreateAnswer( |
| 455 | const webrtc::MediaConstraintsInterface* constraints) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 456 | rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> observer |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 457 | = new WebRtcSessionCreateSDPObserverForTest(); |
| 458 | session_->CreateAnswer(observer, constraints); |
| 459 | EXPECT_TRUE_WAIT( |
| 460 | observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit, |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 461 | 2000); |
mallinath@webrtc.org | a550669 | 2013-08-12 21:18:15 +0000 | [diff] [blame] | 462 | return observer->ReleaseDescription(); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 463 | } |
| 464 | |
wu@webrtc.org | 364f204 | 2013-11-20 21:49:41 +0000 | [diff] [blame] | 465 | bool ChannelsExist() const { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 466 | return (session_->voice_channel() != NULL && |
| 467 | session_->video_channel() != NULL); |
| 468 | } |
| 469 | |
wu@webrtc.org | 364f204 | 2013-11-20 21:49:41 +0000 | [diff] [blame] | 470 | void CheckTransportChannels() const { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 471 | EXPECT_TRUE(session_->GetChannel(cricket::CN_AUDIO, 1) != NULL); |
| 472 | EXPECT_TRUE(session_->GetChannel(cricket::CN_AUDIO, 2) != NULL); |
| 473 | EXPECT_TRUE(session_->GetChannel(cricket::CN_VIDEO, 1) != NULL); |
| 474 | EXPECT_TRUE(session_->GetChannel(cricket::CN_VIDEO, 2) != NULL); |
| 475 | } |
| 476 | |
| 477 | void VerifyCryptoParams(const cricket::SessionDescription* sdp) { |
| 478 | ASSERT_TRUE(session_.get() != NULL); |
| 479 | const cricket::ContentInfo* content = cricket::GetFirstAudioContent(sdp); |
| 480 | ASSERT_TRUE(content != NULL); |
| 481 | const cricket::AudioContentDescription* audio_content = |
| 482 | static_cast<const cricket::AudioContentDescription*>( |
| 483 | content->description); |
| 484 | ASSERT_TRUE(audio_content != NULL); |
| 485 | ASSERT_EQ(1U, audio_content->cryptos().size()); |
| 486 | ASSERT_EQ(47U, audio_content->cryptos()[0].key_params.size()); |
| 487 | ASSERT_EQ("AES_CM_128_HMAC_SHA1_80", |
| 488 | audio_content->cryptos()[0].cipher_suite); |
| 489 | EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), |
| 490 | audio_content->protocol()); |
| 491 | |
| 492 | content = cricket::GetFirstVideoContent(sdp); |
| 493 | ASSERT_TRUE(content != NULL); |
| 494 | const cricket::VideoContentDescription* video_content = |
| 495 | static_cast<const cricket::VideoContentDescription*>( |
| 496 | content->description); |
| 497 | ASSERT_TRUE(video_content != NULL); |
| 498 | ASSERT_EQ(1U, video_content->cryptos().size()); |
| 499 | ASSERT_EQ("AES_CM_128_HMAC_SHA1_80", |
| 500 | video_content->cryptos()[0].cipher_suite); |
| 501 | ASSERT_EQ(47U, video_content->cryptos()[0].key_params.size()); |
| 502 | EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), |
| 503 | video_content->protocol()); |
| 504 | } |
| 505 | |
| 506 | void VerifyNoCryptoParams(const cricket::SessionDescription* sdp, bool dtls) { |
| 507 | const cricket::ContentInfo* content = cricket::GetFirstAudioContent(sdp); |
| 508 | ASSERT_TRUE(content != NULL); |
| 509 | const cricket::AudioContentDescription* audio_content = |
| 510 | static_cast<const cricket::AudioContentDescription*>( |
| 511 | content->description); |
| 512 | ASSERT_TRUE(audio_content != NULL); |
| 513 | ASSERT_EQ(0U, audio_content->cryptos().size()); |
| 514 | |
| 515 | content = cricket::GetFirstVideoContent(sdp); |
| 516 | ASSERT_TRUE(content != NULL); |
| 517 | const cricket::VideoContentDescription* video_content = |
| 518 | static_cast<const cricket::VideoContentDescription*>( |
| 519 | content->description); |
| 520 | ASSERT_TRUE(video_content != NULL); |
| 521 | ASSERT_EQ(0U, video_content->cryptos().size()); |
| 522 | |
| 523 | if (dtls) { |
deadbeef | f393829 | 2015-07-15 12:20:53 -0700 | [diff] [blame] | 524 | EXPECT_EQ(std::string(cricket::kMediaProtocolDtlsSavpf), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 525 | audio_content->protocol()); |
deadbeef | f393829 | 2015-07-15 12:20:53 -0700 | [diff] [blame] | 526 | EXPECT_EQ(std::string(cricket::kMediaProtocolDtlsSavpf), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 527 | video_content->protocol()); |
| 528 | } else { |
| 529 | EXPECT_EQ(std::string(cricket::kMediaProtocolAvpf), |
| 530 | audio_content->protocol()); |
| 531 | EXPECT_EQ(std::string(cricket::kMediaProtocolAvpf), |
| 532 | video_content->protocol()); |
| 533 | } |
| 534 | } |
| 535 | |
| 536 | // Set the internal fake description factories to do DTLS-SRTP. |
| 537 | void SetFactoryDtlsSrtp() { |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 538 | desc_factory_->set_secure(cricket::SEC_DISABLED); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 539 | std::string identity_name = "WebRTC" + |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 540 | rtc::ToString(rtc::CreateRandomId()); |
| 541 | identity_.reset(rtc::SSLIdentity::Generate(identity_name)); |
henrike@webrtc.org | 723d683 | 2013-07-12 16:04:50 +0000 | [diff] [blame] | 542 | tdesc_factory_->set_identity(identity_.get()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 543 | tdesc_factory_->set_secure(cricket::SEC_REQUIRED); |
| 544 | } |
| 545 | |
| 546 | void VerifyFingerprintStatus(const cricket::SessionDescription* sdp, |
| 547 | bool expected) { |
| 548 | const TransportInfo* audio = sdp->GetTransportInfoByName("audio"); |
| 549 | ASSERT_TRUE(audio != NULL); |
| 550 | ASSERT_EQ(expected, audio->description.identity_fingerprint.get() != NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 551 | const TransportInfo* video = sdp->GetTransportInfoByName("video"); |
| 552 | ASSERT_TRUE(video != NULL); |
| 553 | ASSERT_EQ(expected, video->description.identity_fingerprint.get() != NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 554 | } |
| 555 | |
| 556 | void VerifyAnswerFromNonCryptoOffer() { |
jiayl@webrtc.org | 7d4891d | 2014-09-09 21:43:15 +0000 | [diff] [blame] | 557 | // Create an SDP without Crypto. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 558 | cricket::MediaSessionOptions options; |
jiayl@webrtc.org | 742922b | 2014-10-07 21:32:43 +0000 | [diff] [blame] | 559 | options.recv_video = true; |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 560 | JsepSessionDescription* offer( |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 561 | CreateRemoteOffer(options, cricket::SEC_DISABLED)); |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 562 | ASSERT_TRUE(offer != NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 563 | VerifyNoCryptoParams(offer->description(), false); |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 564 | SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesCrypto, |
| 565 | offer); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 566 | const webrtc::SessionDescriptionInterface* answer = CreateAnswer(NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 567 | // Answer should be NULL as no crypto params in offer. |
| 568 | ASSERT_TRUE(answer == NULL); |
| 569 | } |
| 570 | |
| 571 | void VerifyAnswerFromCryptoOffer() { |
| 572 | cricket::MediaSessionOptions options; |
jiayl@webrtc.org | 742922b | 2014-10-07 21:32:43 +0000 | [diff] [blame] | 573 | options.recv_video = true; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 574 | options.bundle_enabled = true; |
| 575 | scoped_ptr<JsepSessionDescription> offer( |
| 576 | CreateRemoteOffer(options, cricket::SEC_REQUIRED)); |
| 577 | ASSERT_TRUE(offer.get() != NULL); |
| 578 | VerifyCryptoParams(offer->description()); |
| 579 | SetRemoteDescriptionWithoutError(offer.release()); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 580 | scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 581 | ASSERT_TRUE(answer.get() != NULL); |
| 582 | VerifyCryptoParams(answer->description()); |
| 583 | } |
| 584 | |
buildbot@webrtc.org | 53df88c | 2014-08-07 22:46:01 +0000 | [diff] [blame] | 585 | void SetAndVerifyNumUnsignalledRecvStreams( |
| 586 | int value_set, int value_expected) { |
| 587 | constraints_.reset(new FakeConstraints()); |
| 588 | constraints_->AddOptional( |
| 589 | webrtc::MediaConstraintsInterface::kNumUnsignalledRecvStreams, |
| 590 | value_set); |
| 591 | session_.reset(); |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 592 | Init(); |
buildbot@webrtc.org | 53df88c | 2014-08-07 22:46:01 +0000 | [diff] [blame] | 593 | mediastream_signaling_.SendAudioVideoStream1(); |
| 594 | SessionDescriptionInterface* offer = CreateOffer(); |
| 595 | |
| 596 | SetLocalDescriptionWithoutError(offer); |
| 597 | |
| 598 | video_channel_ = media_engine_->GetVideoChannel(0); |
| 599 | |
| 600 | ASSERT_TRUE(video_channel_ != NULL); |
| 601 | cricket::VideoOptions video_options; |
| 602 | EXPECT_TRUE(video_channel_->GetOptions(&video_options)); |
| 603 | EXPECT_EQ(value_expected, |
| 604 | video_options.unsignalled_recv_stream_limit.GetWithDefaultIfUnset(-1)); |
| 605 | } |
| 606 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 607 | void CompareIceUfragAndPassword(const cricket::SessionDescription* desc1, |
| 608 | const cricket::SessionDescription* desc2, |
| 609 | bool expect_equal) { |
| 610 | if (desc1->contents().size() != desc2->contents().size()) { |
| 611 | EXPECT_FALSE(expect_equal); |
| 612 | return; |
| 613 | } |
| 614 | |
| 615 | const cricket::ContentInfos& contents = desc1->contents(); |
| 616 | cricket::ContentInfos::const_iterator it = contents.begin(); |
| 617 | |
| 618 | for (; it != contents.end(); ++it) { |
| 619 | const cricket::TransportDescription* transport_desc1 = |
| 620 | desc1->GetTransportDescriptionByName(it->name); |
| 621 | const cricket::TransportDescription* transport_desc2 = |
| 622 | desc2->GetTransportDescriptionByName(it->name); |
| 623 | if (!transport_desc1 || !transport_desc2) { |
| 624 | EXPECT_FALSE(expect_equal); |
| 625 | return; |
| 626 | } |
| 627 | if (transport_desc1->ice_pwd != transport_desc2->ice_pwd || |
| 628 | transport_desc1->ice_ufrag != transport_desc2->ice_ufrag) { |
| 629 | EXPECT_FALSE(expect_equal); |
| 630 | return; |
| 631 | } |
| 632 | } |
| 633 | EXPECT_TRUE(expect_equal); |
| 634 | } |
mallinath@webrtc.org | 19f27e6 | 2013-10-13 17:18:27 +0000 | [diff] [blame] | 635 | |
| 636 | void RemoveIceUfragPwdLines(const SessionDescriptionInterface* current_desc, |
| 637 | std::string *sdp) { |
| 638 | const cricket::SessionDescription* desc = current_desc->description(); |
| 639 | EXPECT_TRUE(current_desc->ToString(sdp)); |
| 640 | |
| 641 | const cricket::ContentInfos& contents = desc->contents(); |
| 642 | cricket::ContentInfos::const_iterator it = contents.begin(); |
| 643 | // Replace ufrag and pwd lines with empty strings. |
| 644 | for (; it != contents.end(); ++it) { |
| 645 | const cricket::TransportDescription* transport_desc = |
| 646 | desc->GetTransportDescriptionByName(it->name); |
| 647 | std::string ufrag_line = "a=ice-ufrag:" + transport_desc->ice_ufrag |
| 648 | + "\r\n"; |
| 649 | std::string pwd_line = "a=ice-pwd:" + transport_desc->ice_pwd |
| 650 | + "\r\n"; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 651 | rtc::replace_substrs(ufrag_line.c_str(), ufrag_line.length(), |
mallinath@webrtc.org | 19f27e6 | 2013-10-13 17:18:27 +0000 | [diff] [blame] | 652 | "", 0, |
| 653 | sdp); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 654 | rtc::replace_substrs(pwd_line.c_str(), pwd_line.length(), |
mallinath@webrtc.org | 19f27e6 | 2013-10-13 17:18:27 +0000 | [diff] [blame] | 655 | "", 0, |
| 656 | sdp); |
| 657 | } |
| 658 | } |
| 659 | |
buildbot@webrtc.org | 7aa1a47 | 2014-05-23 17:33:05 +0000 | [diff] [blame] | 660 | void ModifyIceUfragPwdLines(const SessionDescriptionInterface* current_desc, |
| 661 | const std::string& modified_ice_ufrag, |
| 662 | const std::string& modified_ice_pwd, |
| 663 | std::string* sdp) { |
| 664 | const cricket::SessionDescription* desc = current_desc->description(); |
| 665 | EXPECT_TRUE(current_desc->ToString(sdp)); |
| 666 | |
| 667 | const cricket::ContentInfos& contents = desc->contents(); |
| 668 | cricket::ContentInfos::const_iterator it = contents.begin(); |
| 669 | // Replace ufrag and pwd lines with |modified_ice_ufrag| and |
| 670 | // |modified_ice_pwd| strings. |
| 671 | for (; it != contents.end(); ++it) { |
| 672 | const cricket::TransportDescription* transport_desc = |
| 673 | desc->GetTransportDescriptionByName(it->name); |
| 674 | std::string ufrag_line = "a=ice-ufrag:" + transport_desc->ice_ufrag |
| 675 | + "\r\n"; |
| 676 | std::string pwd_line = "a=ice-pwd:" + transport_desc->ice_pwd |
| 677 | + "\r\n"; |
| 678 | std::string mod_ufrag = "a=ice-ufrag:" + modified_ice_ufrag + "\r\n"; |
| 679 | std::string mod_pwd = "a=ice-pwd:" + modified_ice_pwd + "\r\n"; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 680 | rtc::replace_substrs(ufrag_line.c_str(), ufrag_line.length(), |
buildbot@webrtc.org | 7aa1a47 | 2014-05-23 17:33:05 +0000 | [diff] [blame] | 681 | mod_ufrag.c_str(), mod_ufrag.length(), |
| 682 | sdp); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 683 | rtc::replace_substrs(pwd_line.c_str(), pwd_line.length(), |
buildbot@webrtc.org | 7aa1a47 | 2014-05-23 17:33:05 +0000 | [diff] [blame] | 684 | mod_pwd.c_str(), mod_pwd.length(), |
| 685 | sdp); |
| 686 | } |
| 687 | } |
| 688 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 689 | // Creates a remote offer and and applies it as a remote description, |
| 690 | // creates a local answer and applies is as a local description. |
| 691 | // Call mediastream_signaling_.UseOptionsWithStreamX() before this function |
| 692 | // to decide which local and remote streams to create. |
| 693 | void CreateAndSetRemoteOfferAndLocalAnswer() { |
| 694 | SessionDescriptionInterface* offer = CreateRemoteOffer(); |
| 695 | SetRemoteDescriptionWithoutError(offer); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 696 | SessionDescriptionInterface* answer = CreateAnswer(NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 697 | SetLocalDescriptionWithoutError(answer); |
| 698 | } |
| 699 | void SetLocalDescriptionWithoutError(SessionDescriptionInterface* desc) { |
| 700 | EXPECT_TRUE(session_->SetLocalDescription(desc, NULL)); |
| 701 | } |
| 702 | void SetLocalDescriptionExpectState(SessionDescriptionInterface* desc, |
| 703 | BaseSession::State expected_state) { |
| 704 | SetLocalDescriptionWithoutError(desc); |
| 705 | EXPECT_EQ(expected_state, session_->state()); |
| 706 | } |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 707 | void SetLocalDescriptionExpectError(const std::string& action, |
| 708 | const std::string& expected_error, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 709 | SessionDescriptionInterface* desc) { |
| 710 | std::string error; |
| 711 | EXPECT_FALSE(session_->SetLocalDescription(desc, &error)); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 712 | std::string sdp_type = "local "; |
| 713 | sdp_type.append(action); |
| 714 | EXPECT_NE(std::string::npos, error.find(sdp_type)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 715 | EXPECT_NE(std::string::npos, error.find(expected_error)); |
| 716 | } |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 717 | void SetLocalDescriptionOfferExpectError(const std::string& expected_error, |
| 718 | SessionDescriptionInterface* desc) { |
| 719 | SetLocalDescriptionExpectError(SessionDescriptionInterface::kOffer, |
| 720 | expected_error, desc); |
| 721 | } |
| 722 | void SetLocalDescriptionAnswerExpectError(const std::string& expected_error, |
| 723 | SessionDescriptionInterface* desc) { |
| 724 | SetLocalDescriptionExpectError(SessionDescriptionInterface::kAnswer, |
| 725 | expected_error, desc); |
| 726 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 727 | void SetRemoteDescriptionWithoutError(SessionDescriptionInterface* desc) { |
| 728 | EXPECT_TRUE(session_->SetRemoteDescription(desc, NULL)); |
| 729 | } |
| 730 | void SetRemoteDescriptionExpectState(SessionDescriptionInterface* desc, |
| 731 | BaseSession::State expected_state) { |
| 732 | SetRemoteDescriptionWithoutError(desc); |
| 733 | EXPECT_EQ(expected_state, session_->state()); |
| 734 | } |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 735 | void SetRemoteDescriptionExpectError(const std::string& action, |
| 736 | const std::string& expected_error, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 737 | SessionDescriptionInterface* desc) { |
| 738 | std::string error; |
| 739 | EXPECT_FALSE(session_->SetRemoteDescription(desc, &error)); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 740 | std::string sdp_type = "remote "; |
| 741 | sdp_type.append(action); |
| 742 | EXPECT_NE(std::string::npos, error.find(sdp_type)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 743 | EXPECT_NE(std::string::npos, error.find(expected_error)); |
| 744 | } |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 745 | void SetRemoteDescriptionOfferExpectError( |
| 746 | const std::string& expected_error, SessionDescriptionInterface* desc) { |
| 747 | SetRemoteDescriptionExpectError(SessionDescriptionInterface::kOffer, |
| 748 | expected_error, desc); |
| 749 | } |
| 750 | void SetRemoteDescriptionPranswerExpectError( |
| 751 | const std::string& expected_error, SessionDescriptionInterface* desc) { |
| 752 | SetRemoteDescriptionExpectError(SessionDescriptionInterface::kPrAnswer, |
| 753 | expected_error, desc); |
| 754 | } |
| 755 | void SetRemoteDescriptionAnswerExpectError( |
| 756 | const std::string& expected_error, SessionDescriptionInterface* desc) { |
| 757 | SetRemoteDescriptionExpectError(SessionDescriptionInterface::kAnswer, |
| 758 | expected_error, desc); |
| 759 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 760 | |
| 761 | void CreateCryptoOfferAndNonCryptoAnswer(SessionDescriptionInterface** offer, |
| 762 | SessionDescriptionInterface** nocrypto_answer) { |
| 763 | // Create a SDP without Crypto. |
| 764 | cricket::MediaSessionOptions options; |
jiayl@webrtc.org | 742922b | 2014-10-07 21:32:43 +0000 | [diff] [blame] | 765 | options.recv_video = true; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 766 | options.bundle_enabled = true; |
| 767 | *offer = CreateRemoteOffer(options, cricket::SEC_ENABLED); |
| 768 | ASSERT_TRUE(*offer != NULL); |
| 769 | VerifyCryptoParams((*offer)->description()); |
| 770 | |
| 771 | *nocrypto_answer = CreateRemoteAnswer(*offer, options, |
| 772 | cricket::SEC_DISABLED); |
| 773 | EXPECT_TRUE(*nocrypto_answer != NULL); |
| 774 | } |
| 775 | |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 776 | void CreateDtlsOfferAndNonDtlsAnswer(SessionDescriptionInterface** offer, |
| 777 | SessionDescriptionInterface** nodtls_answer) { |
| 778 | cricket::MediaSessionOptions options; |
jiayl@webrtc.org | 742922b | 2014-10-07 21:32:43 +0000 | [diff] [blame] | 779 | options.recv_video = true; |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 780 | options.bundle_enabled = true; |
| 781 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 782 | rtc::scoped_ptr<SessionDescriptionInterface> temp_offer( |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 783 | CreateRemoteOffer(options, cricket::SEC_ENABLED)); |
| 784 | |
| 785 | *nodtls_answer = |
| 786 | CreateRemoteAnswer(temp_offer.get(), options, cricket::SEC_ENABLED); |
| 787 | EXPECT_TRUE(*nodtls_answer != NULL); |
| 788 | VerifyFingerprintStatus((*nodtls_answer)->description(), false); |
| 789 | VerifyCryptoParams((*nodtls_answer)->description()); |
| 790 | |
| 791 | SetFactoryDtlsSrtp(); |
| 792 | *offer = CreateRemoteOffer(options, cricket::SEC_ENABLED); |
| 793 | ASSERT_TRUE(*offer != NULL); |
| 794 | VerifyFingerprintStatus((*offer)->description(), true); |
| 795 | VerifyCryptoParams((*offer)->description()); |
| 796 | } |
| 797 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 798 | JsepSessionDescription* CreateRemoteOfferWithVersion( |
| 799 | cricket::MediaSessionOptions options, |
| 800 | cricket::SecurePolicy secure_policy, |
| 801 | const std::string& session_version, |
| 802 | const SessionDescriptionInterface* current_desc) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 803 | std::string session_id = rtc::ToString(rtc::CreateRandomId64()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 804 | const cricket::SessionDescription* cricket_desc = NULL; |
| 805 | if (current_desc) { |
| 806 | cricket_desc = current_desc->description(); |
| 807 | session_id = current_desc->session_id(); |
| 808 | } |
| 809 | |
| 810 | desc_factory_->set_secure(secure_policy); |
| 811 | JsepSessionDescription* offer( |
| 812 | new JsepSessionDescription(JsepSessionDescription::kOffer)); |
| 813 | if (!offer->Initialize(desc_factory_->CreateOffer(options, cricket_desc), |
| 814 | session_id, session_version)) { |
| 815 | delete offer; |
| 816 | offer = NULL; |
| 817 | } |
| 818 | return offer; |
| 819 | } |
| 820 | JsepSessionDescription* CreateRemoteOffer( |
| 821 | cricket::MediaSessionOptions options) { |
| 822 | return CreateRemoteOfferWithVersion(options, cricket::SEC_ENABLED, |
| 823 | kSessionVersion, NULL); |
| 824 | } |
| 825 | JsepSessionDescription* CreateRemoteOffer( |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 826 | cricket::MediaSessionOptions options, cricket::SecurePolicy sdes_policy) { |
| 827 | return CreateRemoteOfferWithVersion( |
| 828 | options, sdes_policy, kSessionVersion, NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 829 | } |
| 830 | JsepSessionDescription* CreateRemoteOffer( |
| 831 | cricket::MediaSessionOptions options, |
| 832 | const SessionDescriptionInterface* current_desc) { |
| 833 | return CreateRemoteOfferWithVersion(options, cricket::SEC_ENABLED, |
| 834 | kSessionVersion, current_desc); |
| 835 | } |
| 836 | |
mallinath@webrtc.org | 19f27e6 | 2013-10-13 17:18:27 +0000 | [diff] [blame] | 837 | JsepSessionDescription* CreateRemoteOfferWithSctpPort( |
| 838 | const char* sctp_stream_name, int new_port, |
| 839 | cricket::MediaSessionOptions options) { |
| 840 | options.data_channel_type = cricket::DCT_SCTP; |
jiayl@webrtc.org | 742922b | 2014-10-07 21:32:43 +0000 | [diff] [blame] | 841 | options.AddSendStream(cricket::MEDIA_TYPE_DATA, "datachannel", |
| 842 | sctp_stream_name); |
mallinath@webrtc.org | 19f27e6 | 2013-10-13 17:18:27 +0000 | [diff] [blame] | 843 | return ChangeSDPSctpPort(new_port, CreateRemoteOffer(options)); |
| 844 | } |
| 845 | |
| 846 | // Takes ownership of offer_basis (and deletes it). |
| 847 | JsepSessionDescription* ChangeSDPSctpPort( |
| 848 | int new_port, webrtc::SessionDescriptionInterface *offer_basis) { |
| 849 | // Stringify the input SDP, swap the 5000 for 'new_port' and create a new |
| 850 | // SessionDescription from the mutated string. |
| 851 | const char* default_port_str = "5000"; |
| 852 | char new_port_str[16]; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 853 | rtc::sprintfn(new_port_str, sizeof(new_port_str), "%d", new_port); |
mallinath@webrtc.org | 19f27e6 | 2013-10-13 17:18:27 +0000 | [diff] [blame] | 854 | std::string offer_str; |
| 855 | offer_basis->ToString(&offer_str); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 856 | rtc::replace_substrs(default_port_str, strlen(default_port_str), |
mallinath@webrtc.org | 19f27e6 | 2013-10-13 17:18:27 +0000 | [diff] [blame] | 857 | new_port_str, strlen(new_port_str), |
| 858 | &offer_str); |
| 859 | JsepSessionDescription* offer = new JsepSessionDescription( |
| 860 | offer_basis->type()); |
| 861 | delete offer_basis; |
| 862 | offer->Initialize(offer_str, NULL); |
| 863 | return offer; |
| 864 | } |
| 865 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 866 | // Create a remote offer. Call mediastream_signaling_.UseOptionsWithStreamX() |
| 867 | // before this function to decide which streams to create. |
| 868 | JsepSessionDescription* CreateRemoteOffer() { |
| 869 | cricket::MediaSessionOptions options; |
| 870 | mediastream_signaling_.GetOptionsForAnswer(NULL, &options); |
| 871 | return CreateRemoteOffer(options, session_->remote_description()); |
| 872 | } |
| 873 | |
| 874 | JsepSessionDescription* CreateRemoteAnswer( |
| 875 | const SessionDescriptionInterface* offer, |
| 876 | cricket::MediaSessionOptions options, |
| 877 | cricket::SecurePolicy policy) { |
| 878 | desc_factory_->set_secure(policy); |
| 879 | const std::string session_id = |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 880 | rtc::ToString(rtc::CreateRandomId64()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 881 | JsepSessionDescription* answer( |
| 882 | new JsepSessionDescription(JsepSessionDescription::kAnswer)); |
| 883 | if (!answer->Initialize(desc_factory_->CreateAnswer(offer->description(), |
| 884 | options, NULL), |
| 885 | session_id, kSessionVersion)) { |
| 886 | delete answer; |
| 887 | answer = NULL; |
| 888 | } |
| 889 | return answer; |
| 890 | } |
| 891 | |
| 892 | JsepSessionDescription* CreateRemoteAnswer( |
| 893 | const SessionDescriptionInterface* offer, |
| 894 | cricket::MediaSessionOptions options) { |
| 895 | return CreateRemoteAnswer(offer, options, cricket::SEC_REQUIRED); |
| 896 | } |
| 897 | |
| 898 | // Creates an answer session description with streams based on |
| 899 | // |mediastream_signaling_|. Call |
| 900 | // mediastream_signaling_.UseOptionsWithStreamX() before this function |
| 901 | // to decide which streams to create. |
| 902 | JsepSessionDescription* CreateRemoteAnswer( |
| 903 | const SessionDescriptionInterface* offer) { |
| 904 | cricket::MediaSessionOptions options; |
| 905 | mediastream_signaling_.GetOptionsForAnswer(NULL, &options); |
| 906 | return CreateRemoteAnswer(offer, options, cricket::SEC_REQUIRED); |
| 907 | } |
| 908 | |
| 909 | void TestSessionCandidatesWithBundleRtcpMux(bool bundle, bool rtcp_mux) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 910 | AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 911 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 912 | mediastream_signaling_.SendAudioVideoStream1(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 913 | |
| 914 | PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 915 | options.use_rtp_mux = bundle; |
| 916 | |
| 917 | SessionDescriptionInterface* offer = CreateOffer(options); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 918 | // SetLocalDescription and SetRemoteDescriptions takes ownership of offer |
| 919 | // and answer. |
| 920 | SetLocalDescriptionWithoutError(offer); |
| 921 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 922 | rtc::scoped_ptr<SessionDescriptionInterface> answer( |
henrike@webrtc.org | 723d683 | 2013-07-12 16:04:50 +0000 | [diff] [blame] | 923 | CreateRemoteAnswer(session_->local_description())); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 924 | std::string sdp; |
| 925 | EXPECT_TRUE(answer->ToString(&sdp)); |
| 926 | |
| 927 | size_t expected_candidate_num = 2; |
| 928 | if (!rtcp_mux) { |
| 929 | // If rtcp_mux is enabled we should expect 4 candidates - host and srflex |
| 930 | // for rtp and rtcp. |
| 931 | expected_candidate_num = 4; |
| 932 | // Disable rtcp-mux from the answer |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 933 | const std::string kRtcpMux = "a=rtcp-mux"; |
| 934 | const std::string kXRtcpMux = "a=xrtcp-mux"; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 935 | rtc::replace_substrs(kRtcpMux.c_str(), kRtcpMux.length(), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 936 | kXRtcpMux.c_str(), kXRtcpMux.length(), |
| 937 | &sdp); |
| 938 | } |
| 939 | |
| 940 | SessionDescriptionInterface* new_answer = CreateSessionDescription( |
| 941 | JsepSessionDescription::kAnswer, sdp, NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 942 | |
| 943 | // SetRemoteDescription to enable rtcp mux. |
henrike@webrtc.org | 723d683 | 2013-07-12 16:04:50 +0000 | [diff] [blame] | 944 | SetRemoteDescriptionWithoutError(new_answer); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 945 | EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); |
| 946 | EXPECT_EQ(expected_candidate_num, observer_.mline_0_candidates_.size()); |
| 947 | EXPECT_EQ(expected_candidate_num, observer_.mline_1_candidates_.size()); |
| 948 | for (size_t i = 0; i < observer_.mline_0_candidates_.size(); ++i) { |
| 949 | cricket::Candidate c0 = observer_.mline_0_candidates_[i]; |
| 950 | cricket::Candidate c1 = observer_.mline_1_candidates_[i]; |
| 951 | if (bundle) { |
| 952 | EXPECT_TRUE(c0.IsEquivalent(c1)); |
| 953 | } else { |
| 954 | EXPECT_FALSE(c0.IsEquivalent(c1)); |
| 955 | } |
| 956 | } |
| 957 | } |
| 958 | // Tests that we can only send DTMF when the dtmf codec is supported. |
| 959 | void TestCanInsertDtmf(bool can) { |
| 960 | if (can) { |
| 961 | InitWithDtmfCodec(); |
| 962 | } else { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 963 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 964 | } |
| 965 | mediastream_signaling_.SendAudioVideoStream1(); |
| 966 | CreateAndSetRemoteOfferAndLocalAnswer(); |
| 967 | EXPECT_FALSE(session_->CanInsertDtmf("")); |
| 968 | EXPECT_EQ(can, session_->CanInsertDtmf(kAudioTrack1)); |
| 969 | } |
| 970 | |
guoweis@webrtc.org | 7169afd | 2014-12-04 17:59:29 +0000 | [diff] [blame] | 971 | // Helper class to configure loopback network and verify Best |
| 972 | // Connection using right IP protocol for TestLoopbackCall |
| 973 | // method. LoopbackNetworkManager applies firewall rules to block |
| 974 | // all ping traffic once ICE completed, and remove them to observe |
| 975 | // ICE reconnected again. This LoopbackNetworkConfiguration struct |
| 976 | // verifies the best connection is using the right IP protocol after |
| 977 | // initial ICE convergences. |
| 978 | |
| 979 | class LoopbackNetworkConfiguration { |
| 980 | public: |
| 981 | LoopbackNetworkConfiguration() |
| 982 | : test_ipv6_network_(false), |
| 983 | test_extra_ipv4_network_(false), |
| 984 | best_connection_after_initial_ice_converged_(1, 0) {} |
| 985 | |
| 986 | // Used to track the expected best connection count in each IP protocol. |
| 987 | struct ExpectedBestConnection { |
| 988 | ExpectedBestConnection(int ipv4_count, int ipv6_count) |
| 989 | : ipv4_count_(ipv4_count), |
| 990 | ipv6_count_(ipv6_count) {} |
| 991 | |
| 992 | int ipv4_count_; |
| 993 | int ipv6_count_; |
| 994 | }; |
| 995 | |
| 996 | bool test_ipv6_network_; |
| 997 | bool test_extra_ipv4_network_; |
| 998 | ExpectedBestConnection best_connection_after_initial_ice_converged_; |
| 999 | |
| 1000 | void VerifyBestConnectionAfterIceConverge( |
jbauch | ac8869e | 2015-07-03 01:36:14 -0700 | [diff] [blame] | 1001 | const rtc::scoped_refptr<FakeMetricsObserver> metrics_observer) const { |
guoweis@webrtc.org | 7169afd | 2014-12-04 17:59:29 +0000 | [diff] [blame] | 1002 | Verify(metrics_observer, best_connection_after_initial_ice_converged_); |
| 1003 | } |
| 1004 | |
| 1005 | private: |
jbauch | ac8869e | 2015-07-03 01:36:14 -0700 | [diff] [blame] | 1006 | void Verify(const rtc::scoped_refptr<FakeMetricsObserver> metrics_observer, |
guoweis@webrtc.org | 7169afd | 2014-12-04 17:59:29 +0000 | [diff] [blame] | 1007 | const ExpectedBestConnection& expected) const { |
| 1008 | EXPECT_EQ( |
jbauch | ac8869e | 2015-07-03 01:36:14 -0700 | [diff] [blame] | 1009 | metrics_observer->GetCounter(webrtc::kBestConnections_IPv4), |
guoweis@webrtc.org | 7169afd | 2014-12-04 17:59:29 +0000 | [diff] [blame] | 1010 | expected.ipv4_count_); |
| 1011 | EXPECT_EQ( |
jbauch | ac8869e | 2015-07-03 01:36:14 -0700 | [diff] [blame] | 1012 | metrics_observer->GetCounter(webrtc::kBestConnections_IPv6), |
guoweis@webrtc.org | 7169afd | 2014-12-04 17:59:29 +0000 | [diff] [blame] | 1013 | expected.ipv6_count_); |
| 1014 | } |
| 1015 | }; |
| 1016 | |
| 1017 | class LoopbackNetworkManager { |
| 1018 | public: |
| 1019 | LoopbackNetworkManager(WebRtcSessionTest* session, |
| 1020 | const LoopbackNetworkConfiguration& config) |
| 1021 | : config_(config) { |
| 1022 | session->AddInterface( |
| 1023 | rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
| 1024 | if (config_.test_extra_ipv4_network_) { |
| 1025 | session->AddInterface( |
| 1026 | rtc::SocketAddress(kClientAddrHost2, kClientAddrPort)); |
| 1027 | } |
| 1028 | if (config_.test_ipv6_network_) { |
| 1029 | session->AddInterface( |
| 1030 | rtc::SocketAddress(kClientIPv6AddrHost1, kClientAddrPort)); |
| 1031 | } |
| 1032 | } |
| 1033 | |
| 1034 | void ApplyFirewallRules(rtc::FirewallSocketServer* fss) { |
| 1035 | fss->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, |
| 1036 | rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
| 1037 | if (config_.test_extra_ipv4_network_) { |
| 1038 | fss->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, |
| 1039 | rtc::SocketAddress(kClientAddrHost2, kClientAddrPort)); |
| 1040 | } |
| 1041 | if (config_.test_ipv6_network_) { |
| 1042 | fss->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, |
| 1043 | rtc::SocketAddress(kClientIPv6AddrHost1, kClientAddrPort)); |
| 1044 | } |
| 1045 | } |
| 1046 | |
| 1047 | void ClearRules(rtc::FirewallSocketServer* fss) { fss->ClearRules(); } |
| 1048 | |
| 1049 | private: |
| 1050 | LoopbackNetworkConfiguration config_; |
| 1051 | }; |
| 1052 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1053 | // The method sets up a call from the session to itself, in a loopback |
| 1054 | // arrangement. It also uses a firewall rule to create a temporary |
mallinath@webrtc.org | 385857d | 2014-02-14 00:56:12 +0000 | [diff] [blame] | 1055 | // disconnection, and then a permanent disconnection. |
| 1056 | // This code is placed in a method so that it can be invoked |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1057 | // by multiple tests with different allocators (e.g. with and without BUNDLE). |
| 1058 | // While running the call, this method also checks if the session goes through |
| 1059 | // the correct sequence of ICE states when a connection is established, |
| 1060 | // broken, and re-established. |
| 1061 | // The Connection state should go: |
mallinath@webrtc.org | 385857d | 2014-02-14 00:56:12 +0000 | [diff] [blame] | 1062 | // New -> Checking -> (Connected) -> Completed -> Disconnected -> Completed |
| 1063 | // -> Failed. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1064 | // The Gathering state should go: New -> Gathering -> Completed. |
guoweis@webrtc.org | 7169afd | 2014-12-04 17:59:29 +0000 | [diff] [blame] | 1065 | |
| 1066 | void TestLoopbackCall(const LoopbackNetworkConfiguration& config) { |
| 1067 | LoopbackNetworkManager loopback_network_manager(this, config); |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 1068 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1069 | mediastream_signaling_.SendAudioVideoStream1(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 1070 | SessionDescriptionInterface* offer = CreateOffer(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1071 | |
| 1072 | EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, |
| 1073 | observer_.ice_gathering_state_); |
| 1074 | SetLocalDescriptionWithoutError(offer); |
| 1075 | EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, |
| 1076 | observer_.ice_connection_state_); |
| 1077 | EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringGathering, |
| 1078 | observer_.ice_gathering_state_, |
| 1079 | kIceCandidatesTimeout); |
| 1080 | EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); |
| 1081 | EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringComplete, |
| 1082 | observer_.ice_gathering_state_, |
| 1083 | kIceCandidatesTimeout); |
| 1084 | |
| 1085 | std::string sdp; |
| 1086 | offer->ToString(&sdp); |
| 1087 | SessionDescriptionInterface* desc = |
jbauch | fabe2c9 | 2015-07-16 13:43:14 -0700 | [diff] [blame^] | 1088 | webrtc::CreateSessionDescription( |
| 1089 | JsepSessionDescription::kAnswer, sdp, nullptr); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1090 | ASSERT_TRUE(desc != NULL); |
| 1091 | SetRemoteDescriptionWithoutError(desc); |
| 1092 | |
| 1093 | EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionChecking, |
| 1094 | observer_.ice_connection_state_, |
| 1095 | kIceCandidatesTimeout); |
mallinath@webrtc.org | d3dc424 | 2014-03-01 00:05:52 +0000 | [diff] [blame] | 1096 | |
mallinath@webrtc.org | 385857d | 2014-02-14 00:56:12 +0000 | [diff] [blame] | 1097 | // The ice connection state is "Connected" too briefly to catch in a test. |
| 1098 | EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1099 | observer_.ice_connection_state_, |
| 1100 | kIceCandidatesTimeout); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1101 | |
guoweis@webrtc.org | 7169afd | 2014-12-04 17:59:29 +0000 | [diff] [blame] | 1102 | config.VerifyBestConnectionAfterIceConverge(metrics_observer_); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1103 | // Adding firewall rule to block ping requests, which should cause |
| 1104 | // transport channel failure. |
guoweis@webrtc.org | 7169afd | 2014-12-04 17:59:29 +0000 | [diff] [blame] | 1105 | |
| 1106 | loopback_network_manager.ApplyFirewallRules(fss_.get()); |
| 1107 | |
| 1108 | LOG(LS_INFO) << "Firewall Rules applied"; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1109 | EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionDisconnected, |
| 1110 | observer_.ice_connection_state_, |
| 1111 | kIceCandidatesTimeout); |
| 1112 | |
jbauch | ac8869e | 2015-07-03 01:36:14 -0700 | [diff] [blame] | 1113 | metrics_observer_->Reset(); |
guoweis@webrtc.org | 7169afd | 2014-12-04 17:59:29 +0000 | [diff] [blame] | 1114 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1115 | // Clearing the rules, session should move back to completed state. |
guoweis@webrtc.org | 7169afd | 2014-12-04 17:59:29 +0000 | [diff] [blame] | 1116 | loopback_network_manager.ClearRules(fss_.get()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1117 | // Session is automatically calling OnSignalingReady after creation of |
| 1118 | // new portallocator session which will allocate new set of candidates. |
| 1119 | |
guoweis@webrtc.org | 7169afd | 2014-12-04 17:59:29 +0000 | [diff] [blame] | 1120 | LOG(LS_INFO) << "Firewall Rules cleared"; |
| 1121 | |
mallinath@webrtc.org | 385857d | 2014-02-14 00:56:12 +0000 | [diff] [blame] | 1122 | EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1123 | observer_.ice_connection_state_, |
| 1124 | kIceCandidatesTimeout); |
mallinath@webrtc.org | 385857d | 2014-02-14 00:56:12 +0000 | [diff] [blame] | 1125 | |
| 1126 | // Now we block ping requests and wait until the ICE connection transitions |
| 1127 | // to the Failed state. This will take at least 30 seconds because it must |
| 1128 | // wait for the Port to timeout. |
| 1129 | int port_timeout = 30000; |
guoweis@webrtc.org | 7169afd | 2014-12-04 17:59:29 +0000 | [diff] [blame] | 1130 | |
| 1131 | loopback_network_manager.ApplyFirewallRules(fss_.get()); |
| 1132 | LOG(LS_INFO) << "Firewall Rules applied again"; |
jlmiller@webrtc.org | 804eb46 | 2015-02-20 02:20:03 +0000 | [diff] [blame] | 1133 | EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionDisconnected, |
mallinath@webrtc.org | 385857d | 2014-02-14 00:56:12 +0000 | [diff] [blame] | 1134 | observer_.ice_connection_state_, |
| 1135 | kIceCandidatesTimeout + port_timeout); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1136 | } |
| 1137 | |
guoweis@webrtc.org | 7169afd | 2014-12-04 17:59:29 +0000 | [diff] [blame] | 1138 | void TestLoopbackCall() { |
| 1139 | LoopbackNetworkConfiguration config; |
| 1140 | TestLoopbackCall(config); |
| 1141 | } |
| 1142 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1143 | void VerifyTransportType(const std::string& content_name, |
| 1144 | cricket::TransportProtocol protocol) { |
| 1145 | const cricket::Transport* transport = session_->GetTransport(content_name); |
| 1146 | ASSERT_TRUE(transport != NULL); |
| 1147 | EXPECT_EQ(protocol, transport->protocol()); |
| 1148 | } |
| 1149 | |
| 1150 | // Adds CN codecs to FakeMediaEngine and MediaDescriptionFactory. |
| 1151 | void AddCNCodecs() { |
wu@webrtc.org | 364f204 | 2013-11-20 21:49:41 +0000 | [diff] [blame] | 1152 | const cricket::AudioCodec kCNCodec1(102, "CN", 8000, 0, 1, 0); |
| 1153 | const cricket::AudioCodec kCNCodec2(103, "CN", 16000, 0, 1, 0); |
| 1154 | |
| 1155 | // Add kCNCodec for dtmf test. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1156 | std::vector<cricket::AudioCodec> codecs = media_engine_->audio_codecs();; |
| 1157 | codecs.push_back(kCNCodec1); |
| 1158 | codecs.push_back(kCNCodec2); |
| 1159 | media_engine_->SetAudioCodecs(codecs); |
| 1160 | desc_factory_->set_audio_codecs(codecs); |
| 1161 | } |
| 1162 | |
| 1163 | bool VerifyNoCNCodecs(const cricket::ContentInfo* content) { |
| 1164 | const cricket::ContentDescription* description = content->description; |
| 1165 | ASSERT(description != NULL); |
| 1166 | const cricket::AudioContentDescription* audio_content_desc = |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 1167 | static_cast<const cricket::AudioContentDescription*>(description); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1168 | ASSERT(audio_content_desc != NULL); |
| 1169 | for (size_t i = 0; i < audio_content_desc->codecs().size(); ++i) { |
| 1170 | if (audio_content_desc->codecs()[i].name == "CN") |
| 1171 | return false; |
| 1172 | } |
| 1173 | return true; |
| 1174 | } |
| 1175 | |
| 1176 | void SetLocalDescriptionWithDataChannel() { |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 +0000 | [diff] [blame] | 1177 | webrtc::InternalDataChannelInit dci; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1178 | dci.reliable = false; |
| 1179 | session_->CreateDataChannel("datachannel", &dci); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 1180 | SessionDescriptionInterface* offer = CreateOffer(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1181 | SetLocalDescriptionWithoutError(offer); |
| 1182 | } |
| 1183 | |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 1184 | void VerifyMultipleAsyncCreateDescription( |
| 1185 | bool success, CreateSessionDescriptionRequest::Type type) { |
henrike@webrtc.org | 7666db7 | 2013-08-22 14:45:42 +0000 | [diff] [blame] | 1186 | InitWithDtls(!success); |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1187 | SetFactoryDtlsSrtp(); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 1188 | if (type == CreateSessionDescriptionRequest::kAnswer) { |
| 1189 | cricket::MediaSessionOptions options; |
| 1190 | scoped_ptr<JsepSessionDescription> offer( |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1191 | CreateRemoteOffer(options, cricket::SEC_DISABLED)); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 1192 | ASSERT_TRUE(offer.get() != NULL); |
| 1193 | SetRemoteDescriptionWithoutError(offer.release()); |
| 1194 | } |
| 1195 | |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 1196 | PeerConnectionInterface::RTCOfferAnswerOptions options; |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 1197 | const int kNumber = 3; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 1198 | rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 1199 | observers[kNumber]; |
| 1200 | for (int i = 0; i < kNumber; ++i) { |
| 1201 | observers[i] = new WebRtcSessionCreateSDPObserverForTest(); |
| 1202 | if (type == CreateSessionDescriptionRequest::kOffer) { |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 1203 | session_->CreateOffer(observers[i], options); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 1204 | } else { |
| 1205 | session_->CreateAnswer(observers[i], NULL); |
| 1206 | } |
| 1207 | } |
| 1208 | |
| 1209 | WebRtcSessionCreateSDPObserverForTest::State expected_state = |
| 1210 | success ? WebRtcSessionCreateSDPObserverForTest::kSucceeded : |
| 1211 | WebRtcSessionCreateSDPObserverForTest::kFailed; |
| 1212 | |
| 1213 | for (int i = 0; i < kNumber; ++i) { |
| 1214 | EXPECT_EQ_WAIT(expected_state, observers[i]->state(), 1000); |
| 1215 | if (success) { |
| 1216 | EXPECT_TRUE(observers[i]->description() != NULL); |
| 1217 | } else { |
| 1218 | EXPECT_TRUE(observers[i]->description() == NULL); |
| 1219 | } |
| 1220 | } |
| 1221 | } |
| 1222 | |
mallinath@webrtc.org | 3d81b1b | 2014-09-09 14:38:10 +0000 | [diff] [blame] | 1223 | void ConfigureAllocatorWithTurn() { |
| 1224 | cricket::RelayServerConfig relay_server(cricket::RELAY_TURN); |
| 1225 | cricket::RelayCredentials credentials(kTurnUsername, kTurnPassword); |
| 1226 | relay_server.credentials = credentials; |
| 1227 | relay_server.ports.push_back(cricket::ProtocolAddress( |
| 1228 | kTurnUdpIntAddr, cricket::PROTO_UDP, false)); |
| 1229 | allocator_->AddRelay(relay_server); |
| 1230 | allocator_->set_step_delay(cricket::kMinimumStepDelay); |
| 1231 | allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | |
jiayl@webrtc.org | dacdd94 | 2015-01-23 17:33:34 +0000 | [diff] [blame] | 1232 | cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG); |
mallinath@webrtc.org | 3d81b1b | 2014-09-09 14:38:10 +0000 | [diff] [blame] | 1233 | } |
| 1234 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1235 | cricket::FakeMediaEngine* media_engine_; |
| 1236 | cricket::FakeDataEngine* data_engine_; |
| 1237 | cricket::FakeDeviceManager* device_manager_; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 1238 | rtc::scoped_ptr<cricket::ChannelManager> channel_manager_; |
| 1239 | rtc::scoped_ptr<cricket::TransportDescriptionFactory> tdesc_factory_; |
| 1240 | rtc::scoped_ptr<rtc::SSLIdentity> identity_; |
| 1241 | rtc::scoped_ptr<cricket::MediaSessionDescriptionFactory> desc_factory_; |
| 1242 | rtc::scoped_ptr<rtc::PhysicalSocketServer> pss_; |
| 1243 | rtc::scoped_ptr<rtc::VirtualSocketServer> vss_; |
| 1244 | rtc::scoped_ptr<rtc::FirewallSocketServer> fss_; |
| 1245 | rtc::SocketServerScope ss_scope_; |
| 1246 | rtc::SocketAddress stun_socket_addr_; |
jiayl@webrtc.org | bebc75e | 2014-09-26 23:01:11 +0000 | [diff] [blame] | 1247 | rtc::scoped_ptr<cricket::TestStunServer> stun_server_; |
buildbot@webrtc.org | 41451d4 | 2014-05-03 05:39:45 +0000 | [diff] [blame] | 1248 | cricket::TestTurnServer turn_server_; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 1249 | rtc::FakeNetworkManager network_manager_; |
| 1250 | rtc::scoped_ptr<cricket::BasicPortAllocator> allocator_; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 1251 | PeerConnectionFactoryInterface::Options options_; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 1252 | rtc::scoped_ptr<FakeConstraints> constraints_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1253 | FakeMediaStreamSignaling mediastream_signaling_; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 1254 | rtc::scoped_ptr<WebRtcSessionForTest> session_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1255 | MockIceObserver observer_; |
| 1256 | cricket::FakeVideoMediaChannel* video_channel_; |
| 1257 | cricket::FakeVoiceMediaChannel* voice_channel_; |
jbauch | ac8869e | 2015-07-03 01:36:14 -0700 | [diff] [blame] | 1258 | rtc::scoped_refptr<FakeMetricsObserver> metrics_observer_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1259 | }; |
| 1260 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1261 | TEST_F(WebRtcSessionTest, TestInitializeWithDtls) { |
| 1262 | InitWithDtls(); |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1263 | // SDES is disabled when DTLS is on. |
| 1264 | EXPECT_EQ(cricket::SEC_DISABLED, session_->SdesPolicy()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1265 | } |
| 1266 | |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1267 | TEST_F(WebRtcSessionTest, TestInitializeWithoutDtls) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 1268 | Init(); |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1269 | // SDES is required if DTLS is off. |
| 1270 | EXPECT_EQ(cricket::SEC_REQUIRED, session_->SdesPolicy()); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 1271 | } |
| 1272 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1273 | TEST_F(WebRtcSessionTest, TestSessionCandidates) { |
| 1274 | TestSessionCandidatesWithBundleRtcpMux(false, false); |
| 1275 | } |
| 1276 | |
| 1277 | // Below test cases (TestSessionCandidatesWith*) verify the candidates gathered |
| 1278 | // with rtcp-mux and/or bundle. |
| 1279 | TEST_F(WebRtcSessionTest, TestSessionCandidatesWithRtcpMux) { |
| 1280 | TestSessionCandidatesWithBundleRtcpMux(false, true); |
| 1281 | } |
| 1282 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1283 | TEST_F(WebRtcSessionTest, TestSessionCandidatesWithBundleRtcpMux) { |
| 1284 | TestSessionCandidatesWithBundleRtcpMux(true, true); |
| 1285 | } |
| 1286 | |
| 1287 | TEST_F(WebRtcSessionTest, TestMultihomeCandidates) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 1288 | AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
| 1289 | AddInterface(rtc::SocketAddress(kClientAddrHost2, kClientAddrPort)); |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 1290 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1291 | mediastream_signaling_.SendAudioVideoStream1(); |
| 1292 | InitiateCall(); |
| 1293 | EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); |
| 1294 | EXPECT_EQ(8u, observer_.mline_0_candidates_.size()); |
| 1295 | EXPECT_EQ(8u, observer_.mline_1_candidates_.size()); |
| 1296 | } |
| 1297 | |
| 1298 | TEST_F(WebRtcSessionTest, TestStunError) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 1299 | AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
| 1300 | AddInterface(rtc::SocketAddress(kClientAddrHost2, kClientAddrPort)); |
wu@webrtc.org | 364f204 | 2013-11-20 21:49:41 +0000 | [diff] [blame] | 1301 | fss_->AddRule(false, |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 1302 | rtc::FP_UDP, |
| 1303 | rtc::FD_ANY, |
| 1304 | rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 1305 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1306 | mediastream_signaling_.SendAudioVideoStream1(); |
| 1307 | InitiateCall(); |
wu@webrtc.org | 364f204 | 2013-11-20 21:49:41 +0000 | [diff] [blame] | 1308 | // Since kClientAddrHost1 is blocked, not expecting stun candidates for it. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1309 | EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); |
| 1310 | EXPECT_EQ(6u, observer_.mline_0_candidates_.size()); |
| 1311 | EXPECT_EQ(6u, observer_.mline_1_candidates_.size()); |
| 1312 | } |
| 1313 | |
mallinath@webrtc.org | 3d81b1b | 2014-09-09 14:38:10 +0000 | [diff] [blame] | 1314 | // Test session delivers no candidates gathered when constraint set to "none". |
| 1315 | TEST_F(WebRtcSessionTest, TestIceTransportsNone) { |
| 1316 | AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 1317 | InitWithIceTransport(PeerConnectionInterface::kNone); |
mallinath@webrtc.org | 3d81b1b | 2014-09-09 14:38:10 +0000 | [diff] [blame] | 1318 | mediastream_signaling_.SendAudioVideoStream1(); |
| 1319 | InitiateCall(); |
| 1320 | EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); |
| 1321 | EXPECT_EQ(0u, observer_.mline_0_candidates_.size()); |
| 1322 | EXPECT_EQ(0u, observer_.mline_1_candidates_.size()); |
| 1323 | } |
| 1324 | |
| 1325 | // Test session delivers only relay candidates gathered when constaint set to |
| 1326 | // "relay". |
| 1327 | TEST_F(WebRtcSessionTest, TestIceTransportsRelay) { |
| 1328 | AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
| 1329 | ConfigureAllocatorWithTurn(); |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 1330 | InitWithIceTransport(PeerConnectionInterface::kRelay); |
mallinath@webrtc.org | 3d81b1b | 2014-09-09 14:38:10 +0000 | [diff] [blame] | 1331 | mediastream_signaling_.SendAudioVideoStream1(); |
| 1332 | InitiateCall(); |
| 1333 | EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); |
| 1334 | EXPECT_EQ(2u, observer_.mline_0_candidates_.size()); |
| 1335 | EXPECT_EQ(2u, observer_.mline_1_candidates_.size()); |
| 1336 | for (size_t i = 0; i < observer_.mline_0_candidates_.size(); ++i) { |
| 1337 | EXPECT_EQ(cricket::RELAY_PORT_TYPE, |
| 1338 | observer_.mline_0_candidates_[i].type()); |
| 1339 | } |
| 1340 | for (size_t i = 0; i < observer_.mline_1_candidates_.size(); ++i) { |
| 1341 | EXPECT_EQ(cricket::RELAY_PORT_TYPE, |
| 1342 | observer_.mline_1_candidates_[i].type()); |
| 1343 | } |
| 1344 | } |
| 1345 | |
| 1346 | // Test session delivers all candidates gathered when constaint set to "all". |
| 1347 | TEST_F(WebRtcSessionTest, TestIceTransportsAll) { |
| 1348 | AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 1349 | InitWithIceTransport(PeerConnectionInterface::kAll); |
mallinath@webrtc.org | 3d81b1b | 2014-09-09 14:38:10 +0000 | [diff] [blame] | 1350 | mediastream_signaling_.SendAudioVideoStream1(); |
| 1351 | InitiateCall(); |
| 1352 | EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); |
| 1353 | // Host + STUN. By default allocator is disabled to gather relay candidates. |
| 1354 | EXPECT_EQ(4u, observer_.mline_0_candidates_.size()); |
| 1355 | EXPECT_EQ(4u, observer_.mline_1_candidates_.size()); |
| 1356 | } |
| 1357 | |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1358 | TEST_F(WebRtcSessionTest, SetSdpFailedOnInvalidSdp) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 1359 | Init(); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1360 | SessionDescriptionInterface* offer = NULL; |
| 1361 | // Since |offer| is NULL, there's no way to tell if it's an offer or answer. |
| 1362 | std::string unknown_action; |
| 1363 | SetLocalDescriptionExpectError(unknown_action, kInvalidSdp, offer); |
| 1364 | SetRemoteDescriptionExpectError(unknown_action, kInvalidSdp, offer); |
| 1365 | } |
| 1366 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1367 | // Test creating offers and receive answers and make sure the |
| 1368 | // media engine creates the expected send and receive streams. |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1369 | TEST_F(WebRtcSessionTest, TestCreateSdesOfferReceiveSdesAnswer) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 1370 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1371 | mediastream_signaling_.SendAudioVideoStream1(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 1372 | SessionDescriptionInterface* offer = CreateOffer(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1373 | const std::string session_id_orig = offer->session_id(); |
| 1374 | const std::string session_version_orig = offer->session_version(); |
| 1375 | SetLocalDescriptionWithoutError(offer); |
| 1376 | |
| 1377 | mediastream_signaling_.SendAudioVideoStream2(); |
| 1378 | SessionDescriptionInterface* answer = |
| 1379 | CreateRemoteAnswer(session_->local_description()); |
| 1380 | SetRemoteDescriptionWithoutError(answer); |
| 1381 | |
| 1382 | video_channel_ = media_engine_->GetVideoChannel(0); |
| 1383 | voice_channel_ = media_engine_->GetVoiceChannel(0); |
| 1384 | |
| 1385 | ASSERT_EQ(1u, video_channel_->recv_streams().size()); |
| 1386 | EXPECT_TRUE(kVideoTrack2 == video_channel_->recv_streams()[0].id); |
| 1387 | |
| 1388 | ASSERT_EQ(1u, voice_channel_->recv_streams().size()); |
| 1389 | EXPECT_TRUE(kAudioTrack2 == voice_channel_->recv_streams()[0].id); |
| 1390 | |
| 1391 | ASSERT_EQ(1u, video_channel_->send_streams().size()); |
| 1392 | EXPECT_TRUE(kVideoTrack1 == video_channel_->send_streams()[0].id); |
| 1393 | ASSERT_EQ(1u, voice_channel_->send_streams().size()); |
| 1394 | EXPECT_TRUE(kAudioTrack1 == voice_channel_->send_streams()[0].id); |
| 1395 | |
| 1396 | // Create new offer without send streams. |
| 1397 | mediastream_signaling_.SendNothing(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 1398 | offer = CreateOffer(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1399 | |
| 1400 | // Verify the session id is the same and the session version is |
| 1401 | // increased. |
| 1402 | EXPECT_EQ(session_id_orig, offer->session_id()); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 1403 | EXPECT_LT(rtc::FromString<uint64>(session_version_orig), |
| 1404 | rtc::FromString<uint64>(offer->session_version())); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1405 | |
| 1406 | SetLocalDescriptionWithoutError(offer); |
jiayl@webrtc.org | 7d4891d | 2014-09-09 21:43:15 +0000 | [diff] [blame] | 1407 | EXPECT_EQ(0u, video_channel_->send_streams().size()); |
| 1408 | EXPECT_EQ(0u, voice_channel_->send_streams().size()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1409 | |
| 1410 | mediastream_signaling_.SendAudioVideoStream2(); |
| 1411 | answer = CreateRemoteAnswer(session_->local_description()); |
| 1412 | SetRemoteDescriptionWithoutError(answer); |
| 1413 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1414 | // Make sure the receive streams have not changed. |
| 1415 | ASSERT_EQ(1u, video_channel_->recv_streams().size()); |
| 1416 | EXPECT_TRUE(kVideoTrack2 == video_channel_->recv_streams()[0].id); |
| 1417 | ASSERT_EQ(1u, voice_channel_->recv_streams().size()); |
| 1418 | EXPECT_TRUE(kAudioTrack2 == voice_channel_->recv_streams()[0].id); |
| 1419 | } |
| 1420 | |
| 1421 | // Test receiving offers and creating answers and make sure the |
| 1422 | // media engine creates the expected send and receive streams. |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1423 | TEST_F(WebRtcSessionTest, TestReceiveSdesOfferCreateSdesAnswer) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 1424 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1425 | mediastream_signaling_.SendAudioVideoStream2(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 1426 | SessionDescriptionInterface* offer = CreateOffer(); |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1427 | VerifyCryptoParams(offer->description()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1428 | SetRemoteDescriptionWithoutError(offer); |
| 1429 | |
| 1430 | mediastream_signaling_.SendAudioVideoStream1(); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 1431 | SessionDescriptionInterface* answer = CreateAnswer(NULL); |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1432 | VerifyCryptoParams(answer->description()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1433 | SetLocalDescriptionWithoutError(answer); |
| 1434 | |
| 1435 | const std::string session_id_orig = answer->session_id(); |
| 1436 | const std::string session_version_orig = answer->session_version(); |
| 1437 | |
| 1438 | video_channel_ = media_engine_->GetVideoChannel(0); |
| 1439 | voice_channel_ = media_engine_->GetVoiceChannel(0); |
| 1440 | |
| 1441 | ASSERT_EQ(1u, video_channel_->recv_streams().size()); |
| 1442 | EXPECT_TRUE(kVideoTrack2 == video_channel_->recv_streams()[0].id); |
| 1443 | |
| 1444 | ASSERT_EQ(1u, voice_channel_->recv_streams().size()); |
| 1445 | EXPECT_TRUE(kAudioTrack2 == voice_channel_->recv_streams()[0].id); |
| 1446 | |
| 1447 | ASSERT_EQ(1u, video_channel_->send_streams().size()); |
| 1448 | EXPECT_TRUE(kVideoTrack1 == video_channel_->send_streams()[0].id); |
| 1449 | ASSERT_EQ(1u, voice_channel_->send_streams().size()); |
| 1450 | EXPECT_TRUE(kAudioTrack1 == voice_channel_->send_streams()[0].id); |
| 1451 | |
| 1452 | mediastream_signaling_.SendAudioVideoStream1And2(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 1453 | offer = CreateOffer(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1454 | SetRemoteDescriptionWithoutError(offer); |
| 1455 | |
| 1456 | // Answer by turning off all send streams. |
| 1457 | mediastream_signaling_.SendNothing(); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 1458 | answer = CreateAnswer(NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1459 | |
| 1460 | // Verify the session id is the same and the session version is |
| 1461 | // increased. |
| 1462 | EXPECT_EQ(session_id_orig, answer->session_id()); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 1463 | EXPECT_LT(rtc::FromString<uint64>(session_version_orig), |
| 1464 | rtc::FromString<uint64>(answer->session_version())); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1465 | SetLocalDescriptionWithoutError(answer); |
| 1466 | |
| 1467 | ASSERT_EQ(2u, video_channel_->recv_streams().size()); |
| 1468 | EXPECT_TRUE(kVideoTrack1 == video_channel_->recv_streams()[0].id); |
| 1469 | EXPECT_TRUE(kVideoTrack2 == video_channel_->recv_streams()[1].id); |
| 1470 | ASSERT_EQ(2u, voice_channel_->recv_streams().size()); |
| 1471 | EXPECT_TRUE(kAudioTrack1 == voice_channel_->recv_streams()[0].id); |
| 1472 | EXPECT_TRUE(kAudioTrack2 == voice_channel_->recv_streams()[1].id); |
| 1473 | |
| 1474 | // Make sure we have no send streams. |
| 1475 | EXPECT_EQ(0u, video_channel_->send_streams().size()); |
| 1476 | EXPECT_EQ(0u, voice_channel_->send_streams().size()); |
| 1477 | } |
| 1478 | |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1479 | TEST_F(WebRtcSessionTest, SetLocalSdpFailedOnCreateChannel) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 1480 | Init(); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1481 | media_engine_->set_fail_create_channel(true); |
| 1482 | |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 1483 | SessionDescriptionInterface* offer = CreateOffer(); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1484 | ASSERT_TRUE(offer != NULL); |
| 1485 | // SetRemoteDescription and SetLocalDescription will take the ownership of |
| 1486 | // the offer. |
| 1487 | SetRemoteDescriptionOfferExpectError(kCreateChannelFailed, offer); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 1488 | offer = CreateOffer(); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1489 | ASSERT_TRUE(offer != NULL); |
| 1490 | SetLocalDescriptionOfferExpectError(kCreateChannelFailed, offer); |
| 1491 | } |
| 1492 | |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1493 | // |
| 1494 | // Tests for creating/setting SDP under different SDES/DTLS polices: |
| 1495 | // |
| 1496 | // --DTLS off and SDES on |
| 1497 | // TestCreateSdesOfferReceiveSdesAnswer/TestReceiveSdesOfferCreateSdesAnswer: |
| 1498 | // set local/remote offer/answer with crypto --> success |
| 1499 | // TestSetNonSdesOfferWhenSdesOn: set local/remote offer without crypto ---> |
| 1500 | // failure |
| 1501 | // TestSetLocalNonSdesAnswerWhenSdesOn: set local answer without crypto --> |
| 1502 | // failure |
| 1503 | // TestSetRemoteNonSdesAnswerWhenSdesOn: set remote answer without crypto --> |
| 1504 | // failure |
| 1505 | // |
| 1506 | // --DTLS on and SDES off |
| 1507 | // TestCreateDtlsOfferReceiveDtlsAnswer/TestReceiveDtlsOfferCreateDtlsAnswer: |
| 1508 | // set local/remote offer/answer with DTLS fingerprint --> success |
| 1509 | // TestReceiveNonDtlsOfferWhenDtlsOn: set local/remote offer without DTLS |
| 1510 | // fingerprint --> failure |
| 1511 | // TestSetLocalNonDtlsAnswerWhenDtlsOn: set local answer without fingerprint |
| 1512 | // --> failure |
| 1513 | // TestSetRemoteNonDtlsAnswerWhenDtlsOn: set remote answer without fingerprint |
| 1514 | // --> failure |
| 1515 | // |
| 1516 | // --Encryption disabled: DTLS off and SDES off |
| 1517 | // TestCreateOfferReceiveAnswerWithoutEncryption: set local offer and remote |
| 1518 | // answer without SDES or DTLS --> success |
| 1519 | // TestCreateAnswerReceiveOfferWithoutEncryption: set remote offer and local |
| 1520 | // answer without SDES or DTLS --> success |
| 1521 | // |
| 1522 | |
| 1523 | // Test that we return a failure when applying a remote/local offer that doesn't |
| 1524 | // have cryptos enabled when DTLS is off. |
| 1525 | TEST_F(WebRtcSessionTest, TestSetNonSdesOfferWhenSdesOn) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 1526 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1527 | cricket::MediaSessionOptions options; |
jiayl@webrtc.org | 742922b | 2014-10-07 21:32:43 +0000 | [diff] [blame] | 1528 | options.recv_video = true; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1529 | JsepSessionDescription* offer = CreateRemoteOffer( |
| 1530 | options, cricket::SEC_DISABLED); |
| 1531 | ASSERT_TRUE(offer != NULL); |
| 1532 | VerifyNoCryptoParams(offer->description(), false); |
| 1533 | // SetRemoteDescription and SetLocalDescription will take the ownership of |
| 1534 | // the offer. |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1535 | SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesCrypto, offer); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1536 | offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); |
| 1537 | ASSERT_TRUE(offer != NULL); |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1538 | SetLocalDescriptionOfferExpectError(kSdpWithoutSdesCrypto, offer); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1539 | } |
| 1540 | |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1541 | // Test that we return a failure when applying a local answer that doesn't have |
| 1542 | // cryptos enabled when DTLS is off. |
| 1543 | TEST_F(WebRtcSessionTest, TestSetLocalNonSdesAnswerWhenSdesOn) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 1544 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1545 | SessionDescriptionInterface* offer = NULL; |
| 1546 | SessionDescriptionInterface* answer = NULL; |
| 1547 | CreateCryptoOfferAndNonCryptoAnswer(&offer, &answer); |
| 1548 | // SetRemoteDescription and SetLocalDescription will take the ownership of |
| 1549 | // the offer. |
| 1550 | SetRemoteDescriptionWithoutError(offer); |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1551 | SetLocalDescriptionAnswerExpectError(kSdpWithoutSdesCrypto, answer); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1552 | } |
| 1553 | |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1554 | // Test we will return fail when apply an remote answer that doesn't have |
| 1555 | // crypto enabled when DTLS is off. |
| 1556 | TEST_F(WebRtcSessionTest, TestSetRemoteNonSdesAnswerWhenSdesOn) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 1557 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1558 | SessionDescriptionInterface* offer = NULL; |
| 1559 | SessionDescriptionInterface* answer = NULL; |
| 1560 | CreateCryptoOfferAndNonCryptoAnswer(&offer, &answer); |
| 1561 | // SetRemoteDescription and SetLocalDescription will take the ownership of |
| 1562 | // the offer. |
| 1563 | SetLocalDescriptionWithoutError(offer); |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1564 | SetRemoteDescriptionAnswerExpectError(kSdpWithoutSdesCrypto, answer); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1565 | } |
| 1566 | |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1567 | // Test that we accept an offer with a DTLS fingerprint when DTLS is on |
| 1568 | // and that we return an answer with a DTLS fingerprint. |
| 1569 | TEST_F(WebRtcSessionTest, TestReceiveDtlsOfferCreateDtlsAnswer) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 1570 | MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1571 | mediastream_signaling_.SendAudioVideoStream1(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1572 | InitWithDtls(); |
| 1573 | SetFactoryDtlsSrtp(); |
| 1574 | cricket::MediaSessionOptions options; |
jiayl@webrtc.org | 742922b | 2014-10-07 21:32:43 +0000 | [diff] [blame] | 1575 | options.recv_video = true; |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1576 | JsepSessionDescription* offer = |
| 1577 | CreateRemoteOffer(options, cricket::SEC_DISABLED); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1578 | ASSERT_TRUE(offer != NULL); |
| 1579 | VerifyFingerprintStatus(offer->description(), true); |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1580 | VerifyNoCryptoParams(offer->description(), true); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1581 | |
| 1582 | // SetRemoteDescription will take the ownership of the offer. |
| 1583 | SetRemoteDescriptionWithoutError(offer); |
| 1584 | |
| 1585 | // Verify that we get a crypto fingerprint in the answer. |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 1586 | SessionDescriptionInterface* answer = CreateAnswer(NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1587 | ASSERT_TRUE(answer != NULL); |
| 1588 | VerifyFingerprintStatus(answer->description(), true); |
| 1589 | // Check that we don't have an a=crypto line in the answer. |
| 1590 | VerifyNoCryptoParams(answer->description(), true); |
| 1591 | |
| 1592 | // Now set the local description, which should work, even without a=crypto. |
| 1593 | SetLocalDescriptionWithoutError(answer); |
| 1594 | } |
| 1595 | |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1596 | // Test that we set a local offer with a DTLS fingerprint when DTLS is on |
| 1597 | // and then we accept a remote answer with a DTLS fingerprint successfully. |
| 1598 | TEST_F(WebRtcSessionTest, TestCreateDtlsOfferReceiveDtlsAnswer) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 1599 | MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1600 | mediastream_signaling_.SendAudioVideoStream1(); |
| 1601 | InitWithDtls(); |
| 1602 | SetFactoryDtlsSrtp(); |
| 1603 | |
| 1604 | // Verify that we get a crypto fingerprint in the answer. |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 1605 | SessionDescriptionInterface* offer = CreateOffer(); |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1606 | ASSERT_TRUE(offer != NULL); |
| 1607 | VerifyFingerprintStatus(offer->description(), true); |
| 1608 | // Check that we don't have an a=crypto line in the offer. |
| 1609 | VerifyNoCryptoParams(offer->description(), true); |
| 1610 | |
| 1611 | // Now set the local description, which should work, even without a=crypto. |
| 1612 | SetLocalDescriptionWithoutError(offer); |
| 1613 | |
| 1614 | cricket::MediaSessionOptions options; |
jiayl@webrtc.org | 742922b | 2014-10-07 21:32:43 +0000 | [diff] [blame] | 1615 | options.recv_video = true; |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1616 | JsepSessionDescription* answer = |
| 1617 | CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); |
| 1618 | ASSERT_TRUE(answer != NULL); |
| 1619 | VerifyFingerprintStatus(answer->description(), true); |
| 1620 | VerifyNoCryptoParams(answer->description(), true); |
| 1621 | |
| 1622 | // SetRemoteDescription will take the ownership of the answer. |
| 1623 | SetRemoteDescriptionWithoutError(answer); |
| 1624 | } |
| 1625 | |
| 1626 | // Test that if we support DTLS and the other side didn't offer a fingerprint, |
| 1627 | // we will fail to set the remote description. |
| 1628 | TEST_F(WebRtcSessionTest, TestReceiveNonDtlsOfferWhenDtlsOn) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 1629 | MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1630 | InitWithDtls(); |
| 1631 | cricket::MediaSessionOptions options; |
jiayl@webrtc.org | 742922b | 2014-10-07 21:32:43 +0000 | [diff] [blame] | 1632 | options.recv_video = true; |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1633 | options.bundle_enabled = true; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1634 | JsepSessionDescription* offer = CreateRemoteOffer( |
| 1635 | options, cricket::SEC_REQUIRED); |
| 1636 | ASSERT_TRUE(offer != NULL); |
| 1637 | VerifyFingerprintStatus(offer->description(), false); |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1638 | VerifyCryptoParams(offer->description()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1639 | |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1640 | // SetRemoteDescription will take the ownership of the offer. |
| 1641 | SetRemoteDescriptionOfferExpectError( |
| 1642 | kSdpWithoutDtlsFingerprint, offer); |
| 1643 | |
| 1644 | offer = CreateRemoteOffer(options, cricket::SEC_REQUIRED); |
| 1645 | // SetLocalDescription will take the ownership of the offer. |
| 1646 | SetLocalDescriptionOfferExpectError( |
| 1647 | kSdpWithoutDtlsFingerprint, offer); |
| 1648 | } |
| 1649 | |
| 1650 | // Test that we return a failure when applying a local answer that doesn't have |
| 1651 | // a DTLS fingerprint when DTLS is required. |
| 1652 | TEST_F(WebRtcSessionTest, TestSetLocalNonDtlsAnswerWhenDtlsOn) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 1653 | MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1654 | InitWithDtls(); |
| 1655 | SessionDescriptionInterface* offer = NULL; |
| 1656 | SessionDescriptionInterface* answer = NULL; |
| 1657 | CreateDtlsOfferAndNonDtlsAnswer(&offer, &answer); |
| 1658 | |
| 1659 | // SetRemoteDescription and SetLocalDescription will take the ownership of |
| 1660 | // the offer and answer. |
| 1661 | SetRemoteDescriptionWithoutError(offer); |
| 1662 | SetLocalDescriptionAnswerExpectError( |
| 1663 | kSdpWithoutDtlsFingerprint, answer); |
| 1664 | } |
| 1665 | |
| 1666 | // Test that we return a failure when applying a remote answer that doesn't have |
| 1667 | // a DTLS fingerprint when DTLS is required. |
| 1668 | TEST_F(WebRtcSessionTest, TestSetRemoteNonDtlsAnswerWhenDtlsOn) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 1669 | MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
deadbeef | f393829 | 2015-07-15 12:20:53 -0700 | [diff] [blame] | 1670 | // Enable both SDES and DTLS, so that offer won't be outright rejected as a |
| 1671 | // result of using the "UDP/TLS/RTP/SAVPF" profile. |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1672 | InitWithDtls(); |
deadbeef | f393829 | 2015-07-15 12:20:53 -0700 | [diff] [blame] | 1673 | session_->SetSdesPolicy(cricket::SEC_ENABLED); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 1674 | SessionDescriptionInterface* offer = CreateOffer(); |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1675 | cricket::MediaSessionOptions options; |
jiayl@webrtc.org | 742922b | 2014-10-07 21:32:43 +0000 | [diff] [blame] | 1676 | options.recv_video = true; |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1677 | JsepSessionDescription* answer = |
| 1678 | CreateRemoteAnswer(offer, options, cricket::SEC_ENABLED); |
| 1679 | |
| 1680 | // SetRemoteDescription and SetLocalDescription will take the ownership of |
| 1681 | // the offer and answer. |
| 1682 | SetLocalDescriptionWithoutError(offer); |
| 1683 | SetRemoteDescriptionAnswerExpectError( |
| 1684 | kSdpWithoutDtlsFingerprint, answer); |
| 1685 | } |
| 1686 | |
| 1687 | // Test that we create a local offer without SDES or DTLS and accept a remote |
| 1688 | // answer without SDES or DTLS when encryption is disabled. |
| 1689 | TEST_F(WebRtcSessionTest, TestCreateOfferReceiveAnswerWithoutEncryption) { |
| 1690 | mediastream_signaling_.SendAudioVideoStream1(); |
| 1691 | options_.disable_encryption = true; |
| 1692 | InitWithDtls(); |
| 1693 | |
| 1694 | // Verify that we get a crypto fingerprint in the answer. |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 1695 | SessionDescriptionInterface* offer = CreateOffer(); |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1696 | ASSERT_TRUE(offer != NULL); |
| 1697 | VerifyFingerprintStatus(offer->description(), false); |
| 1698 | // Check that we don't have an a=crypto line in the offer. |
| 1699 | VerifyNoCryptoParams(offer->description(), false); |
| 1700 | |
| 1701 | // Now set the local description, which should work, even without a=crypto. |
| 1702 | SetLocalDescriptionWithoutError(offer); |
| 1703 | |
| 1704 | cricket::MediaSessionOptions options; |
jiayl@webrtc.org | 742922b | 2014-10-07 21:32:43 +0000 | [diff] [blame] | 1705 | options.recv_video = true; |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1706 | JsepSessionDescription* answer = |
| 1707 | CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); |
| 1708 | ASSERT_TRUE(answer != NULL); |
| 1709 | VerifyFingerprintStatus(answer->description(), false); |
| 1710 | VerifyNoCryptoParams(answer->description(), false); |
| 1711 | |
| 1712 | // SetRemoteDescription will take the ownership of the answer. |
| 1713 | SetRemoteDescriptionWithoutError(answer); |
| 1714 | } |
| 1715 | |
| 1716 | // Test that we create a local answer without SDES or DTLS and accept a remote |
| 1717 | // offer without SDES or DTLS when encryption is disabled. |
| 1718 | TEST_F(WebRtcSessionTest, TestCreateAnswerReceiveOfferWithoutEncryption) { |
| 1719 | options_.disable_encryption = true; |
| 1720 | InitWithDtls(); |
| 1721 | |
| 1722 | cricket::MediaSessionOptions options; |
jiayl@webrtc.org | 742922b | 2014-10-07 21:32:43 +0000 | [diff] [blame] | 1723 | options.recv_video = true; |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1724 | JsepSessionDescription* offer = |
| 1725 | CreateRemoteOffer(options, cricket::SEC_DISABLED); |
| 1726 | ASSERT_TRUE(offer != NULL); |
| 1727 | VerifyFingerprintStatus(offer->description(), false); |
| 1728 | VerifyNoCryptoParams(offer->description(), false); |
| 1729 | |
| 1730 | // SetRemoteDescription will take the ownership of the offer. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1731 | SetRemoteDescriptionWithoutError(offer); |
| 1732 | |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1733 | // Verify that we get a crypto fingerprint in the answer. |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 1734 | SessionDescriptionInterface* answer = CreateAnswer(NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1735 | ASSERT_TRUE(answer != NULL); |
| 1736 | VerifyFingerprintStatus(answer->description(), false); |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1737 | // Check that we don't have an a=crypto line in the answer. |
| 1738 | VerifyNoCryptoParams(answer->description(), false); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1739 | |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 1740 | // Now set the local description, which should work, even without a=crypto. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1741 | SetLocalDescriptionWithoutError(answer); |
| 1742 | } |
| 1743 | |
| 1744 | TEST_F(WebRtcSessionTest, TestSetLocalOfferTwice) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 1745 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1746 | mediastream_signaling_.SendNothing(); |
| 1747 | // SetLocalDescription take ownership of offer. |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 1748 | SessionDescriptionInterface* offer = CreateOffer(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1749 | SetLocalDescriptionWithoutError(offer); |
| 1750 | |
| 1751 | // SetLocalDescription take ownership of offer. |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 1752 | SessionDescriptionInterface* offer2 = CreateOffer(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1753 | SetLocalDescriptionWithoutError(offer2); |
| 1754 | } |
| 1755 | |
| 1756 | TEST_F(WebRtcSessionTest, TestSetRemoteOfferTwice) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 1757 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1758 | mediastream_signaling_.SendNothing(); |
| 1759 | // SetLocalDescription take ownership of offer. |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 1760 | SessionDescriptionInterface* offer = CreateOffer(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1761 | SetRemoteDescriptionWithoutError(offer); |
| 1762 | |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 1763 | SessionDescriptionInterface* offer2 = CreateOffer(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1764 | SetRemoteDescriptionWithoutError(offer2); |
| 1765 | } |
| 1766 | |
| 1767 | TEST_F(WebRtcSessionTest, TestSetLocalAndRemoteOffer) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 1768 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1769 | mediastream_signaling_.SendNothing(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 1770 | SessionDescriptionInterface* offer = CreateOffer(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1771 | SetLocalDescriptionWithoutError(offer); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 1772 | offer = CreateOffer(); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1773 | SetRemoteDescriptionOfferExpectError( |
| 1774 | "Called in wrong state: STATE_SENTINITIATE", offer); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1775 | } |
| 1776 | |
| 1777 | TEST_F(WebRtcSessionTest, TestSetRemoteAndLocalOffer) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 1778 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1779 | mediastream_signaling_.SendNothing(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 1780 | SessionDescriptionInterface* offer = CreateOffer(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1781 | SetRemoteDescriptionWithoutError(offer); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 1782 | offer = CreateOffer(); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1783 | SetLocalDescriptionOfferExpectError( |
| 1784 | "Called in wrong state: STATE_RECEIVEDINITIATE", offer); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1785 | } |
| 1786 | |
| 1787 | TEST_F(WebRtcSessionTest, TestSetLocalPrAnswer) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 1788 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1789 | mediastream_signaling_.SendNothing(); |
| 1790 | SessionDescriptionInterface* offer = CreateRemoteOffer(); |
| 1791 | SetRemoteDescriptionExpectState(offer, BaseSession::STATE_RECEIVEDINITIATE); |
| 1792 | |
| 1793 | JsepSessionDescription* pranswer = static_cast<JsepSessionDescription*>( |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 1794 | CreateAnswer(NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1795 | pranswer->set_type(SessionDescriptionInterface::kPrAnswer); |
| 1796 | SetLocalDescriptionExpectState(pranswer, BaseSession::STATE_SENTPRACCEPT); |
| 1797 | |
| 1798 | mediastream_signaling_.SendAudioVideoStream1(); |
| 1799 | JsepSessionDescription* pranswer2 = static_cast<JsepSessionDescription*>( |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 1800 | CreateAnswer(NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1801 | pranswer2->set_type(SessionDescriptionInterface::kPrAnswer); |
| 1802 | |
| 1803 | SetLocalDescriptionExpectState(pranswer2, BaseSession::STATE_SENTPRACCEPT); |
| 1804 | |
| 1805 | mediastream_signaling_.SendAudioVideoStream2(); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 1806 | SessionDescriptionInterface* answer = CreateAnswer(NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1807 | SetLocalDescriptionExpectState(answer, BaseSession::STATE_SENTACCEPT); |
| 1808 | } |
| 1809 | |
| 1810 | TEST_F(WebRtcSessionTest, TestSetRemotePrAnswer) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 1811 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1812 | mediastream_signaling_.SendNothing(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 1813 | SessionDescriptionInterface* offer = CreateOffer(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1814 | SetLocalDescriptionExpectState(offer, BaseSession::STATE_SENTINITIATE); |
| 1815 | |
| 1816 | JsepSessionDescription* pranswer = |
| 1817 | CreateRemoteAnswer(session_->local_description()); |
| 1818 | pranswer->set_type(SessionDescriptionInterface::kPrAnswer); |
| 1819 | |
| 1820 | SetRemoteDescriptionExpectState(pranswer, |
| 1821 | BaseSession::STATE_RECEIVEDPRACCEPT); |
| 1822 | |
| 1823 | mediastream_signaling_.SendAudioVideoStream1(); |
| 1824 | JsepSessionDescription* pranswer2 = |
| 1825 | CreateRemoteAnswer(session_->local_description()); |
| 1826 | pranswer2->set_type(SessionDescriptionInterface::kPrAnswer); |
| 1827 | |
| 1828 | SetRemoteDescriptionExpectState(pranswer2, |
| 1829 | BaseSession::STATE_RECEIVEDPRACCEPT); |
| 1830 | |
| 1831 | mediastream_signaling_.SendAudioVideoStream2(); |
| 1832 | SessionDescriptionInterface* answer = |
| 1833 | CreateRemoteAnswer(session_->local_description()); |
| 1834 | SetRemoteDescriptionExpectState(answer, BaseSession::STATE_RECEIVEDACCEPT); |
| 1835 | } |
| 1836 | |
| 1837 | TEST_F(WebRtcSessionTest, TestSetLocalAnswerWithoutOffer) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 1838 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1839 | mediastream_signaling_.SendNothing(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 1840 | rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 1841 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1842 | SessionDescriptionInterface* answer = |
| 1843 | CreateRemoteAnswer(offer.get()); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1844 | SetLocalDescriptionAnswerExpectError("Called in wrong state: STATE_INIT", |
| 1845 | answer); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1846 | } |
| 1847 | |
| 1848 | TEST_F(WebRtcSessionTest, TestSetRemoteAnswerWithoutOffer) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 1849 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1850 | mediastream_signaling_.SendNothing(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 1851 | rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 1852 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1853 | SessionDescriptionInterface* answer = |
| 1854 | CreateRemoteAnswer(offer.get()); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1855 | SetRemoteDescriptionAnswerExpectError( |
| 1856 | "Called in wrong state: STATE_INIT", answer); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1857 | } |
| 1858 | |
| 1859 | TEST_F(WebRtcSessionTest, TestAddRemoteCandidate) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 1860 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1861 | mediastream_signaling_.SendAudioVideoStream1(); |
| 1862 | |
| 1863 | cricket::Candidate candidate; |
| 1864 | candidate.set_component(1); |
| 1865 | JsepIceCandidate ice_candidate1(kMediaContentName0, 0, candidate); |
| 1866 | |
| 1867 | // Fail since we have not set a offer description. |
| 1868 | EXPECT_FALSE(session_->ProcessIceMessage(&ice_candidate1)); |
| 1869 | |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 1870 | SessionDescriptionInterface* offer = CreateOffer(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1871 | SetLocalDescriptionWithoutError(offer); |
| 1872 | // Candidate should be allowed to add before remote description. |
| 1873 | EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate1)); |
| 1874 | candidate.set_component(2); |
| 1875 | JsepIceCandidate ice_candidate2(kMediaContentName0, 0, candidate); |
| 1876 | EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate2)); |
| 1877 | |
| 1878 | SessionDescriptionInterface* answer = CreateRemoteAnswer( |
| 1879 | session_->local_description()); |
| 1880 | SetRemoteDescriptionWithoutError(answer); |
| 1881 | |
| 1882 | // Verifying the candidates are copied properly from internal vector. |
| 1883 | const SessionDescriptionInterface* remote_desc = |
| 1884 | session_->remote_description(); |
| 1885 | ASSERT_TRUE(remote_desc != NULL); |
| 1886 | ASSERT_EQ(2u, remote_desc->number_of_mediasections()); |
| 1887 | const IceCandidateCollection* candidates = |
| 1888 | remote_desc->candidates(kMediaContentIndex0); |
| 1889 | ASSERT_EQ(2u, candidates->count()); |
| 1890 | EXPECT_EQ(kMediaContentIndex0, candidates->at(0)->sdp_mline_index()); |
| 1891 | EXPECT_EQ(kMediaContentName0, candidates->at(0)->sdp_mid()); |
| 1892 | EXPECT_EQ(1, candidates->at(0)->candidate().component()); |
| 1893 | EXPECT_EQ(2, candidates->at(1)->candidate().component()); |
| 1894 | |
mallinath@webrtc.org | 67ee6b9 | 2014-02-03 16:57:16 +0000 | [diff] [blame] | 1895 | // |ice_candidate3| is identical to |ice_candidate2|. It can be added |
| 1896 | // successfully, but the total count of candidates will not increase. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1897 | candidate.set_component(2); |
| 1898 | JsepIceCandidate ice_candidate3(kMediaContentName0, 0, candidate); |
| 1899 | EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate3)); |
mallinath@webrtc.org | 67ee6b9 | 2014-02-03 16:57:16 +0000 | [diff] [blame] | 1900 | ASSERT_EQ(2u, candidates->count()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1901 | |
| 1902 | JsepIceCandidate bad_ice_candidate("bad content name", 99, candidate); |
| 1903 | EXPECT_FALSE(session_->ProcessIceMessage(&bad_ice_candidate)); |
| 1904 | } |
| 1905 | |
| 1906 | // Test that a remote candidate is added to the remote session description and |
| 1907 | // that it is retained if the remote session description is changed. |
| 1908 | TEST_F(WebRtcSessionTest, TestRemoteCandidatesAddedToSessionDescription) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 1909 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1910 | cricket::Candidate candidate1; |
| 1911 | candidate1.set_component(1); |
| 1912 | JsepIceCandidate ice_candidate1(kMediaContentName0, kMediaContentIndex0, |
| 1913 | candidate1); |
| 1914 | mediastream_signaling_.SendAudioVideoStream1(); |
| 1915 | CreateAndSetRemoteOfferAndLocalAnswer(); |
| 1916 | |
| 1917 | EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate1)); |
| 1918 | const SessionDescriptionInterface* remote_desc = |
| 1919 | session_->remote_description(); |
| 1920 | ASSERT_TRUE(remote_desc != NULL); |
| 1921 | ASSERT_EQ(2u, remote_desc->number_of_mediasections()); |
| 1922 | const IceCandidateCollection* candidates = |
| 1923 | remote_desc->candidates(kMediaContentIndex0); |
| 1924 | ASSERT_EQ(1u, candidates->count()); |
| 1925 | EXPECT_EQ(kMediaContentIndex0, candidates->at(0)->sdp_mline_index()); |
| 1926 | |
| 1927 | // Update the RemoteSessionDescription with a new session description and |
| 1928 | // a candidate and check that the new remote session description contains both |
| 1929 | // candidates. |
| 1930 | SessionDescriptionInterface* offer = CreateRemoteOffer(); |
| 1931 | cricket::Candidate candidate2; |
| 1932 | JsepIceCandidate ice_candidate2(kMediaContentName0, kMediaContentIndex0, |
| 1933 | candidate2); |
| 1934 | EXPECT_TRUE(offer->AddCandidate(&ice_candidate2)); |
| 1935 | SetRemoteDescriptionWithoutError(offer); |
| 1936 | |
| 1937 | remote_desc = session_->remote_description(); |
| 1938 | ASSERT_TRUE(remote_desc != NULL); |
| 1939 | ASSERT_EQ(2u, remote_desc->number_of_mediasections()); |
| 1940 | candidates = remote_desc->candidates(kMediaContentIndex0); |
| 1941 | ASSERT_EQ(2u, candidates->count()); |
| 1942 | EXPECT_EQ(kMediaContentIndex0, candidates->at(0)->sdp_mline_index()); |
| 1943 | // Username and password have be updated with the TransportInfo of the |
| 1944 | // SessionDescription, won't be equal to the original one. |
| 1945 | candidate2.set_username(candidates->at(0)->candidate().username()); |
| 1946 | candidate2.set_password(candidates->at(0)->candidate().password()); |
| 1947 | EXPECT_TRUE(candidate2.IsEquivalent(candidates->at(0)->candidate())); |
| 1948 | EXPECT_EQ(kMediaContentIndex0, candidates->at(1)->sdp_mline_index()); |
| 1949 | // No need to verify the username and password. |
| 1950 | candidate1.set_username(candidates->at(1)->candidate().username()); |
| 1951 | candidate1.set_password(candidates->at(1)->candidate().password()); |
| 1952 | EXPECT_TRUE(candidate1.IsEquivalent(candidates->at(1)->candidate())); |
| 1953 | |
| 1954 | // Test that the candidate is ignored if we can add the same candidate again. |
| 1955 | EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate2)); |
| 1956 | } |
| 1957 | |
| 1958 | // Test that local candidates are added to the local session description and |
| 1959 | // that they are retained if the local session description is changed. |
| 1960 | TEST_F(WebRtcSessionTest, TestLocalCandidatesAddedToSessionDescription) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 1961 | AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 1962 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1963 | mediastream_signaling_.SendAudioVideoStream1(); |
| 1964 | CreateAndSetRemoteOfferAndLocalAnswer(); |
| 1965 | |
| 1966 | const SessionDescriptionInterface* local_desc = session_->local_description(); |
| 1967 | const IceCandidateCollection* candidates = |
| 1968 | local_desc->candidates(kMediaContentIndex0); |
| 1969 | ASSERT_TRUE(candidates != NULL); |
| 1970 | EXPECT_EQ(0u, candidates->count()); |
| 1971 | |
| 1972 | EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); |
| 1973 | |
| 1974 | local_desc = session_->local_description(); |
| 1975 | candidates = local_desc->candidates(kMediaContentIndex0); |
| 1976 | ASSERT_TRUE(candidates != NULL); |
| 1977 | EXPECT_LT(0u, candidates->count()); |
| 1978 | candidates = local_desc->candidates(1); |
| 1979 | ASSERT_TRUE(candidates != NULL); |
| 1980 | EXPECT_LT(0u, candidates->count()); |
| 1981 | |
| 1982 | // Update the session descriptions. |
| 1983 | mediastream_signaling_.SendAudioVideoStream1(); |
| 1984 | CreateAndSetRemoteOfferAndLocalAnswer(); |
| 1985 | |
| 1986 | local_desc = session_->local_description(); |
| 1987 | candidates = local_desc->candidates(kMediaContentIndex0); |
| 1988 | ASSERT_TRUE(candidates != NULL); |
| 1989 | EXPECT_LT(0u, candidates->count()); |
| 1990 | candidates = local_desc->candidates(1); |
| 1991 | ASSERT_TRUE(candidates != NULL); |
| 1992 | EXPECT_LT(0u, candidates->count()); |
| 1993 | } |
| 1994 | |
| 1995 | // Test that we can set a remote session description with remote candidates. |
| 1996 | TEST_F(WebRtcSessionTest, TestSetRemoteSessionDescriptionWithCandidates) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 1997 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1998 | |
| 1999 | cricket::Candidate candidate1; |
| 2000 | candidate1.set_component(1); |
| 2001 | JsepIceCandidate ice_candidate(kMediaContentName0, kMediaContentIndex0, |
| 2002 | candidate1); |
| 2003 | mediastream_signaling_.SendAudioVideoStream1(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 2004 | SessionDescriptionInterface* offer = CreateOffer(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2005 | |
| 2006 | EXPECT_TRUE(offer->AddCandidate(&ice_candidate)); |
| 2007 | SetRemoteDescriptionWithoutError(offer); |
| 2008 | |
| 2009 | const SessionDescriptionInterface* remote_desc = |
| 2010 | session_->remote_description(); |
| 2011 | ASSERT_TRUE(remote_desc != NULL); |
| 2012 | ASSERT_EQ(2u, remote_desc->number_of_mediasections()); |
| 2013 | const IceCandidateCollection* candidates = |
| 2014 | remote_desc->candidates(kMediaContentIndex0); |
| 2015 | ASSERT_EQ(1u, candidates->count()); |
| 2016 | EXPECT_EQ(kMediaContentIndex0, candidates->at(0)->sdp_mline_index()); |
| 2017 | |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 2018 | SessionDescriptionInterface* answer = CreateAnswer(NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2019 | SetLocalDescriptionWithoutError(answer); |
| 2020 | } |
| 2021 | |
| 2022 | // Test that offers and answers contains ice candidates when Ice candidates have |
| 2023 | // been gathered. |
| 2024 | TEST_F(WebRtcSessionTest, TestSetLocalAndRemoteDescriptionWithCandidates) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 2025 | AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2026 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2027 | mediastream_signaling_.SendAudioVideoStream1(); |
| 2028 | // Ice is started but candidates are not provided until SetLocalDescription |
| 2029 | // is called. |
| 2030 | EXPECT_EQ(0u, observer_.mline_0_candidates_.size()); |
| 2031 | EXPECT_EQ(0u, observer_.mline_1_candidates_.size()); |
| 2032 | CreateAndSetRemoteOfferAndLocalAnswer(); |
| 2033 | // Wait until at least one local candidate has been collected. |
| 2034 | EXPECT_TRUE_WAIT(0u < observer_.mline_0_candidates_.size(), |
| 2035 | kIceCandidatesTimeout); |
| 2036 | EXPECT_TRUE_WAIT(0u < observer_.mline_1_candidates_.size(), |
| 2037 | kIceCandidatesTimeout); |
| 2038 | |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 2039 | rtc::scoped_ptr<SessionDescriptionInterface> local_offer(CreateOffer()); |
| 2040 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2041 | ASSERT_TRUE(local_offer->candidates(kMediaContentIndex0) != NULL); |
| 2042 | EXPECT_LT(0u, local_offer->candidates(kMediaContentIndex0)->count()); |
| 2043 | ASSERT_TRUE(local_offer->candidates(kMediaContentIndex1) != NULL); |
| 2044 | EXPECT_LT(0u, local_offer->candidates(kMediaContentIndex1)->count()); |
| 2045 | |
| 2046 | SessionDescriptionInterface* remote_offer(CreateRemoteOffer()); |
| 2047 | SetRemoteDescriptionWithoutError(remote_offer); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 2048 | SessionDescriptionInterface* answer = CreateAnswer(NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2049 | ASSERT_TRUE(answer->candidates(kMediaContentIndex0) != NULL); |
| 2050 | EXPECT_LT(0u, answer->candidates(kMediaContentIndex0)->count()); |
| 2051 | ASSERT_TRUE(answer->candidates(kMediaContentIndex1) != NULL); |
| 2052 | EXPECT_LT(0u, answer->candidates(kMediaContentIndex1)->count()); |
| 2053 | SetLocalDescriptionWithoutError(answer); |
| 2054 | } |
| 2055 | |
| 2056 | // Verifies TransportProxy and media channels are created with content names |
| 2057 | // present in the SessionDescription. |
| 2058 | TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2059 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2060 | mediastream_signaling_.SendAudioVideoStream1(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 2061 | rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2062 | |
| 2063 | // CreateOffer creates session description with the content names "audio" and |
| 2064 | // "video". Goal is to modify these content names and verify transport channel |
| 2065 | // proxy in the BaseSession, as proxies are created with the content names |
| 2066 | // present in SDP. |
| 2067 | std::string sdp; |
| 2068 | EXPECT_TRUE(offer->ToString(&sdp)); |
| 2069 | const std::string kAudioMid = "a=mid:audio"; |
| 2070 | const std::string kAudioMidReplaceStr = "a=mid:audio_content_name"; |
| 2071 | const std::string kVideoMid = "a=mid:video"; |
| 2072 | const std::string kVideoMidReplaceStr = "a=mid:video_content_name"; |
| 2073 | |
| 2074 | // Replacing |audio| with |audio_content_name|. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 2075 | rtc::replace_substrs(kAudioMid.c_str(), kAudioMid.length(), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2076 | kAudioMidReplaceStr.c_str(), |
| 2077 | kAudioMidReplaceStr.length(), |
| 2078 | &sdp); |
| 2079 | // Replacing |video| with |video_content_name|. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 2080 | rtc::replace_substrs(kVideoMid.c_str(), kVideoMid.length(), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2081 | kVideoMidReplaceStr.c_str(), |
| 2082 | kVideoMidReplaceStr.length(), |
| 2083 | &sdp); |
| 2084 | |
| 2085 | SessionDescriptionInterface* modified_offer = |
| 2086 | CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); |
| 2087 | |
| 2088 | SetRemoteDescriptionWithoutError(modified_offer); |
| 2089 | |
| 2090 | SessionDescriptionInterface* answer = |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 2091 | CreateAnswer(NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2092 | SetLocalDescriptionWithoutError(answer); |
| 2093 | |
| 2094 | EXPECT_TRUE(session_->GetTransportProxy("audio_content_name") != NULL); |
| 2095 | EXPECT_TRUE(session_->GetTransportProxy("video_content_name") != NULL); |
| 2096 | EXPECT_TRUE((video_channel_ = media_engine_->GetVideoChannel(0)) != NULL); |
| 2097 | EXPECT_TRUE((voice_channel_ = media_engine_->GetVoiceChannel(0)) != NULL); |
| 2098 | } |
| 2099 | |
| 2100 | // Test that an offer contains the correct media content descriptions based on |
| 2101 | // the send streams when no constraints have been set. |
| 2102 | TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraintsOrStreams) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2103 | Init(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 2104 | rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 2105 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2106 | ASSERT_TRUE(offer != NULL); |
| 2107 | const cricket::ContentInfo* content = |
| 2108 | cricket::GetFirstAudioContent(offer->description()); |
| 2109 | EXPECT_TRUE(content != NULL); |
| 2110 | content = cricket::GetFirstVideoContent(offer->description()); |
| 2111 | EXPECT_TRUE(content == NULL); |
| 2112 | } |
| 2113 | |
| 2114 | // Test that an offer contains the correct media content descriptions based on |
| 2115 | // the send streams when no constraints have been set. |
| 2116 | TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraints) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2117 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2118 | // Test Audio only offer. |
| 2119 | mediastream_signaling_.UseOptionsAudioOnly(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 2120 | rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 2121 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2122 | const cricket::ContentInfo* content = |
| 2123 | cricket::GetFirstAudioContent(offer->description()); |
| 2124 | EXPECT_TRUE(content != NULL); |
| 2125 | content = cricket::GetFirstVideoContent(offer->description()); |
| 2126 | EXPECT_TRUE(content == NULL); |
| 2127 | |
| 2128 | // Test Audio / Video offer. |
| 2129 | mediastream_signaling_.SendAudioVideoStream1(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 2130 | offer.reset(CreateOffer()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2131 | content = cricket::GetFirstAudioContent(offer->description()); |
| 2132 | EXPECT_TRUE(content != NULL); |
| 2133 | content = cricket::GetFirstVideoContent(offer->description()); |
| 2134 | EXPECT_TRUE(content != NULL); |
| 2135 | } |
| 2136 | |
| 2137 | // Test that an offer contains no media content descriptions if |
| 2138 | // kOfferToReceiveVideo and kOfferToReceiveAudio constraints are set to false. |
| 2139 | TEST_F(WebRtcSessionTest, CreateOfferWithConstraintsWithoutStreams) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2140 | Init(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 2141 | PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2142 | options.offer_to_receive_audio = 0; |
| 2143 | options.offer_to_receive_video = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2144 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 2145 | rtc::scoped_ptr<SessionDescriptionInterface> offer( |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 2146 | CreateOffer(options)); |
| 2147 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2148 | ASSERT_TRUE(offer != NULL); |
| 2149 | const cricket::ContentInfo* content = |
| 2150 | cricket::GetFirstAudioContent(offer->description()); |
| 2151 | EXPECT_TRUE(content == NULL); |
| 2152 | content = cricket::GetFirstVideoContent(offer->description()); |
| 2153 | EXPECT_TRUE(content == NULL); |
| 2154 | } |
| 2155 | |
| 2156 | // Test that an offer contains only audio media content descriptions if |
| 2157 | // kOfferToReceiveAudio constraints are set to true. |
| 2158 | TEST_F(WebRtcSessionTest, CreateAudioOnlyOfferWithConstraints) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2159 | Init(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 2160 | PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2161 | options.offer_to_receive_audio = |
| 2162 | RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; |
| 2163 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 2164 | rtc::scoped_ptr<SessionDescriptionInterface> offer( |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 2165 | CreateOffer(options)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2166 | |
| 2167 | const cricket::ContentInfo* content = |
| 2168 | cricket::GetFirstAudioContent(offer->description()); |
| 2169 | EXPECT_TRUE(content != NULL); |
| 2170 | content = cricket::GetFirstVideoContent(offer->description()); |
| 2171 | EXPECT_TRUE(content == NULL); |
| 2172 | } |
| 2173 | |
| 2174 | // Test that an offer contains audio and video media content descriptions if |
| 2175 | // kOfferToReceiveAudio and kOfferToReceiveVideo constraints are set to true. |
| 2176 | TEST_F(WebRtcSessionTest, CreateOfferWithConstraints) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2177 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2178 | // Test Audio / Video offer. |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 2179 | PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2180 | options.offer_to_receive_audio = |
| 2181 | RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; |
| 2182 | options.offer_to_receive_video = |
| 2183 | RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; |
| 2184 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 2185 | rtc::scoped_ptr<SessionDescriptionInterface> offer( |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 2186 | CreateOffer(options)); |
| 2187 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2188 | const cricket::ContentInfo* content = |
| 2189 | cricket::GetFirstAudioContent(offer->description()); |
jiayl@webrtc.org | c172320 | 2014-09-08 20:44:36 +0000 | [diff] [blame] | 2190 | EXPECT_TRUE(content != NULL); |
jiayl@webrtc.org | 7d4891d | 2014-09-09 21:43:15 +0000 | [diff] [blame] | 2191 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2192 | content = cricket::GetFirstVideoContent(offer->description()); |
| 2193 | EXPECT_TRUE(content != NULL); |
| 2194 | |
jiayl@webrtc.org | 7d4891d | 2014-09-09 21:43:15 +0000 | [diff] [blame] | 2195 | // Sets constraints to false and verifies that audio/video contents are |
| 2196 | // removed. |
| 2197 | options.offer_to_receive_audio = 0; |
| 2198 | options.offer_to_receive_video = 0; |
| 2199 | offer.reset(CreateOffer(options)); |
| 2200 | |
| 2201 | content = cricket::GetFirstAudioContent(offer->description()); |
| 2202 | EXPECT_TRUE(content == NULL); |
| 2203 | content = cricket::GetFirstVideoContent(offer->description()); |
| 2204 | EXPECT_TRUE(content == NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2205 | } |
| 2206 | |
| 2207 | // Test that an answer can not be created if the last remote description is not |
| 2208 | // an offer. |
| 2209 | TEST_F(WebRtcSessionTest, CreateAnswerWithoutAnOffer) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2210 | Init(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 2211 | SessionDescriptionInterface* offer = CreateOffer(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2212 | SetLocalDescriptionWithoutError(offer); |
| 2213 | SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); |
| 2214 | SetRemoteDescriptionWithoutError(answer); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 2215 | EXPECT_TRUE(CreateAnswer(NULL) == NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2216 | } |
| 2217 | |
| 2218 | // Test that an answer contains the correct media content descriptions when no |
| 2219 | // constraints have been set. |
| 2220 | TEST_F(WebRtcSessionTest, CreateAnswerWithoutConstraintsOrStreams) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2221 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2222 | // Create a remote offer with audio and video content. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 2223 | rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2224 | SetRemoteDescriptionWithoutError(offer.release()); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 2225 | rtc::scoped_ptr<SessionDescriptionInterface> answer( |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 2226 | CreateAnswer(NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2227 | const cricket::ContentInfo* content = |
| 2228 | cricket::GetFirstAudioContent(answer->description()); |
| 2229 | ASSERT_TRUE(content != NULL); |
| 2230 | EXPECT_FALSE(content->rejected); |
| 2231 | |
| 2232 | content = cricket::GetFirstVideoContent(answer->description()); |
| 2233 | ASSERT_TRUE(content != NULL); |
| 2234 | EXPECT_FALSE(content->rejected); |
| 2235 | } |
| 2236 | |
| 2237 | // Test that an answer contains the correct media content descriptions when no |
| 2238 | // constraints have been set and the offer only contain audio. |
| 2239 | TEST_F(WebRtcSessionTest, CreateAudioAnswerWithoutConstraintsOrStreams) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2240 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2241 | // Create a remote offer with audio only. |
| 2242 | cricket::MediaSessionOptions options; |
jiayl@webrtc.org | 7d4891d | 2014-09-09 21:43:15 +0000 | [diff] [blame] | 2243 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 2244 | rtc::scoped_ptr<JsepSessionDescription> offer( |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2245 | CreateRemoteOffer(options)); |
| 2246 | ASSERT_TRUE(cricket::GetFirstVideoContent(offer->description()) == NULL); |
| 2247 | ASSERT_TRUE(cricket::GetFirstAudioContent(offer->description()) != NULL); |
| 2248 | |
| 2249 | SetRemoteDescriptionWithoutError(offer.release()); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 2250 | rtc::scoped_ptr<SessionDescriptionInterface> answer( |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 2251 | CreateAnswer(NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2252 | const cricket::ContentInfo* content = |
| 2253 | cricket::GetFirstAudioContent(answer->description()); |
| 2254 | ASSERT_TRUE(content != NULL); |
| 2255 | EXPECT_FALSE(content->rejected); |
| 2256 | |
| 2257 | EXPECT_TRUE(cricket::GetFirstVideoContent(answer->description()) == NULL); |
| 2258 | } |
| 2259 | |
| 2260 | // Test that an answer contains the correct media content descriptions when no |
| 2261 | // constraints have been set. |
| 2262 | TEST_F(WebRtcSessionTest, CreateAnswerWithoutConstraints) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2263 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2264 | // Create a remote offer with audio and video content. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 2265 | rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2266 | SetRemoteDescriptionWithoutError(offer.release()); |
| 2267 | // Test with a stream with tracks. |
| 2268 | mediastream_signaling_.SendAudioVideoStream1(); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 2269 | rtc::scoped_ptr<SessionDescriptionInterface> answer( |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 2270 | CreateAnswer(NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2271 | const cricket::ContentInfo* content = |
| 2272 | cricket::GetFirstAudioContent(answer->description()); |
| 2273 | ASSERT_TRUE(content != NULL); |
| 2274 | EXPECT_FALSE(content->rejected); |
| 2275 | |
| 2276 | content = cricket::GetFirstVideoContent(answer->description()); |
| 2277 | ASSERT_TRUE(content != NULL); |
| 2278 | EXPECT_FALSE(content->rejected); |
| 2279 | } |
| 2280 | |
| 2281 | // Test that an answer contains the correct media content descriptions when |
| 2282 | // constraints have been set but no stream is sent. |
| 2283 | TEST_F(WebRtcSessionTest, CreateAnswerWithConstraintsWithoutStreams) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2284 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2285 | // Create a remote offer with audio and video content. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 2286 | rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2287 | SetRemoteDescriptionWithoutError(offer.release()); |
| 2288 | |
| 2289 | webrtc::FakeConstraints constraints_no_receive; |
| 2290 | constraints_no_receive.SetMandatoryReceiveAudio(false); |
| 2291 | constraints_no_receive.SetMandatoryReceiveVideo(false); |
| 2292 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 2293 | rtc::scoped_ptr<SessionDescriptionInterface> answer( |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 2294 | CreateAnswer(&constraints_no_receive)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2295 | const cricket::ContentInfo* content = |
| 2296 | cricket::GetFirstAudioContent(answer->description()); |
| 2297 | ASSERT_TRUE(content != NULL); |
| 2298 | EXPECT_TRUE(content->rejected); |
| 2299 | |
| 2300 | content = cricket::GetFirstVideoContent(answer->description()); |
| 2301 | ASSERT_TRUE(content != NULL); |
| 2302 | EXPECT_TRUE(content->rejected); |
| 2303 | } |
| 2304 | |
| 2305 | // Test that an answer contains the correct media content descriptions when |
| 2306 | // constraints have been set and streams are sent. |
| 2307 | TEST_F(WebRtcSessionTest, CreateAnswerWithConstraints) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2308 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2309 | // Create a remote offer with audio and video content. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 2310 | rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2311 | SetRemoteDescriptionWithoutError(offer.release()); |
| 2312 | |
| 2313 | webrtc::FakeConstraints constraints_no_receive; |
| 2314 | constraints_no_receive.SetMandatoryReceiveAudio(false); |
| 2315 | constraints_no_receive.SetMandatoryReceiveVideo(false); |
| 2316 | |
| 2317 | // Test with a stream with tracks. |
| 2318 | mediastream_signaling_.SendAudioVideoStream1(); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 2319 | rtc::scoped_ptr<SessionDescriptionInterface> answer( |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 2320 | CreateAnswer(&constraints_no_receive)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2321 | |
| 2322 | // TODO(perkj): Should the direction be set to SEND_ONLY? |
| 2323 | const cricket::ContentInfo* content = |
| 2324 | cricket::GetFirstAudioContent(answer->description()); |
| 2325 | ASSERT_TRUE(content != NULL); |
| 2326 | EXPECT_FALSE(content->rejected); |
| 2327 | |
| 2328 | // TODO(perkj): Should the direction be set to SEND_ONLY? |
| 2329 | content = cricket::GetFirstVideoContent(answer->description()); |
| 2330 | ASSERT_TRUE(content != NULL); |
| 2331 | EXPECT_FALSE(content->rejected); |
| 2332 | } |
| 2333 | |
| 2334 | TEST_F(WebRtcSessionTest, CreateOfferWithoutCNCodecs) { |
| 2335 | AddCNCodecs(); |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2336 | Init(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 2337 | PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2338 | options.offer_to_receive_audio = |
| 2339 | RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; |
| 2340 | options.voice_activity_detection = false; |
| 2341 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 2342 | rtc::scoped_ptr<SessionDescriptionInterface> offer( |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 2343 | CreateOffer(options)); |
| 2344 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2345 | const cricket::ContentInfo* content = |
| 2346 | cricket::GetFirstAudioContent(offer->description()); |
| 2347 | EXPECT_TRUE(content != NULL); |
| 2348 | EXPECT_TRUE(VerifyNoCNCodecs(content)); |
| 2349 | } |
| 2350 | |
| 2351 | TEST_F(WebRtcSessionTest, CreateAnswerWithoutCNCodecs) { |
| 2352 | AddCNCodecs(); |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2353 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2354 | // Create a remote offer with audio and video content. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 2355 | rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2356 | SetRemoteDescriptionWithoutError(offer.release()); |
| 2357 | |
| 2358 | webrtc::FakeConstraints constraints; |
| 2359 | constraints.SetOptionalVAD(false); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 2360 | rtc::scoped_ptr<SessionDescriptionInterface> answer( |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 2361 | CreateAnswer(&constraints)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2362 | const cricket::ContentInfo* content = |
| 2363 | cricket::GetFirstAudioContent(answer->description()); |
| 2364 | ASSERT_TRUE(content != NULL); |
| 2365 | EXPECT_TRUE(VerifyNoCNCodecs(content)); |
| 2366 | } |
| 2367 | |
| 2368 | // This test verifies the call setup when remote answer with audio only and |
| 2369 | // later updates with video. |
| 2370 | TEST_F(WebRtcSessionTest, TestAVOfferWithAudioOnlyAnswer) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2371 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2372 | EXPECT_TRUE(media_engine_->GetVideoChannel(0) == NULL); |
| 2373 | EXPECT_TRUE(media_engine_->GetVoiceChannel(0) == NULL); |
| 2374 | |
| 2375 | mediastream_signaling_.SendAudioVideoStream1(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 2376 | SessionDescriptionInterface* offer = CreateOffer(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2377 | |
| 2378 | cricket::MediaSessionOptions options; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2379 | SessionDescriptionInterface* answer = CreateRemoteAnswer(offer, options); |
| 2380 | |
| 2381 | // SetLocalDescription and SetRemoteDescriptions takes ownership of offer |
| 2382 | // and answer; |
| 2383 | SetLocalDescriptionWithoutError(offer); |
| 2384 | SetRemoteDescriptionWithoutError(answer); |
| 2385 | |
| 2386 | video_channel_ = media_engine_->GetVideoChannel(0); |
| 2387 | voice_channel_ = media_engine_->GetVoiceChannel(0); |
| 2388 | |
| 2389 | ASSERT_TRUE(video_channel_ == NULL); |
| 2390 | |
| 2391 | ASSERT_EQ(0u, voice_channel_->recv_streams().size()); |
| 2392 | ASSERT_EQ(1u, voice_channel_->send_streams().size()); |
| 2393 | EXPECT_EQ(kAudioTrack1, voice_channel_->send_streams()[0].id); |
| 2394 | |
| 2395 | // Let the remote end update the session descriptions, with Audio and Video. |
| 2396 | mediastream_signaling_.SendAudioVideoStream2(); |
| 2397 | CreateAndSetRemoteOfferAndLocalAnswer(); |
| 2398 | |
| 2399 | video_channel_ = media_engine_->GetVideoChannel(0); |
| 2400 | voice_channel_ = media_engine_->GetVoiceChannel(0); |
| 2401 | |
| 2402 | ASSERT_TRUE(video_channel_ != NULL); |
| 2403 | ASSERT_TRUE(voice_channel_ != NULL); |
| 2404 | |
| 2405 | ASSERT_EQ(1u, video_channel_->recv_streams().size()); |
| 2406 | ASSERT_EQ(1u, video_channel_->send_streams().size()); |
| 2407 | EXPECT_EQ(kVideoTrack2, video_channel_->recv_streams()[0].id); |
| 2408 | EXPECT_EQ(kVideoTrack2, video_channel_->send_streams()[0].id); |
| 2409 | ASSERT_EQ(1u, voice_channel_->recv_streams().size()); |
| 2410 | ASSERT_EQ(1u, voice_channel_->send_streams().size()); |
| 2411 | EXPECT_EQ(kAudioTrack2, voice_channel_->recv_streams()[0].id); |
| 2412 | EXPECT_EQ(kAudioTrack2, voice_channel_->send_streams()[0].id); |
| 2413 | |
| 2414 | // Change session back to audio only. |
| 2415 | mediastream_signaling_.UseOptionsAudioOnly(); |
| 2416 | CreateAndSetRemoteOfferAndLocalAnswer(); |
| 2417 | |
| 2418 | EXPECT_EQ(0u, video_channel_->recv_streams().size()); |
| 2419 | ASSERT_EQ(1u, voice_channel_->recv_streams().size()); |
| 2420 | EXPECT_EQ(kAudioTrack2, voice_channel_->recv_streams()[0].id); |
| 2421 | ASSERT_EQ(1u, voice_channel_->send_streams().size()); |
| 2422 | EXPECT_EQ(kAudioTrack2, voice_channel_->send_streams()[0].id); |
| 2423 | } |
| 2424 | |
| 2425 | // This test verifies the call setup when remote answer with video only and |
| 2426 | // later updates with audio. |
| 2427 | TEST_F(WebRtcSessionTest, TestAVOfferWithVideoOnlyAnswer) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2428 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2429 | EXPECT_TRUE(media_engine_->GetVideoChannel(0) == NULL); |
| 2430 | EXPECT_TRUE(media_engine_->GetVoiceChannel(0) == NULL); |
| 2431 | mediastream_signaling_.SendAudioVideoStream1(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 2432 | SessionDescriptionInterface* offer = CreateOffer(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2433 | |
| 2434 | cricket::MediaSessionOptions options; |
jiayl@webrtc.org | 742922b | 2014-10-07 21:32:43 +0000 | [diff] [blame] | 2435 | options.recv_audio = false; |
| 2436 | options.recv_video = true; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2437 | SessionDescriptionInterface* answer = CreateRemoteAnswer( |
| 2438 | offer, options, cricket::SEC_ENABLED); |
| 2439 | |
| 2440 | // SetLocalDescription and SetRemoteDescriptions takes ownership of offer |
| 2441 | // and answer. |
| 2442 | SetLocalDescriptionWithoutError(offer); |
| 2443 | SetRemoteDescriptionWithoutError(answer); |
| 2444 | |
| 2445 | video_channel_ = media_engine_->GetVideoChannel(0); |
| 2446 | voice_channel_ = media_engine_->GetVoiceChannel(0); |
| 2447 | |
| 2448 | ASSERT_TRUE(voice_channel_ == NULL); |
| 2449 | ASSERT_TRUE(video_channel_ != NULL); |
| 2450 | |
| 2451 | EXPECT_EQ(0u, video_channel_->recv_streams().size()); |
| 2452 | ASSERT_EQ(1u, video_channel_->send_streams().size()); |
| 2453 | EXPECT_EQ(kVideoTrack1, video_channel_->send_streams()[0].id); |
| 2454 | |
| 2455 | // Update the session descriptions, with Audio and Video. |
| 2456 | mediastream_signaling_.SendAudioVideoStream2(); |
| 2457 | CreateAndSetRemoteOfferAndLocalAnswer(); |
| 2458 | |
| 2459 | voice_channel_ = media_engine_->GetVoiceChannel(0); |
| 2460 | ASSERT_TRUE(voice_channel_ != NULL); |
| 2461 | |
| 2462 | ASSERT_EQ(1u, voice_channel_->recv_streams().size()); |
| 2463 | ASSERT_EQ(1u, voice_channel_->send_streams().size()); |
| 2464 | EXPECT_EQ(kAudioTrack2, voice_channel_->recv_streams()[0].id); |
| 2465 | EXPECT_EQ(kAudioTrack2, voice_channel_->send_streams()[0].id); |
| 2466 | |
| 2467 | // Change session back to video only. |
| 2468 | mediastream_signaling_.UseOptionsVideoOnly(); |
| 2469 | CreateAndSetRemoteOfferAndLocalAnswer(); |
| 2470 | |
| 2471 | video_channel_ = media_engine_->GetVideoChannel(0); |
| 2472 | voice_channel_ = media_engine_->GetVoiceChannel(0); |
| 2473 | |
| 2474 | ASSERT_EQ(1u, video_channel_->recv_streams().size()); |
| 2475 | EXPECT_EQ(kVideoTrack2, video_channel_->recv_streams()[0].id); |
| 2476 | ASSERT_EQ(1u, video_channel_->send_streams().size()); |
| 2477 | EXPECT_EQ(kVideoTrack2, video_channel_->send_streams()[0].id); |
| 2478 | } |
| 2479 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2480 | TEST_F(WebRtcSessionTest, VerifyCryptoParamsInSDP) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2481 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2482 | mediastream_signaling_.SendAudioVideoStream1(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 2483 | scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2484 | VerifyCryptoParams(offer->description()); |
| 2485 | SetRemoteDescriptionWithoutError(offer.release()); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 2486 | scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2487 | VerifyCryptoParams(answer->description()); |
| 2488 | } |
| 2489 | |
| 2490 | TEST_F(WebRtcSessionTest, VerifyNoCryptoParamsInSDP) { |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 2491 | options_.disable_encryption = true; |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2492 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2493 | mediastream_signaling_.SendAudioVideoStream1(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 2494 | scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2495 | VerifyNoCryptoParams(offer->description(), false); |
| 2496 | } |
| 2497 | |
| 2498 | TEST_F(WebRtcSessionTest, VerifyAnswerFromNonCryptoOffer) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2499 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2500 | VerifyAnswerFromNonCryptoOffer(); |
| 2501 | } |
| 2502 | |
| 2503 | TEST_F(WebRtcSessionTest, VerifyAnswerFromCryptoOffer) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2504 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2505 | VerifyAnswerFromCryptoOffer(); |
| 2506 | } |
| 2507 | |
mallinath@webrtc.org | 19f27e6 | 2013-10-13 17:18:27 +0000 | [diff] [blame] | 2508 | // This test verifies that setLocalDescription fails if |
| 2509 | // no a=ice-ufrag and a=ice-pwd lines are present in the SDP. |
| 2510 | TEST_F(WebRtcSessionTest, TestSetLocalDescriptionWithoutIce) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2511 | Init(); |
mallinath@webrtc.org | 19f27e6 | 2013-10-13 17:18:27 +0000 | [diff] [blame] | 2512 | mediastream_signaling_.SendAudioVideoStream1(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 2513 | rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 2514 | |
mallinath@webrtc.org | 19f27e6 | 2013-10-13 17:18:27 +0000 | [diff] [blame] | 2515 | std::string sdp; |
| 2516 | RemoveIceUfragPwdLines(offer.get(), &sdp); |
| 2517 | SessionDescriptionInterface* modified_offer = |
| 2518 | CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 2519 | SetLocalDescriptionOfferExpectError(kSdpWithoutIceUfragPwd, modified_offer); |
mallinath@webrtc.org | 19f27e6 | 2013-10-13 17:18:27 +0000 | [diff] [blame] | 2520 | } |
| 2521 | |
| 2522 | // This test verifies that setRemoteDescription fails if |
| 2523 | // no a=ice-ufrag and a=ice-pwd lines are present in the SDP. |
| 2524 | TEST_F(WebRtcSessionTest, TestSetRemoteDescriptionWithoutIce) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2525 | Init(); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 2526 | rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateRemoteOffer()); |
mallinath@webrtc.org | 19f27e6 | 2013-10-13 17:18:27 +0000 | [diff] [blame] | 2527 | std::string sdp; |
| 2528 | RemoveIceUfragPwdLines(offer.get(), &sdp); |
| 2529 | SessionDescriptionInterface* modified_offer = |
| 2530 | CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 2531 | SetRemoteDescriptionOfferExpectError(kSdpWithoutIceUfragPwd, modified_offer); |
mallinath@webrtc.org | 19f27e6 | 2013-10-13 17:18:27 +0000 | [diff] [blame] | 2532 | } |
| 2533 | |
buildbot@webrtc.org | 7aa1a47 | 2014-05-23 17:33:05 +0000 | [diff] [blame] | 2534 | // This test verifies that setLocalDescription fails if local offer has |
| 2535 | // too short ice ufrag and pwd strings. |
| 2536 | TEST_F(WebRtcSessionTest, TestSetLocalDescriptionInvalidIceCredentials) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2537 | Init(); |
buildbot@webrtc.org | 7aa1a47 | 2014-05-23 17:33:05 +0000 | [diff] [blame] | 2538 | tdesc_factory_->set_protocol(cricket::ICEPROTO_RFC5245); |
| 2539 | mediastream_signaling_.SendAudioVideoStream1(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 2540 | rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 2541 | |
buildbot@webrtc.org | 7aa1a47 | 2014-05-23 17:33:05 +0000 | [diff] [blame] | 2542 | std::string sdp; |
| 2543 | // Modifying ice ufrag and pwd in local offer with strings smaller than the |
| 2544 | // recommended values of 4 and 22 bytes respectively. |
| 2545 | ModifyIceUfragPwdLines(offer.get(), "ice", "icepwd", &sdp); |
| 2546 | SessionDescriptionInterface* modified_offer = |
| 2547 | CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); |
| 2548 | std::string error; |
| 2549 | EXPECT_FALSE(session_->SetLocalDescription(modified_offer, &error)); |
| 2550 | |
| 2551 | // Test with string greater than 256. |
| 2552 | sdp.clear(); |
| 2553 | ModifyIceUfragPwdLines(offer.get(), kTooLongIceUfragPwd, kTooLongIceUfragPwd, |
| 2554 | &sdp); |
| 2555 | modified_offer = CreateSessionDescription(JsepSessionDescription::kOffer, sdp, |
| 2556 | NULL); |
| 2557 | EXPECT_FALSE(session_->SetLocalDescription(modified_offer, &error)); |
| 2558 | } |
| 2559 | |
| 2560 | // This test verifies that setRemoteDescription fails if remote offer has |
| 2561 | // too short ice ufrag and pwd strings. |
| 2562 | TEST_F(WebRtcSessionTest, TestSetRemoteDescriptionInvalidIceCredentials) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2563 | Init(); |
buildbot@webrtc.org | 7aa1a47 | 2014-05-23 17:33:05 +0000 | [diff] [blame] | 2564 | tdesc_factory_->set_protocol(cricket::ICEPROTO_RFC5245); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 2565 | rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateRemoteOffer()); |
buildbot@webrtc.org | 7aa1a47 | 2014-05-23 17:33:05 +0000 | [diff] [blame] | 2566 | std::string sdp; |
| 2567 | // Modifying ice ufrag and pwd in remote offer with strings smaller than the |
| 2568 | // recommended values of 4 and 22 bytes respectively. |
| 2569 | ModifyIceUfragPwdLines(offer.get(), "ice", "icepwd", &sdp); |
| 2570 | SessionDescriptionInterface* modified_offer = |
| 2571 | CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); |
| 2572 | std::string error; |
| 2573 | EXPECT_FALSE(session_->SetRemoteDescription(modified_offer, &error)); |
| 2574 | |
| 2575 | sdp.clear(); |
| 2576 | ModifyIceUfragPwdLines(offer.get(), kTooLongIceUfragPwd, kTooLongIceUfragPwd, |
| 2577 | &sdp); |
| 2578 | modified_offer = CreateSessionDescription(JsepSessionDescription::kOffer, sdp, |
| 2579 | NULL); |
| 2580 | EXPECT_FALSE(session_->SetRemoteDescription(modified_offer, &error)); |
| 2581 | } |
| 2582 | |
Donald Curtis | d4f769d | 2015-05-28 09:48:21 -0700 | [diff] [blame] | 2583 | // Test that candidates sent to the "video" transport do not get pushed down to |
| 2584 | // the "audio" transport channel when bundling using TransportProxy. |
| 2585 | TEST_F(WebRtcSessionTest, TestIgnoreCandidatesForUnusedTransportWhenBundling) { |
| 2586 | AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
| 2587 | |
| 2588 | InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); |
| 2589 | mediastream_signaling_.SendAudioVideoStream1(); |
| 2590 | |
| 2591 | PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2592 | options.use_rtp_mux = true; |
| 2593 | |
| 2594 | SessionDescriptionInterface* offer = CreateRemoteOffer(); |
| 2595 | SetRemoteDescriptionWithoutError(offer); |
| 2596 | |
| 2597 | SessionDescriptionInterface* answer = CreateAnswer(NULL); |
| 2598 | SetLocalDescriptionWithoutError(answer); |
| 2599 | |
| 2600 | EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), |
| 2601 | session_->GetTransportProxy("video")->impl()); |
| 2602 | |
| 2603 | cricket::Transport* t = session_->GetTransport("audio"); |
| 2604 | |
| 2605 | // Checks if one of the transport channels contains a connection using a given |
| 2606 | // port. |
| 2607 | auto connection_with_remote_port = [t](int port) { |
| 2608 | cricket::TransportStats stats; |
| 2609 | t->GetStats(&stats); |
| 2610 | for (auto& chan_stat : stats.channel_stats) { |
| 2611 | for (auto& conn_info : chan_stat.connection_infos) { |
| 2612 | if (conn_info.remote_candidate.address().port() == port) { |
| 2613 | return true; |
| 2614 | } |
| 2615 | } |
| 2616 | } |
| 2617 | return false; |
| 2618 | }; |
| 2619 | |
| 2620 | EXPECT_FALSE(connection_with_remote_port(5000)); |
| 2621 | EXPECT_FALSE(connection_with_remote_port(5001)); |
| 2622 | EXPECT_FALSE(connection_with_remote_port(6000)); |
| 2623 | |
| 2624 | // The way the *_WAIT checks work is they only wait if the condition fails, |
| 2625 | // which does not help in the case where state is not changing. This is |
| 2626 | // problematic in this test since we want to verify that adding a video |
| 2627 | // candidate does _not_ change state. So we interleave candidates and assume |
| 2628 | // that messages are executed in the order they were posted. |
| 2629 | |
| 2630 | // First audio candidate. |
| 2631 | cricket::Candidate candidate0; |
| 2632 | candidate0.set_address(rtc::SocketAddress("1.1.1.1", 5000)); |
| 2633 | candidate0.set_component(1); |
| 2634 | candidate0.set_protocol("udp"); |
| 2635 | JsepIceCandidate ice_candidate0(kMediaContentName0, kMediaContentIndex0, |
| 2636 | candidate0); |
| 2637 | EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate0)); |
| 2638 | |
| 2639 | // Video candidate. |
| 2640 | cricket::Candidate candidate1; |
| 2641 | candidate1.set_address(rtc::SocketAddress("1.1.1.1", 6000)); |
| 2642 | candidate1.set_component(1); |
| 2643 | candidate1.set_protocol("udp"); |
| 2644 | JsepIceCandidate ice_candidate1(kMediaContentName1, kMediaContentIndex1, |
| 2645 | candidate1); |
| 2646 | EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate1)); |
| 2647 | |
| 2648 | // Second audio candidate. |
| 2649 | cricket::Candidate candidate2; |
| 2650 | candidate2.set_address(rtc::SocketAddress("1.1.1.1", 5001)); |
| 2651 | candidate2.set_component(1); |
| 2652 | candidate2.set_protocol("udp"); |
| 2653 | JsepIceCandidate ice_candidate2(kMediaContentName0, kMediaContentIndex0, |
| 2654 | candidate2); |
| 2655 | EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate2)); |
| 2656 | |
| 2657 | EXPECT_TRUE_WAIT(connection_with_remote_port(5000), 1000); |
| 2658 | EXPECT_TRUE_WAIT(connection_with_remote_port(5001), 1000); |
| 2659 | |
| 2660 | // No need here for a _WAIT check since we are checking that state hasn't |
| 2661 | // changed: if this is false we would be doing waits for nothing and if this |
| 2662 | // is true then there will be no messages processed anyways. |
| 2663 | EXPECT_FALSE(connection_with_remote_port(6000)); |
| 2664 | } |
| 2665 | |
Peter Thatcher | 4eddf18 | 2015-04-30 10:55:59 -0700 | [diff] [blame] | 2666 | // kBundlePolicyBalanced bundle policy and answer contains BUNDLE. |
Donald Curtis | 0e209b0 | 2015-03-24 09:29:54 -0700 | [diff] [blame] | 2667 | TEST_F(WebRtcSessionTest, TestBalancedBundleInAnswer) { |
| 2668 | InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2669 | mediastream_signaling_.SendAudioVideoStream1(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 2670 | |
| 2671 | PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2672 | options.use_rtp_mux = true; |
| 2673 | |
| 2674 | SessionDescriptionInterface* offer = CreateOffer(options); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2675 | SetLocalDescriptionWithoutError(offer); |
Donald Curtis | 0e209b0 | 2015-03-24 09:29:54 -0700 | [diff] [blame] | 2676 | |
| 2677 | EXPECT_NE(session_->GetTransportProxy("audio")->impl(), |
| 2678 | session_->GetTransportProxy("video")->impl()); |
| 2679 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2680 | mediastream_signaling_.SendAudioVideoStream2(); |
Donald Curtis | 0e209b0 | 2015-03-24 09:29:54 -0700 | [diff] [blame] | 2681 | SessionDescriptionInterface* answer = |
| 2682 | CreateRemoteAnswer(session_->local_description()); |
| 2683 | SetRemoteDescriptionWithoutError(answer); |
| 2684 | |
| 2685 | EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), |
| 2686 | session_->GetTransportProxy("video")->impl()); |
| 2687 | } |
| 2688 | |
| 2689 | // kBundlePolicyBalanced bundle policy but no BUNDLE in the answer. |
| 2690 | TEST_F(WebRtcSessionTest, TestBalancedNoBundleInAnswer) { |
| 2691 | InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); |
| 2692 | mediastream_signaling_.SendAudioVideoStream1(); |
Peter Thatcher | 4eddf18 | 2015-04-30 10:55:59 -0700 | [diff] [blame] | 2693 | |
Donald Curtis | 0e209b0 | 2015-03-24 09:29:54 -0700 | [diff] [blame] | 2694 | PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2695 | options.use_rtp_mux = true; |
| 2696 | |
| 2697 | SessionDescriptionInterface* offer = CreateOffer(options); |
| 2698 | SetLocalDescriptionWithoutError(offer); |
| 2699 | |
| 2700 | EXPECT_NE(session_->GetTransportProxy("audio")->impl(), |
| 2701 | session_->GetTransportProxy("video")->impl()); |
| 2702 | |
| 2703 | mediastream_signaling_.SendAudioVideoStream2(); |
| 2704 | |
| 2705 | // Remove BUNDLE from the answer. |
| 2706 | rtc::scoped_ptr<SessionDescriptionInterface> answer( |
| 2707 | CreateRemoteAnswer(session_->local_description())); |
| 2708 | cricket::SessionDescription* answer_copy = answer->description()->Copy(); |
| 2709 | answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE); |
| 2710 | JsepSessionDescription* modified_answer = |
| 2711 | new JsepSessionDescription(JsepSessionDescription::kAnswer); |
| 2712 | modified_answer->Initialize(answer_copy, "1", "1"); |
| 2713 | SetRemoteDescriptionWithoutError(modified_answer); // |
| 2714 | |
| 2715 | EXPECT_NE(session_->GetTransportProxy("audio")->impl(), |
| 2716 | session_->GetTransportProxy("video")->impl()); |
| 2717 | } |
| 2718 | |
| 2719 | // kBundlePolicyMaxBundle policy with BUNDLE in the answer. |
| 2720 | TEST_F(WebRtcSessionTest, TestMaxBundleBundleInAnswer) { |
| 2721 | InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); |
| 2722 | mediastream_signaling_.SendAudioVideoStream1(); |
| 2723 | |
| 2724 | PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2725 | options.use_rtp_mux = true; |
| 2726 | |
| 2727 | SessionDescriptionInterface* offer = CreateOffer(options); |
| 2728 | SetLocalDescriptionWithoutError(offer); |
| 2729 | |
| 2730 | EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), |
| 2731 | session_->GetTransportProxy("video")->impl()); |
| 2732 | |
| 2733 | mediastream_signaling_.SendAudioVideoStream2(); |
| 2734 | SessionDescriptionInterface* answer = |
| 2735 | CreateRemoteAnswer(session_->local_description()); |
| 2736 | SetRemoteDescriptionWithoutError(answer); |
| 2737 | |
| 2738 | EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), |
| 2739 | session_->GetTransportProxy("video")->impl()); |
| 2740 | } |
| 2741 | |
| 2742 | // kBundlePolicyMaxBundle policy but no BUNDLE in the answer. |
| 2743 | TEST_F(WebRtcSessionTest, TestMaxBundleNoBundleInAnswer) { |
| 2744 | InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); |
| 2745 | mediastream_signaling_.SendAudioVideoStream1(); |
Peter Thatcher | 4eddf18 | 2015-04-30 10:55:59 -0700 | [diff] [blame] | 2746 | |
Donald Curtis | 0e209b0 | 2015-03-24 09:29:54 -0700 | [diff] [blame] | 2747 | PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2748 | options.use_rtp_mux = true; |
| 2749 | |
| 2750 | SessionDescriptionInterface* offer = CreateOffer(options); |
| 2751 | SetLocalDescriptionWithoutError(offer); |
| 2752 | |
| 2753 | EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), |
| 2754 | session_->GetTransportProxy("video")->impl()); |
| 2755 | |
| 2756 | mediastream_signaling_.SendAudioVideoStream2(); |
| 2757 | |
| 2758 | // Remove BUNDLE from the answer. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 2759 | rtc::scoped_ptr<SessionDescriptionInterface> answer( |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2760 | CreateRemoteAnswer(session_->local_description())); |
| 2761 | cricket::SessionDescription* answer_copy = answer->description()->Copy(); |
| 2762 | answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE); |
| 2763 | JsepSessionDescription* modified_answer = |
| 2764 | new JsepSessionDescription(JsepSessionDescription::kAnswer); |
| 2765 | modified_answer->Initialize(answer_copy, "1", "1"); |
| 2766 | SetRemoteDescriptionWithoutError(modified_answer); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2767 | |
Donald Curtis | 0e209b0 | 2015-03-24 09:29:54 -0700 | [diff] [blame] | 2768 | EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), |
| 2769 | session_->GetTransportProxy("video")->impl()); |
| 2770 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2771 | |
Peter Thatcher | 4eddf18 | 2015-04-30 10:55:59 -0700 | [diff] [blame] | 2772 | // kBundlePolicyMaxCompat bundle policy and answer contains BUNDLE. |
Donald Curtis | 0e209b0 | 2015-03-24 09:29:54 -0700 | [diff] [blame] | 2773 | TEST_F(WebRtcSessionTest, TestMaxCompatBundleInAnswer) { |
| 2774 | InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxCompat); |
| 2775 | mediastream_signaling_.SendAudioVideoStream1(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2776 | |
Donald Curtis | 0e209b0 | 2015-03-24 09:29:54 -0700 | [diff] [blame] | 2777 | PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2778 | options.use_rtp_mux = true; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2779 | |
Donald Curtis | 0e209b0 | 2015-03-24 09:29:54 -0700 | [diff] [blame] | 2780 | SessionDescriptionInterface* offer = CreateOffer(options); |
| 2781 | SetLocalDescriptionWithoutError(offer); |
| 2782 | |
| 2783 | EXPECT_NE(session_->GetTransportProxy("audio")->impl(), |
| 2784 | session_->GetTransportProxy("video")->impl()); |
| 2785 | |
| 2786 | mediastream_signaling_.SendAudioVideoStream2(); |
| 2787 | SessionDescriptionInterface* answer = |
| 2788 | CreateRemoteAnswer(session_->local_description()); |
| 2789 | SetRemoteDescriptionWithoutError(answer); |
| 2790 | |
| 2791 | // This should lead to an audio-only call but isn't implemented |
| 2792 | // correctly yet. |
| 2793 | EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), |
| 2794 | session_->GetTransportProxy("video")->impl()); |
| 2795 | } |
| 2796 | |
| 2797 | // kBundlePolicyMaxCompat bundle policy but no BUNDLE in the answer. |
| 2798 | TEST_F(WebRtcSessionTest, TestMaxCompatNoBundleInAnswer) { |
| 2799 | InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxCompat); |
| 2800 | mediastream_signaling_.SendAudioVideoStream1(); |
| 2801 | PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2802 | options.use_rtp_mux = true; |
| 2803 | |
| 2804 | SessionDescriptionInterface* offer = CreateOffer(options); |
| 2805 | SetLocalDescriptionWithoutError(offer); |
| 2806 | |
| 2807 | EXPECT_NE(session_->GetTransportProxy("audio")->impl(), |
| 2808 | session_->GetTransportProxy("video")->impl()); |
| 2809 | |
| 2810 | mediastream_signaling_.SendAudioVideoStream2(); |
| 2811 | |
| 2812 | // Remove BUNDLE from the answer. |
| 2813 | rtc::scoped_ptr<SessionDescriptionInterface> answer( |
| 2814 | CreateRemoteAnswer(session_->local_description())); |
| 2815 | cricket::SessionDescription* answer_copy = answer->description()->Copy(); |
| 2816 | answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE); |
| 2817 | JsepSessionDescription* modified_answer = |
| 2818 | new JsepSessionDescription(JsepSessionDescription::kAnswer); |
| 2819 | modified_answer->Initialize(answer_copy, "1", "1"); |
| 2820 | SetRemoteDescriptionWithoutError(modified_answer); // |
| 2821 | |
| 2822 | EXPECT_NE(session_->GetTransportProxy("audio")->impl(), |
| 2823 | session_->GetTransportProxy("video")->impl()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2824 | } |
| 2825 | |
Peter Thatcher | 4eddf18 | 2015-04-30 10:55:59 -0700 | [diff] [blame] | 2826 | // kBundlePolicyMaxbundle and then we call SetRemoteDescription first. |
| 2827 | TEST_F(WebRtcSessionTest, TestMaxBundleWithSetRemoteDescriptionFirst) { |
| 2828 | InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); |
| 2829 | mediastream_signaling_.SendAudioVideoStream1(); |
| 2830 | |
| 2831 | PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2832 | options.use_rtp_mux = true; |
| 2833 | |
| 2834 | SessionDescriptionInterface* offer = CreateOffer(options); |
| 2835 | SetRemoteDescriptionWithoutError(offer); |
| 2836 | |
| 2837 | EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), |
| 2838 | session_->GetTransportProxy("video")->impl()); |
| 2839 | } |
| 2840 | |
Peter Thatcher | af55ccc | 2015-05-21 07:48:41 -0700 | [diff] [blame] | 2841 | TEST_F(WebRtcSessionTest, TestRequireRtcpMux) { |
| 2842 | InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyRequire); |
| 2843 | mediastream_signaling_.SendAudioVideoStream1(); |
| 2844 | |
| 2845 | PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2846 | SessionDescriptionInterface* offer = CreateOffer(options); |
| 2847 | SetLocalDescriptionWithoutError(offer); |
| 2848 | |
| 2849 | EXPECT_FALSE(session_->GetTransportProxy("audio")->impl()->HasChannel(2)); |
| 2850 | EXPECT_FALSE(session_->GetTransportProxy("video")->impl()->HasChannel(2)); |
| 2851 | |
| 2852 | mediastream_signaling_.SendAudioVideoStream2(); |
| 2853 | SessionDescriptionInterface* answer = |
| 2854 | CreateRemoteAnswer(session_->local_description()); |
| 2855 | SetRemoteDescriptionWithoutError(answer); |
| 2856 | |
| 2857 | EXPECT_FALSE(session_->GetTransportProxy("audio")->impl()->HasChannel(2)); |
| 2858 | EXPECT_FALSE(session_->GetTransportProxy("video")->impl()->HasChannel(2)); |
| 2859 | } |
| 2860 | |
| 2861 | TEST_F(WebRtcSessionTest, TestNegotiateRtcpMux) { |
| 2862 | InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyNegotiate); |
| 2863 | mediastream_signaling_.SendAudioVideoStream1(); |
| 2864 | |
| 2865 | PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2866 | SessionDescriptionInterface* offer = CreateOffer(options); |
| 2867 | SetLocalDescriptionWithoutError(offer); |
| 2868 | |
| 2869 | EXPECT_TRUE(session_->GetTransportProxy("audio")->impl()->HasChannel(2)); |
| 2870 | EXPECT_TRUE(session_->GetTransportProxy("video")->impl()->HasChannel(2)); |
| 2871 | |
| 2872 | mediastream_signaling_.SendAudioVideoStream2(); |
| 2873 | SessionDescriptionInterface* answer = |
| 2874 | CreateRemoteAnswer(session_->local_description()); |
| 2875 | SetRemoteDescriptionWithoutError(answer); |
| 2876 | |
| 2877 | EXPECT_FALSE(session_->GetTransportProxy("audio")->impl()->HasChannel(2)); |
| 2878 | EXPECT_FALSE(session_->GetTransportProxy("video")->impl()->HasChannel(2)); |
| 2879 | } |
| 2880 | |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 2881 | // This test verifies that SetLocalDescription and SetRemoteDescription fails |
| 2882 | // if BUNDLE is enabled but rtcp-mux is disabled in m-lines. |
| 2883 | TEST_F(WebRtcSessionTest, TestDisabledRtcpMuxWithBundleEnabled) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2884 | Init(); |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 2885 | mediastream_signaling_.SendAudioVideoStream1(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 2886 | |
| 2887 | PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2888 | options.use_rtp_mux = true; |
| 2889 | |
| 2890 | SessionDescriptionInterface* offer = CreateOffer(options); |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 2891 | std::string offer_str; |
| 2892 | offer->ToString(&offer_str); |
| 2893 | // Disable rtcp-mux |
| 2894 | const std::string rtcp_mux = "rtcp-mux"; |
| 2895 | const std::string xrtcp_mux = "xrtcp-mux"; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 2896 | rtc::replace_substrs(rtcp_mux.c_str(), rtcp_mux.length(), |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 2897 | xrtcp_mux.c_str(), xrtcp_mux.length(), |
| 2898 | &offer_str); |
| 2899 | JsepSessionDescription *local_offer = |
| 2900 | new JsepSessionDescription(JsepSessionDescription::kOffer); |
| 2901 | EXPECT_TRUE((local_offer)->Initialize(offer_str, NULL)); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 2902 | SetLocalDescriptionOfferExpectError(kBundleWithoutRtcpMux, local_offer); |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 2903 | JsepSessionDescription *remote_offer = |
| 2904 | new JsepSessionDescription(JsepSessionDescription::kOffer); |
| 2905 | EXPECT_TRUE((remote_offer)->Initialize(offer_str, NULL)); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 2906 | SetRemoteDescriptionOfferExpectError(kBundleWithoutRtcpMux, remote_offer); |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 2907 | // Trying unmodified SDP. |
| 2908 | SetLocalDescriptionWithoutError(offer); |
| 2909 | } |
| 2910 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2911 | TEST_F(WebRtcSessionTest, SetAudioPlayout) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2912 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2913 | mediastream_signaling_.SendAudioVideoStream1(); |
| 2914 | CreateAndSetRemoteOfferAndLocalAnswer(); |
| 2915 | cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); |
| 2916 | ASSERT_TRUE(channel != NULL); |
| 2917 | ASSERT_EQ(1u, channel->recv_streams().size()); |
| 2918 | uint32 receive_ssrc = channel->recv_streams()[0].first_ssrc(); |
| 2919 | double left_vol, right_vol; |
| 2920 | EXPECT_TRUE(channel->GetOutputScaling(receive_ssrc, &left_vol, &right_vol)); |
| 2921 | EXPECT_EQ(1, left_vol); |
| 2922 | EXPECT_EQ(1, right_vol); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 2923 | rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer()); |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 2924 | session_->SetAudioPlayout(receive_ssrc, false, renderer.get()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2925 | EXPECT_TRUE(channel->GetOutputScaling(receive_ssrc, &left_vol, &right_vol)); |
| 2926 | EXPECT_EQ(0, left_vol); |
| 2927 | EXPECT_EQ(0, right_vol); |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 2928 | EXPECT_EQ(0, renderer->channel_id()); |
| 2929 | session_->SetAudioPlayout(receive_ssrc, true, NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2930 | EXPECT_TRUE(channel->GetOutputScaling(receive_ssrc, &left_vol, &right_vol)); |
| 2931 | EXPECT_EQ(1, left_vol); |
| 2932 | EXPECT_EQ(1, right_vol); |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 2933 | EXPECT_EQ(-1, renderer->channel_id()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2934 | } |
| 2935 | |
| 2936 | TEST_F(WebRtcSessionTest, SetAudioSend) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2937 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2938 | mediastream_signaling_.SendAudioVideoStream1(); |
| 2939 | CreateAndSetRemoteOfferAndLocalAnswer(); |
| 2940 | cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); |
| 2941 | ASSERT_TRUE(channel != NULL); |
| 2942 | ASSERT_EQ(1u, channel->send_streams().size()); |
| 2943 | uint32 send_ssrc = channel->send_streams()[0].first_ssrc(); |
| 2944 | EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); |
| 2945 | |
| 2946 | cricket::AudioOptions options; |
| 2947 | options.echo_cancellation.Set(true); |
| 2948 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 2949 | rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer()); |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 2950 | session_->SetAudioSend(send_ssrc, false, options, renderer.get()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2951 | EXPECT_TRUE(channel->IsStreamMuted(send_ssrc)); |
| 2952 | EXPECT_FALSE(channel->options().echo_cancellation.IsSet()); |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 2953 | EXPECT_EQ(0, renderer->channel_id()); |
henrike@webrtc.org | a7b9818 | 2014-02-21 15:51:43 +0000 | [diff] [blame] | 2954 | EXPECT_TRUE(renderer->sink() != NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2955 | |
henrike@webrtc.org | a7b9818 | 2014-02-21 15:51:43 +0000 | [diff] [blame] | 2956 | // This will trigger SetSink(NULL) to the |renderer|. |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 2957 | session_->SetAudioSend(send_ssrc, true, options, NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2958 | EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); |
| 2959 | bool value; |
| 2960 | EXPECT_TRUE(channel->options().echo_cancellation.Get(&value)); |
| 2961 | EXPECT_TRUE(value); |
henrike@webrtc.org | 1e09a71 | 2013-07-26 19:17:59 +0000 | [diff] [blame] | 2962 | EXPECT_EQ(-1, renderer->channel_id()); |
henrike@webrtc.org | a7b9818 | 2014-02-21 15:51:43 +0000 | [diff] [blame] | 2963 | EXPECT_TRUE(renderer->sink() == NULL); |
| 2964 | } |
| 2965 | |
| 2966 | TEST_F(WebRtcSessionTest, AudioRendererForLocalStream) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2967 | Init(); |
henrike@webrtc.org | a7b9818 | 2014-02-21 15:51:43 +0000 | [diff] [blame] | 2968 | mediastream_signaling_.SendAudioVideoStream1(); |
| 2969 | CreateAndSetRemoteOfferAndLocalAnswer(); |
| 2970 | cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); |
| 2971 | ASSERT_TRUE(channel != NULL); |
| 2972 | ASSERT_EQ(1u, channel->send_streams().size()); |
| 2973 | uint32 send_ssrc = channel->send_streams()[0].first_ssrc(); |
| 2974 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 2975 | rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer()); |
henrike@webrtc.org | a7b9818 | 2014-02-21 15:51:43 +0000 | [diff] [blame] | 2976 | cricket::AudioOptions options; |
| 2977 | session_->SetAudioSend(send_ssrc, true, options, renderer.get()); |
| 2978 | EXPECT_TRUE(renderer->sink() != NULL); |
| 2979 | |
| 2980 | // Delete the |renderer| and it will trigger OnClose() to the sink, and this |
| 2981 | // will invalidate the |renderer_| pointer in the sink and prevent getting a |
| 2982 | // SetSink(NULL) callback afterwards. |
| 2983 | renderer.reset(); |
| 2984 | |
| 2985 | // This will trigger SetSink(NULL) if no OnClose() callback. |
| 2986 | session_->SetAudioSend(send_ssrc, true, options, NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2987 | } |
| 2988 | |
| 2989 | TEST_F(WebRtcSessionTest, SetVideoPlayout) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 2990 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2991 | mediastream_signaling_.SendAudioVideoStream1(); |
| 2992 | CreateAndSetRemoteOfferAndLocalAnswer(); |
| 2993 | cricket::FakeVideoMediaChannel* channel = media_engine_->GetVideoChannel(0); |
| 2994 | ASSERT_TRUE(channel != NULL); |
| 2995 | ASSERT_LT(0u, channel->renderers().size()); |
| 2996 | EXPECT_TRUE(channel->renderers().begin()->second == NULL); |
| 2997 | ASSERT_EQ(1u, channel->recv_streams().size()); |
| 2998 | uint32 receive_ssrc = channel->recv_streams()[0].first_ssrc(); |
| 2999 | cricket::FakeVideoRenderer renderer; |
| 3000 | session_->SetVideoPlayout(receive_ssrc, true, &renderer); |
| 3001 | EXPECT_TRUE(channel->renderers().begin()->second == &renderer); |
| 3002 | session_->SetVideoPlayout(receive_ssrc, false, &renderer); |
| 3003 | EXPECT_TRUE(channel->renderers().begin()->second == NULL); |
| 3004 | } |
| 3005 | |
| 3006 | TEST_F(WebRtcSessionTest, SetVideoSend) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 3007 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3008 | mediastream_signaling_.SendAudioVideoStream1(); |
| 3009 | CreateAndSetRemoteOfferAndLocalAnswer(); |
| 3010 | cricket::FakeVideoMediaChannel* channel = media_engine_->GetVideoChannel(0); |
| 3011 | ASSERT_TRUE(channel != NULL); |
| 3012 | ASSERT_EQ(1u, channel->send_streams().size()); |
| 3013 | uint32 send_ssrc = channel->send_streams()[0].first_ssrc(); |
| 3014 | EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); |
| 3015 | cricket::VideoOptions* options = NULL; |
| 3016 | session_->SetVideoSend(send_ssrc, false, options); |
| 3017 | EXPECT_TRUE(channel->IsStreamMuted(send_ssrc)); |
| 3018 | session_->SetVideoSend(send_ssrc, true, options); |
| 3019 | EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); |
| 3020 | } |
| 3021 | |
| 3022 | TEST_F(WebRtcSessionTest, CanNotInsertDtmf) { |
| 3023 | TestCanInsertDtmf(false); |
| 3024 | } |
| 3025 | |
| 3026 | TEST_F(WebRtcSessionTest, CanInsertDtmf) { |
| 3027 | TestCanInsertDtmf(true); |
| 3028 | } |
| 3029 | |
| 3030 | TEST_F(WebRtcSessionTest, InsertDtmf) { |
| 3031 | // Setup |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 3032 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3033 | mediastream_signaling_.SendAudioVideoStream1(); |
| 3034 | CreateAndSetRemoteOfferAndLocalAnswer(); |
| 3035 | FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); |
| 3036 | EXPECT_EQ(0U, channel->dtmf_info_queue().size()); |
| 3037 | |
| 3038 | // Insert DTMF |
| 3039 | const int expected_flags = DF_SEND; |
| 3040 | const int expected_duration = 90; |
| 3041 | session_->InsertDtmf(kAudioTrack1, 0, expected_duration); |
| 3042 | session_->InsertDtmf(kAudioTrack1, 1, expected_duration); |
| 3043 | session_->InsertDtmf(kAudioTrack1, 2, expected_duration); |
| 3044 | |
| 3045 | // Verify |
| 3046 | ASSERT_EQ(3U, channel->dtmf_info_queue().size()); |
| 3047 | const uint32 send_ssrc = channel->send_streams()[0].first_ssrc(); |
| 3048 | EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[0], send_ssrc, 0, |
| 3049 | expected_duration, expected_flags)); |
| 3050 | EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[1], send_ssrc, 1, |
| 3051 | expected_duration, expected_flags)); |
| 3052 | EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[2], send_ssrc, 2, |
| 3053 | expected_duration, expected_flags)); |
| 3054 | } |
| 3055 | |
| 3056 | // This test verifies the |initiator| flag when session initiates the call. |
| 3057 | TEST_F(WebRtcSessionTest, TestInitiatorFlagAsOriginator) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 3058 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3059 | EXPECT_FALSE(session_->initiator()); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 3060 | SessionDescriptionInterface* offer = CreateOffer(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3061 | SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); |
| 3062 | SetLocalDescriptionWithoutError(offer); |
| 3063 | EXPECT_TRUE(session_->initiator()); |
| 3064 | SetRemoteDescriptionWithoutError(answer); |
| 3065 | EXPECT_TRUE(session_->initiator()); |
| 3066 | } |
| 3067 | |
| 3068 | // This test verifies the |initiator| flag when session receives the call. |
| 3069 | TEST_F(WebRtcSessionTest, TestInitiatorFlagAsReceiver) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 3070 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3071 | EXPECT_FALSE(session_->initiator()); |
| 3072 | SessionDescriptionInterface* offer = CreateRemoteOffer(); |
| 3073 | SetRemoteDescriptionWithoutError(offer); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3074 | SessionDescriptionInterface* answer = CreateAnswer(NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3075 | |
| 3076 | EXPECT_FALSE(session_->initiator()); |
| 3077 | SetLocalDescriptionWithoutError(answer); |
| 3078 | EXPECT_FALSE(session_->initiator()); |
| 3079 | } |
| 3080 | |
| 3081 | // This test verifies the ice protocol type at initiator of the call |
| 3082 | // if |a=ice-options:google-ice| is present in answer. |
| 3083 | TEST_F(WebRtcSessionTest, TestInitiatorGIceInAnswer) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 3084 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3085 | mediastream_signaling_.SendAudioVideoStream1(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 3086 | SessionDescriptionInterface* offer = CreateOffer(); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3087 | rtc::scoped_ptr<SessionDescriptionInterface> answer( |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3088 | CreateRemoteAnswer(offer)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3089 | SetLocalDescriptionWithoutError(offer); |
| 3090 | std::string sdp; |
| 3091 | EXPECT_TRUE(answer->ToString(&sdp)); |
| 3092 | // Adding ice-options to the session level. |
| 3093 | InjectAfter("t=0 0\r\n", |
| 3094 | "a=ice-options:google-ice\r\n", |
| 3095 | &sdp); |
| 3096 | SessionDescriptionInterface* answer_with_gice = |
| 3097 | CreateSessionDescription(JsepSessionDescription::kAnswer, sdp, NULL); |
jlmiller@webrtc.org | 804eb46 | 2015-02-20 02:20:03 +0000 | [diff] [blame] | 3098 | // Default offer is ICEPROTO_RFC5245, so we expect responder with |
| 3099 | // only gice to fail. |
| 3100 | SetRemoteDescriptionAnswerExpectError(kPushDownTDFailed, answer_with_gice); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3101 | } |
| 3102 | |
| 3103 | // This test verifies the ice protocol type at initiator of the call |
| 3104 | // if ICE RFC5245 is supported in answer. |
| 3105 | TEST_F(WebRtcSessionTest, TestInitiatorIceInAnswer) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 3106 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3107 | mediastream_signaling_.SendAudioVideoStream1(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 3108 | SessionDescriptionInterface* offer = CreateOffer(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3109 | SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); |
| 3110 | SetLocalDescriptionWithoutError(offer); |
| 3111 | |
| 3112 | SetRemoteDescriptionWithoutError(answer); |
| 3113 | VerifyTransportType("audio", cricket::ICEPROTO_RFC5245); |
| 3114 | VerifyTransportType("video", cricket::ICEPROTO_RFC5245); |
| 3115 | } |
| 3116 | |
| 3117 | // This test verifies the ice protocol type at receiver side of the call if |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3118 | // receiver decides to use ice RFC 5245. |
| 3119 | TEST_F(WebRtcSessionTest, TestReceiverIceInOffer) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 3120 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3121 | mediastream_signaling_.SendAudioVideoStream1(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 3122 | SessionDescriptionInterface* offer = CreateOffer(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3123 | SetRemoteDescriptionWithoutError(offer); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3124 | SessionDescriptionInterface* answer = CreateAnswer(NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3125 | SetLocalDescriptionWithoutError(answer); |
| 3126 | VerifyTransportType("audio", cricket::ICEPROTO_RFC5245); |
| 3127 | VerifyTransportType("video", cricket::ICEPROTO_RFC5245); |
| 3128 | } |
| 3129 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3130 | // Verifing local offer and remote answer have matching m-lines as per RFC 3264. |
| 3131 | TEST_F(WebRtcSessionTest, TestIncorrectMLinesInRemoteAnswer) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 3132 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3133 | mediastream_signaling_.SendAudioVideoStream1(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 3134 | SessionDescriptionInterface* offer = CreateOffer(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3135 | SetLocalDescriptionWithoutError(offer); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3136 | rtc::scoped_ptr<SessionDescriptionInterface> answer( |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3137 | CreateRemoteAnswer(session_->local_description())); |
| 3138 | |
| 3139 | cricket::SessionDescription* answer_copy = answer->description()->Copy(); |
| 3140 | answer_copy->RemoveContentByName("video"); |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 3141 | JsepSessionDescription* modified_answer = |
| 3142 | new JsepSessionDescription(JsepSessionDescription::kAnswer); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3143 | |
| 3144 | EXPECT_TRUE(modified_answer->Initialize(answer_copy, |
| 3145 | answer->session_id(), |
| 3146 | answer->session_version())); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 3147 | SetRemoteDescriptionAnswerExpectError(kMlineMismatch, modified_answer); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3148 | |
wu@webrtc.org | 4e39307 | 2014-04-07 17:04:35 +0000 | [diff] [blame] | 3149 | // Different content names. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3150 | std::string sdp; |
| 3151 | EXPECT_TRUE(answer->ToString(&sdp)); |
| 3152 | const std::string kAudioMid = "a=mid:audio"; |
| 3153 | const std::string kAudioMidReplaceStr = "a=mid:audio_content_name"; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3154 | rtc::replace_substrs(kAudioMid.c_str(), kAudioMid.length(), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3155 | kAudioMidReplaceStr.c_str(), |
| 3156 | kAudioMidReplaceStr.length(), |
| 3157 | &sdp); |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 3158 | SessionDescriptionInterface* modified_answer1 = |
| 3159 | CreateSessionDescription(JsepSessionDescription::kAnswer, sdp, NULL); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 3160 | SetRemoteDescriptionAnswerExpectError(kMlineMismatch, modified_answer1); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3161 | |
wu@webrtc.org | 4e39307 | 2014-04-07 17:04:35 +0000 | [diff] [blame] | 3162 | // Different media types. |
| 3163 | EXPECT_TRUE(answer->ToString(&sdp)); |
| 3164 | const std::string kAudioMline = "m=audio"; |
| 3165 | const std::string kAudioMlineReplaceStr = "m=video"; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3166 | rtc::replace_substrs(kAudioMline.c_str(), kAudioMline.length(), |
wu@webrtc.org | 4e39307 | 2014-04-07 17:04:35 +0000 | [diff] [blame] | 3167 | kAudioMlineReplaceStr.c_str(), |
| 3168 | kAudioMlineReplaceStr.length(), |
| 3169 | &sdp); |
| 3170 | SessionDescriptionInterface* modified_answer2 = |
| 3171 | CreateSessionDescription(JsepSessionDescription::kAnswer, sdp, NULL); |
| 3172 | SetRemoteDescriptionAnswerExpectError(kMlineMismatch, modified_answer2); |
| 3173 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3174 | SetRemoteDescriptionWithoutError(answer.release()); |
| 3175 | } |
| 3176 | |
| 3177 | // Verifying remote offer and local answer have matching m-lines as per |
| 3178 | // RFC 3264. |
| 3179 | TEST_F(WebRtcSessionTest, TestIncorrectMLinesInLocalAnswer) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 3180 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3181 | mediastream_signaling_.SendAudioVideoStream1(); |
| 3182 | SessionDescriptionInterface* offer = CreateRemoteOffer(); |
| 3183 | SetRemoteDescriptionWithoutError(offer); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3184 | SessionDescriptionInterface* answer = CreateAnswer(NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3185 | |
| 3186 | cricket::SessionDescription* answer_copy = answer->description()->Copy(); |
| 3187 | answer_copy->RemoveContentByName("video"); |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 3188 | JsepSessionDescription* modified_answer = |
| 3189 | new JsepSessionDescription(JsepSessionDescription::kAnswer); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3190 | |
| 3191 | EXPECT_TRUE(modified_answer->Initialize(answer_copy, |
| 3192 | answer->session_id(), |
| 3193 | answer->session_version())); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 3194 | SetLocalDescriptionAnswerExpectError(kMlineMismatch, modified_answer); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3195 | SetLocalDescriptionWithoutError(answer); |
| 3196 | } |
| 3197 | |
| 3198 | // This test verifies that WebRtcSession does not start candidate allocation |
| 3199 | // before SetLocalDescription is called. |
| 3200 | TEST_F(WebRtcSessionTest, TestIceStartAfterSetLocalDescriptionOnly) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 3201 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3202 | mediastream_signaling_.SendAudioVideoStream1(); |
| 3203 | SessionDescriptionInterface* offer = CreateRemoteOffer(); |
| 3204 | cricket::Candidate candidate; |
| 3205 | candidate.set_component(1); |
| 3206 | JsepIceCandidate ice_candidate(kMediaContentName0, kMediaContentIndex0, |
| 3207 | candidate); |
| 3208 | EXPECT_TRUE(offer->AddCandidate(&ice_candidate)); |
| 3209 | cricket::Candidate candidate1; |
| 3210 | candidate1.set_component(1); |
| 3211 | JsepIceCandidate ice_candidate1(kMediaContentName1, kMediaContentIndex1, |
| 3212 | candidate1); |
| 3213 | EXPECT_TRUE(offer->AddCandidate(&ice_candidate1)); |
| 3214 | SetRemoteDescriptionWithoutError(offer); |
| 3215 | ASSERT_TRUE(session_->GetTransportProxy("audio") != NULL); |
| 3216 | ASSERT_TRUE(session_->GetTransportProxy("video") != NULL); |
| 3217 | |
| 3218 | // Pump for 1 second and verify that no candidates are generated. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3219 | rtc::Thread::Current()->ProcessMessages(1000); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3220 | EXPECT_TRUE(observer_.mline_0_candidates_.empty()); |
| 3221 | EXPECT_TRUE(observer_.mline_1_candidates_.empty()); |
| 3222 | |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3223 | SessionDescriptionInterface* answer = CreateAnswer(NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3224 | SetLocalDescriptionWithoutError(answer); |
| 3225 | EXPECT_TRUE(session_->GetTransportProxy("audio")->negotiated()); |
| 3226 | EXPECT_TRUE(session_->GetTransportProxy("video")->negotiated()); |
| 3227 | EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); |
| 3228 | } |
| 3229 | |
| 3230 | // This test verifies that crypto parameter is updated in local session |
| 3231 | // description as per security policy set in MediaSessionDescriptionFactory. |
| 3232 | TEST_F(WebRtcSessionTest, TestCryptoAfterSetLocalDescription) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 3233 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3234 | mediastream_signaling_.SendAudioVideoStream1(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 3235 | rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3236 | |
| 3237 | // Making sure SetLocalDescription correctly sets crypto value in |
| 3238 | // SessionDescription object after de-serialization of sdp string. The value |
| 3239 | // will be set as per MediaSessionDescriptionFactory. |
| 3240 | std::string offer_str; |
| 3241 | offer->ToString(&offer_str); |
| 3242 | SessionDescriptionInterface* jsep_offer_str = |
| 3243 | CreateSessionDescription(JsepSessionDescription::kOffer, offer_str, NULL); |
| 3244 | SetLocalDescriptionWithoutError(jsep_offer_str); |
| 3245 | EXPECT_TRUE(session_->voice_channel()->secure_required()); |
| 3246 | EXPECT_TRUE(session_->video_channel()->secure_required()); |
| 3247 | } |
| 3248 | |
| 3249 | // This test verifies the crypto parameter when security is disabled. |
| 3250 | TEST_F(WebRtcSessionTest, TestCryptoAfterSetLocalDescriptionWithDisabled) { |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 3251 | options_.disable_encryption = true; |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 3252 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3253 | mediastream_signaling_.SendAudioVideoStream1(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 3254 | rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3255 | |
| 3256 | // Making sure SetLocalDescription correctly sets crypto value in |
| 3257 | // SessionDescription object after de-serialization of sdp string. The value |
| 3258 | // will be set as per MediaSessionDescriptionFactory. |
| 3259 | std::string offer_str; |
| 3260 | offer->ToString(&offer_str); |
| 3261 | SessionDescriptionInterface *jsep_offer_str = |
| 3262 | CreateSessionDescription(JsepSessionDescription::kOffer, offer_str, NULL); |
| 3263 | SetLocalDescriptionWithoutError(jsep_offer_str); |
| 3264 | EXPECT_FALSE(session_->voice_channel()->secure_required()); |
| 3265 | EXPECT_FALSE(session_->video_channel()->secure_required()); |
| 3266 | } |
| 3267 | |
| 3268 | // This test verifies that an answer contains new ufrag and password if an offer |
| 3269 | // with new ufrag and password is received. |
| 3270 | TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewUfragAndPassword) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 3271 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3272 | cricket::MediaSessionOptions options; |
jiayl@webrtc.org | 742922b | 2014-10-07 21:32:43 +0000 | [diff] [blame] | 3273 | options.recv_video = true; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3274 | rtc::scoped_ptr<JsepSessionDescription> offer( |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3275 | CreateRemoteOffer(options)); |
| 3276 | SetRemoteDescriptionWithoutError(offer.release()); |
| 3277 | |
| 3278 | mediastream_signaling_.SendAudioVideoStream1(); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3279 | rtc::scoped_ptr<SessionDescriptionInterface> answer( |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3280 | CreateAnswer(NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3281 | SetLocalDescriptionWithoutError(answer.release()); |
| 3282 | |
| 3283 | // Receive an offer with new ufrag and password. |
| 3284 | options.transport_options.ice_restart = true; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3285 | rtc::scoped_ptr<JsepSessionDescription> updated_offer1( |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3286 | CreateRemoteOffer(options, session_->remote_description())); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3287 | SetRemoteDescriptionWithoutError(updated_offer1.release()); |
| 3288 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3289 | rtc::scoped_ptr<SessionDescriptionInterface> updated_answer1( |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3290 | CreateAnswer(NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3291 | |
| 3292 | CompareIceUfragAndPassword(updated_answer1->description(), |
| 3293 | session_->local_description()->description(), |
| 3294 | false); |
| 3295 | |
| 3296 | SetLocalDescriptionWithoutError(updated_answer1.release()); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3297 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3298 | |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3299 | // This test verifies that an answer contains old ufrag and password if an offer |
| 3300 | // with old ufrag and password is received. |
| 3301 | TEST_F(WebRtcSessionTest, TestCreateAnswerWithOldUfragAndPassword) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 3302 | Init(); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3303 | cricket::MediaSessionOptions options; |
jiayl@webrtc.org | 742922b | 2014-10-07 21:32:43 +0000 | [diff] [blame] | 3304 | options.recv_video = true; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3305 | rtc::scoped_ptr<JsepSessionDescription> offer( |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3306 | CreateRemoteOffer(options)); |
| 3307 | SetRemoteDescriptionWithoutError(offer.release()); |
| 3308 | |
| 3309 | mediastream_signaling_.SendAudioVideoStream1(); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3310 | rtc::scoped_ptr<SessionDescriptionInterface> answer( |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3311 | CreateAnswer(NULL)); |
| 3312 | SetLocalDescriptionWithoutError(answer.release()); |
| 3313 | |
| 3314 | // Receive an offer without changed ufrag or password. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3315 | options.transport_options.ice_restart = false; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3316 | rtc::scoped_ptr<JsepSessionDescription> updated_offer2( |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3317 | CreateRemoteOffer(options, session_->remote_description())); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3318 | SetRemoteDescriptionWithoutError(updated_offer2.release()); |
| 3319 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3320 | rtc::scoped_ptr<SessionDescriptionInterface> updated_answer2( |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3321 | CreateAnswer(NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3322 | |
| 3323 | CompareIceUfragAndPassword(updated_answer2->description(), |
| 3324 | session_->local_description()->description(), |
| 3325 | true); |
| 3326 | |
| 3327 | SetLocalDescriptionWithoutError(updated_answer2.release()); |
| 3328 | } |
| 3329 | |
| 3330 | TEST_F(WebRtcSessionTest, TestSessionContentError) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 3331 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3332 | mediastream_signaling_.SendAudioVideoStream1(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 3333 | SessionDescriptionInterface* offer = CreateOffer(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3334 | const std::string session_id_orig = offer->session_id(); |
| 3335 | const std::string session_version_orig = offer->session_version(); |
| 3336 | SetLocalDescriptionWithoutError(offer); |
| 3337 | |
| 3338 | video_channel_ = media_engine_->GetVideoChannel(0); |
| 3339 | video_channel_->set_fail_set_send_codecs(true); |
| 3340 | |
| 3341 | mediastream_signaling_.SendAudioVideoStream2(); |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 3342 | SessionDescriptionInterface* answer = |
| 3343 | CreateRemoteAnswer(session_->local_description()); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 3344 | SetRemoteDescriptionAnswerExpectError("ERROR_CONTENT", answer); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3345 | } |
| 3346 | |
| 3347 | // Runs the loopback call test with BUNDLE and STUN disabled. |
| 3348 | TEST_F(WebRtcSessionTest, TestIceStatesBasic) { |
| 3349 | // Lets try with only UDP ports. |
buildbot@webrtc.org | 41451d4 | 2014-05-03 05:39:45 +0000 | [diff] [blame] | 3350 | allocator_->set_flags(cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |
guoweis@webrtc.org | 7169afd | 2014-12-04 17:59:29 +0000 | [diff] [blame] | 3351 | cricket::PORTALLOCATOR_DISABLE_TCP | |
| 3352 | cricket::PORTALLOCATOR_DISABLE_STUN | |
| 3353 | cricket::PORTALLOCATOR_DISABLE_RELAY); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3354 | TestLoopbackCall(); |
| 3355 | } |
| 3356 | |
guoweis@webrtc.org | 7169afd | 2014-12-04 17:59:29 +0000 | [diff] [blame] | 3357 | TEST_F(WebRtcSessionTest, TestIceStatesBasicIPv6) { |
| 3358 | allocator_->set_flags(cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |
| 3359 | cricket::PORTALLOCATOR_DISABLE_TCP | |
| 3360 | cricket::PORTALLOCATOR_DISABLE_STUN | |
| 3361 | cricket::PORTALLOCATOR_ENABLE_IPV6 | |
| 3362 | cricket::PORTALLOCATOR_DISABLE_RELAY); |
| 3363 | |
| 3364 | // best connection is IPv6 since it has higher network preference. |
| 3365 | LoopbackNetworkConfiguration config; |
| 3366 | config.test_ipv6_network_ = true; |
| 3367 | config.best_connection_after_initial_ice_converged_ = |
| 3368 | LoopbackNetworkConfiguration::ExpectedBestConnection(0, 1); |
| 3369 | |
| 3370 | TestLoopbackCall(config); |
| 3371 | } |
| 3372 | |
mallinath@webrtc.org | d3dc424 | 2014-03-01 00:05:52 +0000 | [diff] [blame] | 3373 | // Runs the loopback call test with BUNDLE and STUN enabled. |
mallinath@webrtc.org | 385857d | 2014-02-14 00:56:12 +0000 | [diff] [blame] | 3374 | TEST_F(WebRtcSessionTest, TestIceStatesBundle) { |
buildbot@webrtc.org | 41451d4 | 2014-05-03 05:39:45 +0000 | [diff] [blame] | 3375 | allocator_->set_flags(cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |
mallinath@webrtc.org | d3dc424 | 2014-03-01 00:05:52 +0000 | [diff] [blame] | 3376 | cricket::PORTALLOCATOR_DISABLE_TCP | |
mallinath@webrtc.org | 385857d | 2014-02-14 00:56:12 +0000 | [diff] [blame] | 3377 | cricket::PORTALLOCATOR_DISABLE_RELAY); |
| 3378 | TestLoopbackCall(); |
| 3379 | } |
| 3380 | |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 3381 | TEST_F(WebRtcSessionTest, SetSdpFailedOnSessionError) { |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 3382 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3383 | cricket::MediaSessionOptions options; |
jiayl@webrtc.org | 742922b | 2014-10-07 21:32:43 +0000 | [diff] [blame] | 3384 | options.recv_video = true; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3385 | |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 3386 | cricket::BaseSession::Error error_code = cricket::BaseSession::ERROR_CONTENT; |
| 3387 | std::string error_code_str = "ERROR_CONTENT"; |
| 3388 | std::string error_desc = "Fake session error description."; |
| 3389 | session_->SetError(error_code, error_desc); |
| 3390 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3391 | SessionDescriptionInterface* offer = CreateRemoteOffer(options); |
| 3392 | SessionDescriptionInterface* answer = |
| 3393 | CreateRemoteAnswer(offer, options); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 3394 | |
| 3395 | std::string action; |
| 3396 | std::ostringstream session_error_msg; |
| 3397 | session_error_msg << kSessionError << error_code_str << ". "; |
| 3398 | session_error_msg << kSessionErrorDesc << error_desc << "."; |
| 3399 | SetRemoteDescriptionExpectError(action, session_error_msg.str(), offer); |
| 3400 | SetLocalDescriptionExpectError(action, session_error_msg.str(), answer); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3401 | } |
| 3402 | |
| 3403 | TEST_F(WebRtcSessionTest, TestRtpDataChannel) { |
| 3404 | constraints_.reset(new FakeConstraints()); |
| 3405 | constraints_->AddOptional( |
| 3406 | webrtc::MediaConstraintsInterface::kEnableRtpDataChannels, true); |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 3407 | Init(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3408 | |
| 3409 | SetLocalDescriptionWithDataChannel(); |
| 3410 | EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type()); |
| 3411 | } |
| 3412 | |
| 3413 | TEST_F(WebRtcSessionTest, TestRtpDataChannelConstraintTakesPrecedence) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3414 | MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3415 | |
| 3416 | constraints_.reset(new FakeConstraints()); |
| 3417 | constraints_->AddOptional( |
| 3418 | webrtc::MediaConstraintsInterface::kEnableRtpDataChannels, true); |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 3419 | options_.disable_sctp_data_channels = false; |
| 3420 | |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 3421 | InitWithDtls(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3422 | |
| 3423 | SetLocalDescriptionWithDataChannel(); |
| 3424 | EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type()); |
| 3425 | } |
| 3426 | |
wu@webrtc.org | 967bfff | 2013-09-19 05:49:50 +0000 | [diff] [blame] | 3427 | TEST_F(WebRtcSessionTest, TestCreateOfferWithSctpEnabledWithoutStreams) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3428 | MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
wu@webrtc.org | 967bfff | 2013-09-19 05:49:50 +0000 | [diff] [blame] | 3429 | |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 3430 | InitWithDtls(); |
sergeyu@chromium.org | a59696b | 2013-09-13 23:48:58 +0000 | [diff] [blame] | 3431 | |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 3432 | rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
sergeyu@chromium.org | a59696b | 2013-09-13 23:48:58 +0000 | [diff] [blame] | 3433 | EXPECT_TRUE(offer->description()->GetContentByName("data") == NULL); |
mallinath@webrtc.org | 1112c30 | 2013-09-23 20:34:45 +0000 | [diff] [blame] | 3434 | EXPECT_TRUE(offer->description()->GetTransportInfoByName("data") == NULL); |
| 3435 | } |
| 3436 | |
| 3437 | TEST_F(WebRtcSessionTest, TestCreateAnswerWithSctpInOfferAndNoStreams) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3438 | MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
mallinath@webrtc.org | 1112c30 | 2013-09-23 20:34:45 +0000 | [diff] [blame] | 3439 | SetFactoryDtlsSrtp(); |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 3440 | InitWithDtls(); |
mallinath@webrtc.org | 1112c30 | 2013-09-23 20:34:45 +0000 | [diff] [blame] | 3441 | |
| 3442 | // Create remote offer with SCTP. |
| 3443 | cricket::MediaSessionOptions options; |
| 3444 | options.data_channel_type = cricket::DCT_SCTP; |
| 3445 | JsepSessionDescription* offer = |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 3446 | CreateRemoteOffer(options, cricket::SEC_DISABLED); |
mallinath@webrtc.org | 1112c30 | 2013-09-23 20:34:45 +0000 | [diff] [blame] | 3447 | SetRemoteDescriptionWithoutError(offer); |
| 3448 | |
| 3449 | // Verifies the answer contains SCTP. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3450 | rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(NULL)); |
mallinath@webrtc.org | 1112c30 | 2013-09-23 20:34:45 +0000 | [diff] [blame] | 3451 | EXPECT_TRUE(answer != NULL); |
| 3452 | EXPECT_TRUE(answer->description()->GetContentByName("data") != NULL); |
| 3453 | EXPECT_TRUE(answer->description()->GetTransportInfoByName("data") != NULL); |
sergeyu@chromium.org | a59696b | 2013-09-13 23:48:58 +0000 | [diff] [blame] | 3454 | } |
| 3455 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3456 | TEST_F(WebRtcSessionTest, TestSctpDataChannelWithoutDtls) { |
| 3457 | constraints_.reset(new FakeConstraints()); |
| 3458 | constraints_->AddOptional( |
sergeyu@chromium.org | a59696b | 2013-09-13 23:48:58 +0000 | [diff] [blame] | 3459 | webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, false); |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 3460 | InitWithDtls(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3461 | |
| 3462 | SetLocalDescriptionWithDataChannel(); |
| 3463 | EXPECT_EQ(cricket::DCT_NONE, data_engine_->last_channel_type()); |
| 3464 | } |
| 3465 | |
| 3466 | TEST_F(WebRtcSessionTest, TestSctpDataChannelWithDtls) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3467 | MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3468 | |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 3469 | InitWithDtls(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3470 | |
| 3471 | SetLocalDescriptionWithDataChannel(); |
| 3472 | EXPECT_EQ(cricket::DCT_SCTP, data_engine_->last_channel_type()); |
| 3473 | } |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3474 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 3475 | TEST_F(WebRtcSessionTest, TestDisableSctpDataChannels) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3476 | MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 3477 | options_.disable_sctp_data_channels = true; |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 3478 | InitWithDtls(); |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 3479 | |
| 3480 | SetLocalDescriptionWithDataChannel(); |
| 3481 | EXPECT_EQ(cricket::DCT_NONE, data_engine_->last_channel_type()); |
| 3482 | } |
| 3483 | |
mallinath@webrtc.org | 19f27e6 | 2013-10-13 17:18:27 +0000 | [diff] [blame] | 3484 | TEST_F(WebRtcSessionTest, TestSctpDataChannelSendPortParsing) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3485 | MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
mallinath@webrtc.org | 19f27e6 | 2013-10-13 17:18:27 +0000 | [diff] [blame] | 3486 | const int new_send_port = 9998; |
| 3487 | const int new_recv_port = 7775; |
| 3488 | |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 3489 | InitWithDtls(); |
mallinath@webrtc.org | 19f27e6 | 2013-10-13 17:18:27 +0000 | [diff] [blame] | 3490 | SetFactoryDtlsSrtp(); |
| 3491 | |
| 3492 | // By default, don't actually add the codecs to desc_factory_; they don't |
| 3493 | // actually get serialized for SCTP in BuildMediaDescription(). Instead, |
| 3494 | // let the session description get parsed. That'll get the proper codecs |
| 3495 | // into the stream. |
| 3496 | cricket::MediaSessionOptions options; |
| 3497 | JsepSessionDescription* offer = CreateRemoteOfferWithSctpPort( |
| 3498 | "stream1", new_send_port, options); |
| 3499 | |
| 3500 | // SetRemoteDescription will take the ownership of the offer. |
| 3501 | SetRemoteDescriptionWithoutError(offer); |
| 3502 | |
| 3503 | SessionDescriptionInterface* answer = ChangeSDPSctpPort( |
| 3504 | new_recv_port, CreateAnswer(NULL)); |
| 3505 | ASSERT_TRUE(answer != NULL); |
| 3506 | |
| 3507 | // Now set the local description, which'll take ownership of the answer. |
| 3508 | SetLocalDescriptionWithoutError(answer); |
| 3509 | |
| 3510 | // TEST PLAN: Set the port number to something new, set it in the SDP, |
| 3511 | // and pass it all the way down. |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 +0000 | [diff] [blame] | 3512 | webrtc::InternalDataChannelInit dci; |
mallinath@webrtc.org | 19f27e6 | 2013-10-13 17:18:27 +0000 | [diff] [blame] | 3513 | dci.reliable = true; |
| 3514 | EXPECT_EQ(cricket::DCT_SCTP, data_engine_->last_channel_type()); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3515 | rtc::scoped_refptr<webrtc::DataChannel> dc = |
mallinath@webrtc.org | 19f27e6 | 2013-10-13 17:18:27 +0000 | [diff] [blame] | 3516 | session_->CreateDataChannel("datachannel", &dci); |
| 3517 | |
| 3518 | cricket::FakeDataMediaChannel* ch = data_engine_->GetChannel(0); |
| 3519 | int portnum = -1; |
| 3520 | ASSERT_TRUE(ch != NULL); |
| 3521 | ASSERT_EQ(1UL, ch->send_codecs().size()); |
| 3522 | EXPECT_EQ(cricket::kGoogleSctpDataCodecId, ch->send_codecs()[0].id); |
Donald Curtis | d4f769d | 2015-05-28 09:48:21 -0700 | [diff] [blame] | 3523 | EXPECT_EQ(0, strcmp(cricket::kGoogleSctpDataCodecName, |
mallinath@webrtc.org | 19f27e6 | 2013-10-13 17:18:27 +0000 | [diff] [blame] | 3524 | ch->send_codecs()[0].name.c_str())); |
| 3525 | EXPECT_TRUE(ch->send_codecs()[0].GetParam(cricket::kCodecParamPort, |
| 3526 | &portnum)); |
| 3527 | EXPECT_EQ(new_send_port, portnum); |
| 3528 | |
| 3529 | ASSERT_EQ(1UL, ch->recv_codecs().size()); |
| 3530 | EXPECT_EQ(cricket::kGoogleSctpDataCodecId, ch->recv_codecs()[0].id); |
Donald Curtis | d4f769d | 2015-05-28 09:48:21 -0700 | [diff] [blame] | 3531 | EXPECT_EQ(0, strcmp(cricket::kGoogleSctpDataCodecName, |
mallinath@webrtc.org | 19f27e6 | 2013-10-13 17:18:27 +0000 | [diff] [blame] | 3532 | ch->recv_codecs()[0].name.c_str())); |
| 3533 | EXPECT_TRUE(ch->recv_codecs()[0].GetParam(cricket::kCodecParamPort, |
| 3534 | &portnum)); |
| 3535 | EXPECT_EQ(new_recv_port, portnum); |
| 3536 | } |
| 3537 | |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3538 | // Verifies that CreateOffer succeeds when CreateOffer is called before async |
| 3539 | // identity generation is finished. |
| 3540 | TEST_F(WebRtcSessionTest, TestCreateOfferBeforeIdentityRequestReturnSuccess) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3541 | MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 3542 | InitWithDtls(); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3543 | |
| 3544 | EXPECT_TRUE(session_->waiting_for_identity()); |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 3545 | mediastream_signaling_.SendAudioVideoStream1(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 3546 | rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 3547 | |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3548 | EXPECT_TRUE(offer != NULL); |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 3549 | VerifyNoCryptoParams(offer->description(), true); |
| 3550 | VerifyFingerprintStatus(offer->description(), true); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3551 | } |
| 3552 | |
| 3553 | // Verifies that CreateAnswer succeeds when CreateOffer is called before async |
| 3554 | // identity generation is finished. |
| 3555 | TEST_F(WebRtcSessionTest, TestCreateAnswerBeforeIdentityRequestReturnSuccess) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3556 | MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 3557 | InitWithDtls(); |
| 3558 | SetFactoryDtlsSrtp(); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3559 | |
| 3560 | cricket::MediaSessionOptions options; |
jiayl@webrtc.org | 742922b | 2014-10-07 21:32:43 +0000 | [diff] [blame] | 3561 | options.recv_video = true; |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3562 | scoped_ptr<JsepSessionDescription> offer( |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 3563 | CreateRemoteOffer(options, cricket::SEC_DISABLED)); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3564 | ASSERT_TRUE(offer.get() != NULL); |
| 3565 | SetRemoteDescriptionWithoutError(offer.release()); |
| 3566 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3567 | rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(NULL)); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3568 | EXPECT_TRUE(answer != NULL); |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 3569 | VerifyNoCryptoParams(answer->description(), true); |
| 3570 | VerifyFingerprintStatus(answer->description(), true); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3571 | } |
| 3572 | |
| 3573 | // Verifies that CreateOffer succeeds when CreateOffer is called after async |
| 3574 | // identity generation is finished. |
| 3575 | TEST_F(WebRtcSessionTest, TestCreateOfferAfterIdentityRequestReturnSuccess) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3576 | MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 3577 | InitWithDtls(); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3578 | |
| 3579 | EXPECT_TRUE_WAIT(!session_->waiting_for_identity(), 1000); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 3580 | |
| 3581 | rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3582 | EXPECT_TRUE(offer != NULL); |
| 3583 | } |
| 3584 | |
| 3585 | // Verifies that CreateOffer fails when CreateOffer is called after async |
| 3586 | // identity generation fails. |
| 3587 | TEST_F(WebRtcSessionTest, TestCreateOfferAfterIdentityRequestReturnFailure) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3588 | MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
henrike@webrtc.org | 7666db7 | 2013-08-22 14:45:42 +0000 | [diff] [blame] | 3589 | InitWithDtls(true); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3590 | |
| 3591 | EXPECT_TRUE_WAIT(!session_->waiting_for_identity(), 1000); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 3592 | |
| 3593 | rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3594 | EXPECT_TRUE(offer == NULL); |
| 3595 | } |
| 3596 | |
| 3597 | // Verifies that CreateOffer succeeds when Multiple CreateOffer calls are made |
| 3598 | // before async identity generation is finished. |
| 3599 | TEST_F(WebRtcSessionTest, |
| 3600 | TestMultipleCreateOfferBeforeIdentityRequestReturnSuccess) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3601 | MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3602 | VerifyMultipleAsyncCreateDescription( |
| 3603 | true, CreateSessionDescriptionRequest::kOffer); |
| 3604 | } |
| 3605 | |
| 3606 | // Verifies that CreateOffer fails when Multiple CreateOffer calls are made |
| 3607 | // before async identity generation fails. |
| 3608 | TEST_F(WebRtcSessionTest, |
| 3609 | TestMultipleCreateOfferBeforeIdentityRequestReturnFailure) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3610 | MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3611 | VerifyMultipleAsyncCreateDescription( |
| 3612 | false, CreateSessionDescriptionRequest::kOffer); |
| 3613 | } |
| 3614 | |
| 3615 | // Verifies that CreateAnswer succeeds when Multiple CreateAnswer calls are made |
| 3616 | // before async identity generation is finished. |
| 3617 | TEST_F(WebRtcSessionTest, |
| 3618 | TestMultipleCreateAnswerBeforeIdentityRequestReturnSuccess) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3619 | MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3620 | VerifyMultipleAsyncCreateDescription( |
| 3621 | true, CreateSessionDescriptionRequest::kAnswer); |
| 3622 | } |
| 3623 | |
| 3624 | // Verifies that CreateAnswer fails when Multiple CreateAnswer calls are made |
| 3625 | // before async identity generation fails. |
| 3626 | TEST_F(WebRtcSessionTest, |
| 3627 | TestMultipleCreateAnswerBeforeIdentityRequestReturnFailure) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3628 | MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 3629 | VerifyMultipleAsyncCreateDescription( |
| 3630 | false, CreateSessionDescriptionRequest::kAnswer); |
| 3631 | } |
mallinath@webrtc.org | a27be8e | 2013-09-27 23:04:10 +0000 | [diff] [blame] | 3632 | |
| 3633 | // Verifies that setRemoteDescription fails when DTLS is disabled and the remote |
| 3634 | // offer has no SDES crypto but only DTLS fingerprint. |
| 3635 | TEST_F(WebRtcSessionTest, TestSetRemoteOfferFailIfDtlsDisabledAndNoCrypto) { |
| 3636 | // Init without DTLS. |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 3637 | Init(); |
mallinath@webrtc.org | a27be8e | 2013-09-27 23:04:10 +0000 | [diff] [blame] | 3638 | // Create a remote offer with secured transport disabled. |
| 3639 | cricket::MediaSessionOptions options; |
| 3640 | JsepSessionDescription* offer(CreateRemoteOffer( |
| 3641 | options, cricket::SEC_DISABLED)); |
| 3642 | // Adds a DTLS fingerprint to the remote offer. |
| 3643 | cricket::SessionDescription* sdp = offer->description(); |
| 3644 | TransportInfo* audio = sdp->GetTransportInfoByName("audio"); |
| 3645 | ASSERT_TRUE(audio != NULL); |
| 3646 | ASSERT_TRUE(audio->description.identity_fingerprint.get() == NULL); |
| 3647 | audio->description.identity_fingerprint.reset( |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3648 | rtc::SSLFingerprint::CreateFromRfc4572( |
| 3649 | rtc::DIGEST_SHA_256, kFakeDtlsFingerprint)); |
henrike@webrtc.org | b90991d | 2014-03-04 19:54:57 +0000 | [diff] [blame] | 3650 | SetRemoteDescriptionOfferExpectError(kSdpWithoutSdesCrypto, |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 3651 | offer); |
mallinath@webrtc.org | a27be8e | 2013-09-27 23:04:10 +0000 | [diff] [blame] | 3652 | } |
| 3653 | |
wu@webrtc.org | de30501 | 2013-10-31 15:40:38 +0000 | [diff] [blame] | 3654 | // This test verifies DSCP is properly applied on the media channels. |
| 3655 | TEST_F(WebRtcSessionTest, TestDscpConstraint) { |
| 3656 | constraints_.reset(new FakeConstraints()); |
| 3657 | constraints_->AddOptional( |
| 3658 | webrtc::MediaConstraintsInterface::kEnableDscp, true); |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 3659 | Init(); |
wu@webrtc.org | de30501 | 2013-10-31 15:40:38 +0000 | [diff] [blame] | 3660 | mediastream_signaling_.SendAudioVideoStream1(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 3661 | SessionDescriptionInterface* offer = CreateOffer(); |
wu@webrtc.org | de30501 | 2013-10-31 15:40:38 +0000 | [diff] [blame] | 3662 | |
| 3663 | SetLocalDescriptionWithoutError(offer); |
| 3664 | |
| 3665 | video_channel_ = media_engine_->GetVideoChannel(0); |
| 3666 | voice_channel_ = media_engine_->GetVoiceChannel(0); |
| 3667 | |
| 3668 | ASSERT_TRUE(video_channel_ != NULL); |
| 3669 | ASSERT_TRUE(voice_channel_ != NULL); |
| 3670 | cricket::AudioOptions audio_options; |
| 3671 | EXPECT_TRUE(voice_channel_->GetOptions(&audio_options)); |
| 3672 | cricket::VideoOptions video_options; |
| 3673 | EXPECT_TRUE(video_channel_->GetOptions(&video_options)); |
| 3674 | EXPECT_TRUE(audio_options.dscp.IsSet()); |
| 3675 | EXPECT_TRUE(audio_options.dscp.GetWithDefaultIfUnset(false)); |
| 3676 | EXPECT_TRUE(video_options.dscp.IsSet()); |
| 3677 | EXPECT_TRUE(video_options.dscp.GetWithDefaultIfUnset(false)); |
| 3678 | } |
| 3679 | |
henrike@webrtc.org | 6e3dbc2 | 2014-03-25 17:09:47 +0000 | [diff] [blame] | 3680 | TEST_F(WebRtcSessionTest, TestSuspendBelowMinBitrateConstraint) { |
| 3681 | constraints_.reset(new FakeConstraints()); |
| 3682 | constraints_->AddOptional( |
| 3683 | webrtc::MediaConstraintsInterface::kEnableVideoSuspendBelowMinBitrate, |
| 3684 | true); |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 3685 | Init(); |
henrike@webrtc.org | 6e3dbc2 | 2014-03-25 17:09:47 +0000 | [diff] [blame] | 3686 | mediastream_signaling_.SendAudioVideoStream1(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 3687 | SessionDescriptionInterface* offer = CreateOffer(); |
henrike@webrtc.org | 6e3dbc2 | 2014-03-25 17:09:47 +0000 | [diff] [blame] | 3688 | |
| 3689 | SetLocalDescriptionWithoutError(offer); |
| 3690 | |
| 3691 | video_channel_ = media_engine_->GetVideoChannel(0); |
| 3692 | |
| 3693 | ASSERT_TRUE(video_channel_ != NULL); |
| 3694 | cricket::VideoOptions video_options; |
| 3695 | EXPECT_TRUE(video_channel_->GetOptions(&video_options)); |
| 3696 | EXPECT_TRUE( |
| 3697 | video_options.suspend_below_min_bitrate.GetWithDefaultIfUnset(false)); |
| 3698 | } |
| 3699 | |
buildbot@webrtc.org | 53df88c | 2014-08-07 22:46:01 +0000 | [diff] [blame] | 3700 | TEST_F(WebRtcSessionTest, TestNumUnsignalledRecvStreamsConstraint) { |
| 3701 | // Number of unsignalled receiving streams should be between 0 and |
| 3702 | // kMaxUnsignalledRecvStreams. |
| 3703 | SetAndVerifyNumUnsignalledRecvStreams(10, 10); |
| 3704 | SetAndVerifyNumUnsignalledRecvStreams(kMaxUnsignalledRecvStreams + 1, |
| 3705 | kMaxUnsignalledRecvStreams); |
| 3706 | SetAndVerifyNumUnsignalledRecvStreams(-1, 0); |
| 3707 | } |
| 3708 | |
buildbot@webrtc.org | b4c7b09 | 2014-08-25 12:11:58 +0000 | [diff] [blame] | 3709 | TEST_F(WebRtcSessionTest, TestCombinedAudioVideoBweConstraint) { |
| 3710 | constraints_.reset(new FakeConstraints()); |
| 3711 | constraints_->AddOptional( |
| 3712 | webrtc::MediaConstraintsInterface::kCombinedAudioVideoBwe, |
| 3713 | true); |
pthatcher@webrtc.org | 877ac76 | 2015-02-04 22:03:09 +0000 | [diff] [blame] | 3714 | Init(); |
buildbot@webrtc.org | b4c7b09 | 2014-08-25 12:11:58 +0000 | [diff] [blame] | 3715 | mediastream_signaling_.SendAudioVideoStream1(); |
| 3716 | SessionDescriptionInterface* offer = CreateOffer(); |
| 3717 | |
| 3718 | SetLocalDescriptionWithoutError(offer); |
| 3719 | |
| 3720 | voice_channel_ = media_engine_->GetVoiceChannel(0); |
| 3721 | |
| 3722 | ASSERT_TRUE(voice_channel_ != NULL); |
| 3723 | cricket::AudioOptions audio_options; |
| 3724 | EXPECT_TRUE(voice_channel_->GetOptions(&audio_options)); |
| 3725 | EXPECT_TRUE( |
| 3726 | audio_options.combined_audio_video_bwe.GetWithDefaultIfUnset(false)); |
| 3727 | } |
| 3728 | |
jiayl@webrtc.org | e10d28c | 2014-07-17 17:07:49 +0000 | [diff] [blame] | 3729 | // Tests that we can renegotiate new media content with ICE candidates in the |
| 3730 | // new remote SDP. |
| 3731 | TEST_F(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesInSdp) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3732 | MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
jiayl@webrtc.org | e10d28c | 2014-07-17 17:07:49 +0000 | [diff] [blame] | 3733 | InitWithDtls(); |
| 3734 | SetFactoryDtlsSrtp(); |
| 3735 | |
| 3736 | mediastream_signaling_.UseOptionsAudioOnly(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 3737 | SessionDescriptionInterface* offer = CreateOffer(); |
jiayl@webrtc.org | e10d28c | 2014-07-17 17:07:49 +0000 | [diff] [blame] | 3738 | SetLocalDescriptionWithoutError(offer); |
| 3739 | |
| 3740 | SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); |
| 3741 | SetRemoteDescriptionWithoutError(answer); |
| 3742 | |
| 3743 | cricket::MediaSessionOptions options; |
jiayl@webrtc.org | 742922b | 2014-10-07 21:32:43 +0000 | [diff] [blame] | 3744 | options.recv_video = true; |
jiayl@webrtc.org | e10d28c | 2014-07-17 17:07:49 +0000 | [diff] [blame] | 3745 | offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); |
| 3746 | |
| 3747 | cricket::Candidate candidate1; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3748 | candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000)); |
jiayl@webrtc.org | e10d28c | 2014-07-17 17:07:49 +0000 | [diff] [blame] | 3749 | candidate1.set_component(1); |
| 3750 | JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1, |
| 3751 | candidate1); |
| 3752 | EXPECT_TRUE(offer->AddCandidate(&ice_candidate)); |
| 3753 | SetRemoteDescriptionWithoutError(offer); |
| 3754 | |
| 3755 | answer = CreateAnswer(NULL); |
| 3756 | SetLocalDescriptionWithoutError(answer); |
| 3757 | } |
| 3758 | |
| 3759 | // Tests that we can renegotiate new media content with ICE candidates separated |
| 3760 | // from the remote SDP. |
| 3761 | TEST_F(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesSeparated) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3762 | MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
jiayl@webrtc.org | e10d28c | 2014-07-17 17:07:49 +0000 | [diff] [blame] | 3763 | InitWithDtls(); |
| 3764 | SetFactoryDtlsSrtp(); |
| 3765 | |
| 3766 | mediastream_signaling_.UseOptionsAudioOnly(); |
jiayl@webrtc.org | b18bf5e | 2014-08-04 18:34:16 +0000 | [diff] [blame] | 3767 | SessionDescriptionInterface* offer = CreateOffer(); |
jiayl@webrtc.org | e10d28c | 2014-07-17 17:07:49 +0000 | [diff] [blame] | 3768 | SetLocalDescriptionWithoutError(offer); |
| 3769 | |
| 3770 | SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); |
| 3771 | SetRemoteDescriptionWithoutError(answer); |
| 3772 | |
| 3773 | cricket::MediaSessionOptions options; |
jiayl@webrtc.org | 742922b | 2014-10-07 21:32:43 +0000 | [diff] [blame] | 3774 | options.recv_video = true; |
jiayl@webrtc.org | e10d28c | 2014-07-17 17:07:49 +0000 | [diff] [blame] | 3775 | offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); |
| 3776 | SetRemoteDescriptionWithoutError(offer); |
| 3777 | |
| 3778 | cricket::Candidate candidate1; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 3779 | candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000)); |
jiayl@webrtc.org | e10d28c | 2014-07-17 17:07:49 +0000 | [diff] [blame] | 3780 | candidate1.set_component(1); |
| 3781 | JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1, |
| 3782 | candidate1); |
| 3783 | EXPECT_TRUE(session_->ProcessIceMessage(&ice_candidate)); |
| 3784 | |
| 3785 | answer = CreateAnswer(NULL); |
| 3786 | SetLocalDescriptionWithoutError(answer); |
| 3787 | } |
changbin.shao@webrtc.org | 2d25b44 | 2015-03-16 04:14:34 +0000 | [diff] [blame] | 3788 | // Tests that RTX codec is removed from the answer when it isn't supported |
| 3789 | // by local side. |
| 3790 | TEST_F(WebRtcSessionTest, TestRtxRemovedByCreateAnswer) { |
| 3791 | Init(); |
| 3792 | mediastream_signaling_.SendAudioVideoStream1(); |
| 3793 | std::string offer_sdp(kSdpWithRtx); |
| 3794 | |
| 3795 | SessionDescriptionInterface* offer = |
| 3796 | CreateSessionDescription(JsepSessionDescription::kOffer, offer_sdp, NULL); |
| 3797 | EXPECT_TRUE(offer->ToString(&offer_sdp)); |
| 3798 | |
| 3799 | // Offer SDP contains the RTX codec. |
| 3800 | EXPECT_TRUE(offer_sdp.find("rtx") != std::string::npos); |
| 3801 | SetRemoteDescriptionWithoutError(offer); |
| 3802 | |
| 3803 | SessionDescriptionInterface* answer = CreateAnswer(NULL); |
| 3804 | std::string answer_sdp; |
| 3805 | answer->ToString(&answer_sdp); |
| 3806 | // Answer SDP removes the unsupported RTX codec. |
| 3807 | EXPECT_TRUE(answer_sdp.find("rtx") == std::string::npos); |
| 3808 | SetLocalDescriptionWithoutError(answer); |
| 3809 | } |
jiayl@webrtc.org | e10d28c | 2014-07-17 17:07:49 +0000 | [diff] [blame] | 3810 | |
guoweis@webrtc.org | 4f85288 | 2015-03-12 20:09:44 +0000 | [diff] [blame] | 3811 | // This verifies that the voice channel after bundle has both options from video |
| 3812 | // and voice channels. |
| 3813 | TEST_F(WebRtcSessionTest, TestSetSocketOptionBeforeBundle) { |
| 3814 | InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); |
| 3815 | mediastream_signaling_.SendAudioVideoStream1(); |
| 3816 | |
| 3817 | PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 3818 | options.use_rtp_mux = true; |
| 3819 | |
| 3820 | SessionDescriptionInterface* offer = CreateOffer(options); |
| 3821 | SetLocalDescriptionWithoutError(offer); |
| 3822 | |
| 3823 | session_->video_channel()->SetOption(cricket::BaseChannel::ST_RTP, |
| 3824 | rtc::Socket::Option::OPT_SNDBUF, 4000); |
| 3825 | |
| 3826 | session_->voice_channel()->SetOption(cricket::BaseChannel::ST_RTP, |
| 3827 | rtc::Socket::Option::OPT_RCVBUF, 8000); |
| 3828 | |
| 3829 | int option_val; |
| 3830 | EXPECT_TRUE(session_->video_channel()->transport_channel()->GetOption( |
| 3831 | rtc::Socket::Option::OPT_SNDBUF, &option_val)); |
| 3832 | EXPECT_EQ(4000, option_val); |
| 3833 | EXPECT_FALSE(session_->voice_channel()->transport_channel()->GetOption( |
| 3834 | rtc::Socket::Option::OPT_SNDBUF, &option_val)); |
| 3835 | |
| 3836 | EXPECT_TRUE(session_->voice_channel()->transport_channel()->GetOption( |
| 3837 | rtc::Socket::Option::OPT_RCVBUF, &option_val)); |
| 3838 | EXPECT_EQ(8000, option_val); |
| 3839 | EXPECT_FALSE(session_->video_channel()->transport_channel()->GetOption( |
| 3840 | rtc::Socket::Option::OPT_RCVBUF, &option_val)); |
| 3841 | |
| 3842 | EXPECT_NE(session_->voice_channel()->transport_channel(), |
| 3843 | session_->video_channel()->transport_channel()); |
| 3844 | |
| 3845 | mediastream_signaling_.SendAudioVideoStream2(); |
| 3846 | SessionDescriptionInterface* answer = |
| 3847 | CreateRemoteAnswer(session_->local_description()); |
| 3848 | SetRemoteDescriptionWithoutError(answer); |
| 3849 | |
| 3850 | EXPECT_TRUE(session_->voice_channel()->transport_channel()->GetOption( |
| 3851 | rtc::Socket::Option::OPT_SNDBUF, &option_val)); |
| 3852 | EXPECT_EQ(4000, option_val); |
| 3853 | |
| 3854 | EXPECT_TRUE(session_->voice_channel()->transport_channel()->GetOption( |
| 3855 | rtc::Socket::Option::OPT_RCVBUF, &option_val)); |
| 3856 | EXPECT_EQ(8000, option_val); |
| 3857 | } |
| 3858 | |
tommi | 0f620f4 | 2015-07-09 03:25:02 -0700 | [diff] [blame] | 3859 | // Test creating a session, request multiple offers, destroy the session |
| 3860 | // and make sure we got success/failure callbacks for all of the requests. |
| 3861 | // Background: crbug.com/507307 |
| 3862 | TEST_F(WebRtcSessionTest, CreateOffersAndShutdown) { |
| 3863 | Init(); |
| 3864 | |
| 3865 | rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> observers[100]; |
| 3866 | PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 3867 | options.offer_to_receive_audio = |
| 3868 | RTCOfferAnswerOptions::kOfferToReceiveMediaTrue; |
| 3869 | |
| 3870 | for (auto& o : observers) { |
| 3871 | o = new WebRtcSessionCreateSDPObserverForTest(); |
| 3872 | session_->CreateOffer(o, options); |
| 3873 | } |
| 3874 | |
| 3875 | session_.reset(); |
| 3876 | |
| 3877 | // Make sure we process pending messages on the current (signaling) thread |
| 3878 | // before checking we we got our callbacks. Quit() will do this and then |
| 3879 | // immediately exit. We won't need the queue after this point anyway. |
| 3880 | rtc::Thread::Current()->Quit(); |
| 3881 | |
| 3882 | for (auto& o : observers) { |
| 3883 | // We expect to have received a notification now even if the session was |
| 3884 | // terminated. The offer creation may or may not have succeeded, but we |
| 3885 | // must have received a notification which, so the only invalid state |
| 3886 | // is kInit. |
| 3887 | EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state()); |
| 3888 | } |
| 3889 | } |
| 3890 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3891 | // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
| 3892 | // currently fails because upon disconnection and reconnection OnIceComplete is |
| 3893 | // called more than once without returning to IceGatheringGathering. |