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