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