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