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