blob: 1a6a212cdd9f0f1ad704088594e8e76cbc285575 [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:361/*
kjellanderb24317b2016-02-10 15:54:432 * Copyright 2011 The WebRTC project authors. All Rights Reserved.
henrike@webrtc.org28e20752013-07-10 00:45:363 *
kjellanderb24317b2016-02-10 15:54:434 * 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.org28e20752013-07-10 00:45:369 */
10
kwibergd1fe2812016-04-27 13:47:2911#include <memory>
henrike@webrtc.org28e20752013-07-10 00:45:3612#include <set>
13#include <string>
14#include <vector>
15
Henrik Kjellander15583c12016-02-10 09:53:1216#include "webrtc/api/jsepsessiondescription.h"
nissec80e7412017-01-11 13:56:4617#include "webrtc/base/checks.h"
buildbot@webrtc.orgd4e598d2014-07-29 17:36:5218#include "webrtc/base/gunit.h"
19#include "webrtc/base/logging.h"
20#include "webrtc/base/messagedigest.h"
buildbot@webrtc.orgd4e598d2014-07-29 17:36:5221#include "webrtc/base/sslfingerprint.h"
22#include "webrtc/base/stringencode.h"
23#include "webrtc/base/stringutils.h"
kjellanderf4752772016-03-02 13:42:3024#include "webrtc/media/base/mediaconstants.h"
htaa6b99442016-04-12 17:29:1725#include "webrtc/media/engine/webrtcvideoengine2.h"
26#include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
kjellanderf4752772016-03-02 13:42:3027#include "webrtc/p2p/base/p2pconstants.h"
kjellander@webrtc.org9b8df252016-02-12 05:47:5928#include "webrtc/pc/mediasession.h"
ossu7bb87ee2017-01-23 12:56:2529#ifdef WEBRTC_ANDROID
30#include "webrtc/pc/test/androidtestinitializer.h"
31#endif
32#include "webrtc/pc/webrtcsdp.h"
henrike@webrtc.org28e20752013-07-10 00:45:3633
34using cricket::AudioCodec;
35using cricket::AudioContentDescription;
36using cricket::Candidate;
37using cricket::ContentInfo;
38using cricket::CryptoParams;
39using cricket::ContentGroup;
40using cricket::DataCodec;
41using cricket::DataContentDescription;
42using cricket::ICE_CANDIDATE_COMPONENT_RTCP;
43using cricket::ICE_CANDIDATE_COMPONENT_RTP;
44using cricket::kFecSsrcGroupSemantics;
45using cricket::LOCAL_PORT_TYPE;
46using cricket::NS_JINGLE_DRAFT_SCTP;
henrike@webrtc.org28e20752013-07-10 00:45:3647using cricket::NS_JINGLE_RTP;
henrike@webrtc.org28e20752013-07-10 00:45:3648using cricket::RELAY_PORT_TYPE;
49using cricket::SessionDescription;
50using cricket::StreamParams;
51using cricket::STUN_PORT_TYPE;
52using cricket::TransportDescription;
53using cricket::TransportInfo;
54using cricket::VideoCodec;
55using cricket::VideoContentDescription;
56using webrtc::IceCandidateCollection;
57using webrtc::IceCandidateInterface;
58using webrtc::JsepIceCandidate;
59using webrtc::JsepSessionDescription;
isheriff6f8d6862016-05-26 18:24:5560using webrtc::RtpExtension;
henrike@webrtc.org28e20752013-07-10 00:45:3661using webrtc::SdpParseError;
62using webrtc::SessionDescriptionInterface;
63
64typedef std::vector<AudioCodec> AudioCodecs;
65typedef std::vector<Candidate> Candidates;
66
Peter Boström0c4e06b2015-10-07 10:23:2167static const uint32_t kDefaultSctpPort = 5000;
henrike@webrtc.org28e20752013-07-10 00:45:3668static const char kSessionTime[] = "t=0 0\r\n";
Peter Boström0c4e06b2015-10-07 10:23:2169static const uint32_t kCandidatePriority = 2130706432U; // pref = 1.0
deadbeef3f7219b2015-12-28 23:17:1470static const char kAttributeIceUfragVoice[] = "a=ice-ufrag:ufrag_voice\r\n";
henrike@webrtc.org28e20752013-07-10 00:45:3671static const char kAttributeIcePwdVoice[] = "a=ice-pwd:pwd_voice\r\n";
deadbeef3f7219b2015-12-28 23:17:1472static const char kAttributeIceUfragVideo[] = "a=ice-ufrag:ufrag_video\r\n";
henrike@webrtc.org28e20752013-07-10 00:45:3673static const char kAttributeIcePwdVideo[] = "a=ice-pwd:pwd_video\r\n";
Peter Boström0c4e06b2015-10-07 10:23:2174static const uint32_t kCandidateGeneration = 2;
henrike@webrtc.org28e20752013-07-10 00:45:3675static const char kCandidateFoundation1[] = "a0+B/1";
76static const char kCandidateFoundation2[] = "a0+B/2";
77static const char kCandidateFoundation3[] = "a0+B/3";
78static const char kCandidateFoundation4[] = "a0+B/4";
79static const char kAttributeCryptoVoice[] =
80 "a=crypto:1 AES_CM_128_HMAC_SHA1_32 "
81 "inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj|2^20|1:32 "
82 "dummy_session_params\r\n";
83static const char kAttributeCryptoVideo[] =
84 "a=crypto:1 AES_CM_128_HMAC_SHA1_80 "
85 "inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj|2^20|1:32\r\n";
86static const char kFingerprint[] = "a=fingerprint:sha-1 "
87 "4A:AD:B9:B1:3F:82:18:3B:54:02:12:DF:3E:5D:49:6B:19:E5:7C:AB\r\n";
88static const int kExtmapId = 1;
89static const char kExtmapUri[] = "http://example.com/082005/ext.htm#ttime";
90static const char kExtmap[] =
91 "a=extmap:1 http://example.com/082005/ext.htm#ttime\r\n";
92static const char kExtmapWithDirectionAndAttribute[] =
93 "a=extmap:1/sendrecv http://example.com/082005/ext.htm#ttime a1 a2\r\n";
94
Peter Boström0c4e06b2015-10-07 10:23:2195static const uint8_t kIdentityDigest[] = {
96 0x4A, 0xAD, 0xB9, 0xB1, 0x3F, 0x82, 0x18, 0x3B, 0x54, 0x02,
97 0x12, 0xDF, 0x3E, 0x5D, 0x49, 0x6B, 0x19, 0xE5, 0x7C, 0xAB};
henrike@webrtc.org28e20752013-07-10 00:45:3698
lally@webrtc.org34807282015-02-24 20:19:3999static const char kDtlsSctp[] = "DTLS/SCTP";
100static const char kUdpDtlsSctp[] = "UDP/DTLS/SCTP";
101static const char kTcpDtlsSctp[] = "TCP/DTLS/SCTP";
lally@webrtc.org36300852015-02-24 20:19:35102
henrike@webrtc.org28e20752013-07-10 00:45:36103struct CodecParams {
104 int max_ptime;
105 int ptime;
106 int min_ptime;
107 int sprop_stereo;
108 int stereo;
109 int useinband;
henrike@webrtc.org1e09a712013-07-26 19:17:59110 int maxaveragebitrate;
henrike@webrtc.org28e20752013-07-10 00:45:36111};
112
deadbeef9d3584c2016-02-17 01:54:10113// TODO(deadbeef): In these reference strings, use "a=fingerprint" by default
114// instead of "a=crypto", and have an explicit test for adding "a=crypto".
115// Currently it's the other way around.
116
henrike@webrtc.org28e20752013-07-10 00:45:36117// Reference sdp string
118static const char kSdpFullString[] =
119 "v=0\r\n"
120 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n"
121 "s=-\r\n"
122 "t=0 0\r\n"
deadbeef9d3584c2016-02-17 01:54:10123 "a=msid-semantic: WMS local_stream_1\r\n"
henrike@webrtc.org28e20752013-07-10 00:45:36124 "m=audio 2345 RTP/SAVPF 111 103 104\r\n"
125 "c=IN IP4 74.125.127.126\r\n"
126 "a=rtcp:2347 IN IP4 74.125.127.126\r\n"
127 "a=candidate:a0+B/1 1 udp 2130706432 192.168.1.5 1234 typ host "
128 "generation 2\r\n"
129 "a=candidate:a0+B/1 2 udp 2130706432 192.168.1.5 1235 typ host "
130 "generation 2\r\n"
131 "a=candidate:a0+B/2 1 udp 2130706432 ::1 1238 typ host "
132 "generation 2\r\n"
133 "a=candidate:a0+B/2 2 udp 2130706432 ::1 1239 typ host "
134 "generation 2\r\n"
135 "a=candidate:a0+B/3 1 udp 2130706432 74.125.127.126 2345 typ srflx "
136 "raddr 192.168.1.5 rport 2346 "
137 "generation 2\r\n"
138 "a=candidate:a0+B/3 2 udp 2130706432 74.125.127.126 2347 typ srflx "
139 "raddr 192.168.1.5 rport 2348 "
140 "generation 2\r\n"
141 "a=ice-ufrag:ufrag_voice\r\na=ice-pwd:pwd_voice\r\n"
142 "a=mid:audio_content_name\r\n"
143 "a=sendrecv\r\n"
144 "a=rtcp-mux\r\n"
deadbeef13871492015-12-09 20:37:51145 "a=rtcp-rsize\r\n"
henrike@webrtc.org28e20752013-07-10 00:45:36146 "a=crypto:1 AES_CM_128_HMAC_SHA1_32 "
147 "inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj|2^20|1:32 "
148 "dummy_session_params\r\n"
149 "a=rtpmap:111 opus/48000/2\r\n"
150 "a=rtpmap:103 ISAC/16000\r\n"
minyue@webrtc.orgf9b5c1b2015-02-17 12:36:41151 "a=rtpmap:104 ISAC/32000\r\n"
henrike@webrtc.org28e20752013-07-10 00:45:36152 "a=ssrc:1 cname:stream_1_cname\r\n"
153 "a=ssrc:1 msid:local_stream_1 audio_track_id_1\r\n"
154 "a=ssrc:1 mslabel:local_stream_1\r\n"
155 "a=ssrc:1 label:audio_track_id_1\r\n"
henrike@webrtc.org28e20752013-07-10 00:45:36156 "m=video 3457 RTP/SAVPF 120\r\n"
157 "c=IN IP4 74.125.224.39\r\n"
158 "a=rtcp:3456 IN IP4 74.125.224.39\r\n"
159 "a=candidate:a0+B/1 2 udp 2130706432 192.168.1.5 1236 typ host "
160 "generation 2\r\n"
161 "a=candidate:a0+B/1 1 udp 2130706432 192.168.1.5 1237 typ host "
162 "generation 2\r\n"
163 "a=candidate:a0+B/2 2 udp 2130706432 ::1 1240 typ host "
164 "generation 2\r\n"
165 "a=candidate:a0+B/2 1 udp 2130706432 ::1 1241 typ host "
166 "generation 2\r\n"
167 "a=candidate:a0+B/4 2 udp 2130706432 74.125.224.39 3456 typ relay "
168 "generation 2\r\n"
169 "a=candidate:a0+B/4 1 udp 2130706432 74.125.224.39 3457 typ relay "
170 "generation 2\r\n"
171 "a=ice-ufrag:ufrag_video\r\na=ice-pwd:pwd_video\r\n"
172 "a=mid:video_content_name\r\n"
173 "a=sendrecv\r\n"
174 "a=crypto:1 AES_CM_128_HMAC_SHA1_80 "
175 "inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj|2^20|1:32\r\n"
176 "a=rtpmap:120 VP8/90000\r\n"
deadbeef9d3584c2016-02-17 01:54:10177 "a=ssrc-group:FEC 2 3\r\n"
henrike@webrtc.org28e20752013-07-10 00:45:36178 "a=ssrc:2 cname:stream_1_cname\r\n"
179 "a=ssrc:2 msid:local_stream_1 video_track_id_1\r\n"
180 "a=ssrc:2 mslabel:local_stream_1\r\n"
181 "a=ssrc:2 label:video_track_id_1\r\n"
182 "a=ssrc:3 cname:stream_1_cname\r\n"
deadbeef9d3584c2016-02-17 01:54:10183 "a=ssrc:3 msid:local_stream_1 video_track_id_1\r\n"
henrike@webrtc.org28e20752013-07-10 00:45:36184 "a=ssrc:3 mslabel:local_stream_1\r\n"
deadbeef9d3584c2016-02-17 01:54:10185 "a=ssrc:3 label:video_track_id_1\r\n";
henrike@webrtc.org28e20752013-07-10 00:45:36186
187// SDP reference string without the candidates.
188static const char kSdpString[] =
189 "v=0\r\n"
190 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n"
191 "s=-\r\n"
192 "t=0 0\r\n"
deadbeef9d3584c2016-02-17 01:54:10193 "a=msid-semantic: WMS local_stream_1\r\n"
pthatcher@webrtc.orgc9d6d142014-10-23 23:37:22194 "m=audio 9 RTP/SAVPF 111 103 104\r\n"
perkj@webrtc.orgd105cc82014-11-07 11:22:06195 "c=IN IP4 0.0.0.0\r\n"
196 "a=rtcp:9 IN IP4 0.0.0.0\r\n"
henrike@webrtc.org28e20752013-07-10 00:45:36197 "a=ice-ufrag:ufrag_voice\r\na=ice-pwd:pwd_voice\r\n"
198 "a=mid:audio_content_name\r\n"
199 "a=sendrecv\r\n"
200 "a=rtcp-mux\r\n"
deadbeef13871492015-12-09 20:37:51201 "a=rtcp-rsize\r\n"
henrike@webrtc.org28e20752013-07-10 00:45:36202 "a=crypto:1 AES_CM_128_HMAC_SHA1_32 "
203 "inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj|2^20|1:32 "
204 "dummy_session_params\r\n"
205 "a=rtpmap:111 opus/48000/2\r\n"
206 "a=rtpmap:103 ISAC/16000\r\n"
minyue@webrtc.orgf9b5c1b2015-02-17 12:36:41207 "a=rtpmap:104 ISAC/32000\r\n"
henrike@webrtc.org28e20752013-07-10 00:45:36208 "a=ssrc:1 cname:stream_1_cname\r\n"
209 "a=ssrc:1 msid:local_stream_1 audio_track_id_1\r\n"
210 "a=ssrc:1 mslabel:local_stream_1\r\n"
211 "a=ssrc:1 label:audio_track_id_1\r\n"
pthatcher@webrtc.orgc9d6d142014-10-23 23:37:22212 "m=video 9 RTP/SAVPF 120\r\n"
perkj@webrtc.orgd105cc82014-11-07 11:22:06213 "c=IN IP4 0.0.0.0\r\n"
214 "a=rtcp:9 IN IP4 0.0.0.0\r\n"
henrike@webrtc.org28e20752013-07-10 00:45:36215 "a=ice-ufrag:ufrag_video\r\na=ice-pwd:pwd_video\r\n"
216 "a=mid:video_content_name\r\n"
217 "a=sendrecv\r\n"
218 "a=crypto:1 AES_CM_128_HMAC_SHA1_80 "
219 "inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj|2^20|1:32\r\n"
220 "a=rtpmap:120 VP8/90000\r\n"
deadbeef9d3584c2016-02-17 01:54:10221 "a=ssrc-group:FEC 2 3\r\n"
henrike@webrtc.org28e20752013-07-10 00:45:36222 "a=ssrc:2 cname:stream_1_cname\r\n"
223 "a=ssrc:2 msid:local_stream_1 video_track_id_1\r\n"
224 "a=ssrc:2 mslabel:local_stream_1\r\n"
225 "a=ssrc:2 label:video_track_id_1\r\n"
226 "a=ssrc:3 cname:stream_1_cname\r\n"
deadbeef9d3584c2016-02-17 01:54:10227 "a=ssrc:3 msid:local_stream_1 video_track_id_1\r\n"
henrike@webrtc.org28e20752013-07-10 00:45:36228 "a=ssrc:3 mslabel:local_stream_1\r\n"
deadbeef9d3584c2016-02-17 01:54:10229 "a=ssrc:3 label:video_track_id_1\r\n";
henrike@webrtc.org28e20752013-07-10 00:45:36230
231static const char kSdpRtpDataChannelString[] =
pthatcher@webrtc.orgc9d6d142014-10-23 23:37:22232 "m=application 9 RTP/SAVPF 101\r\n"
perkj@webrtc.orgd105cc82014-11-07 11:22:06233 "c=IN IP4 0.0.0.0\r\n"
234 "a=rtcp:9 IN IP4 0.0.0.0\r\n"
henrike@webrtc.org28e20752013-07-10 00:45:36235 "a=ice-ufrag:ufrag_data\r\n"
236 "a=ice-pwd:pwd_data\r\n"
237 "a=mid:data_content_name\r\n"
238 "a=sendrecv\r\n"
239 "a=crypto:1 AES_CM_128_HMAC_SHA1_80 "
240 "inline:FvLcvU2P3ZWmQxgPAgcDu7Zl9vftYElFOjEzhWs5\r\n"
241 "a=rtpmap:101 google-data/90000\r\n"
242 "a=ssrc:10 cname:data_channel_cname\r\n"
243 "a=ssrc:10 msid:data_channel data_channeld0\r\n"
244 "a=ssrc:10 mslabel:data_channel\r\n"
245 "a=ssrc:10 label:data_channeld0\r\n";
246
247static const char kSdpSctpDataChannelString[] =
pthatcher@webrtc.orgc9d6d142014-10-23 23:37:22248 "m=application 9 DTLS/SCTP 5000\r\n"
perkj@webrtc.orgd105cc82014-11-07 11:22:06249 "c=IN IP4 0.0.0.0\r\n"
henrike@webrtc.org28e20752013-07-10 00:45:36250 "a=ice-ufrag:ufrag_data\r\n"
251 "a=ice-pwd:pwd_data\r\n"
252 "a=mid:data_content_name\r\n"
wu@webrtc.org97077a32013-10-25 21:18:33253 "a=sctpmap:5000 webrtc-datachannel 1024\r\n";
henrike@webrtc.org28e20752013-07-10 00:45:36254
lally@webrtc.orgec97c652015-02-24 20:18:48255// draft-ietf-mmusic-sctp-sdp-12
jiayl@webrtc.orgddb85ab2014-09-05 16:31:56256static const char kSdpSctpDataChannelStringWithSctpPort[] =
lally@webrtc.orgc7848b72015-02-24 20:19:26257 "m=application 9 DTLS/SCTP webrtc-datachannel\r\n"
258 "a=max-message-size=100000\r\n"
259 "a=sctp-port 5000\r\n"
260 "c=IN IP4 0.0.0.0\r\n"
261 "a=ice-ufrag:ufrag_data\r\n"
262 "a=ice-pwd:pwd_data\r\n"
263 "a=mid:data_content_name\r\n";
264
lally69f57602015-10-08 17:15:04265static const char kSdpSctpDataChannelStringWithSctpColonPort[] =
266 "m=application 9 DTLS/SCTP webrtc-datachannel\r\n"
267 "a=max-message-size=100000\r\n"
268 "a=sctp-port:5000\r\n"
269 "c=IN IP4 0.0.0.0\r\n"
270 "a=ice-ufrag:ufrag_data\r\n"
271 "a=ice-pwd:pwd_data\r\n"
272 "a=mid:data_content_name\r\n";
273
henrike@webrtc.org28e20752013-07-10 00:45:36274static const char kSdpSctpDataChannelWithCandidatesString[] =
275 "m=application 2345 DTLS/SCTP 5000\r\n"
276 "c=IN IP4 74.125.127.126\r\n"
277 "a=candidate:a0+B/1 1 udp 2130706432 192.168.1.5 1234 typ host "
278 "generation 2\r\n"
279 "a=candidate:a0+B/2 1 udp 2130706432 ::1 1238 typ host "
280 "generation 2\r\n"
281 "a=candidate:a0+B/3 1 udp 2130706432 74.125.127.126 2345 typ srflx "
282 "raddr 192.168.1.5 rport 2346 "
283 "generation 2\r\n"
284 "a=ice-ufrag:ufrag_data\r\n"
285 "a=ice-pwd:pwd_data\r\n"
286 "a=mid:data_content_name\r\n"
wu@webrtc.org97077a32013-10-25 21:18:33287 "a=sctpmap:5000 webrtc-datachannel 1024\r\n";
henrike@webrtc.org28e20752013-07-10 00:45:36288
jiayl@webrtc.org9c16c392014-05-01 18:30:30289static const char kSdpConferenceString[] =
henrike@webrtc.org704bf9e2014-02-27 17:52:04290 "v=0\r\n"
291 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n"
292 "s=-\r\n"
293 "t=0 0\r\n"
294 "a=msid-semantic: WMS\r\n"
pthatcher@webrtc.orgc9d6d142014-10-23 23:37:22295 "m=audio 9 RTP/SAVPF 111 103 104\r\n"
perkj@webrtc.orgd105cc82014-11-07 11:22:06296 "c=IN IP4 0.0.0.0\r\n"
henrike@webrtc.org704bf9e2014-02-27 17:52:04297 "a=x-google-flag:conference\r\n"
pthatcher@webrtc.orgc9d6d142014-10-23 23:37:22298 "m=video 9 RTP/SAVPF 120\r\n"
perkj@webrtc.orgd105cc82014-11-07 11:22:06299 "c=IN IP4 0.0.0.0\r\n"
henrike@webrtc.org704bf9e2014-02-27 17:52:04300 "a=x-google-flag:conference\r\n";
301
jiayl@webrtc.orge7d47a12014-08-05 19:19:05302static const char kSdpSessionString[] =
303 "v=0\r\n"
304 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n"
305 "s=-\r\n"
306 "t=0 0\r\n"
307 "a=msid-semantic: WMS local_stream\r\n";
308
309static const char kSdpAudioString[] =
pthatcher@webrtc.orgc9d6d142014-10-23 23:37:22310 "m=audio 9 RTP/SAVPF 111\r\n"
perkj@webrtc.orgd105cc82014-11-07 11:22:06311 "c=IN IP4 0.0.0.0\r\n"
312 "a=rtcp:9 IN IP4 0.0.0.0\r\n"
jiayl@webrtc.orge7d47a12014-08-05 19:19:05313 "a=ice-ufrag:ufrag_voice\r\na=ice-pwd:pwd_voice\r\n"
314 "a=mid:audio_content_name\r\n"
315 "a=sendrecv\r\n"
316 "a=rtpmap:111 opus/48000/2\r\n"
317 "a=ssrc:1 cname:stream_1_cname\r\n"
318 "a=ssrc:1 msid:local_stream audio_track_id_1\r\n"
319 "a=ssrc:1 mslabel:local_stream\r\n"
320 "a=ssrc:1 label:audio_track_id_1\r\n";
321
322static const char kSdpVideoString[] =
pthatcher@webrtc.orgc9d6d142014-10-23 23:37:22323 "m=video 9 RTP/SAVPF 120\r\n"
perkj@webrtc.orgd105cc82014-11-07 11:22:06324 "c=IN IP4 0.0.0.0\r\n"
325 "a=rtcp:9 IN IP4 0.0.0.0\r\n"
jiayl@webrtc.orge7d47a12014-08-05 19:19:05326 "a=ice-ufrag:ufrag_video\r\na=ice-pwd:pwd_video\r\n"
327 "a=mid:video_content_name\r\n"
328 "a=sendrecv\r\n"
329 "a=rtpmap:120 VP8/90000\r\n"
330 "a=ssrc:2 cname:stream_1_cname\r\n"
331 "a=ssrc:2 msid:local_stream video_track_id_1\r\n"
332 "a=ssrc:2 mslabel:local_stream\r\n"
333 "a=ssrc:2 label:video_track_id_1\r\n";
334
deadbeef25ed4352016-12-13 02:37:36335// Reference sdp string using bundle-only.
336static const char kBundleOnlySdpFullString[] =
337 "v=0\r\n"
338 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n"
339 "s=-\r\n"
340 "t=0 0\r\n"
341 "a=group:BUNDLE audio_content_name video_content_name\r\n"
342 "a=msid-semantic: WMS local_stream_1\r\n"
343 "m=audio 2345 RTP/SAVPF 111 103 104\r\n"
344 "c=IN IP4 74.125.127.126\r\n"
345 "a=rtcp:2347 IN IP4 74.125.127.126\r\n"
346 "a=candidate:a0+B/1 1 udp 2130706432 192.168.1.5 1234 typ host "
347 "generation 2\r\n"
348 "a=candidate:a0+B/1 2 udp 2130706432 192.168.1.5 1235 typ host "
349 "generation 2\r\n"
350 "a=candidate:a0+B/2 1 udp 2130706432 ::1 1238 typ host "
351 "generation 2\r\n"
352 "a=candidate:a0+B/2 2 udp 2130706432 ::1 1239 typ host "
353 "generation 2\r\n"
354 "a=candidate:a0+B/3 1 udp 2130706432 74.125.127.126 2345 typ srflx "
355 "raddr 192.168.1.5 rport 2346 "
356 "generation 2\r\n"
357 "a=candidate:a0+B/3 2 udp 2130706432 74.125.127.126 2347 typ srflx "
358 "raddr 192.168.1.5 rport 2348 "
359 "generation 2\r\n"
360 "a=ice-ufrag:ufrag_voice\r\na=ice-pwd:pwd_voice\r\n"
361 "a=mid:audio_content_name\r\n"
362 "a=sendrecv\r\n"
363 "a=rtcp-mux\r\n"
364 "a=rtcp-rsize\r\n"
365 "a=crypto:1 AES_CM_128_HMAC_SHA1_32 "
366 "inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj|2^20|1:32 "
367 "dummy_session_params\r\n"
368 "a=rtpmap:111 opus/48000/2\r\n"
369 "a=rtpmap:103 ISAC/16000\r\n"
370 "a=rtpmap:104 ISAC/32000\r\n"
371 "a=ssrc:1 cname:stream_1_cname\r\n"
372 "a=ssrc:1 msid:local_stream_1 audio_track_id_1\r\n"
373 "a=ssrc:1 mslabel:local_stream_1\r\n"
374 "a=ssrc:1 label:audio_track_id_1\r\n"
375 "m=video 0 RTP/SAVPF 120\r\n"
376 "c=IN IP4 0.0.0.0\r\n"
377 "a=rtcp:9 IN IP4 0.0.0.0\r\n"
378 "a=bundle-only\r\n"
379 "a=mid:video_content_name\r\n"
380 "a=sendrecv\r\n"
381 "a=crypto:1 AES_CM_128_HMAC_SHA1_80 "
382 "inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj|2^20|1:32\r\n"
383 "a=rtpmap:120 VP8/90000\r\n"
384 "a=ssrc-group:FEC 2 3\r\n"
385 "a=ssrc:2 cname:stream_1_cname\r\n"
386 "a=ssrc:2 msid:local_stream_1 video_track_id_1\r\n"
387 "a=ssrc:2 mslabel:local_stream_1\r\n"
388 "a=ssrc:2 label:video_track_id_1\r\n"
389 "a=ssrc:3 cname:stream_1_cname\r\n"
390 "a=ssrc:3 msid:local_stream_1 video_track_id_1\r\n"
391 "a=ssrc:3 mslabel:local_stream_1\r\n"
392 "a=ssrc:3 label:video_track_id_1\r\n";
393
deadbeef9d3584c2016-02-17 01:54:10394// Plan B SDP reference string, with 2 streams, 2 audio tracks and 3 video
395// tracks.
396static const char kPlanBSdpFullString[] =
397 "v=0\r\n"
398 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n"
399 "s=-\r\n"
400 "t=0 0\r\n"
401 "a=msid-semantic: WMS local_stream_1 local_stream_2\r\n"
402 "m=audio 2345 RTP/SAVPF 111 103 104\r\n"
403 "c=IN IP4 74.125.127.126\r\n"
404 "a=rtcp:2347 IN IP4 74.125.127.126\r\n"
405 "a=candidate:a0+B/1 1 udp 2130706432 192.168.1.5 1234 typ host "
406 "generation 2\r\n"
407 "a=candidate:a0+B/1 2 udp 2130706432 192.168.1.5 1235 typ host "
408 "generation 2\r\n"
409 "a=candidate:a0+B/2 1 udp 2130706432 ::1 1238 typ host "
410 "generation 2\r\n"
411 "a=candidate:a0+B/2 2 udp 2130706432 ::1 1239 typ host "
412 "generation 2\r\n"
413 "a=candidate:a0+B/3 1 udp 2130706432 74.125.127.126 2345 typ srflx "
414 "raddr 192.168.1.5 rport 2346 "
415 "generation 2\r\n"
416 "a=candidate:a0+B/3 2 udp 2130706432 74.125.127.126 2347 typ srflx "
417 "raddr 192.168.1.5 rport 2348 "
418 "generation 2\r\n"
419 "a=ice-ufrag:ufrag_voice\r\na=ice-pwd:pwd_voice\r\n"
420 "a=mid:audio_content_name\r\n"
421 "a=sendrecv\r\n"
422 "a=rtcp-mux\r\n"
423 "a=rtcp-rsize\r\n"
424 "a=crypto:1 AES_CM_128_HMAC_SHA1_32 "
425 "inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj|2^20|1:32 "
426 "dummy_session_params\r\n"
427 "a=rtpmap:111 opus/48000/2\r\n"
428 "a=rtpmap:103 ISAC/16000\r\n"
429 "a=rtpmap:104 ISAC/32000\r\n"
430 "a=ssrc:1 cname:stream_1_cname\r\n"
431 "a=ssrc:1 msid:local_stream_1 audio_track_id_1\r\n"
432 "a=ssrc:1 mslabel:local_stream_1\r\n"
433 "a=ssrc:1 label:audio_track_id_1\r\n"
434 "a=ssrc:4 cname:stream_2_cname\r\n"
435 "a=ssrc:4 msid:local_stream_2 audio_track_id_2\r\n"
436 "a=ssrc:4 mslabel:local_stream_2\r\n"
437 "a=ssrc:4 label:audio_track_id_2\r\n"
438 "m=video 3457 RTP/SAVPF 120\r\n"
439 "c=IN IP4 74.125.224.39\r\n"
440 "a=rtcp:3456 IN IP4 74.125.224.39\r\n"
441 "a=candidate:a0+B/1 2 udp 2130706432 192.168.1.5 1236 typ host "
442 "generation 2\r\n"
443 "a=candidate:a0+B/1 1 udp 2130706432 192.168.1.5 1237 typ host "
444 "generation 2\r\n"
445 "a=candidate:a0+B/2 2 udp 2130706432 ::1 1240 typ host "
446 "generation 2\r\n"
447 "a=candidate:a0+B/2 1 udp 2130706432 ::1 1241 typ host "
448 "generation 2\r\n"
449 "a=candidate:a0+B/4 2 udp 2130706432 74.125.224.39 3456 typ relay "
450 "generation 2\r\n"
451 "a=candidate:a0+B/4 1 udp 2130706432 74.125.224.39 3457 typ relay "
452 "generation 2\r\n"
453 "a=ice-ufrag:ufrag_video\r\na=ice-pwd:pwd_video\r\n"
454 "a=mid:video_content_name\r\n"
455 "a=sendrecv\r\n"
456 "a=crypto:1 AES_CM_128_HMAC_SHA1_80 "
457 "inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj|2^20|1:32\r\n"
458 "a=rtpmap:120 VP8/90000\r\n"
459 "a=ssrc-group:FEC 2 3\r\n"
460 "a=ssrc:2 cname:stream_1_cname\r\n"
461 "a=ssrc:2 msid:local_stream_1 video_track_id_1\r\n"
462 "a=ssrc:2 mslabel:local_stream_1\r\n"
463 "a=ssrc:2 label:video_track_id_1\r\n"
464 "a=ssrc:3 cname:stream_1_cname\r\n"
465 "a=ssrc:3 msid:local_stream_1 video_track_id_1\r\n"
466 "a=ssrc:3 mslabel:local_stream_1\r\n"
467 "a=ssrc:3 label:video_track_id_1\r\n"
468 "a=ssrc:5 cname:stream_2_cname\r\n"
469 "a=ssrc:5 msid:local_stream_2 video_track_id_2\r\n"
470 "a=ssrc:5 mslabel:local_stream_2\r\n"
471 "a=ssrc:5 label:video_track_id_2\r\n"
472 "a=ssrc:6 cname:stream_2_cname\r\n"
473 "a=ssrc:6 msid:local_stream_2 video_track_id_3\r\n"
474 "a=ssrc:6 mslabel:local_stream_2\r\n"
475 "a=ssrc:6 label:video_track_id_3\r\n";
476
Taylor Brandstetter5de6b752016-03-10 01:02:30477// Plan B SDP reference string, with 2 streams, 2 audio tracks and 3 video
478// tracks, but with the unified plan "a=msid" attribute.
479static const char kPlanBSdpFullStringWithMsid[] =
480 "v=0\r\n"
481 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n"
482 "s=-\r\n"
483 "t=0 0\r\n"
484 "a=msid-semantic: WMS local_stream_1 local_stream_2\r\n"
485 "m=audio 2345 RTP/SAVPF 111 103 104\r\n"
486 "c=IN IP4 74.125.127.126\r\n"
487 "a=rtcp:2347 IN IP4 74.125.127.126\r\n"
488 "a=candidate:a0+B/1 1 udp 2130706432 192.168.1.5 1234 typ host "
489 "generation 2\r\n"
490 "a=candidate:a0+B/1 2 udp 2130706432 192.168.1.5 1235 typ host "
491 "generation 2\r\n"
492 "a=candidate:a0+B/2 1 udp 2130706432 ::1 1238 typ host "
493 "generation 2\r\n"
494 "a=candidate:a0+B/2 2 udp 2130706432 ::1 1239 typ host "
495 "generation 2\r\n"
496 "a=candidate:a0+B/3 1 udp 2130706432 74.125.127.126 2345 typ srflx "
497 "raddr 192.168.1.5 rport 2346 "
498 "generation 2\r\n"
499 "a=candidate:a0+B/3 2 udp 2130706432 74.125.127.126 2347 typ srflx "
500 "raddr 192.168.1.5 rport 2348 "
501 "generation 2\r\n"
502 "a=ice-ufrag:ufrag_voice\r\na=ice-pwd:pwd_voice\r\n"
503 "a=mid:audio_content_name\r\n"
504 "a=msid:local_stream_1 audio_track_id_1\r\n"
505 "a=sendrecv\r\n"
506 "a=rtcp-mux\r\n"
507 "a=rtcp-rsize\r\n"
508 "a=crypto:1 AES_CM_128_HMAC_SHA1_32 "
509 "inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj|2^20|1:32 "
510 "dummy_session_params\r\n"
511 "a=rtpmap:111 opus/48000/2\r\n"
512 "a=rtpmap:103 ISAC/16000\r\n"
513 "a=rtpmap:104 ISAC/32000\r\n"
514 "a=ssrc:1 cname:stream_1_cname\r\n"
515 "a=ssrc:1 msid:local_stream_1 audio_track_id_1\r\n"
516 "a=ssrc:1 mslabel:local_stream_1\r\n"
517 "a=ssrc:1 label:audio_track_id_1\r\n"
518 "a=ssrc:4 cname:stream_2_cname\r\n"
519 "a=ssrc:4 msid:local_stream_2 audio_track_id_2\r\n"
520 "a=ssrc:4 mslabel:local_stream_2\r\n"
521 "a=ssrc:4 label:audio_track_id_2\r\n"
522 "m=video 3457 RTP/SAVPF 120\r\n"
523 "c=IN IP4 74.125.224.39\r\n"
524 "a=rtcp:3456 IN IP4 74.125.224.39\r\n"
525 "a=candidate:a0+B/1 2 udp 2130706432 192.168.1.5 1236 typ host "
526 "generation 2\r\n"
527 "a=candidate:a0+B/1 1 udp 2130706432 192.168.1.5 1237 typ host "
528 "generation 2\r\n"
529 "a=candidate:a0+B/2 2 udp 2130706432 ::1 1240 typ host "
530 "generation 2\r\n"
531 "a=candidate:a0+B/2 1 udp 2130706432 ::1 1241 typ host "
532 "generation 2\r\n"
533 "a=candidate:a0+B/4 2 udp 2130706432 74.125.224.39 3456 typ relay "
534 "generation 2\r\n"
535 "a=candidate:a0+B/4 1 udp 2130706432 74.125.224.39 3457 typ relay "
536 "generation 2\r\n"
537 "a=ice-ufrag:ufrag_video\r\na=ice-pwd:pwd_video\r\n"
538 "a=mid:video_content_name\r\n"
539 "a=msid:local_stream_1 video_track_id_1\r\n"
540 "a=sendrecv\r\n"
541 "a=crypto:1 AES_CM_128_HMAC_SHA1_80 "
542 "inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj|2^20|1:32\r\n"
543 "a=rtpmap:120 VP8/90000\r\n"
544 "a=ssrc-group:FEC 2 3\r\n"
545 "a=ssrc:2 cname:stream_1_cname\r\n"
546 "a=ssrc:2 msid:local_stream_1 video_track_id_1\r\n"
547 "a=ssrc:2 mslabel:local_stream_1\r\n"
548 "a=ssrc:2 label:video_track_id_1\r\n"
549 "a=ssrc:3 cname:stream_1_cname\r\n"
550 "a=ssrc:3 msid:local_stream_1 video_track_id_1\r\n"
551 "a=ssrc:3 mslabel:local_stream_1\r\n"
552 "a=ssrc:3 label:video_track_id_1\r\n"
553 "a=ssrc:5 cname:stream_2_cname\r\n"
554 "a=ssrc:5 msid:local_stream_2 video_track_id_2\r\n"
555 "a=ssrc:5 mslabel:local_stream_2\r\n"
556 "a=ssrc:5 label:video_track_id_2\r\n"
557 "a=ssrc:6 cname:stream_2_cname\r\n"
558 "a=ssrc:6 msid:local_stream_2 video_track_id_3\r\n"
559 "a=ssrc:6 mslabel:local_stream_2\r\n"
560 "a=ssrc:6 label:video_track_id_3\r\n";
561
deadbeef9d3584c2016-02-17 01:54:10562// Unified Plan SDP reference string, with 2 streams, 2 audio tracks and 3 video
563// tracks.
564static const char kUnifiedPlanSdpFullString[] =
565 "v=0\r\n"
566 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n"
567 "s=-\r\n"
568 "t=0 0\r\n"
569 "a=msid-semantic: WMS local_stream_1\r\n"
570 // Audio track 1, stream 1 (with candidates).
571 "m=audio 2345 RTP/SAVPF 111 103 104\r\n"
572 "c=IN IP4 74.125.127.126\r\n"
573 "a=rtcp:2347 IN IP4 74.125.127.126\r\n"
574 "a=candidate:a0+B/1 1 udp 2130706432 192.168.1.5 1234 typ host "
575 "generation 2\r\n"
576 "a=candidate:a0+B/1 2 udp 2130706432 192.168.1.5 1235 typ host "
577 "generation 2\r\n"
578 "a=candidate:a0+B/2 1 udp 2130706432 ::1 1238 typ host "
579 "generation 2\r\n"
580 "a=candidate:a0+B/2 2 udp 2130706432 ::1 1239 typ host "
581 "generation 2\r\n"
582 "a=candidate:a0+B/3 1 udp 2130706432 74.125.127.126 2345 typ srflx "
583 "raddr 192.168.1.5 rport 2346 "
584 "generation 2\r\n"
585 "a=candidate:a0+B/3 2 udp 2130706432 74.125.127.126 2347 typ srflx "
586 "raddr 192.168.1.5 rport 2348 "
587 "generation 2\r\n"
588 "a=ice-ufrag:ufrag_voice\r\na=ice-pwd:pwd_voice\r\n"
589 "a=mid:audio_content_name\r\n"
590 "a=msid:local_stream_1 audio_track_id_1\r\n"
591 "a=sendrecv\r\n"
592 "a=rtcp-mux\r\n"
593 "a=rtcp-rsize\r\n"
594 "a=crypto:1 AES_CM_128_HMAC_SHA1_32 "
595 "inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj|2^20|1:32 "
596 "dummy_session_params\r\n"
597 "a=rtpmap:111 opus/48000/2\r\n"
598 "a=rtpmap:103 ISAC/16000\r\n"
599 "a=rtpmap:104 ISAC/32000\r\n"
600 "a=ssrc:1 cname:stream_1_cname\r\n"
601 // Video track 1, stream 1 (with candidates).
602 "m=video 3457 RTP/SAVPF 120\r\n"
603 "c=IN IP4 74.125.224.39\r\n"
604 "a=rtcp:3456 IN IP4 74.125.224.39\r\n"
605 "a=candidate:a0+B/1 2 udp 2130706432 192.168.1.5 1236 typ host "
606 "generation 2\r\n"
607 "a=candidate:a0+B/1 1 udp 2130706432 192.168.1.5 1237 typ host "
608 "generation 2\r\n"
609 "a=candidate:a0+B/2 2 udp 2130706432 ::1 1240 typ host "
610 "generation 2\r\n"
611 "a=candidate:a0+B/2 1 udp 2130706432 ::1 1241 typ host "
612 "generation 2\r\n"
613 "a=candidate:a0+B/4 2 udp 2130706432 74.125.224.39 3456 typ relay "
614 "generation 2\r\n"
615 "a=candidate:a0+B/4 1 udp 2130706432 74.125.224.39 3457 typ relay "
616 "generation 2\r\n"
617 "a=ice-ufrag:ufrag_video\r\na=ice-pwd:pwd_video\r\n"
618 "a=mid:video_content_name\r\n"
619 "a=msid:local_stream_1 video_track_id_1\r\n"
620 "a=sendrecv\r\n"
621 "a=crypto:1 AES_CM_128_HMAC_SHA1_80 "
622 "inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj|2^20|1:32\r\n"
623 "a=rtpmap:120 VP8/90000\r\n"
624 "a=ssrc-group:FEC 2 3\r\n"
625 "a=ssrc:2 cname:stream_1_cname\r\n"
626 "a=ssrc:3 cname:stream_1_cname\r\n"
627 // Audio track 2, stream 2.
628 "m=audio 9 RTP/SAVPF 111 103 104\r\n"
629 "c=IN IP4 0.0.0.0\r\n"
630 "a=rtcp:9 IN IP4 0.0.0.0\r\n"
631 "a=ice-ufrag:ufrag_voice_2\r\na=ice-pwd:pwd_voice_2\r\n"
632 "a=mid:audio_content_name_2\r\n"
633 "a=msid:local_stream_2 audio_track_id_2\r\n"
634 "a=sendrecv\r\n"
635 "a=rtcp-mux\r\n"
636 "a=rtcp-rsize\r\n"
637 "a=crypto:1 AES_CM_128_HMAC_SHA1_32 "
638 "inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj|2^20|1:32 "
639 "dummy_session_params\r\n"
640 "a=rtpmap:111 opus/48000/2\r\n"
641 "a=rtpmap:103 ISAC/16000\r\n"
642 "a=rtpmap:104 ISAC/32000\r\n"
643 "a=ssrc:4 cname:stream_2_cname\r\n"
644 // Video track 2, stream 2.
645 "m=video 9 RTP/SAVPF 120\r\n"
646 "c=IN IP4 0.0.0.0\r\n"
647 "a=rtcp:9 IN IP4 0.0.0.0\r\n"
648 "a=ice-ufrag:ufrag_video_2\r\na=ice-pwd:pwd_video_2\r\n"
649 "a=mid:video_content_name_2\r\n"
650 "a=msid:local_stream_2 video_track_id_2\r\n"
651 "a=sendrecv\r\n"
652 "a=crypto:1 AES_CM_128_HMAC_SHA1_80 "
653 "inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj|2^20|1:32\r\n"
654 "a=rtpmap:120 VP8/90000\r\n"
655 "a=ssrc:5 cname:stream_2_cname\r\n"
656 // Video track 3, stream 2.
657 "m=video 9 RTP/SAVPF 120\r\n"
658 "c=IN IP4 0.0.0.0\r\n"
659 "a=rtcp:9 IN IP4 0.0.0.0\r\n"
660 "a=ice-ufrag:ufrag_video_3\r\na=ice-pwd:pwd_video_3\r\n"
661 "a=mid:video_content_name_3\r\n"
662 "a=msid:local_stream_2 video_track_id_3\r\n"
663 "a=sendrecv\r\n"
664 "a=crypto:1 AES_CM_128_HMAC_SHA1_80 "
665 "inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj|2^20|1:32\r\n"
666 "a=rtpmap:120 VP8/90000\r\n"
667 "a=ssrc:6 cname:stream_2_cname\r\n";
henrike@webrtc.org28e20752013-07-10 00:45:36668
669// One candidate reference string as per W3c spec.
670// candidate:<blah> not a=candidate:<blah>CRLF
671static const char kRawCandidate[] =
672 "candidate:a0+B/1 1 udp 2130706432 192.168.1.5 1234 typ host generation 2";
673// One candidate reference string.
674static const char kSdpOneCandidate[] =
675 "a=candidate:a0+B/1 1 udp 2130706432 192.168.1.5 1234 typ host "
676 "generation 2\r\n";
jiayl@webrtc.org7ec3f9f2014-08-08 23:09:15677
mallinath@webrtc.org2d60c5e2014-08-08 22:29:20678static const char kSdpTcpActiveCandidate[] =
679 "candidate:a0+B/1 1 tcp 2130706432 192.168.1.5 9 typ host "
680 "tcptype active generation 2";
681static const char kSdpTcpPassiveCandidate[] =
682 "candidate:a0+B/1 1 tcp 2130706432 192.168.1.5 9 typ host "
683 "tcptype passive generation 2";
684static const char kSdpTcpSOCandidate[] =
685 "candidate:a0+B/1 1 tcp 2130706432 192.168.1.5 9 typ host "
686 "tcptype so generation 2";
687static const char kSdpTcpInvalidCandidate[] =
688 "candidate:a0+B/1 1 tcp 2130706432 192.168.1.5 9 typ host "
689 "tcptype invalid generation 2";
690
jiayl@webrtc.org7ec3f9f2014-08-08 23:09:15691// One candidate reference string with IPV6 address.
692static const char kRawIPV6Candidate[] =
693 "candidate:a0+B/1 1 udp 2130706432 "
694 "abcd::abcd::abcd::abcd::abcd::abcd::abcd::abcd 1234 typ host generation 2";
henrike@webrtc.org28e20752013-07-10 00:45:36695
696// One candidate reference string.
honghaiza54a0802015-12-17 02:37:23697static const char kSdpOneCandidateWithUfragPwd[] =
henrike@webrtc.org28e20752013-07-10 00:45:36698 "a=candidate:a0+B/1 1 udp 2130706432 192.168.1.5 1234 typ host network_name"
honghaiza54a0802015-12-17 02:37:23699 " eth0 ufrag user_rtp pwd password_rtp generation 2\r\n";
henrike@webrtc.org28e20752013-07-10 00:45:36700
701// Session id and version
702static const char kSessionId[] = "18446744069414584320";
703static const char kSessionVersion[] = "18446462598732840960";
704
deadbeef9d3584c2016-02-17 01:54:10705// ICE options.
henrike@webrtc.org28e20752013-07-10 00:45:36706static const char kIceOption1[] = "iceoption1";
707static const char kIceOption2[] = "iceoption2";
708static const char kIceOption3[] = "iceoption3";
709
deadbeef9d3584c2016-02-17 01:54:10710// ICE ufrags/passwords.
711static const char kUfragVoice[] = "ufrag_voice";
712static const char kPwdVoice[] = "pwd_voice";
713static const char kUfragVideo[] = "ufrag_video";
714static const char kPwdVideo[] = "pwd_video";
715static const char kUfragData[] = "ufrag_data";
716static const char kPwdData[] = "pwd_data";
717
718// Extra ufrags/passwords for extra unified plan m= sections.
719static const char kUfragVoice2[] = "ufrag_voice_2";
720static const char kPwdVoice2[] = "pwd_voice_2";
721static const char kUfragVideo2[] = "ufrag_video_2";
722static const char kPwdVideo2[] = "pwd_video_2";
723static const char kUfragVideo3[] = "ufrag_video_3";
724static const char kPwdVideo3[] = "pwd_video_3";
725
henrike@webrtc.org28e20752013-07-10 00:45:36726// Content name
727static const char kAudioContentName[] = "audio_content_name";
728static const char kVideoContentName[] = "video_content_name";
729static const char kDataContentName[] = "data_content_name";
730
deadbeef9d3584c2016-02-17 01:54:10731// Extra content names for extra unified plan m= sections.
732static const char kAudioContentName2[] = "audio_content_name_2";
733static const char kVideoContentName2[] = "video_content_name_2";
734static const char kVideoContentName3[] = "video_content_name_3";
735
henrike@webrtc.org28e20752013-07-10 00:45:36736// MediaStream 1
737static const char kStreamLabel1[] = "local_stream_1";
738static const char kStream1Cname[] = "stream_1_cname";
739static const char kAudioTrackId1[] = "audio_track_id_1";
Peter Boström0c4e06b2015-10-07 10:23:21740static const uint32_t kAudioTrack1Ssrc = 1;
henrike@webrtc.org28e20752013-07-10 00:45:36741static const char kVideoTrackId1[] = "video_track_id_1";
deadbeef9d3584c2016-02-17 01:54:10742static const uint32_t kVideoTrack1Ssrc1 = 2;
743static const uint32_t kVideoTrack1Ssrc2 = 3;
henrike@webrtc.org28e20752013-07-10 00:45:36744
745// MediaStream 2
746static const char kStreamLabel2[] = "local_stream_2";
747static const char kStream2Cname[] = "stream_2_cname";
748static const char kAudioTrackId2[] = "audio_track_id_2";
Peter Boström0c4e06b2015-10-07 10:23:21749static const uint32_t kAudioTrack2Ssrc = 4;
deadbeef9d3584c2016-02-17 01:54:10750static const char kVideoTrackId2[] = "video_track_id_2";
751static const uint32_t kVideoTrack2Ssrc = 5;
henrike@webrtc.org28e20752013-07-10 00:45:36752static const char kVideoTrackId3[] = "video_track_id_3";
deadbeef9d3584c2016-02-17 01:54:10753static const uint32_t kVideoTrack3Ssrc = 6;
henrike@webrtc.org28e20752013-07-10 00:45:36754
755// DataChannel
756static const char kDataChannelLabel[] = "data_channel";
757static const char kDataChannelMsid[] = "data_channeld0";
758static const char kDataChannelCname[] = "data_channel_cname";
Peter Boström0c4e06b2015-10-07 10:23:21759static const uint32_t kDataChannelSsrc = 10;
henrike@webrtc.org28e20752013-07-10 00:45:36760
761// Candidate
762static const char kDummyMid[] = "dummy_mid";
763static const int kDummyIndex = 123;
764
765// Misc
766static const char kDummyString[] = "dummy";
767
768// Helper functions
769
770static bool SdpDeserialize(const std::string& message,
771 JsepSessionDescription* jdesc) {
772 return webrtc::SdpDeserialize(message, jdesc, NULL);
773}
774
775static bool SdpDeserializeCandidate(const std::string& message,
776 JsepIceCandidate* candidate) {
777 return webrtc::SdpDeserializeCandidate(message, candidate, NULL);
778}
779
780// Add some extra |newlines| to the |message| after |line|.
781static void InjectAfter(const std::string& line,
782 const std::string& newlines,
783 std::string* message) {
784 const std::string tmp = line + newlines;
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52785 rtc::replace_substrs(line.c_str(), line.length(),
henrike@webrtc.org28e20752013-07-10 00:45:36786 tmp.c_str(), tmp.length(), message);
787}
788
789static void Replace(const std::string& line,
790 const std::string& newlines,
791 std::string* message) {
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52792 rtc::replace_substrs(line.c_str(), line.length(),
henrike@webrtc.org28e20752013-07-10 00:45:36793 newlines.c_str(), newlines.length(), message);
794}
795
wu@webrtc.org5e760e72014-04-02 23:19:09796// Expect fail to parase |bad_sdp| and expect |bad_part| be part of the error
797// message.
798static void ExpectParseFailure(const std::string& bad_sdp,
799 const std::string& bad_part) {
henrike@webrtc.org28e20752013-07-10 00:45:36800 JsepSessionDescription desc(kDummyString);
henrike@webrtc.org28e20752013-07-10 00:45:36801 SdpParseError error;
wu@webrtc.org5e760e72014-04-02 23:19:09802 bool ret = webrtc::SdpDeserialize(bad_sdp, &desc, &error);
henrike@webrtc.org28e20752013-07-10 00:45:36803 EXPECT_FALSE(ret);
wu@webrtc.org5e760e72014-04-02 23:19:09804 EXPECT_NE(std::string::npos, error.line.find(bad_part.c_str()));
805}
806
807// Expect fail to parse kSdpFullString if replace |good_part| with |bad_part|.
808static void ExpectParseFailure(const char* good_part, const char* bad_part) {
809 std::string bad_sdp = kSdpFullString;
810 Replace(good_part, bad_part, &bad_sdp);
811 ExpectParseFailure(bad_sdp, bad_part);
812}
813
814// Expect fail to parse kSdpFullString if add |newlines| after |injectpoint|.
815static void ExpectParseFailureWithNewLines(const std::string& injectpoint,
816 const std::string& newlines,
817 const std::string& bad_part) {
818 std::string bad_sdp = kSdpFullString;
819 InjectAfter(injectpoint, newlines, &bad_sdp);
820 ExpectParseFailure(bad_sdp, bad_part);
henrike@webrtc.org28e20752013-07-10 00:45:36821}
822
823static void ReplaceDirection(cricket::MediaContentDirection direction,
824 std::string* message) {
825 std::string new_direction;
826 switch (direction) {
827 case cricket::MD_INACTIVE:
828 new_direction = "a=inactive";
829 break;
830 case cricket::MD_SENDONLY:
831 new_direction = "a=sendonly";
832 break;
833 case cricket::MD_RECVONLY:
834 new_direction = "a=recvonly";
835 break;
836 case cricket::MD_SENDRECV:
837 default:
838 new_direction = "a=sendrecv";
839 break;
840 }
841 Replace("a=sendrecv", new_direction, message);
842}
843
844static void ReplaceRejected(bool audio_rejected, bool video_rejected,
845 std::string* message) {
846 if (audio_rejected) {
deadbeef3f7219b2015-12-28 23:17:14847 Replace("m=audio 9", "m=audio 0", message);
848 Replace(kAttributeIceUfragVoice, "", message);
849 Replace(kAttributeIcePwdVoice, "", message);
henrike@webrtc.org28e20752013-07-10 00:45:36850 }
851 if (video_rejected) {
deadbeef3f7219b2015-12-28 23:17:14852 Replace("m=video 9", "m=video 0", message);
853 Replace(kAttributeIceUfragVideo, "", message);
854 Replace(kAttributeIcePwdVideo, "", message);
henrike@webrtc.org28e20752013-07-10 00:45:36855 }
856}
857
858// WebRtcSdpTest
859
860class WebRtcSdpTest : public testing::Test {
861 public:
862 WebRtcSdpTest()
863 : jdesc_(kDummyString) {
phoglund37ebcf02016-01-08 13:04:57864#ifdef WEBRTC_ANDROID
865 webrtc::InitializeAndroidObjects();
866#endif
henrike@webrtc.org28e20752013-07-10 00:45:36867 // AudioContentDescription
868 audio_desc_ = CreateAudioContentDescription();
deadbeef9d3584c2016-02-17 01:54:10869 StreamParams audio_stream;
870 audio_stream.id = kAudioTrackId1;
871 audio_stream.cname = kStream1Cname;
872 audio_stream.sync_label = kStreamLabel1;
873 audio_stream.ssrcs.push_back(kAudioTrack1Ssrc);
874 audio_desc_->AddStream(audio_stream);
henrike@webrtc.org28e20752013-07-10 00:45:36875 desc_.AddContent(kAudioContentName, NS_JINGLE_RTP, audio_desc_);
876
877 // VideoContentDescription
deadbeef9d3584c2016-02-17 01:54:10878 video_desc_ = CreateVideoContentDescription();
879 StreamParams video_stream;
880 video_stream.id = kVideoTrackId1;
881 video_stream.cname = kStream1Cname;
882 video_stream.sync_label = kStreamLabel1;
883 video_stream.ssrcs.push_back(kVideoTrack1Ssrc1);
884 video_stream.ssrcs.push_back(kVideoTrack1Ssrc2);
885 cricket::SsrcGroup ssrc_group(kFecSsrcGroupSemantics, video_stream.ssrcs);
886 video_stream.ssrc_groups.push_back(ssrc_group);
887 video_desc_->AddStream(video_stream);
888 desc_.AddContent(kVideoContentName, NS_JINGLE_RTP, video_desc_);
henrike@webrtc.org28e20752013-07-10 00:45:36889
890 // TransportInfo
deadbeef9d3584c2016-02-17 01:54:10891 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo(
892 kAudioContentName, TransportDescription(kUfragVoice, kPwdVoice))));
893 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo(
894 kVideoContentName, TransportDescription(kUfragVideo, kPwdVideo))));
henrike@webrtc.org28e20752013-07-10 00:45:36895
896 // v4 host
897 int port = 1234;
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52898 rtc::SocketAddress address("192.168.1.5", port++);
guoweis@webrtc.org61c12472015-01-15 06:53:07899 Candidate candidate1(ICE_CANDIDATE_COMPONENT_RTP, "udp", address,
guoweis@webrtc.org950c5182014-12-16 23:01:31900 kCandidatePriority, "", "", LOCAL_PORT_TYPE,
901 kCandidateGeneration, kCandidateFoundation1);
henrike@webrtc.org28e20752013-07-10 00:45:36902 address.SetPort(port++);
guoweis@webrtc.org61c12472015-01-15 06:53:07903 Candidate candidate2(ICE_CANDIDATE_COMPONENT_RTCP, "udp", address,
guoweis@webrtc.org950c5182014-12-16 23:01:31904 kCandidatePriority, "", "", LOCAL_PORT_TYPE,
905 kCandidateGeneration, kCandidateFoundation1);
henrike@webrtc.org28e20752013-07-10 00:45:36906 address.SetPort(port++);
guoweis@webrtc.org61c12472015-01-15 06:53:07907 Candidate candidate3(ICE_CANDIDATE_COMPONENT_RTCP, "udp", address,
guoweis@webrtc.org950c5182014-12-16 23:01:31908 kCandidatePriority, "", "", LOCAL_PORT_TYPE,
909 kCandidateGeneration, kCandidateFoundation1);
henrike@webrtc.org28e20752013-07-10 00:45:36910 address.SetPort(port++);
guoweis@webrtc.org61c12472015-01-15 06:53:07911 Candidate candidate4(ICE_CANDIDATE_COMPONENT_RTP, "udp", address,
guoweis@webrtc.org950c5182014-12-16 23:01:31912 kCandidatePriority, "", "", LOCAL_PORT_TYPE,
913 kCandidateGeneration, kCandidateFoundation1);
henrike@webrtc.org28e20752013-07-10 00:45:36914
915 // v6 host
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52916 rtc::SocketAddress v6_address("::1", port++);
guoweis@webrtc.org61c12472015-01-15 06:53:07917 cricket::Candidate candidate5(cricket::ICE_CANDIDATE_COMPONENT_RTP, "udp",
918 v6_address, kCandidatePriority, "", "",
guoweis@webrtc.org950c5182014-12-16 23:01:31919 cricket::LOCAL_PORT_TYPE,
920 kCandidateGeneration, kCandidateFoundation2);
henrike@webrtc.org28e20752013-07-10 00:45:36921 v6_address.SetPort(port++);
guoweis@webrtc.org61c12472015-01-15 06:53:07922 cricket::Candidate candidate6(cricket::ICE_CANDIDATE_COMPONENT_RTCP, "udp",
923 v6_address, kCandidatePriority, "", "",
guoweis@webrtc.org950c5182014-12-16 23:01:31924 cricket::LOCAL_PORT_TYPE,
925 kCandidateGeneration, kCandidateFoundation2);
henrike@webrtc.org28e20752013-07-10 00:45:36926 v6_address.SetPort(port++);
guoweis@webrtc.org61c12472015-01-15 06:53:07927 cricket::Candidate candidate7(cricket::ICE_CANDIDATE_COMPONENT_RTCP, "udp",
928 v6_address, kCandidatePriority, "", "",
guoweis@webrtc.org950c5182014-12-16 23:01:31929 cricket::LOCAL_PORT_TYPE,
930 kCandidateGeneration, kCandidateFoundation2);
henrike@webrtc.org28e20752013-07-10 00:45:36931 v6_address.SetPort(port++);
guoweis@webrtc.org61c12472015-01-15 06:53:07932 cricket::Candidate candidate8(cricket::ICE_CANDIDATE_COMPONENT_RTP, "udp",
933 v6_address, kCandidatePriority, "", "",
guoweis@webrtc.org950c5182014-12-16 23:01:31934 cricket::LOCAL_PORT_TYPE,
935 kCandidateGeneration, kCandidateFoundation2);
henrike@webrtc.org28e20752013-07-10 00:45:36936
937 // stun
938 int port_stun = 2345;
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52939 rtc::SocketAddress address_stun("74.125.127.126", port_stun++);
940 rtc::SocketAddress rel_address_stun("192.168.1.5", port_stun++);
guoweis@webrtc.org61c12472015-01-15 06:53:07941 cricket::Candidate candidate9(cricket::ICE_CANDIDATE_COMPONENT_RTP, "udp",
942 address_stun, kCandidatePriority, "", "",
943 STUN_PORT_TYPE, kCandidateGeneration,
guoweis@webrtc.org950c5182014-12-16 23:01:31944 kCandidateFoundation3);
henrike@webrtc.org28e20752013-07-10 00:45:36945 candidate9.set_related_address(rel_address_stun);
946
947 address_stun.SetPort(port_stun++);
948 rel_address_stun.SetPort(port_stun++);
guoweis@webrtc.org61c12472015-01-15 06:53:07949 cricket::Candidate candidate10(cricket::ICE_CANDIDATE_COMPONENT_RTCP, "udp",
950 address_stun, kCandidatePriority, "", "",
951 STUN_PORT_TYPE, kCandidateGeneration,
guoweis@webrtc.org950c5182014-12-16 23:01:31952 kCandidateFoundation3);
henrike@webrtc.org28e20752013-07-10 00:45:36953 candidate10.set_related_address(rel_address_stun);
954
955 // relay
956 int port_relay = 3456;
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52957 rtc::SocketAddress address_relay("74.125.224.39", port_relay++);
guoweis@webrtc.org61c12472015-01-15 06:53:07958 cricket::Candidate candidate11(cricket::ICE_CANDIDATE_COMPONENT_RTCP, "udp",
959 address_relay, kCandidatePriority, "", "",
960 cricket::RELAY_PORT_TYPE,
guoweis@webrtc.org950c5182014-12-16 23:01:31961 kCandidateGeneration, kCandidateFoundation4);
henrike@webrtc.org28e20752013-07-10 00:45:36962 address_relay.SetPort(port_relay++);
guoweis@webrtc.org61c12472015-01-15 06:53:07963 cricket::Candidate candidate12(cricket::ICE_CANDIDATE_COMPONENT_RTP, "udp",
964 address_relay, kCandidatePriority, "", "",
965 RELAY_PORT_TYPE, kCandidateGeneration,
guoweis@webrtc.org950c5182014-12-16 23:01:31966 kCandidateFoundation4);
henrike@webrtc.org28e20752013-07-10 00:45:36967
968 // voice
969 candidates_.push_back(candidate1);
970 candidates_.push_back(candidate2);
971 candidates_.push_back(candidate5);
972 candidates_.push_back(candidate6);
973 candidates_.push_back(candidate9);
974 candidates_.push_back(candidate10);
975
976 // video
977 candidates_.push_back(candidate3);
978 candidates_.push_back(candidate4);
979 candidates_.push_back(candidate7);
980 candidates_.push_back(candidate8);
981 candidates_.push_back(candidate11);
982 candidates_.push_back(candidate12);
983
984 jcandidate_.reset(new JsepIceCandidate(std::string("audio_content_name"),
985 0, candidate1));
986
987 // Set up JsepSessionDescription.
988 jdesc_.Initialize(desc_.Copy(), kSessionId, kSessionVersion);
989 std::string mline_id;
990 int mline_index = 0;
991 for (size_t i = 0; i< candidates_.size(); ++i) {
992 // In this test, the audio m line index will be 0, and the video m line
993 // will be 1.
994 bool is_video = (i > 5);
995 mline_id = is_video ? "video_content_name" : "audio_content_name";
996 mline_index = is_video ? 1 : 0;
997 JsepIceCandidate jice(mline_id,
998 mline_index,
999 candidates_.at(i));
1000 jdesc_.AddCandidate(&jice);
1001 }
1002 }
1003
deadbeef25ed4352016-12-13 02:37:361004 // Turns the existing reference description into a description using
1005 // a=bundle-only. This means no transport attributes and a 0 port value on
1006 // the m= sections not associated with the BUNDLE-tag.
1007 void MakeBundleOnlyDescription() {
1008 // Remove video candidates. JsepSessionDescription doesn't make it
1009 // simple.
1010 const IceCandidateCollection* video_candidates_collection =
1011 jdesc_.candidates(1);
1012 ASSERT_NE(nullptr, video_candidates_collection);
1013 std::vector<cricket::Candidate> video_candidates;
1014 for (size_t i = 0; i < video_candidates_collection->count(); ++i) {
1015 cricket::Candidate c = video_candidates_collection->at(i)->candidate();
1016 c.set_transport_name("video_content_name");
1017 video_candidates.push_back(c);
1018 }
1019 jdesc_.RemoveCandidates(video_candidates);
1020
1021 // And the rest of the transport attributes.
1022 desc_.transport_infos()[1].description.ice_ufrag.clear();
1023 desc_.transport_infos()[1].description.ice_pwd.clear();
1024 desc_.transport_infos()[1].description.connection_role =
1025 cricket::CONNECTIONROLE_NONE;
1026
1027 // Set bundle-only flag.
1028 desc_.contents()[1].bundle_only = true;
1029
1030 // Add BUNDLE group.
1031 ContentGroup group(cricket::GROUP_TYPE_BUNDLE);
1032 group.AddContentName(kAudioContentName);
1033 group.AddContentName(kVideoContentName);
1034 desc_.AddGroup(group);
1035
1036 ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), jdesc_.session_id(),
1037 jdesc_.session_version()));
1038 }
1039
deadbeef9d3584c2016-02-17 01:54:101040 // Turns the existing reference description into a plan B description,
1041 // with 2 audio tracks and 3 video tracks.
1042 void MakePlanBDescription() {
1043 audio_desc_ = static_cast<AudioContentDescription*>(audio_desc_->Copy());
1044 video_desc_ = static_cast<VideoContentDescription*>(video_desc_->Copy());
1045
1046 StreamParams audio_track_2;
1047 audio_track_2.id = kAudioTrackId2;
1048 audio_track_2.cname = kStream2Cname;
1049 audio_track_2.sync_label = kStreamLabel2;
1050 audio_track_2.ssrcs.push_back(kAudioTrack2Ssrc);
1051 audio_desc_->AddStream(audio_track_2);
1052
1053 StreamParams video_track_2;
1054 video_track_2.id = kVideoTrackId2;
1055 video_track_2.cname = kStream2Cname;
1056 video_track_2.sync_label = kStreamLabel2;
1057 video_track_2.ssrcs.push_back(kVideoTrack2Ssrc);
1058 video_desc_->AddStream(video_track_2);
1059
1060 StreamParams video_track_3;
1061 video_track_3.id = kVideoTrackId3;
1062 video_track_3.cname = kStream2Cname;
1063 video_track_3.sync_label = kStreamLabel2;
1064 video_track_3.ssrcs.push_back(kVideoTrack3Ssrc);
1065 video_desc_->AddStream(video_track_3);
1066
1067 desc_.RemoveContentByName(kAudioContentName);
1068 desc_.RemoveContentByName(kVideoContentName);
1069 desc_.AddContent(kAudioContentName, NS_JINGLE_RTP, audio_desc_);
1070 desc_.AddContent(kVideoContentName, NS_JINGLE_RTP, video_desc_);
1071
1072 ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), jdesc_.session_id(),
1073 jdesc_.session_version()));
1074 }
1075
1076 // Turns the existing reference description into a unified plan description,
1077 // with 2 audio tracks and 3 video tracks.
1078 void MakeUnifiedPlanDescription() {
1079 // Audio track 2.
1080 AudioContentDescription* audio_desc_2 = CreateAudioContentDescription();
1081 StreamParams audio_track_2;
1082 audio_track_2.id = kAudioTrackId2;
1083 audio_track_2.cname = kStream2Cname;
1084 audio_track_2.sync_label = kStreamLabel2;
1085 audio_track_2.ssrcs.push_back(kAudioTrack2Ssrc);
1086 audio_desc_2->AddStream(audio_track_2);
1087 desc_.AddContent(kAudioContentName2, NS_JINGLE_RTP, audio_desc_2);
1088 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo(
1089 kAudioContentName2, TransportDescription(kUfragVoice2, kPwdVoice2))));
1090
1091 // Video track 2, in stream 2.
1092 VideoContentDescription* video_desc_2 = CreateVideoContentDescription();
1093 StreamParams video_track_2;
1094 video_track_2.id = kVideoTrackId2;
1095 video_track_2.cname = kStream2Cname;
1096 video_track_2.sync_label = kStreamLabel2;
1097 video_track_2.ssrcs.push_back(kVideoTrack2Ssrc);
1098 video_desc_2->AddStream(video_track_2);
1099 desc_.AddContent(kVideoContentName2, NS_JINGLE_RTP, video_desc_2);
1100 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo(
1101 kVideoContentName2, TransportDescription(kUfragVideo2, kPwdVideo2))));
1102
1103 // Video track 3, in stream 2.
1104 VideoContentDescription* video_desc_3 = CreateVideoContentDescription();
1105 StreamParams video_track_3;
1106 video_track_3.id = kVideoTrackId3;
1107 video_track_3.cname = kStream2Cname;
1108 video_track_3.sync_label = kStreamLabel2;
1109 video_track_3.ssrcs.push_back(kVideoTrack3Ssrc);
1110 video_desc_3->AddStream(video_track_3);
1111 desc_.AddContent(kVideoContentName3, NS_JINGLE_RTP, video_desc_3);
1112 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo(
1113 kVideoContentName3, TransportDescription(kUfragVideo3, kPwdVideo3))));
1114
1115 ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(), jdesc_.session_id(),
1116 jdesc_.session_version()));
1117 }
1118
1119 // Creates an audio content description with no streams, and some default
1120 // configuration.
henrike@webrtc.org28e20752013-07-10 00:45:361121 AudioContentDescription* CreateAudioContentDescription() {
1122 AudioContentDescription* audio = new AudioContentDescription();
1123 audio->set_rtcp_mux(true);
deadbeef13871492015-12-09 20:37:511124 audio->set_rtcp_reduced_size(true);
henrike@webrtc.org28e20752013-07-10 00:45:361125 audio->AddCrypto(CryptoParams(1, "AES_CM_128_HMAC_SHA1_32",
1126 "inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj|2^20|1:32",
1127 "dummy_session_params"));
1128 audio->set_protocol(cricket::kMediaProtocolSavpf);
deadbeef67cf2c12016-04-13 17:07:161129 AudioCodec opus(111, "opus", 48000, 0, 2);
deadbeef9d3584c2016-02-17 01:54:101130 audio->AddCodec(opus);
ossue1405ad2017-01-23 16:55:481131 audio->AddCodec(AudioCodec(103, "ISAC", 16000, 0, 1));
1132 audio->AddCodec(AudioCodec(104, "ISAC", 32000, 0, 1));
henrike@webrtc.org28e20752013-07-10 00:45:361133 return audio;
1134 }
1135
deadbeef9d3584c2016-02-17 01:54:101136 // Creates a video content description with no streams, and some default
1137 // configuration.
1138 VideoContentDescription* CreateVideoContentDescription() {
1139 VideoContentDescription* video = new VideoContentDescription();
1140 video->AddCrypto(CryptoParams(
1141 1, "AES_CM_128_HMAC_SHA1_80",
1142 "inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj|2^20|1:32", ""));
1143 video->set_protocol(cricket::kMediaProtocolSavpf);
1144 video->AddCodec(
perkj26752742016-10-24 08:21:161145 VideoCodec(120, JsepSessionDescription::kDefaultVideoCodecName));
deadbeef9d3584c2016-02-17 01:54:101146 return video;
1147 }
1148
henrike@webrtc.org28e20752013-07-10 00:45:361149 template <class MCD>
1150 void CompareMediaContentDescription(const MCD* cd1,
1151 const MCD* cd2) {
1152 // type
1153 EXPECT_EQ(cd1->type(), cd1->type());
1154
1155 // content direction
1156 EXPECT_EQ(cd1->direction(), cd2->direction());
1157
1158 // rtcp_mux
1159 EXPECT_EQ(cd1->rtcp_mux(), cd2->rtcp_mux());
1160
deadbeef13871492015-12-09 20:37:511161 // rtcp_reduced_size
1162 EXPECT_EQ(cd1->rtcp_reduced_size(), cd2->rtcp_reduced_size());
1163
henrike@webrtc.org28e20752013-07-10 00:45:361164 // cryptos
1165 EXPECT_EQ(cd1->cryptos().size(), cd2->cryptos().size());
1166 if (cd1->cryptos().size() != cd2->cryptos().size()) {
1167 ADD_FAILURE();
1168 return;
1169 }
1170 for (size_t i = 0; i< cd1->cryptos().size(); ++i) {
1171 const CryptoParams c1 = cd1->cryptos().at(i);
1172 const CryptoParams c2 = cd2->cryptos().at(i);
1173 EXPECT_TRUE(c1.Matches(c2));
1174 EXPECT_EQ(c1.key_params, c2.key_params);
1175 EXPECT_EQ(c1.session_params, c2.session_params);
1176 }
lally@webrtc.orgd7b61652015-02-24 20:18:551177
henrike@webrtc.org28e20752013-07-10 00:45:361178 // protocol
lally@webrtc.orgd7b61652015-02-24 20:18:551179 // Use an equivalence class here, for old and new versions of the
1180 // protocol description.
1181 if (cd1->protocol() == cricket::kMediaProtocolDtlsSctp
lally@webrtc.org36300852015-02-24 20:19:351182 || cd1->protocol() == cricket::kMediaProtocolUdpDtlsSctp
1183 || cd1->protocol() == cricket::kMediaProtocolTcpDtlsSctp) {
1184 const bool cd2_is_also_dtls_sctp =
lally@webrtc.orgd7b61652015-02-24 20:18:551185 cd2->protocol() == cricket::kMediaProtocolDtlsSctp
lally@webrtc.org36300852015-02-24 20:19:351186 || cd2->protocol() == cricket::kMediaProtocolUdpDtlsSctp
1187 || cd2->protocol() == cricket::kMediaProtocolTcpDtlsSctp;
1188 EXPECT_TRUE(cd2_is_also_dtls_sctp);
lally@webrtc.orgd7b61652015-02-24 20:18:551189 } else {
1190 EXPECT_EQ(cd1->protocol(), cd2->protocol());
1191 }
henrike@webrtc.org28e20752013-07-10 00:45:361192
1193 // codecs
1194 EXPECT_EQ(cd1->codecs(), cd2->codecs());
1195
1196 // bandwidth
1197 EXPECT_EQ(cd1->bandwidth(), cd2->bandwidth());
1198
1199 // streams
1200 EXPECT_EQ(cd1->streams(), cd2->streams());
1201
1202 // extmap
1203 ASSERT_EQ(cd1->rtp_header_extensions().size(),
1204 cd2->rtp_header_extensions().size());
1205 for (size_t i = 0; i< cd1->rtp_header_extensions().size(); ++i) {
isheriff6f8d6862016-05-26 18:24:551206 const RtpExtension ext1 = cd1->rtp_header_extensions().at(i);
1207 const RtpExtension ext2 = cd2->rtp_header_extensions().at(i);
henrike@webrtc.org28e20752013-07-10 00:45:361208 EXPECT_EQ(ext1.uri, ext2.uri);
1209 EXPECT_EQ(ext1.id, ext2.id);
1210 }
henrike@webrtc.org28e20752013-07-10 00:45:361211 }
1212
1213
1214 void CompareSessionDescription(const SessionDescription& desc1,
1215 const SessionDescription& desc2) {
1216 // Compare content descriptions.
1217 if (desc1.contents().size() != desc2.contents().size()) {
1218 ADD_FAILURE();
1219 return;
1220 }
1221 for (size_t i = 0 ; i < desc1.contents().size(); ++i) {
1222 const cricket::ContentInfo& c1 = desc1.contents().at(i);
1223 const cricket::ContentInfo& c2 = desc2.contents().at(i);
deadbeef25ed4352016-12-13 02:37:361224 // ContentInfo properties.
henrike@webrtc.org28e20752013-07-10 00:45:361225 EXPECT_EQ(c1.name, c2.name);
deadbeef25ed4352016-12-13 02:37:361226 EXPECT_EQ(c1.type, c2.type);
1227 EXPECT_EQ(c1.rejected, c2.rejected);
1228 EXPECT_EQ(c1.bundle_only, c2.bundle_only);
henrike@webrtc.org28e20752013-07-10 00:45:361229
1230 ASSERT_EQ(IsAudioContent(&c1), IsAudioContent(&c2));
1231 if (IsAudioContent(&c1)) {
1232 const AudioContentDescription* acd1 =
1233 static_cast<const AudioContentDescription*>(c1.description);
1234 const AudioContentDescription* acd2 =
1235 static_cast<const AudioContentDescription*>(c2.description);
1236 CompareMediaContentDescription<AudioContentDescription>(acd1, acd2);
1237 }
1238
1239 ASSERT_EQ(IsVideoContent(&c1), IsVideoContent(&c2));
1240 if (IsVideoContent(&c1)) {
1241 const VideoContentDescription* vcd1 =
1242 static_cast<const VideoContentDescription*>(c1.description);
1243 const VideoContentDescription* vcd2 =
1244 static_cast<const VideoContentDescription*>(c2.description);
1245 CompareMediaContentDescription<VideoContentDescription>(vcd1, vcd2);
1246 }
1247
1248 ASSERT_EQ(IsDataContent(&c1), IsDataContent(&c2));
1249 if (IsDataContent(&c1)) {
1250 const DataContentDescription* dcd1 =
1251 static_cast<const DataContentDescription*>(c1.description);
1252 const DataContentDescription* dcd2 =
1253 static_cast<const DataContentDescription*>(c2.description);
1254 CompareMediaContentDescription<DataContentDescription>(dcd1, dcd2);
1255 }
1256 }
1257
1258 // group
1259 const cricket::ContentGroups groups1 = desc1.groups();
1260 const cricket::ContentGroups groups2 = desc2.groups();
1261 EXPECT_EQ(groups1.size(), groups1.size());
1262 if (groups1.size() != groups2.size()) {
1263 ADD_FAILURE();
1264 return;
1265 }
1266 for (size_t i = 0; i < groups1.size(); ++i) {
1267 const cricket::ContentGroup group1 = groups1.at(i);
1268 const cricket::ContentGroup group2 = groups2.at(i);
1269 EXPECT_EQ(group1.semantics(), group2.semantics());
1270 const cricket::ContentNames names1 = group1.content_names();
1271 const cricket::ContentNames names2 = group2.content_names();
1272 EXPECT_EQ(names1.size(), names2.size());
1273 if (names1.size() != names2.size()) {
1274 ADD_FAILURE();
1275 return;
1276 }
1277 cricket::ContentNames::const_iterator iter1 = names1.begin();
1278 cricket::ContentNames::const_iterator iter2 = names2.begin();
1279 while (iter1 != names1.end()) {
1280 EXPECT_EQ(*iter1++, *iter2++);
1281 }
1282 }
1283
1284 // transport info
1285 const cricket::TransportInfos transports1 = desc1.transport_infos();
1286 const cricket::TransportInfos transports2 = desc2.transport_infos();
1287 EXPECT_EQ(transports1.size(), transports2.size());
1288 if (transports1.size() != transports2.size()) {
1289 ADD_FAILURE();
1290 return;
1291 }
1292 for (size_t i = 0; i < transports1.size(); ++i) {
1293 const cricket::TransportInfo transport1 = transports1.at(i);
1294 const cricket::TransportInfo transport2 = transports2.at(i);
1295 EXPECT_EQ(transport1.content_name, transport2.content_name);
henrike@webrtc.org28e20752013-07-10 00:45:361296 EXPECT_EQ(transport1.description.ice_ufrag,
1297 transport2.description.ice_ufrag);
1298 EXPECT_EQ(transport1.description.ice_pwd,
1299 transport2.description.ice_pwd);
1300 if (transport1.description.identity_fingerprint) {
1301 EXPECT_EQ(*transport1.description.identity_fingerprint,
1302 *transport2.description.identity_fingerprint);
1303 } else {
1304 EXPECT_EQ(transport1.description.identity_fingerprint.get(),
1305 transport2.description.identity_fingerprint.get());
1306 }
1307 EXPECT_EQ(transport1.description.transport_options,
1308 transport2.description.transport_options);
henrike@webrtc.org28e20752013-07-10 00:45:361309 }
deadbeefc80741f2015-10-22 20:14:451310
1311 // global attributes
1312 EXPECT_EQ(desc1.msid_supported(), desc2.msid_supported());
henrike@webrtc.org28e20752013-07-10 00:45:361313 }
1314
henrike@webrtc.org28e20752013-07-10 00:45:361315 bool CompareSessionDescription(
1316 const JsepSessionDescription& desc1,
1317 const JsepSessionDescription& desc2) {
1318 EXPECT_EQ(desc1.session_id(), desc2.session_id());
1319 EXPECT_EQ(desc1.session_version(), desc2.session_version());
1320 CompareSessionDescription(*desc1.description(), *desc2.description());
1321 if (desc1.number_of_mediasections() != desc2.number_of_mediasections())
1322 return false;
1323 for (size_t i = 0; i < desc1.number_of_mediasections(); ++i) {
1324 const IceCandidateCollection* cc1 = desc1.candidates(i);
1325 const IceCandidateCollection* cc2 = desc2.candidates(i);
deadbeef25ed4352016-12-13 02:37:361326 if (cc1->count() != cc2->count()) {
1327 ADD_FAILURE();
henrike@webrtc.org28e20752013-07-10 00:45:361328 return false;
deadbeef25ed4352016-12-13 02:37:361329 }
henrike@webrtc.org28e20752013-07-10 00:45:361330 for (size_t j = 0; j < cc1->count(); ++j) {
1331 const IceCandidateInterface* c1 = cc1->at(j);
1332 const IceCandidateInterface* c2 = cc2->at(j);
1333 EXPECT_EQ(c1->sdp_mid(), c2->sdp_mid());
1334 EXPECT_EQ(c1->sdp_mline_index(), c2->sdp_mline_index());
1335 EXPECT_TRUE(c1->candidate().IsEquivalent(c2->candidate()));
1336 }
1337 }
1338 return true;
1339 }
1340
1341 // Disable the ice-ufrag and ice-pwd in given |sdp| message by replacing
1342 // them with invalid keywords so that the parser will just ignore them.
1343 bool RemoveCandidateUfragPwd(std::string* sdp) {
1344 const char ice_ufrag[] = "a=ice-ufrag";
1345 const char ice_ufragx[] = "a=xice-ufrag";
1346 const char ice_pwd[] = "a=ice-pwd";
1347 const char ice_pwdx[] = "a=xice-pwd";
buildbot@webrtc.orgd4e598d2014-07-29 17:36:521348 rtc::replace_substrs(ice_ufrag, strlen(ice_ufrag),
henrike@webrtc.org28e20752013-07-10 00:45:361349 ice_ufragx, strlen(ice_ufragx), sdp);
buildbot@webrtc.orgd4e598d2014-07-29 17:36:521350 rtc::replace_substrs(ice_pwd, strlen(ice_pwd),
henrike@webrtc.org28e20752013-07-10 00:45:361351 ice_pwdx, strlen(ice_pwdx), sdp);
1352 return true;
1353 }
1354
1355 // Update the candidates in |jdesc| to use the given |ufrag| and |pwd|.
1356 bool UpdateCandidateUfragPwd(JsepSessionDescription* jdesc, int mline_index,
1357 const std::string& ufrag, const std::string& pwd) {
1358 std::string content_name;
1359 if (mline_index == 0) {
1360 content_name = kAudioContentName;
1361 } else if (mline_index == 1) {
1362 content_name = kVideoContentName;
1363 } else {
nissec80e7412017-01-11 13:56:461364 RTC_NOTREACHED();
henrike@webrtc.org28e20752013-07-10 00:45:361365 }
1366 TransportInfo transport_info(
Peter Thatcher7cbd1882015-09-18 01:54:521367 content_name, TransportDescription(ufrag, pwd));
henrike@webrtc.org28e20752013-07-10 00:45:361368 SessionDescription* desc =
1369 const_cast<SessionDescription*>(jdesc->description());
1370 desc->RemoveTransportInfoByName(content_name);
1371 EXPECT_TRUE(desc->AddTransportInfo(transport_info));
1372 for (size_t i = 0; i < jdesc_.number_of_mediasections(); ++i) {
1373 const IceCandidateCollection* cc = jdesc_.candidates(i);
1374 for (size_t j = 0; j < cc->count(); ++j) {
1375 if (cc->at(j)->sdp_mline_index() == mline_index) {
1376 const_cast<Candidate&>(cc->at(j)->candidate()).set_username(
1377 ufrag);
1378 const_cast<Candidate&>(cc->at(j)->candidate()).set_password(
1379 pwd);
1380 }
1381 }
1382 }
1383 return true;
1384 }
1385
1386 void AddIceOptions(const std::string& content_name,
1387 const std::vector<std::string>& transport_options) {
1388 ASSERT_TRUE(desc_.GetTransportInfoByName(content_name) != NULL);
1389 cricket::TransportInfo transport_info =
1390 *(desc_.GetTransportInfoByName(content_name));
1391 desc_.RemoveTransportInfoByName(content_name);
1392 transport_info.description.transport_options = transport_options;
1393 desc_.AddTransportInfo(transport_info);
1394 }
1395
deadbeef3f7219b2015-12-28 23:17:141396 void SetIceUfragPwd(const std::string& content_name,
1397 const std::string& ice_ufrag,
1398 const std::string& ice_pwd) {
1399 ASSERT_TRUE(desc_.GetTransportInfoByName(content_name) != NULL);
1400 cricket::TransportInfo transport_info =
1401 *(desc_.GetTransportInfoByName(content_name));
1402 desc_.RemoveTransportInfoByName(content_name);
1403 transport_info.description.ice_ufrag = ice_ufrag;
1404 transport_info.description.ice_pwd = ice_pwd;
1405 desc_.AddTransportInfo(transport_info);
1406 }
1407
henrike@webrtc.org28e20752013-07-10 00:45:361408 void AddFingerprint() {
1409 desc_.RemoveTransportInfoByName(kAudioContentName);
1410 desc_.RemoveTransportInfoByName(kVideoContentName);
buildbot@webrtc.orgd4e598d2014-07-29 17:36:521411 rtc::SSLFingerprint fingerprint(rtc::DIGEST_SHA_1,
henrike@webrtc.org28e20752013-07-10 00:45:361412 kIdentityDigest,
1413 sizeof(kIdentityDigest));
deadbeef46eed762016-01-28 21:24:371414 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo(
1415 kAudioContentName,
deadbeef9d3584c2016-02-17 01:54:101416 TransportDescription(std::vector<std::string>(), kUfragVoice, kPwdVoice,
1417 cricket::ICEMODE_FULL,
deadbeef46eed762016-01-28 21:24:371418 cricket::CONNECTIONROLE_NONE, &fingerprint))));
1419 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo(
1420 kVideoContentName,
deadbeef9d3584c2016-02-17 01:54:101421 TransportDescription(std::vector<std::string>(), kUfragVideo, kPwdVideo,
1422 cricket::ICEMODE_FULL,
deadbeef46eed762016-01-28 21:24:371423 cricket::CONNECTIONROLE_NONE, &fingerprint))));
henrike@webrtc.org28e20752013-07-10 00:45:361424 }
1425
1426 void AddExtmap() {
1427 audio_desc_ = static_cast<AudioContentDescription*>(
1428 audio_desc_->Copy());
1429 video_desc_ = static_cast<VideoContentDescription*>(
1430 video_desc_->Copy());
isheriff6f8d6862016-05-26 18:24:551431 audio_desc_->AddRtpHeaderExtension(RtpExtension(kExtmapUri, kExtmapId));
1432 video_desc_->AddRtpHeaderExtension(RtpExtension(kExtmapUri, kExtmapId));
henrike@webrtc.org28e20752013-07-10 00:45:361433 desc_.RemoveContentByName(kAudioContentName);
1434 desc_.RemoveContentByName(kVideoContentName);
1435 desc_.AddContent(kAudioContentName, NS_JINGLE_RTP, audio_desc_);
1436 desc_.AddContent(kVideoContentName, NS_JINGLE_RTP, video_desc_);
1437 }
1438
1439 void RemoveCryptos() {
1440 audio_desc_->set_cryptos(std::vector<CryptoParams>());
1441 video_desc_->set_cryptos(std::vector<CryptoParams>());
1442 }
1443
1444 bool TestSerializeDirection(cricket::MediaContentDirection direction) {
1445 audio_desc_->set_direction(direction);
1446 video_desc_->set_direction(direction);
1447 std::string new_sdp = kSdpFullString;
1448 ReplaceDirection(direction, &new_sdp);
1449
1450 if (!jdesc_.Initialize(desc_.Copy(),
1451 jdesc_.session_id(),
1452 jdesc_.session_version())) {
1453 return false;
1454 }
deadbeef9d3584c2016-02-17 01:54:101455 std::string message = webrtc::SdpSerialize(jdesc_, false);
henrike@webrtc.org28e20752013-07-10 00:45:361456 EXPECT_EQ(new_sdp, message);
1457 return true;
1458 }
1459
1460 bool TestSerializeRejected(bool audio_rejected, bool video_rejected) {
1461 audio_desc_ = static_cast<AudioContentDescription*>(
1462 audio_desc_->Copy());
1463 video_desc_ = static_cast<VideoContentDescription*>(
1464 video_desc_->Copy());
1465 desc_.RemoveContentByName(kAudioContentName);
1466 desc_.RemoveContentByName(kVideoContentName);
1467 desc_.AddContent(kAudioContentName, NS_JINGLE_RTP, audio_rejected,
1468 audio_desc_);
1469 desc_.AddContent(kVideoContentName, NS_JINGLE_RTP, video_rejected,
1470 video_desc_);
deadbeef9d3584c2016-02-17 01:54:101471 SetIceUfragPwd(kAudioContentName, audio_rejected ? "" : kUfragVoice,
1472 audio_rejected ? "" : kPwdVoice);
1473 SetIceUfragPwd(kVideoContentName, video_rejected ? "" : kUfragVideo,
1474 video_rejected ? "" : kPwdVideo);
deadbeef3f7219b2015-12-28 23:17:141475
1476 std::string new_sdp = kSdpString;
henrike@webrtc.org28e20752013-07-10 00:45:361477 ReplaceRejected(audio_rejected, video_rejected, &new_sdp);
1478
deadbeef3f7219b2015-12-28 23:17:141479 JsepSessionDescription jdesc_no_candidates(kDummyString);
1480 if (!jdesc_no_candidates.Initialize(desc_.Copy(), kSessionId,
1481 kSessionVersion)) {
henrike@webrtc.org28e20752013-07-10 00:45:361482 return false;
1483 }
deadbeef9d3584c2016-02-17 01:54:101484 std::string message = webrtc::SdpSerialize(jdesc_no_candidates, false);
henrike@webrtc.org28e20752013-07-10 00:45:361485 EXPECT_EQ(new_sdp, message);
1486 return true;
1487 }
1488
1489 void AddSctpDataChannel() {
kwibergd1fe2812016-04-27 13:47:291490 std::unique_ptr<DataContentDescription> data(new DataContentDescription());
henrike@webrtc.org28e20752013-07-10 00:45:361491 data_desc_ = data.get();
1492 data_desc_->set_protocol(cricket::kMediaProtocolDtlsSctp);
solenberg9fa49752016-10-08 20:02:441493 DataCodec codec(cricket::kGoogleSctpDataCodecPlType,
deadbeef67cf2c12016-04-13 17:07:161494 cricket::kGoogleSctpDataCodecName);
wu@webrtc.org78187522013-10-07 23:32:021495 codec.SetParam(cricket::kCodecParamPort, kDefaultSctpPort);
1496 data_desc_->AddCodec(codec);
henrike@webrtc.org28e20752013-07-10 00:45:361497 desc_.AddContent(kDataContentName, NS_JINGLE_DRAFT_SCTP, data.release());
deadbeef9d3584c2016-02-17 01:54:101498 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo(
1499 kDataContentName, TransportDescription(kUfragData, kPwdData))));
henrike@webrtc.org28e20752013-07-10 00:45:361500 }
1501
1502 void AddRtpDataChannel() {
kwibergd1fe2812016-04-27 13:47:291503 std::unique_ptr<DataContentDescription> data(new DataContentDescription());
henrike@webrtc.org28e20752013-07-10 00:45:361504 data_desc_ = data.get();
1505
deadbeef67cf2c12016-04-13 17:07:161506 data_desc_->AddCodec(DataCodec(101, "google-data"));
henrike@webrtc.org28e20752013-07-10 00:45:361507 StreamParams data_stream;
1508 data_stream.id = kDataChannelMsid;
1509 data_stream.cname = kDataChannelCname;
1510 data_stream.sync_label = kDataChannelLabel;
1511 data_stream.ssrcs.push_back(kDataChannelSsrc);
1512 data_desc_->AddStream(data_stream);
1513 data_desc_->AddCrypto(CryptoParams(
1514 1, "AES_CM_128_HMAC_SHA1_80",
1515 "inline:FvLcvU2P3ZWmQxgPAgcDu7Zl9vftYElFOjEzhWs5", ""));
1516 data_desc_->set_protocol(cricket::kMediaProtocolSavpf);
1517 desc_.AddContent(kDataContentName, NS_JINGLE_RTP, data.release());
deadbeef9d3584c2016-02-17 01:54:101518 EXPECT_TRUE(desc_.AddTransportInfo(TransportInfo(
1519 kDataContentName, TransportDescription(kUfragData, kPwdData))));
henrike@webrtc.org28e20752013-07-10 00:45:361520 }
1521
1522 bool TestDeserializeDirection(cricket::MediaContentDirection direction) {
1523 std::string new_sdp = kSdpFullString;
1524 ReplaceDirection(direction, &new_sdp);
1525 JsepSessionDescription new_jdesc(kDummyString);
1526
1527 EXPECT_TRUE(SdpDeserialize(new_sdp, &new_jdesc));
1528
1529 audio_desc_->set_direction(direction);
1530 video_desc_->set_direction(direction);
1531 if (!jdesc_.Initialize(desc_.Copy(),
1532 jdesc_.session_id(),
1533 jdesc_.session_version())) {
1534 return false;
1535 }
1536 EXPECT_TRUE(CompareSessionDescription(jdesc_, new_jdesc));
1537 return true;
1538 }
1539
1540 bool TestDeserializeRejected(bool audio_rejected, bool video_rejected) {
deadbeef3f7219b2015-12-28 23:17:141541 std::string new_sdp = kSdpString;
henrike@webrtc.org28e20752013-07-10 00:45:361542 ReplaceRejected(audio_rejected, video_rejected, &new_sdp);
1543 JsepSessionDescription new_jdesc(JsepSessionDescription::kOffer);
henrike@webrtc.org28e20752013-07-10 00:45:361544 EXPECT_TRUE(SdpDeserialize(new_sdp, &new_jdesc));
deadbeef3f7219b2015-12-28 23:17:141545
henrike@webrtc.org28e20752013-07-10 00:45:361546 audio_desc_ = static_cast<AudioContentDescription*>(
1547 audio_desc_->Copy());
1548 video_desc_ = static_cast<VideoContentDescription*>(
1549 video_desc_->Copy());
1550 desc_.RemoveContentByName(kAudioContentName);
1551 desc_.RemoveContentByName(kVideoContentName);
1552 desc_.AddContent(kAudioContentName, NS_JINGLE_RTP, audio_rejected,
1553 audio_desc_);
1554 desc_.AddContent(kVideoContentName, NS_JINGLE_RTP, video_rejected,
1555 video_desc_);
deadbeef9d3584c2016-02-17 01:54:101556 SetIceUfragPwd(kAudioContentName, audio_rejected ? "" : kUfragVoice,
1557 audio_rejected ? "" : kPwdVoice);
1558 SetIceUfragPwd(kVideoContentName, video_rejected ? "" : kUfragVideo,
1559 video_rejected ? "" : kPwdVideo);
deadbeef3f7219b2015-12-28 23:17:141560 JsepSessionDescription jdesc_no_candidates(kDummyString);
1561 if (!jdesc_no_candidates.Initialize(desc_.Copy(), jdesc_.session_id(),
1562 jdesc_.session_version())) {
henrike@webrtc.org28e20752013-07-10 00:45:361563 return false;
1564 }
deadbeef3f7219b2015-12-28 23:17:141565 EXPECT_TRUE(CompareSessionDescription(jdesc_no_candidates, new_jdesc));
henrike@webrtc.org28e20752013-07-10 00:45:361566 return true;
1567 }
1568
1569 void TestDeserializeExtmap(bool session_level, bool media_level) {
1570 AddExtmap();
1571 JsepSessionDescription new_jdesc("dummy");
1572 ASSERT_TRUE(new_jdesc.Initialize(desc_.Copy(),
1573 jdesc_.session_id(),
1574 jdesc_.session_version()));
1575 JsepSessionDescription jdesc_with_extmap("dummy");
1576 std::string sdp_with_extmap = kSdpString;
1577 if (session_level) {
1578 InjectAfter(kSessionTime, kExtmapWithDirectionAndAttribute,
1579 &sdp_with_extmap);
1580 }
1581 if (media_level) {
1582 InjectAfter(kAttributeIcePwdVoice, kExtmapWithDirectionAndAttribute,
1583 &sdp_with_extmap);
1584 InjectAfter(kAttributeIcePwdVideo, kExtmapWithDirectionAndAttribute,
1585 &sdp_with_extmap);
1586 }
1587 // The extmap can't be present at the same time in both session level and
1588 // media level.
1589 if (session_level && media_level) {
1590 SdpParseError error;
1591 EXPECT_FALSE(webrtc::SdpDeserialize(sdp_with_extmap,
1592 &jdesc_with_extmap, &error));
1593 EXPECT_NE(std::string::npos, error.description.find("a=extmap"));
1594 } else {
1595 EXPECT_TRUE(SdpDeserialize(sdp_with_extmap, &jdesc_with_extmap));
1596 EXPECT_TRUE(CompareSessionDescription(jdesc_with_extmap, new_jdesc));
1597 }
1598 }
1599
1600 void VerifyCodecParameter(const cricket::CodecParameterMap& params,
1601 const std::string& name, int expected_value) {
1602 cricket::CodecParameterMap::const_iterator found = params.find(name);
1603 ASSERT_TRUE(found != params.end());
buildbot@webrtc.orgd4e598d2014-07-29 17:36:521604 EXPECT_EQ(found->second, rtc::ToString<int>(expected_value));
henrike@webrtc.org28e20752013-07-10 00:45:361605 }
1606
1607 void TestDeserializeCodecParams(const CodecParams& params,
1608 JsepSessionDescription* jdesc_output) {
1609 std::string sdp =
1610 "v=0\r\n"
1611 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n"
1612 "s=-\r\n"
1613 "t=0 0\r\n"
1614 // Include semantics for WebRTC Media Streams since it is supported by
1615 // this parser, and will be added to the SDP when serializing a session
1616 // description.
1617 "a=msid-semantic: WMS\r\n"
1618 // Pl type 111 preferred.
minyue@webrtc.orgf9b5c1b2015-02-17 12:36:411619 "m=audio 9 RTP/SAVPF 111 104 103\r\n"
henrike@webrtc.org28e20752013-07-10 00:45:361620 // Pltype 111 listed before 103 and 104 in the map.
1621 "a=rtpmap:111 opus/48000/2\r\n"
1622 // Pltype 103 listed before 104.
1623 "a=rtpmap:103 ISAC/16000\r\n"
minyue@webrtc.orgf9b5c1b2015-02-17 12:36:411624 "a=rtpmap:104 ISAC/32000\r\n"
mallinath@webrtc.orga5506692013-08-12 21:18:151625 "a=fmtp:111 0-15,66,70\r\n"
1626 "a=fmtp:111 ";
henrike@webrtc.org28e20752013-07-10 00:45:361627 std::ostringstream os;
Donald Curtis144d0182015-05-15 20:14:241628 os << "minptime=" << params.min_ptime << "; stereo=" << params.stereo
mallinath@webrtc.orga5506692013-08-12 21:18:151629 << "; sprop-stereo=" << params.sprop_stereo
1630 << "; useinbandfec=" << params.useinband
Donald Curtis0e07f922015-05-15 16:21:231631 << "; maxaveragebitrate=" << params.maxaveragebitrate << "\r\n"
henrike@webrtc.org28e20752013-07-10 00:45:361632 << "a=ptime:" << params.ptime << "\r\n"
1633 << "a=maxptime:" << params.max_ptime << "\r\n";
1634 sdp += os.str();
1635
stefan@webrtc.org85d27942014-06-09 12:51:391636 os.clear();
1637 os.str("");
1638 // Pl type 100 preferred.
pthatcher@webrtc.orgc9d6d142014-10-23 23:37:221639 os << "m=video 9 RTP/SAVPF 99 95\r\n"
stefan@webrtc.org85d27942014-06-09 12:51:391640 << "a=rtpmap:99 VP8/90000\r\n"
1641 << "a=rtpmap:95 RTX/90000\r\n"
Donald Curtis0e07f922015-05-15 16:21:231642 << "a=fmtp:95 apt=99;\r\n";
stefan@webrtc.org85d27942014-06-09 12:51:391643 sdp += os.str();
1644
henrike@webrtc.org28e20752013-07-10 00:45:361645 // Deserialize
1646 SdpParseError error;
1647 EXPECT_TRUE(webrtc::SdpDeserialize(sdp, jdesc_output, &error));
1648
1649 const ContentInfo* ac = GetFirstAudioContent(jdesc_output->description());
1650 ASSERT_TRUE(ac != NULL);
1651 const AudioContentDescription* acd =
1652 static_cast<const AudioContentDescription*>(ac->description);
1653 ASSERT_FALSE(acd->codecs().empty());
1654 cricket::AudioCodec opus = acd->codecs()[0];
1655 EXPECT_EQ("opus", opus.name);
1656 EXPECT_EQ(111, opus.id);
1657 VerifyCodecParameter(opus.params, "minptime", params.min_ptime);
1658 VerifyCodecParameter(opus.params, "stereo", params.stereo);
1659 VerifyCodecParameter(opus.params, "sprop-stereo", params.sprop_stereo);
1660 VerifyCodecParameter(opus.params, "useinbandfec", params.useinband);
henrike@webrtc.org1e09a712013-07-26 19:17:591661 VerifyCodecParameter(opus.params, "maxaveragebitrate",
1662 params.maxaveragebitrate);
henrike@webrtc.org28e20752013-07-10 00:45:361663 for (size_t i = 0; i < acd->codecs().size(); ++i) {
1664 cricket::AudioCodec codec = acd->codecs()[i];
1665 VerifyCodecParameter(codec.params, "ptime", params.ptime);
1666 VerifyCodecParameter(codec.params, "maxptime", params.max_ptime);
henrike@webrtc.org28e20752013-07-10 00:45:361667 }
stefan@webrtc.org85d27942014-06-09 12:51:391668
1669 const ContentInfo* vc = GetFirstVideoContent(jdesc_output->description());
1670 ASSERT_TRUE(vc != NULL);
1671 const VideoContentDescription* vcd =
1672 static_cast<const VideoContentDescription*>(vc->description);
1673 ASSERT_FALSE(vcd->codecs().empty());
1674 cricket::VideoCodec vp8 = vcd->codecs()[0];
1675 EXPECT_EQ("VP8", vp8.name);
1676 EXPECT_EQ(99, vp8.id);
1677 cricket::VideoCodec rtx = vcd->codecs()[1];
1678 EXPECT_EQ("RTX", rtx.name);
1679 EXPECT_EQ(95, rtx.id);
1680 VerifyCodecParameter(rtx.params, "apt", vp8.id);
henrike@webrtc.org28e20752013-07-10 00:45:361681 }
1682
1683 void TestDeserializeRtcpFb(JsepSessionDescription* jdesc_output,
1684 bool use_wildcard) {
jlmiller@webrtc.orga744a282015-02-18 21:37:461685 std::string sdp_session_and_audio =
henrike@webrtc.org28e20752013-07-10 00:45:361686 "v=0\r\n"
1687 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n"
1688 "s=-\r\n"
1689 "t=0 0\r\n"
1690 // Include semantics for WebRTC Media Streams since it is supported by
1691 // this parser, and will be added to the SDP when serializing a session
1692 // description.
1693 "a=msid-semantic: WMS\r\n"
pthatcher@webrtc.orgc9d6d142014-10-23 23:37:221694 "m=audio 9 RTP/SAVPF 111\r\n"
jlmiller@webrtc.orga744a282015-02-18 21:37:461695 "a=rtpmap:111 opus/48000/2\r\n";
1696 std::string sdp_video =
henrike@webrtc.org28e20752013-07-10 00:45:361697 "m=video 3457 RTP/SAVPF 101\r\n"
1698 "a=rtpmap:101 VP8/90000\r\n"
1699 "a=rtcp-fb:101 nack\r\n"
henrika@webrtc.orgaebb1ad2014-01-14 10:00:581700 "a=rtcp-fb:101 nack pli\r\n"
jlmiller@webrtc.orga744a282015-02-18 21:37:461701 "a=rtcp-fb:101 goog-remb\r\n";
henrike@webrtc.org28e20752013-07-10 00:45:361702 std::ostringstream os;
jlmiller@webrtc.orga744a282015-02-18 21:37:461703 os << sdp_session_and_audio;
1704 os << "a=rtcp-fb:" << (use_wildcard ? "*" : "111") << " nack\r\n";
1705 os << sdp_video;
henrike@webrtc.org28e20752013-07-10 00:45:361706 os << "a=rtcp-fb:" << (use_wildcard ? "*" : "101") << " ccm fir\r\n";
jlmiller@webrtc.orga744a282015-02-18 21:37:461707 std::string sdp = os.str();
henrike@webrtc.org28e20752013-07-10 00:45:361708 // Deserialize
1709 SdpParseError error;
1710 EXPECT_TRUE(webrtc::SdpDeserialize(sdp, jdesc_output, &error));
1711 const ContentInfo* ac = GetFirstAudioContent(jdesc_output->description());
1712 ASSERT_TRUE(ac != NULL);
1713 const AudioContentDescription* acd =
1714 static_cast<const AudioContentDescription*>(ac->description);
1715 ASSERT_FALSE(acd->codecs().empty());
1716 cricket::AudioCodec opus = acd->codecs()[0];
1717 EXPECT_EQ(111, opus.id);
1718 EXPECT_TRUE(opus.HasFeedbackParam(
1719 cricket::FeedbackParam(cricket::kRtcpFbParamNack,
1720 cricket::kParamValueEmpty)));
1721
1722 const ContentInfo* vc = GetFirstVideoContent(jdesc_output->description());
1723 ASSERT_TRUE(vc != NULL);
1724 const VideoContentDescription* vcd =
1725 static_cast<const VideoContentDescription*>(vc->description);
1726 ASSERT_FALSE(vcd->codecs().empty());
1727 cricket::VideoCodec vp8 = vcd->codecs()[0];
1728 EXPECT_STREQ(webrtc::JsepSessionDescription::kDefaultVideoCodecName,
1729 vp8.name.c_str());
1730 EXPECT_EQ(101, vp8.id);
1731 EXPECT_TRUE(vp8.HasFeedbackParam(
1732 cricket::FeedbackParam(cricket::kRtcpFbParamNack,
1733 cricket::kParamValueEmpty)));
1734 EXPECT_TRUE(vp8.HasFeedbackParam(
henrika@webrtc.orgaebb1ad2014-01-14 10:00:581735 cricket::FeedbackParam(cricket::kRtcpFbParamNack,
1736 cricket::kRtcpFbNackParamPli)));
1737 EXPECT_TRUE(vp8.HasFeedbackParam(
henrike@webrtc.org28e20752013-07-10 00:45:361738 cricket::FeedbackParam(cricket::kRtcpFbParamRemb,
1739 cricket::kParamValueEmpty)));
1740 EXPECT_TRUE(vp8.HasFeedbackParam(
1741 cricket::FeedbackParam(cricket::kRtcpFbParamCcm,
1742 cricket::kRtcpFbCcmParamFir)));
1743 }
1744
1745 // Two SDP messages can mean the same thing but be different strings, e.g.
1746 // some of the lines can be serialized in different order.
1747 // However, a deserialized description can be compared field by field and has
1748 // no order. If deserializer has already been tested, serializing then
1749 // deserializing and comparing JsepSessionDescription will test
1750 // the serializer sufficiently.
deadbeef9d3584c2016-02-17 01:54:101751 void TestSerialize(const JsepSessionDescription& jdesc,
1752 bool unified_plan_sdp) {
1753 std::string message = webrtc::SdpSerialize(jdesc, unified_plan_sdp);
henrike@webrtc.org28e20752013-07-10 00:45:361754 JsepSessionDescription jdesc_output_des(kDummyString);
1755 SdpParseError error;
1756 EXPECT_TRUE(webrtc::SdpDeserialize(message, &jdesc_output_des, &error));
1757 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output_des));
1758 }
1759
1760 protected:
1761 SessionDescription desc_;
1762 AudioContentDescription* audio_desc_;
1763 VideoContentDescription* video_desc_;
1764 DataContentDescription* data_desc_;
1765 Candidates candidates_;
kwibergd1fe2812016-04-27 13:47:291766 std::unique_ptr<IceCandidateInterface> jcandidate_;
henrike@webrtc.org28e20752013-07-10 00:45:361767 JsepSessionDescription jdesc_;
1768};
1769
1770void TestMismatch(const std::string& string1, const std::string& string2) {
1771 int position = 0;
1772 for (size_t i = 0; i < string1.length() && i < string2.length(); ++i) {
1773 if (string1.c_str()[i] != string2.c_str()[i]) {
henrike@webrtc.org28654cb2013-07-22 21:07:491774 position = static_cast<int>(i);
henrike@webrtc.org28e20752013-07-10 00:45:361775 break;
1776 }
1777 }
1778 EXPECT_EQ(0, position) << "Strings mismatch at the " << position
1779 << " character\n"
1780 << " 1: " << string1.substr(position, 20) << "\n"
1781 << " 2: " << string2.substr(position, 20) << "\n";
1782}
1783
henrike@webrtc.org28e20752013-07-10 00:45:361784TEST_F(WebRtcSdpTest, SerializeSessionDescription) {
1785 // SessionDescription with desc and candidates.
deadbeef9d3584c2016-02-17 01:54:101786 std::string message = webrtc::SdpSerialize(jdesc_, false);
henrike@webrtc.org28e20752013-07-10 00:45:361787 TestMismatch(std::string(kSdpFullString), message);
1788}
1789
1790TEST_F(WebRtcSdpTest, SerializeSessionDescriptionEmpty) {
1791 JsepSessionDescription jdesc_empty(kDummyString);
deadbeef9d3584c2016-02-17 01:54:101792 EXPECT_EQ("", webrtc::SdpSerialize(jdesc_empty, false));
henrike@webrtc.org28e20752013-07-10 00:45:361793}
1794
guoweis@webrtc.org57ac2c82015-02-06 00:45:131795// This tests serialization of SDP with only IPv6 candidates and verifies that
1796// IPv6 is used as default address in c line according to preference.
1797TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithIPv6Only) {
1798 // Only test 1 m line.
1799 desc_.RemoveContentByName("video_content_name");
1800 // Stun has a high preference than local host.
1801 cricket::Candidate candidate1(
1802 cricket::ICE_CANDIDATE_COMPONENT_RTP, "udp",
1803 rtc::SocketAddress("::1", 1234), kCandidatePriority, "", "",
1804 cricket::STUN_PORT_TYPE, kCandidateGeneration, kCandidateFoundation1);
1805 cricket::Candidate candidate2(
1806 cricket::ICE_CANDIDATE_COMPONENT_RTP, "udp",
1807 rtc::SocketAddress("::2", 1235), kCandidatePriority, "", "",
1808 cricket::LOCAL_PORT_TYPE, kCandidateGeneration, kCandidateFoundation1);
1809 JsepSessionDescription jdesc(kDummyString);
1810 ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion));
1811
1812 // Only add the candidates to audio m line.
1813 JsepIceCandidate jice1("audio_content_name", 0, candidate1);
1814 JsepIceCandidate jice2("audio_content_name", 0, candidate2);
1815 ASSERT_TRUE(jdesc.AddCandidate(&jice1));
1816 ASSERT_TRUE(jdesc.AddCandidate(&jice2));
deadbeef9d3584c2016-02-17 01:54:101817 std::string message = webrtc::SdpSerialize(jdesc, false);
guoweis@webrtc.org57ac2c82015-02-06 00:45:131818
1819 // Audio line should have a c line like this one.
1820 EXPECT_NE(message.find("c=IN IP6 ::1"), std::string::npos);
1821 // Shouldn't have a IP4 c line.
1822 EXPECT_EQ(message.find("c=IN IP4"), std::string::npos);
1823}
1824
1825// This tests serialization of SDP with both IPv4 and IPv6 candidates and
1826// verifies that IPv4 is used as default address in c line even if the
1827// preference of IPv4 is lower.
1828TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithBothIPFamilies) {
1829 // Only test 1 m line.
1830 desc_.RemoveContentByName("video_content_name");
1831 cricket::Candidate candidate_v4(
1832 cricket::ICE_CANDIDATE_COMPONENT_RTP, "udp",
1833 rtc::SocketAddress("192.168.1.5", 1234), kCandidatePriority, "", "",
1834 cricket::STUN_PORT_TYPE, kCandidateGeneration, kCandidateFoundation1);
1835 cricket::Candidate candidate_v6(
1836 cricket::ICE_CANDIDATE_COMPONENT_RTP, "udp",
1837 rtc::SocketAddress("::1", 1234), kCandidatePriority, "", "",
1838 cricket::LOCAL_PORT_TYPE, kCandidateGeneration, kCandidateFoundation1);
1839 JsepSessionDescription jdesc(kDummyString);
1840 ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion));
1841
1842 // Only add the candidates to audio m line.
1843 JsepIceCandidate jice_v4("audio_content_name", 0, candidate_v4);
1844 JsepIceCandidate jice_v6("audio_content_name", 0, candidate_v6);
1845 ASSERT_TRUE(jdesc.AddCandidate(&jice_v4));
1846 ASSERT_TRUE(jdesc.AddCandidate(&jice_v6));
deadbeef9d3584c2016-02-17 01:54:101847 std::string message = webrtc::SdpSerialize(jdesc, false);
guoweis@webrtc.org57ac2c82015-02-06 00:45:131848
1849 // Audio line should have a c line like this one.
1850 EXPECT_NE(message.find("c=IN IP4 192.168.1.5"), std::string::npos);
1851 // Shouldn't have a IP6 c line.
1852 EXPECT_EQ(message.find("c=IN IP6"), std::string::npos);
1853}
1854
1855// This tests serialization of SDP with both UDP and TCP candidates and
1856// verifies that UDP is used as default address in c line even if the
1857// preference of UDP is lower.
1858TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithBothProtocols) {
1859 // Only test 1 m line.
1860 desc_.RemoveContentByName("video_content_name");
1861 // Stun has a high preference than local host.
1862 cricket::Candidate candidate1(
1863 cricket::ICE_CANDIDATE_COMPONENT_RTP, "tcp",
1864 rtc::SocketAddress("::1", 1234), kCandidatePriority, "", "",
1865 cricket::STUN_PORT_TYPE, kCandidateGeneration, kCandidateFoundation1);
1866 cricket::Candidate candidate2(
1867 cricket::ICE_CANDIDATE_COMPONENT_RTP, "udp",
1868 rtc::SocketAddress("fe80::1234:5678:abcd:ef12", 1235), kCandidatePriority,
1869 "", "", cricket::LOCAL_PORT_TYPE, kCandidateGeneration,
1870 kCandidateFoundation1);
1871 JsepSessionDescription jdesc(kDummyString);
1872 ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion));
1873
1874 // Only add the candidates to audio m line.
1875 JsepIceCandidate jice1("audio_content_name", 0, candidate1);
1876 JsepIceCandidate jice2("audio_content_name", 0, candidate2);
1877 ASSERT_TRUE(jdesc.AddCandidate(&jice1));
1878 ASSERT_TRUE(jdesc.AddCandidate(&jice2));
deadbeef9d3584c2016-02-17 01:54:101879 std::string message = webrtc::SdpSerialize(jdesc, false);
guoweis@webrtc.org57ac2c82015-02-06 00:45:131880
1881 // Audio line should have a c line like this one.
1882 EXPECT_NE(message.find("c=IN IP6 fe80::1234:5678:abcd:ef12"),
1883 std::string::npos);
1884 // Shouldn't have a IP4 c line.
1885 EXPECT_EQ(message.find("c=IN IP4"), std::string::npos);
1886}
1887
1888// This tests serialization of SDP with only TCP candidates and verifies that
1889// null IPv4 is used as default address in c line.
1890TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithTCPOnly) {
1891 // Only test 1 m line.
1892 desc_.RemoveContentByName("video_content_name");
1893 // Stun has a high preference than local host.
1894 cricket::Candidate candidate1(
1895 cricket::ICE_CANDIDATE_COMPONENT_RTP, "tcp",
1896 rtc::SocketAddress("::1", 1234), kCandidatePriority, "", "",
1897 cricket::STUN_PORT_TYPE, kCandidateGeneration, kCandidateFoundation1);
1898 cricket::Candidate candidate2(
1899 cricket::ICE_CANDIDATE_COMPONENT_RTP, "tcp",
1900 rtc::SocketAddress("::2", 1235), kCandidatePriority, "", "",
1901 cricket::LOCAL_PORT_TYPE, kCandidateGeneration, kCandidateFoundation1);
1902 JsepSessionDescription jdesc(kDummyString);
1903 ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion));
1904
1905 // Only add the candidates to audio m line.
1906 JsepIceCandidate jice1("audio_content_name", 0, candidate1);
1907 JsepIceCandidate jice2("audio_content_name", 0, candidate2);
1908 ASSERT_TRUE(jdesc.AddCandidate(&jice1));
1909 ASSERT_TRUE(jdesc.AddCandidate(&jice2));
deadbeef9d3584c2016-02-17 01:54:101910 std::string message = webrtc::SdpSerialize(jdesc, false);
guoweis@webrtc.org57ac2c82015-02-06 00:45:131911
1912 // Audio line should have a c line like this one when no any default exists.
1913 EXPECT_NE(message.find("c=IN IP4 0.0.0.0"), std::string::npos);
1914}
1915
henrike@webrtc.org28e20752013-07-10 00:45:361916// This tests serialization of SDP with a=crypto and a=fingerprint, as would be
1917// the case in a DTLS offer.
1918TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithFingerprint) {
1919 AddFingerprint();
1920 JsepSessionDescription jdesc_with_fingerprint(kDummyString);
1921 ASSERT_TRUE(jdesc_with_fingerprint.Initialize(desc_.Copy(),
1922 kSessionId, kSessionVersion));
deadbeef9d3584c2016-02-17 01:54:101923 std::string message = webrtc::SdpSerialize(jdesc_with_fingerprint, false);
henrike@webrtc.org28e20752013-07-10 00:45:361924
1925 std::string sdp_with_fingerprint = kSdpString;
1926 InjectAfter(kAttributeIcePwdVoice,
1927 kFingerprint, &sdp_with_fingerprint);
1928 InjectAfter(kAttributeIcePwdVideo,
1929 kFingerprint, &sdp_with_fingerprint);
1930
1931 EXPECT_EQ(sdp_with_fingerprint, message);
1932}
1933
1934// This tests serialization of SDP with a=fingerprint with no a=crypto, as would
1935// be the case in a DTLS answer.
1936TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithFingerprintNoCryptos) {
1937 AddFingerprint();
1938 RemoveCryptos();
1939 JsepSessionDescription jdesc_with_fingerprint(kDummyString);
1940 ASSERT_TRUE(jdesc_with_fingerprint.Initialize(desc_.Copy(),
1941 kSessionId, kSessionVersion));
deadbeef9d3584c2016-02-17 01:54:101942 std::string message = webrtc::SdpSerialize(jdesc_with_fingerprint, false);
henrike@webrtc.org28e20752013-07-10 00:45:361943
1944 std::string sdp_with_fingerprint = kSdpString;
1945 Replace(kAttributeCryptoVoice, "", &sdp_with_fingerprint);
1946 Replace(kAttributeCryptoVideo, "", &sdp_with_fingerprint);
1947 InjectAfter(kAttributeIcePwdVoice,
1948 kFingerprint, &sdp_with_fingerprint);
1949 InjectAfter(kAttributeIcePwdVideo,
1950 kFingerprint, &sdp_with_fingerprint);
1951
1952 EXPECT_EQ(sdp_with_fingerprint, message);
1953}
1954
1955TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithoutCandidates) {
1956 // JsepSessionDescription with desc but without candidates.
1957 JsepSessionDescription jdesc_no_candidates(kDummyString);
deadbeef3f7219b2015-12-28 23:17:141958 ASSERT_TRUE(jdesc_no_candidates.Initialize(desc_.Copy(), kSessionId,
1959 kSessionVersion));
deadbeef9d3584c2016-02-17 01:54:101960 std::string message = webrtc::SdpSerialize(jdesc_no_candidates, false);
henrike@webrtc.org28e20752013-07-10 00:45:361961 EXPECT_EQ(std::string(kSdpString), message);
1962}
1963
1964TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithBundle) {
1965 ContentGroup group(cricket::GROUP_TYPE_BUNDLE);
1966 group.AddContentName(kAudioContentName);
1967 group.AddContentName(kVideoContentName);
1968 desc_.AddGroup(group);
1969 ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(),
1970 jdesc_.session_id(),
1971 jdesc_.session_version()));
deadbeef9d3584c2016-02-17 01:54:101972 std::string message = webrtc::SdpSerialize(jdesc_, false);
henrike@webrtc.org28e20752013-07-10 00:45:361973 std::string sdp_with_bundle = kSdpFullString;
1974 InjectAfter(kSessionTime,
1975 "a=group:BUNDLE audio_content_name video_content_name\r\n",
1976 &sdp_with_bundle);
1977 EXPECT_EQ(sdp_with_bundle, message);
1978}
1979
1980TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithBandwidth) {
1981 VideoContentDescription* vcd = static_cast<VideoContentDescription*>(
1982 GetFirstVideoContent(&desc_)->description);
1983 vcd->set_bandwidth(100 * 1000);
1984 AudioContentDescription* acd = static_cast<AudioContentDescription*>(
1985 GetFirstAudioContent(&desc_)->description);
1986 acd->set_bandwidth(50 * 1000);
1987 ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(),
1988 jdesc_.session_id(),
1989 jdesc_.session_version()));
deadbeef9d3584c2016-02-17 01:54:101990 std::string message = webrtc::SdpSerialize(jdesc_, false);
henrike@webrtc.org28e20752013-07-10 00:45:361991 std::string sdp_with_bandwidth = kSdpFullString;
wu@webrtc.org4c3e9912014-07-16 21:03:131992 InjectAfter("c=IN IP4 74.125.224.39\r\n",
henrike@webrtc.org28e20752013-07-10 00:45:361993 "b=AS:100\r\n",
1994 &sdp_with_bandwidth);
wu@webrtc.org4c3e9912014-07-16 21:03:131995 InjectAfter("c=IN IP4 74.125.127.126\r\n",
henrike@webrtc.org28e20752013-07-10 00:45:361996 "b=AS:50\r\n",
1997 &sdp_with_bandwidth);
1998 EXPECT_EQ(sdp_with_bandwidth, message);
1999}
2000
2001TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithIceOptions) {
2002 std::vector<std::string> transport_options;
2003 transport_options.push_back(kIceOption1);
2004 transport_options.push_back(kIceOption3);
2005 AddIceOptions(kAudioContentName, transport_options);
2006 transport_options.clear();
2007 transport_options.push_back(kIceOption2);
2008 transport_options.push_back(kIceOption3);
2009 AddIceOptions(kVideoContentName, transport_options);
2010 ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(),
2011 jdesc_.session_id(),
2012 jdesc_.session_version()));
deadbeef9d3584c2016-02-17 01:54:102013 std::string message = webrtc::SdpSerialize(jdesc_, false);
henrike@webrtc.org28e20752013-07-10 00:45:362014 std::string sdp_with_ice_options = kSdpFullString;
2015 InjectAfter(kAttributeIcePwdVoice,
2016 "a=ice-options:iceoption1 iceoption3\r\n",
2017 &sdp_with_ice_options);
2018 InjectAfter(kAttributeIcePwdVideo,
2019 "a=ice-options:iceoption2 iceoption3\r\n",
2020 &sdp_with_ice_options);
2021 EXPECT_EQ(sdp_with_ice_options, message);
2022}
2023
2024TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithRecvOnlyContent) {
2025 EXPECT_TRUE(TestSerializeDirection(cricket::MD_RECVONLY));
2026}
2027
2028TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithSendOnlyContent) {
2029 EXPECT_TRUE(TestSerializeDirection(cricket::MD_SENDONLY));
2030}
2031
2032TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithInactiveContent) {
2033 EXPECT_TRUE(TestSerializeDirection(cricket::MD_INACTIVE));
2034}
2035
2036TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithAudioRejected) {
2037 EXPECT_TRUE(TestSerializeRejected(true, false));
2038}
2039
2040TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithVideoRejected) {
2041 EXPECT_TRUE(TestSerializeRejected(false, true));
2042}
2043
2044TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithAudioVideoRejected) {
2045 EXPECT_TRUE(TestSerializeRejected(true, true));
2046}
2047
2048TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithRtpDataChannel) {
2049 AddRtpDataChannel();
2050 JsepSessionDescription jsep_desc(kDummyString);
2051
2052 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion));
deadbeef9d3584c2016-02-17 01:54:102053 std::string message = webrtc::SdpSerialize(jsep_desc, false);
henrike@webrtc.org28e20752013-07-10 00:45:362054
2055 std::string expected_sdp = kSdpString;
2056 expected_sdp.append(kSdpRtpDataChannelString);
2057 EXPECT_EQ(expected_sdp, message);
2058}
2059
2060TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithSctpDataChannel) {
2061 AddSctpDataChannel();
2062 JsepSessionDescription jsep_desc(kDummyString);
2063
2064 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion));
deadbeef9d3584c2016-02-17 01:54:102065 std::string message = webrtc::SdpSerialize(jsep_desc, false);
henrike@webrtc.org28e20752013-07-10 00:45:362066
2067 std::string expected_sdp = kSdpString;
2068 expected_sdp.append(kSdpSctpDataChannelString);
2069 EXPECT_EQ(message, expected_sdp);
2070}
2071
jiayl@webrtc.org9c16c392014-05-01 18:30:302072TEST_F(WebRtcSdpTest, SerializeWithSctpDataChannelAndNewPort) {
2073 AddSctpDataChannel();
2074 JsepSessionDescription jsep_desc(kDummyString);
2075
2076 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion));
2077 DataContentDescription* dcdesc = static_cast<DataContentDescription*>(
2078 jsep_desc.description()->GetContentDescriptionByName(kDataContentName));
2079
2080 const int kNewPort = 1234;
solenberg9fa49752016-10-08 20:02:442081 cricket::DataCodec codec(cricket::kGoogleSctpDataCodecPlType,
deadbeef67cf2c12016-04-13 17:07:162082 cricket::kGoogleSctpDataCodecName);
jiayl@webrtc.org9c16c392014-05-01 18:30:302083 codec.SetParam(cricket::kCodecParamPort, kNewPort);
2084 dcdesc->AddOrReplaceCodec(codec);
2085
deadbeef9d3584c2016-02-17 01:54:102086 std::string message = webrtc::SdpSerialize(jsep_desc, false);
jiayl@webrtc.org9c16c392014-05-01 18:30:302087
2088 std::string expected_sdp = kSdpString;
2089 expected_sdp.append(kSdpSctpDataChannelString);
2090
2091 char default_portstr[16];
2092 char new_portstr[16];
buildbot@webrtc.orgd4e598d2014-07-29 17:36:522093 rtc::sprintfn(default_portstr, sizeof(default_portstr), "%d",
jiayl@webrtc.org9c16c392014-05-01 18:30:302094 kDefaultSctpPort);
buildbot@webrtc.orgd4e598d2014-07-29 17:36:522095 rtc::sprintfn(new_portstr, sizeof(new_portstr), "%d", kNewPort);
2096 rtc::replace_substrs(default_portstr, strlen(default_portstr),
jiayl@webrtc.org9c16c392014-05-01 18:30:302097 new_portstr, strlen(new_portstr),
2098 &expected_sdp);
2099
2100 EXPECT_EQ(expected_sdp, message);
2101}
2102
wu@webrtc.orgcadf9042013-08-30 21:24:162103TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithDataChannelAndBandwidth) {
2104 AddRtpDataChannel();
2105 data_desc_->set_bandwidth(100*1000);
2106 JsepSessionDescription jsep_desc(kDummyString);
2107
2108 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion));
deadbeef9d3584c2016-02-17 01:54:102109 std::string message = webrtc::SdpSerialize(jsep_desc, false);
wu@webrtc.orgcadf9042013-08-30 21:24:162110
2111 std::string expected_sdp = kSdpString;
2112 expected_sdp.append(kSdpRtpDataChannelString);
Peter Thatcherc0c3a862015-06-24 22:31:252113 // Serializing data content shouldn't ignore bandwidth settings.
perkj@webrtc.orgd105cc82014-11-07 11:22:062114 InjectAfter("m=application 9 RTP/SAVPF 101\r\nc=IN IP4 0.0.0.0\r\n",
sergeyu@chromium.orga59696b2013-09-13 23:48:582115 "b=AS:100\r\n",
2116 &expected_sdp);
2117 EXPECT_EQ(expected_sdp, message);
wu@webrtc.orgcadf9042013-08-30 21:24:162118}
2119
henrike@webrtc.org28e20752013-07-10 00:45:362120TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithExtmap) {
2121 AddExtmap();
2122 JsepSessionDescription desc_with_extmap("dummy");
2123 ASSERT_TRUE(desc_with_extmap.Initialize(desc_.Copy(),
2124 kSessionId, kSessionVersion));
deadbeef9d3584c2016-02-17 01:54:102125 std::string message = webrtc::SdpSerialize(desc_with_extmap, false);
henrike@webrtc.org28e20752013-07-10 00:45:362126
2127 std::string sdp_with_extmap = kSdpString;
2128 InjectAfter("a=mid:audio_content_name\r\n",
2129 kExtmap, &sdp_with_extmap);
2130 InjectAfter("a=mid:video_content_name\r\n",
2131 kExtmap, &sdp_with_extmap);
2132
2133 EXPECT_EQ(sdp_with_extmap, message);
2134}
2135
henrike@webrtc.org28e20752013-07-10 00:45:362136TEST_F(WebRtcSdpTest, SerializeCandidates) {
2137 std::string message = webrtc::SdpSerializeCandidate(*jcandidate_);
wu@webrtc.orgec9f5fb2014-06-24 17:05:102138 EXPECT_EQ(std::string(kRawCandidate), message);
honghaiza54a0802015-12-17 02:37:232139
2140 Candidate candidate_with_ufrag(candidates_.front());
2141 candidate_with_ufrag.set_username("ABC");
2142 jcandidate_.reset(new JsepIceCandidate(std::string("audio_content_name"), 0,
2143 candidate_with_ufrag));
2144 message = webrtc::SdpSerializeCandidate(*jcandidate_);
2145 EXPECT_EQ(std::string(kRawCandidate) + " ufrag ABC", message);
honghaiza0c44ea2016-03-23 23:07:482146
2147 Candidate candidate_with_network_info(candidates_.front());
2148 candidate_with_network_info.set_network_id(1);
2149 jcandidate_.reset(new JsepIceCandidate(std::string("audio"), 0,
2150 candidate_with_network_info));
2151 message = webrtc::SdpSerializeCandidate(*jcandidate_);
2152 EXPECT_EQ(std::string(kRawCandidate) + " network-id 1", message);
2153 candidate_with_network_info.set_network_cost(999);
2154 jcandidate_.reset(new JsepIceCandidate(std::string("audio"), 0,
2155 candidate_with_network_info));
2156 message = webrtc::SdpSerializeCandidate(*jcandidate_);
2157 EXPECT_EQ(std::string(kRawCandidate) + " network-id 1 network-cost 999",
2158 message);
henrike@webrtc.org28e20752013-07-10 00:45:362159}
2160
mallinath@webrtc.org2d60c5e2014-08-08 22:29:202161// TODO(mallinath) : Enable this test once WebRTCSdp capable of parsing
2162// RFC 6544.
mallinath@webrtc.orge999bd02014-08-13 06:05:552163TEST_F(WebRtcSdpTest, SerializeTcpCandidates) {
guoweis@webrtc.org61c12472015-01-15 06:53:072164 Candidate candidate(ICE_CANDIDATE_COMPONENT_RTP, "tcp",
guoweis@webrtc.org950c5182014-12-16 23:01:312165 rtc::SocketAddress("192.168.1.5", 9), kCandidatePriority,
2166 "", "", LOCAL_PORT_TYPE, kCandidateGeneration,
2167 kCandidateFoundation1);
mallinath@webrtc.org2d60c5e2014-08-08 22:29:202168 candidate.set_tcptype(cricket::TCPTYPE_ACTIVE_STR);
kwibergd1fe2812016-04-27 13:47:292169 std::unique_ptr<IceCandidateInterface> jcandidate(
2170 new JsepIceCandidate(std::string("audio_content_name"), 0, candidate));
mallinath@webrtc.org2d60c5e2014-08-08 22:29:202171
2172 std::string message = webrtc::SdpSerializeCandidate(*jcandidate);
2173 EXPECT_EQ(std::string(kSdpTcpActiveCandidate), message);
2174}
2175
htaa6b99442016-04-12 17:29:172176TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithH264) {
magjed509e4fe2016-11-18 09:34:112177 cricket::VideoCodec h264_codec("H264");
2178 h264_codec.SetParam("profile-level-id", "42e01f");
2179 h264_codec.SetParam("level-asymmetry-allowed", "1");
2180 h264_codec.SetParam("packetization-mode", "1");
2181 video_desc_->AddCodec(h264_codec);
2182
htaa6b99442016-04-12 17:29:172183 jdesc_.Initialize(desc_.Copy(), kSessionId, kSessionVersion);
2184
2185 std::string message = webrtc::SdpSerialize(jdesc_, false);
2186 size_t after_pt = message.find(" H264/90000");
2187 ASSERT_NE(after_pt, std::string::npos);
2188 size_t before_pt = message.rfind("a=rtpmap:", after_pt);
2189 ASSERT_NE(before_pt, std::string::npos);
2190 before_pt += strlen("a=rtpmap:");
2191 std::string pt = message.substr(before_pt, after_pt - before_pt);
2192 // TODO(hta): Check if payload type |pt| occurs in the m=video line.
2193 std::string to_find = "a=fmtp:" + pt + " ";
2194 size_t fmtp_pos = message.find(to_find);
2195 ASSERT_NE(std::string::npos, fmtp_pos) << "Failed to find " << to_find;
2196 size_t fmtp_endpos = message.find("\n", fmtp_pos);
2197 ASSERT_NE(std::string::npos, fmtp_endpos);
2198 std::string fmtp_value = message.substr(fmtp_pos, fmtp_endpos);
2199 EXPECT_NE(std::string::npos, fmtp_value.find("level-asymmetry-allowed=1"));
2200 EXPECT_NE(std::string::npos, fmtp_value.find("packetization-mode=1"));
2201 EXPECT_NE(std::string::npos, fmtp_value.find("profile-level-id=42e01f"));
hta62a216e2016-04-15 18:02:142202 // Check that there are no spaces after semicolons.
2203 // https://bugs.webrtc.org/5793
2204 EXPECT_EQ(std::string::npos, fmtp_value.find("; "));
htaa6b99442016-04-12 17:29:172205}
2206
henrike@webrtc.org28e20752013-07-10 00:45:362207TEST_F(WebRtcSdpTest, DeserializeSessionDescription) {
2208 JsepSessionDescription jdesc(kDummyString);
2209 // Deserialize
2210 EXPECT_TRUE(SdpDeserialize(kSdpFullString, &jdesc));
2211 // Verify
2212 EXPECT_TRUE(CompareSessionDescription(jdesc_, jdesc));
2213}
2214
wu@webrtc.orgcecfd182013-10-30 05:18:122215TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithoutMline) {
2216 JsepSessionDescription jdesc(kDummyString);
2217 const char kSdpWithoutMline[] =
2218 "v=0\r\n"
2219 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n"
2220 "s=-\r\n"
2221 "t=0 0\r\n"
2222 "a=msid-semantic: WMS local_stream_1 local_stream_2\r\n";
2223 // Deserialize
2224 EXPECT_TRUE(SdpDeserialize(kSdpWithoutMline, &jdesc));
2225 EXPECT_EQ(0u, jdesc.description()->contents().size());
2226}
2227
henrike@webrtc.org28e20752013-07-10 00:45:362228TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithoutCarriageReturn) {
2229 JsepSessionDescription jdesc(kDummyString);
2230 std::string sdp_without_carriage_return = kSdpFullString;
2231 Replace("\r\n", "\n", &sdp_without_carriage_return);
2232 // Deserialize
2233 EXPECT_TRUE(SdpDeserialize(sdp_without_carriage_return, &jdesc));
2234 // Verify
2235 EXPECT_TRUE(CompareSessionDescription(jdesc_, jdesc));
2236}
2237
2238TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithoutCandidates) {
2239 // SessionDescription with desc but without candidates.
2240 JsepSessionDescription jdesc_no_candidates(kDummyString);
2241 ASSERT_TRUE(jdesc_no_candidates.Initialize(desc_.Copy(),
2242 kSessionId, kSessionVersion));
2243 JsepSessionDescription new_jdesc(kDummyString);
2244 EXPECT_TRUE(SdpDeserialize(kSdpString, &new_jdesc));
2245 EXPECT_TRUE(CompareSessionDescription(jdesc_no_candidates, new_jdesc));
2246}
2247
2248TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithoutRtpmap) {
2249 static const char kSdpNoRtpmapString[] =
2250 "v=0\r\n"
2251 "o=- 11 22 IN IP4 127.0.0.1\r\n"
2252 "s=-\r\n"
2253 "t=0 0\r\n"
2254 "m=audio 49232 RTP/AVP 0 18 103\r\n"
2255 // Codec that doesn't appear in the m= line will be ignored.
minyue@webrtc.orgf9b5c1b2015-02-17 12:36:412256 "a=rtpmap:104 ISAC/32000\r\n"
henrike@webrtc.org28e20752013-07-10 00:45:362257 // The rtpmap line for static payload codec is optional.
2258 "a=rtpmap:18 G729/16000\r\n"
2259 "a=rtpmap:103 ISAC/16000\r\n";
2260
2261 JsepSessionDescription jdesc(kDummyString);
2262 EXPECT_TRUE(SdpDeserialize(kSdpNoRtpmapString, &jdesc));
2263 cricket::AudioContentDescription* audio =
2264 static_cast<AudioContentDescription*>(
2265 jdesc.description()->GetContentDescriptionByName(cricket::CN_AUDIO));
2266 AudioCodecs ref_codecs;
deadbeef67cf2c12016-04-13 17:07:162267 // The codecs in the AudioContentDescription should be in the same order as
2268 // the payload types (<fmt>s) on the m= line.
2269 ref_codecs.push_back(AudioCodec(0, "PCMU", 8000, 0, 1));
2270 ref_codecs.push_back(AudioCodec(18, "G729", 16000, 0, 1));
ossue1405ad2017-01-23 16:55:482271 ref_codecs.push_back(AudioCodec(103, "ISAC", 16000, 0, 1));
henrike@webrtc.org28e20752013-07-10 00:45:362272 EXPECT_EQ(ref_codecs, audio->codecs());
2273}
2274
henrike@webrtc.org704bf9e2014-02-27 17:52:042275TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithoutRtpmapButWithFmtp) {
2276 static const char kSdpNoRtpmapString[] =
2277 "v=0\r\n"
2278 "o=- 11 22 IN IP4 127.0.0.1\r\n"
2279 "s=-\r\n"
2280 "t=0 0\r\n"
2281 "m=audio 49232 RTP/AVP 18 103\r\n"
2282 "a=fmtp:18 annexb=yes\r\n"
2283 "a=rtpmap:103 ISAC/16000\r\n";
2284
2285 JsepSessionDescription jdesc(kDummyString);
2286 EXPECT_TRUE(SdpDeserialize(kSdpNoRtpmapString, &jdesc));
2287 cricket::AudioContentDescription* audio =
2288 static_cast<AudioContentDescription*>(
2289 jdesc.description()->GetContentDescriptionByName(cricket::CN_AUDIO));
2290
2291 cricket::AudioCodec g729 = audio->codecs()[0];
2292 EXPECT_EQ("G729", g729.name);
2293 EXPECT_EQ(8000, g729.clockrate);
2294 EXPECT_EQ(18, g729.id);
2295 cricket::CodecParameterMap::iterator found =
2296 g729.params.find("annexb");
2297 ASSERT_TRUE(found != g729.params.end());
2298 EXPECT_EQ(found->second, "yes");
2299
2300 cricket::AudioCodec isac = audio->codecs()[1];
2301 EXPECT_EQ("ISAC", isac.name);
2302 EXPECT_EQ(103, isac.id);
2303 EXPECT_EQ(16000, isac.clockrate);
2304}
2305
henrike@webrtc.org28e20752013-07-10 00:45:362306// Ensure that we can deserialize SDP with a=fingerprint properly.
2307TEST_F(WebRtcSdpTest, DeserializeJsepSessionDescriptionWithFingerprint) {
2308 // Add a DTLS a=fingerprint attribute to our session description.
2309 AddFingerprint();
2310 JsepSessionDescription new_jdesc(kDummyString);
2311 ASSERT_TRUE(new_jdesc.Initialize(desc_.Copy(),
2312 jdesc_.session_id(),
2313 jdesc_.session_version()));
2314
2315 JsepSessionDescription jdesc_with_fingerprint(kDummyString);
2316 std::string sdp_with_fingerprint = kSdpString;
2317 InjectAfter(kAttributeIcePwdVoice, kFingerprint, &sdp_with_fingerprint);
2318 InjectAfter(kAttributeIcePwdVideo, kFingerprint, &sdp_with_fingerprint);
2319 EXPECT_TRUE(SdpDeserialize(sdp_with_fingerprint, &jdesc_with_fingerprint));
2320 EXPECT_TRUE(CompareSessionDescription(jdesc_with_fingerprint, new_jdesc));
2321}
2322
2323TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithBundle) {
2324 JsepSessionDescription jdesc_with_bundle(kDummyString);
2325 std::string sdp_with_bundle = kSdpFullString;
2326 InjectAfter(kSessionTime,
2327 "a=group:BUNDLE audio_content_name video_content_name\r\n",
2328 &sdp_with_bundle);
2329 EXPECT_TRUE(SdpDeserialize(sdp_with_bundle, &jdesc_with_bundle));
2330 ContentGroup group(cricket::GROUP_TYPE_BUNDLE);
2331 group.AddContentName(kAudioContentName);
2332 group.AddContentName(kVideoContentName);
2333 desc_.AddGroup(group);
2334 ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(),
2335 jdesc_.session_id(),
2336 jdesc_.session_version()));
2337 EXPECT_TRUE(CompareSessionDescription(jdesc_, jdesc_with_bundle));
2338}
2339
2340TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithBandwidth) {
2341 JsepSessionDescription jdesc_with_bandwidth(kDummyString);
2342 std::string sdp_with_bandwidth = kSdpFullString;
2343 InjectAfter("a=mid:video_content_name\r\na=sendrecv\r\n",
2344 "b=AS:100\r\n",
2345 &sdp_with_bandwidth);
2346 InjectAfter("a=mid:audio_content_name\r\na=sendrecv\r\n",
2347 "b=AS:50\r\n",
2348 &sdp_with_bandwidth);
2349 EXPECT_TRUE(
2350 SdpDeserialize(sdp_with_bandwidth, &jdesc_with_bandwidth));
2351 VideoContentDescription* vcd = static_cast<VideoContentDescription*>(
2352 GetFirstVideoContent(&desc_)->description);
2353 vcd->set_bandwidth(100 * 1000);
2354 AudioContentDescription* acd = static_cast<AudioContentDescription*>(
2355 GetFirstAudioContent(&desc_)->description);
2356 acd->set_bandwidth(50 * 1000);
2357 ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(),
2358 jdesc_.session_id(),
2359 jdesc_.session_version()));
2360 EXPECT_TRUE(CompareSessionDescription(jdesc_, jdesc_with_bandwidth));
2361}
2362
2363TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithIceOptions) {
2364 JsepSessionDescription jdesc_with_ice_options(kDummyString);
2365 std::string sdp_with_ice_options = kSdpFullString;
2366 InjectAfter(kSessionTime,
2367 "a=ice-options:iceoption3\r\n",
2368 &sdp_with_ice_options);
2369 InjectAfter(kAttributeIcePwdVoice,
2370 "a=ice-options:iceoption1\r\n",
2371 &sdp_with_ice_options);
2372 InjectAfter(kAttributeIcePwdVideo,
2373 "a=ice-options:iceoption2\r\n",
2374 &sdp_with_ice_options);
2375 EXPECT_TRUE(SdpDeserialize(sdp_with_ice_options, &jdesc_with_ice_options));
2376 std::vector<std::string> transport_options;
2377 transport_options.push_back(kIceOption3);
2378 transport_options.push_back(kIceOption1);
2379 AddIceOptions(kAudioContentName, transport_options);
2380 transport_options.clear();
2381 transport_options.push_back(kIceOption3);
2382 transport_options.push_back(kIceOption2);
2383 AddIceOptions(kVideoContentName, transport_options);
2384 ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(),
2385 jdesc_.session_id(),
2386 jdesc_.session_version()));
2387 EXPECT_TRUE(CompareSessionDescription(jdesc_, jdesc_with_ice_options));
2388}
2389
2390TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithUfragPwd) {
2391 // Remove the original ice-ufrag and ice-pwd
2392 JsepSessionDescription jdesc_with_ufrag_pwd(kDummyString);
2393 std::string sdp_with_ufrag_pwd = kSdpFullString;
2394 EXPECT_TRUE(RemoveCandidateUfragPwd(&sdp_with_ufrag_pwd));
2395 // Add session level ufrag and pwd
2396 InjectAfter(kSessionTime,
2397 "a=ice-pwd:session+level+icepwd\r\n"
2398 "a=ice-ufrag:session+level+iceufrag\r\n",
2399 &sdp_with_ufrag_pwd);
2400 // Add media level ufrag and pwd for audio
2401 InjectAfter("a=mid:audio_content_name\r\n",
2402 "a=ice-pwd:media+level+icepwd\r\na=ice-ufrag:media+level+iceufrag\r\n",
2403 &sdp_with_ufrag_pwd);
2404 // Update the candidate ufrag and pwd to the expected ones.
2405 EXPECT_TRUE(UpdateCandidateUfragPwd(&jdesc_, 0,
2406 "media+level+iceufrag", "media+level+icepwd"));
2407 EXPECT_TRUE(UpdateCandidateUfragPwd(&jdesc_, 1,
2408 "session+level+iceufrag", "session+level+icepwd"));
2409 EXPECT_TRUE(SdpDeserialize(sdp_with_ufrag_pwd, &jdesc_with_ufrag_pwd));
2410 EXPECT_TRUE(CompareSessionDescription(jdesc_, jdesc_with_ufrag_pwd));
2411}
2412
henrike@webrtc.org28e20752013-07-10 00:45:362413TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithRecvOnlyContent) {
2414 EXPECT_TRUE(TestDeserializeDirection(cricket::MD_RECVONLY));
2415}
2416
2417TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithSendOnlyContent) {
2418 EXPECT_TRUE(TestDeserializeDirection(cricket::MD_SENDONLY));
2419}
2420
2421TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithInactiveContent) {
2422 EXPECT_TRUE(TestDeserializeDirection(cricket::MD_INACTIVE));
2423}
2424
2425TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithRejectedAudio) {
2426 EXPECT_TRUE(TestDeserializeRejected(true, false));
2427}
2428
2429TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithRejectedVideo) {
2430 EXPECT_TRUE(TestDeserializeRejected(false, true));
2431}
2432
2433TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithRejectedAudioVideo) {
2434 EXPECT_TRUE(TestDeserializeRejected(true, true));
2435}
2436
2437// Tests that we can still handle the sdp uses mslabel and label instead of
2438// msid for backward compatibility.
2439TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithoutMsid) {
deadbeefc80741f2015-10-22 20:14:452440 jdesc_.description()->set_msid_supported(false);
henrike@webrtc.org28e20752013-07-10 00:45:362441 JsepSessionDescription jdesc(kDummyString);
2442 std::string sdp_without_msid = kSdpFullString;
2443 Replace("msid", "xmsid", &sdp_without_msid);
2444 // Deserialize
2445 EXPECT_TRUE(SdpDeserialize(sdp_without_msid, &jdesc));
2446 // Verify
2447 EXPECT_TRUE(CompareSessionDescription(jdesc_, jdesc));
2448}
2449
2450TEST_F(WebRtcSdpTest, DeserializeCandidate) {
2451 JsepIceCandidate jcandidate(kDummyMid, kDummyIndex);
2452
2453 std::string sdp = kSdpOneCandidate;
2454 EXPECT_TRUE(SdpDeserializeCandidate(sdp, &jcandidate));
2455 EXPECT_EQ(kDummyMid, jcandidate.sdp_mid());
2456 EXPECT_EQ(kDummyIndex, jcandidate.sdp_mline_index());
2457 EXPECT_TRUE(jcandidate.candidate().IsEquivalent(jcandidate_->candidate()));
honghaiza0c44ea2016-03-23 23:07:482458 EXPECT_EQ(0, jcandidate.candidate().network_cost());
henrike@webrtc.org28e20752013-07-10 00:45:362459
2460 // Candidate line without generation extension.
2461 sdp = kSdpOneCandidate;
2462 Replace(" generation 2", "", &sdp);
2463 EXPECT_TRUE(SdpDeserializeCandidate(sdp, &jcandidate));
2464 EXPECT_EQ(kDummyMid, jcandidate.sdp_mid());
2465 EXPECT_EQ(kDummyIndex, jcandidate.sdp_mline_index());
2466 Candidate expected = jcandidate_->candidate();
2467 expected.set_generation(0);
2468 EXPECT_TRUE(jcandidate.candidate().IsEquivalent(expected));
2469
honghaiza0c44ea2016-03-23 23:07:482470 // Candidate with network id and/or cost.
2471 sdp = kSdpOneCandidate;
2472 Replace(" generation 2", " generation 2 network-id 2", &sdp);
2473 EXPECT_TRUE(SdpDeserializeCandidate(sdp, &jcandidate));
2474 EXPECT_EQ(kDummyMid, jcandidate.sdp_mid());
2475 EXPECT_EQ(kDummyIndex, jcandidate.sdp_mline_index());
2476 expected = jcandidate_->candidate();
2477 expected.set_network_id(2);
2478 EXPECT_TRUE(jcandidate.candidate().IsEquivalent(expected));
2479 EXPECT_EQ(0, jcandidate.candidate().network_cost());
2480 // Add network cost
2481 Replace(" network-id 2", " network-id 2 network-cost 9", &sdp);
2482 EXPECT_TRUE(SdpDeserializeCandidate(sdp, &jcandidate));
2483 EXPECT_TRUE(jcandidate.candidate().IsEquivalent(expected));
2484 EXPECT_EQ(9, jcandidate.candidate().network_cost());
2485
mallinath@webrtc.org2d60c5e2014-08-08 22:29:202486 sdp = kSdpTcpActiveCandidate;
2487 EXPECT_TRUE(SdpDeserializeCandidate(sdp, &jcandidate));
2488 // Make a cricket::Candidate equivalent to kSdpTcpCandidate string.
guoweis@webrtc.org61c12472015-01-15 06:53:072489 Candidate candidate(ICE_CANDIDATE_COMPONENT_RTP, "tcp",
guoweis@webrtc.org950c5182014-12-16 23:01:312490 rtc::SocketAddress("192.168.1.5", 9), kCandidatePriority,
2491 "", "", LOCAL_PORT_TYPE, kCandidateGeneration,
2492 kCandidateFoundation1);
kwibergd1fe2812016-04-27 13:47:292493 std::unique_ptr<IceCandidateInterface> jcandidate_template(
2494 new JsepIceCandidate(std::string("audio_content_name"), 0, candidate));
mallinath@webrtc.org2d60c5e2014-08-08 22:29:202495 EXPECT_TRUE(jcandidate.candidate().IsEquivalent(
2496 jcandidate_template->candidate()));
2497 sdp = kSdpTcpPassiveCandidate;
2498 EXPECT_TRUE(SdpDeserializeCandidate(sdp, &jcandidate));
2499 sdp = kSdpTcpSOCandidate;
2500 EXPECT_TRUE(SdpDeserializeCandidate(sdp, &jcandidate));
henrike@webrtc.org28e20752013-07-10 00:45:362501}
2502
2503// This test verifies the deserialization of candidate-attribute
2504// as per RFC 5245. Candiate-attribute will be of the format
2505// candidate:<blah>. This format will be used when candidates
2506// are trickled.
2507TEST_F(WebRtcSdpTest, DeserializeRawCandidateAttribute) {
2508 JsepIceCandidate jcandidate(kDummyMid, kDummyIndex);
2509
2510 std::string candidate_attribute = kRawCandidate;
2511 EXPECT_TRUE(SdpDeserializeCandidate(candidate_attribute, &jcandidate));
2512 EXPECT_EQ(kDummyMid, jcandidate.sdp_mid());
2513 EXPECT_EQ(kDummyIndex, jcandidate.sdp_mline_index());
2514 EXPECT_TRUE(jcandidate.candidate().IsEquivalent(jcandidate_->candidate()));
2515 EXPECT_EQ(2u, jcandidate.candidate().generation());
2516
2517 // Candidate line without generation extension.
2518 candidate_attribute = kRawCandidate;
2519 Replace(" generation 2", "", &candidate_attribute);
2520 EXPECT_TRUE(SdpDeserializeCandidate(candidate_attribute, &jcandidate));
2521 EXPECT_EQ(kDummyMid, jcandidate.sdp_mid());
2522 EXPECT_EQ(kDummyIndex, jcandidate.sdp_mline_index());
2523 Candidate expected = jcandidate_->candidate();
2524 expected.set_generation(0);
2525 EXPECT_TRUE(jcandidate.candidate().IsEquivalent(expected));
2526
2527 // Candidate line without candidate:
2528 candidate_attribute = kRawCandidate;
2529 Replace("candidate:", "", &candidate_attribute);
2530 EXPECT_FALSE(SdpDeserializeCandidate(candidate_attribute, &jcandidate));
2531
jiayl@webrtc.org7ec3f9f2014-08-08 23:09:152532 // Candidate line with IPV6 address.
2533 EXPECT_TRUE(SdpDeserializeCandidate(kRawIPV6Candidate, &jcandidate));
2534}
2535
2536// This test verifies that the deserialization of an invalid candidate string
2537// fails.
2538TEST_F(WebRtcSdpTest, DeserializeInvalidCandidiate) {
2539 JsepIceCandidate jcandidate(kDummyMid, kDummyIndex);
2540
2541 std::string candidate_attribute = kRawCandidate;
2542 candidate_attribute.replace(0, 1, "x");
henrike@webrtc.org28e20752013-07-10 00:45:362543 EXPECT_FALSE(SdpDeserializeCandidate(candidate_attribute, &jcandidate));
jiayl@webrtc.org7ec3f9f2014-08-08 23:09:152544
2545 candidate_attribute = kSdpOneCandidate;
2546 candidate_attribute.replace(0, 1, "x");
2547 EXPECT_FALSE(SdpDeserializeCandidate(candidate_attribute, &jcandidate));
2548
2549 candidate_attribute = kRawCandidate;
2550 candidate_attribute.append("\r\n");
2551 candidate_attribute.append(kRawCandidate);
2552 EXPECT_FALSE(SdpDeserializeCandidate(candidate_attribute, &jcandidate));
2553
2554 EXPECT_FALSE(SdpDeserializeCandidate(kSdpTcpInvalidCandidate, &jcandidate));
henrike@webrtc.org28e20752013-07-10 00:45:362555}
2556
2557TEST_F(WebRtcSdpTest, DeserializeSdpWithRtpDataChannels) {
2558 AddRtpDataChannel();
2559 JsepSessionDescription jdesc(kDummyString);
2560 ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion));
2561
2562 std::string sdp_with_data = kSdpString;
2563 sdp_with_data.append(kSdpRtpDataChannelString);
2564 JsepSessionDescription jdesc_output(kDummyString);
2565
2566 // Deserialize
2567 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output));
2568 // Verify
2569 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output));
2570}
2571
2572TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannels) {
2573 AddSctpDataChannel();
2574 JsepSessionDescription jdesc(kDummyString);
2575 ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion));
2576
2577 std::string sdp_with_data = kSdpString;
2578 sdp_with_data.append(kSdpSctpDataChannelString);
2579 JsepSessionDescription jdesc_output(kDummyString);
2580
lally@webrtc.org36300852015-02-24 20:19:352581 // Verify with DTLS/SCTP (already in kSdpSctpDataChannelString).
2582 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output));
2583 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output));
2584
2585 // Verify with UDP/DTLS/SCTP.
2586 sdp_with_data.replace(sdp_with_data.find(kDtlsSctp),
2587 strlen(kDtlsSctp), kUdpDtlsSctp);
2588 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output));
2589 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output));
2590
2591 // Verify with TCP/DTLS/SCTP.
2592 sdp_with_data.replace(sdp_with_data.find(kUdpDtlsSctp),
2593 strlen(kUdpDtlsSctp), kTcpDtlsSctp);
henrike@webrtc.org28e20752013-07-10 00:45:362594 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output));
2595 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output));
2596}
2597
jiayl@webrtc.orgddb85ab2014-09-05 16:31:562598TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannelsWithSctpPort) {
2599 AddSctpDataChannel();
2600 JsepSessionDescription jdesc(kDummyString);
2601 ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion));
2602
2603 std::string sdp_with_data = kSdpString;
2604 sdp_with_data.append(kSdpSctpDataChannelStringWithSctpPort);
2605 JsepSessionDescription jdesc_output(kDummyString);
2606
lally@webrtc.org36300852015-02-24 20:19:352607 // Verify with DTLS/SCTP (already in kSdpSctpDataChannelStringWithSctpPort).
jiayl@webrtc.orgddb85ab2014-09-05 16:31:562608 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output));
2609 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output));
jiayl@webrtc.orgddb85ab2014-09-05 16:31:562610
lally@webrtc.org36300852015-02-24 20:19:352611 // Verify with UDP/DTLS/SCTP.
2612 sdp_with_data.replace(sdp_with_data.find(kDtlsSctp),
2613 strlen(kDtlsSctp), kUdpDtlsSctp);
2614 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output));
2615 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output));
lally@webrtc.orgc7848b72015-02-24 20:19:262616
lally@webrtc.org36300852015-02-24 20:19:352617 // Verify with TCP/DTLS/SCTP.
2618 sdp_with_data.replace(sdp_with_data.find(kUdpDtlsSctp),
2619 strlen(kUdpDtlsSctp), kTcpDtlsSctp);
lally@webrtc.orgc7848b72015-02-24 20:19:262620 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output));
2621 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output));
2622}
2623
lally69f57602015-10-08 17:15:042624TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannelsWithSctpColonPort) {
2625 AddSctpDataChannel();
2626 JsepSessionDescription jdesc(kDummyString);
2627 ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion));
2628
2629 std::string sdp_with_data = kSdpString;
2630 sdp_with_data.append(kSdpSctpDataChannelStringWithSctpColonPort);
2631 JsepSessionDescription jdesc_output(kDummyString);
2632
2633 // Verify with DTLS/SCTP.
2634 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output));
2635 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output));
2636
2637 // Verify with UDP/DTLS/SCTP.
2638 sdp_with_data.replace(sdp_with_data.find(kDtlsSctp),
2639 strlen(kDtlsSctp), kUdpDtlsSctp);
2640 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output));
2641 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output));
2642
2643 // Verify with TCP/DTLS/SCTP.
2644 sdp_with_data.replace(sdp_with_data.find(kUdpDtlsSctp),
2645 strlen(kUdpDtlsSctp), kTcpDtlsSctp);
2646 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output));
2647 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output));
2648}
2649
jiayl@webrtc.orgddb85ab2014-09-05 16:31:562650// Test to check the behaviour if sctp-port is specified
2651// on the m= line and in a=sctp-port.
2652TEST_F(WebRtcSdpTest, DeserializeSdpWithMultiSctpPort) {
2653 AddSctpDataChannel();
2654 JsepSessionDescription jdesc(kDummyString);
2655 ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion));
2656
2657 std::string sdp_with_data = kSdpString;
2658 // Append m= attributes
2659 sdp_with_data.append(kSdpSctpDataChannelString);
2660 // Append a=sctp-port attribute
2661 sdp_with_data.append("a=sctp-port 5000\r\n");
2662 JsepSessionDescription jdesc_output(kDummyString);
2663
2664 EXPECT_FALSE(SdpDeserialize(sdp_with_data, &jdesc_output));
2665}
2666
henrike@webrtc.org571df2d2014-02-19 23:04:262667// For crbug/344475.
2668TEST_F(WebRtcSdpTest, DeserializeSdpWithCorruptedSctpDataChannels) {
2669 std::string sdp_with_data = kSdpString;
2670 sdp_with_data.append(kSdpSctpDataChannelString);
2671 // Remove the "\n" at the end.
2672 sdp_with_data = sdp_with_data.substr(0, sdp_with_data.size() - 1);
2673 JsepSessionDescription jdesc_output(kDummyString);
2674
2675 EXPECT_FALSE(SdpDeserialize(sdp_with_data, &jdesc_output));
2676 // No crash is a pass.
2677}
2678
wu@webrtc.org78187522013-10-07 23:32:022679TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannelAndNewPort) {
2680 AddSctpDataChannel();
Peter Boström0c4e06b2015-10-07 10:23:212681 const uint16_t kUnusualSctpPort = 9556;
wu@webrtc.org78187522013-10-07 23:32:022682 char default_portstr[16];
2683 char unusual_portstr[16];
buildbot@webrtc.orgd4e598d2014-07-29 17:36:522684 rtc::sprintfn(default_portstr, sizeof(default_portstr), "%d",
wu@webrtc.org78187522013-10-07 23:32:022685 kDefaultSctpPort);
buildbot@webrtc.orgd4e598d2014-07-29 17:36:522686 rtc::sprintfn(unusual_portstr, sizeof(unusual_portstr), "%d",
wu@webrtc.org78187522013-10-07 23:32:022687 kUnusualSctpPort);
2688
jiayl@webrtc.org9c16c392014-05-01 18:30:302689 // First setup the expected JsepSessionDescription.
wu@webrtc.org78187522013-10-07 23:32:022690 JsepSessionDescription jdesc(kDummyString);
2691 // take our pre-built session description and change the SCTP port.
2692 cricket::SessionDescription* mutant = desc_.Copy();
2693 DataContentDescription* dcdesc = static_cast<DataContentDescription*>(
2694 mutant->GetContentDescriptionByName(kDataContentName));
2695 std::vector<cricket::DataCodec> codecs(dcdesc->codecs());
pkasting@chromium.orgd3245462015-02-23 21:28:222696 EXPECT_EQ(1U, codecs.size());
solenberg9fa49752016-10-08 20:02:442697 EXPECT_EQ(cricket::kGoogleSctpDataCodecPlType, codecs[0].id);
wu@webrtc.org78187522013-10-07 23:32:022698 codecs[0].SetParam(cricket::kCodecParamPort, kUnusualSctpPort);
jiayl@webrtc.org9c16c392014-05-01 18:30:302699 dcdesc->set_codecs(codecs);
wu@webrtc.org78187522013-10-07 23:32:022700
2701 // note: mutant's owned by jdesc now.
2702 ASSERT_TRUE(jdesc.Initialize(mutant, kSessionId, kSessionVersion));
2703 mutant = NULL;
2704
jiayl@webrtc.org9c16c392014-05-01 18:30:302705 // Then get the deserialized JsepSessionDescription.
wu@webrtc.org78187522013-10-07 23:32:022706 std::string sdp_with_data = kSdpString;
2707 sdp_with_data.append(kSdpSctpDataChannelString);
buildbot@webrtc.orgd4e598d2014-07-29 17:36:522708 rtc::replace_substrs(default_portstr, strlen(default_portstr),
wu@webrtc.org78187522013-10-07 23:32:022709 unusual_portstr, strlen(unusual_portstr),
2710 &sdp_with_data);
2711 JsepSessionDescription jdesc_output(kDummyString);
2712
2713 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output));
2714 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output));
jiayl@webrtc.orgddb85ab2014-09-05 16:31:562715
2716 // We need to test the deserialized JsepSessionDescription from
2717 // kSdpSctpDataChannelStringWithSctpPort for
2718 // draft-ietf-mmusic-sctp-sdp-07
2719 // a=sctp-port
2720 sdp_with_data = kSdpString;
2721 sdp_with_data.append(kSdpSctpDataChannelStringWithSctpPort);
2722 rtc::replace_substrs(default_portstr, strlen(default_portstr),
2723 unusual_portstr, strlen(unusual_portstr),
2724 &sdp_with_data);
2725
2726 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output));
2727 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output));
wu@webrtc.org78187522013-10-07 23:32:022728}
2729
wu@webrtc.orgcadf9042013-08-30 21:24:162730TEST_F(WebRtcSdpTest, DeserializeSdpWithRtpDataChannelsAndBandwidth) {
Peter Thatcherc0c3a862015-06-24 22:31:252731 // We want to test that deserializing data content limits bandwidth
2732 // settings (it should never be greater than the default).
2733 // This should prevent someone from using unlimited data bandwidth through
2734 // JS and "breaking the Internet".
2735 // See: https://code.google.com/p/chromium/issues/detail?id=280726
wu@webrtc.orgcadf9042013-08-30 21:24:162736 std::string sdp_with_bandwidth = kSdpString;
2737 sdp_with_bandwidth.append(kSdpRtpDataChannelString);
2738 InjectAfter("a=mid:data_content_name\r\n",
2739 "b=AS:100\r\n",
2740 &sdp_with_bandwidth);
2741 JsepSessionDescription jdesc_with_bandwidth(kDummyString);
2742
Peter Thatcherc0c3a862015-06-24 22:31:252743 EXPECT_FALSE(SdpDeserialize(sdp_with_bandwidth, &jdesc_with_bandwidth));
2744}
2745
2746TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannelsAndBandwidth) {
2747 AddSctpDataChannel();
2748 JsepSessionDescription jdesc(kDummyString);
2749 DataContentDescription* dcd = static_cast<DataContentDescription*>(
2750 GetFirstDataContent(&desc_)->description);
2751 dcd->set_bandwidth(100 * 1000);
2752 ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion));
2753
2754 std::string sdp_with_bandwidth = kSdpString;
2755 sdp_with_bandwidth.append(kSdpSctpDataChannelString);
2756 InjectAfter("a=mid:data_content_name\r\n",
2757 "b=AS:100\r\n",
2758 &sdp_with_bandwidth);
2759 JsepSessionDescription jdesc_with_bandwidth(kDummyString);
2760
2761 // SCTP has congestion control, so we shouldn't limit the bandwidth
2762 // as we do for RTP.
2763 EXPECT_TRUE(SdpDeserialize(sdp_with_bandwidth, &jdesc_with_bandwidth));
wu@webrtc.orgcadf9042013-08-30 21:24:162764 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_with_bandwidth));
2765}
2766
henrike@webrtc.org28e20752013-07-10 00:45:362767TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithSessionLevelExtmap) {
2768 TestDeserializeExtmap(true, false);
2769}
2770
2771TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithMediaLevelExtmap) {
2772 TestDeserializeExtmap(false, true);
2773}
2774
2775TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithInvalidExtmap) {
2776 TestDeserializeExtmap(true, true);
2777}
2778
sergeyu@chromium.org5bc25c42013-12-05 00:24:062779TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithoutEndLineBreak) {
2780 JsepSessionDescription jdesc(kDummyString);
2781 std::string sdp = kSdpFullString;
2782 sdp = sdp.substr(0, sdp.size() - 2); // Remove \r\n at the end.
2783 // Deserialize
2784 SdpParseError error;
2785 EXPECT_FALSE(webrtc::SdpDeserialize(sdp, &jdesc, &error));
deadbeef9d3584c2016-02-17 01:54:102786 const std::string lastline = "a=ssrc:3 label:video_track_id_1";
sergeyu@chromium.org5bc25c42013-12-05 00:24:062787 EXPECT_EQ(lastline, error.line);
2788 EXPECT_EQ("Invalid SDP line.", error.description);
2789}
2790
henrike@webrtc.org28e20752013-07-10 00:45:362791TEST_F(WebRtcSdpTest, DeserializeCandidateWithDifferentTransport) {
2792 JsepIceCandidate jcandidate(kDummyMid, kDummyIndex);
2793 std::string new_sdp = kSdpOneCandidate;
2794 Replace("udp", "unsupported_transport", &new_sdp);
2795 EXPECT_FALSE(SdpDeserializeCandidate(new_sdp, &jcandidate));
2796 new_sdp = kSdpOneCandidate;
2797 Replace("udp", "uDP", &new_sdp);
2798 EXPECT_TRUE(SdpDeserializeCandidate(new_sdp, &jcandidate));
2799 EXPECT_EQ(kDummyMid, jcandidate.sdp_mid());
2800 EXPECT_EQ(kDummyIndex, jcandidate.sdp_mline_index());
2801 EXPECT_TRUE(jcandidate.candidate().IsEquivalent(jcandidate_->candidate()));
2802}
2803
honghaiza54a0802015-12-17 02:37:232804TEST_F(WebRtcSdpTest, DeserializeCandidateWithUfragPwd) {
henrike@webrtc.org28e20752013-07-10 00:45:362805 JsepIceCandidate jcandidate(kDummyMid, kDummyIndex);
honghaiza54a0802015-12-17 02:37:232806 EXPECT_TRUE(
2807 SdpDeserializeCandidate(kSdpOneCandidateWithUfragPwd, &jcandidate));
henrike@webrtc.org28e20752013-07-10 00:45:362808 EXPECT_EQ(kDummyMid, jcandidate.sdp_mid());
2809 EXPECT_EQ(kDummyIndex, jcandidate.sdp_mline_index());
2810 Candidate ref_candidate = jcandidate_->candidate();
2811 ref_candidate.set_username("user_rtp");
2812 ref_candidate.set_password("password_rtp");
2813 EXPECT_TRUE(jcandidate.candidate().IsEquivalent(ref_candidate));
2814}
2815
henrike@webrtc.org704bf9e2014-02-27 17:52:042816TEST_F(WebRtcSdpTest, DeserializeSdpWithConferenceFlag) {
2817 JsepSessionDescription jdesc(kDummyString);
2818
2819 // Deserialize
2820 EXPECT_TRUE(SdpDeserialize(kSdpConferenceString, &jdesc));
2821
2822 // Verify
2823 cricket::AudioContentDescription* audio =
2824 static_cast<AudioContentDescription*>(
2825 jdesc.description()->GetContentDescriptionByName(cricket::CN_AUDIO));
2826 EXPECT_TRUE(audio->conference_mode());
2827
2828 cricket::VideoContentDescription* video =
2829 static_cast<VideoContentDescription*>(
2830 jdesc.description()->GetContentDescriptionByName(cricket::CN_VIDEO));
2831 EXPECT_TRUE(video->conference_mode());
2832}
2833
henrike@webrtc.org28e20752013-07-10 00:45:362834TEST_F(WebRtcSdpTest, DeserializeBrokenSdp) {
2835 const char kSdpDestroyer[] = "!@#$%^&";
decurtis@webrtc.org8af11042015-01-07 19:15:512836 const char kSdpEmptyType[] = " =candidate";
2837 const char kSdpEqualAsPlus[] = "a+candidate";
2838 const char kSdpSpaceAfterEqual[] = "a= candidate";
2839 const char kSdpUpperType[] = "A=candidate";
2840 const char kSdpEmptyLine[] = "";
2841 const char kSdpMissingValue[] = "a=";
2842
2843 const char kSdpBrokenFingerprint[] = "a=fingerprint:sha-1 "
henrike@webrtc.org28e20752013-07-10 00:45:362844 "4AAD:B9:B1:3F:82:18:3B:54:02:12:DF:3E:5D:49:6B:19:E5:7C:AB";
decurtis@webrtc.org8af11042015-01-07 19:15:512845 const char kSdpExtraField[] = "a=fingerprint:sha-1 "
henrike@webrtc.org28e20752013-07-10 00:45:362846 "4A:AD:B9:B1:3F:82:18:3B:54:02:12:DF:3E:5D:49:6B:19:E5:7C:AB XXX";
decurtis@webrtc.org8af11042015-01-07 19:15:512847 const char kSdpMissingSpace[] = "a=fingerprint:sha-1"
henrike@webrtc.org28e20752013-07-10 00:45:362848 "4A:AD:B9:B1:3F:82:18:3B:54:02:12:DF:3E:5D:49:6B:19:E5:7C:AB";
henrika@webrtc.orgaebb1ad2014-01-14 10:00:582849 // MD5 is not allowed in fingerprints.
decurtis@webrtc.org8af11042015-01-07 19:15:512850 const char kSdpMd5[] = "a=fingerprint:md5 "
henrika@webrtc.orgaebb1ad2014-01-14 10:00:582851 "4A:AD:B9:B1:3F:82:18:3B:54:02:12:DF:3E:5D:49:6B";
henrike@webrtc.org28e20752013-07-10 00:45:362852
2853 // Broken session description
wu@webrtc.org5e760e72014-04-02 23:19:092854 ExpectParseFailure("v=", kSdpDestroyer);
2855 ExpectParseFailure("o=", kSdpDestroyer);
2856 ExpectParseFailure("s=-", kSdpDestroyer);
henrike@webrtc.org28e20752013-07-10 00:45:362857 // Broken time description
wu@webrtc.org5e760e72014-04-02 23:19:092858 ExpectParseFailure("t=", kSdpDestroyer);
henrike@webrtc.org28e20752013-07-10 00:45:362859
2860 // Broken media description
wu@webrtc.org5e760e72014-04-02 23:19:092861 ExpectParseFailure("m=audio", "c=IN IP4 74.125.224.39");
2862 ExpectParseFailure("m=video", kSdpDestroyer);
henrike@webrtc.org28e20752013-07-10 00:45:362863
2864 // Invalid lines
decurtis@webrtc.org8af11042015-01-07 19:15:512865 ExpectParseFailure("a=candidate", kSdpEmptyType);
2866 ExpectParseFailure("a=candidate", kSdpEqualAsPlus);
2867 ExpectParseFailure("a=candidate", kSdpSpaceAfterEqual);
2868 ExpectParseFailure("a=candidate", kSdpUpperType);
henrike@webrtc.org28e20752013-07-10 00:45:362869
2870 // Bogus fingerprint replacing a=sendrev. We selected this attribute
2871 // because it's orthogonal to what we are replacing and hence
2872 // safe.
decurtis@webrtc.org8af11042015-01-07 19:15:512873 ExpectParseFailure("a=sendrecv", kSdpBrokenFingerprint);
2874 ExpectParseFailure("a=sendrecv", kSdpExtraField);
2875 ExpectParseFailure("a=sendrecv", kSdpMissingSpace);
2876 ExpectParseFailure("a=sendrecv", kSdpMd5);
2877
2878 // Empty Line
2879 ExpectParseFailure("a=rtcp:2347 IN IP4 74.125.127.126", kSdpEmptyLine);
2880 ExpectParseFailure("a=rtcp:2347 IN IP4 74.125.127.126", kSdpMissingValue);
wu@webrtc.org5e760e72014-04-02 23:19:092881}
2882
2883TEST_F(WebRtcSdpTest, DeserializeSdpWithInvalidAttributeValue) {
2884 // ssrc
2885 ExpectParseFailure("a=ssrc:1", "a=ssrc:badvalue");
deadbeef9d3584c2016-02-17 01:54:102886 ExpectParseFailure("a=ssrc-group:FEC 2 3", "a=ssrc-group:FEC badvalue 3");
wu@webrtc.org5e760e72014-04-02 23:19:092887 // crypto
2888 ExpectParseFailure("a=crypto:1 ", "a=crypto:badvalue ");
2889 // rtpmap
2890 ExpectParseFailure("a=rtpmap:111 ", "a=rtpmap:badvalue ");
2891 ExpectParseFailure("opus/48000/2", "opus/badvalue/2");
2892 ExpectParseFailure("opus/48000/2", "opus/48000/badvalue");
2893 // candidate
2894 ExpectParseFailure("1 udp 2130706432", "badvalue udp 2130706432");
2895 ExpectParseFailure("1 udp 2130706432", "1 udp badvalue");
2896 ExpectParseFailure("192.168.1.5 1234", "192.168.1.5 badvalue");
2897 ExpectParseFailure("rport 2346", "rport badvalue");
2898 ExpectParseFailure("rport 2346 generation 2",
2899 "rport 2346 generation badvalue");
2900 // m line
2901 ExpectParseFailure("m=audio 2345 RTP/SAVPF 111 103 104",
2902 "m=audio 2345 RTP/SAVPF 111 badvalue 104");
2903
2904 // bandwidth
2905 ExpectParseFailureWithNewLines("a=mid:video_content_name\r\n",
2906 "b=AS:badvalue\r\n",
2907 "b=AS:badvalue");
2908 // rtcp-fb
2909 ExpectParseFailureWithNewLines("a=mid:video_content_name\r\n",
2910 "a=rtcp-fb:badvalue nack\r\n",
2911 "a=rtcp-fb:badvalue nack");
2912 // extmap
2913 ExpectParseFailureWithNewLines("a=mid:video_content_name\r\n",
2914 "a=extmap:badvalue http://example.com\r\n",
2915 "a=extmap:badvalue http://example.com");
henrike@webrtc.org28e20752013-07-10 00:45:362916}
2917
2918TEST_F(WebRtcSdpTest, DeserializeSdpWithReorderedPltypes) {
2919 JsepSessionDescription jdesc_output(kDummyString);
2920
2921 const char kSdpWithReorderedPlTypesString[] =
2922 "v=0\r\n"
2923 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n"
2924 "s=-\r\n"
2925 "t=0 0\r\n"
pthatcher@webrtc.orgc9d6d142014-10-23 23:37:222926 "m=audio 9 RTP/SAVPF 104 103\r\n" // Pl type 104 preferred.
henrike@webrtc.org28e20752013-07-10 00:45:362927 "a=rtpmap:111 opus/48000/2\r\n" // Pltype 111 listed before 103 and 104
2928 // in the map.
2929 "a=rtpmap:103 ISAC/16000\r\n" // Pltype 103 listed before 104 in the map.
minyue@webrtc.orgf9b5c1b2015-02-17 12:36:412930 "a=rtpmap:104 ISAC/32000\r\n";
henrike@webrtc.org28e20752013-07-10 00:45:362931
2932 // Deserialize
2933 EXPECT_TRUE(SdpDeserialize(kSdpWithReorderedPlTypesString, &jdesc_output));
2934
2935 const ContentInfo* ac = GetFirstAudioContent(jdesc_output.description());
2936 ASSERT_TRUE(ac != NULL);
2937 const AudioContentDescription* acd =
2938 static_cast<const AudioContentDescription*>(ac->description);
2939 ASSERT_FALSE(acd->codecs().empty());
minyue@webrtc.orgf9b5c1b2015-02-17 12:36:412940 EXPECT_EQ("ISAC", acd->codecs()[0].name);
2941 EXPECT_EQ(32000, acd->codecs()[0].clockrate);
henrike@webrtc.org28e20752013-07-10 00:45:362942 EXPECT_EQ(104, acd->codecs()[0].id);
2943}
2944
2945TEST_F(WebRtcSdpTest, DeserializeSerializeCodecParams) {
2946 JsepSessionDescription jdesc_output(kDummyString);
2947 CodecParams params;
2948 params.max_ptime = 40;
2949 params.ptime = 30;
2950 params.min_ptime = 10;
2951 params.sprop_stereo = 1;
2952 params.stereo = 1;
2953 params.useinband = 1;
henrike@webrtc.org1e09a712013-07-26 19:17:592954 params.maxaveragebitrate = 128000;
henrike@webrtc.org28e20752013-07-10 00:45:362955 TestDeserializeCodecParams(params, &jdesc_output);
deadbeef9d3584c2016-02-17 01:54:102956 TestSerialize(jdesc_output, false);
henrike@webrtc.org28e20752013-07-10 00:45:362957}
2958
2959TEST_F(WebRtcSdpTest, DeserializeSerializeRtcpFb) {
2960 const bool kUseWildcard = false;
2961 JsepSessionDescription jdesc_output(kDummyString);
2962 TestDeserializeRtcpFb(&jdesc_output, kUseWildcard);
deadbeef9d3584c2016-02-17 01:54:102963 TestSerialize(jdesc_output, false);
henrike@webrtc.org28e20752013-07-10 00:45:362964}
2965
2966TEST_F(WebRtcSdpTest, DeserializeSerializeRtcpFbWildcard) {
2967 const bool kUseWildcard = true;
2968 JsepSessionDescription jdesc_output(kDummyString);
2969 TestDeserializeRtcpFb(&jdesc_output, kUseWildcard);
deadbeef9d3584c2016-02-17 01:54:102970 TestSerialize(jdesc_output, false);
henrike@webrtc.org28e20752013-07-10 00:45:362971}
2972
2973TEST_F(WebRtcSdpTest, DeserializeVideoFmtp) {
2974 JsepSessionDescription jdesc_output(kDummyString);
2975
2976 const char kSdpWithFmtpString[] =
2977 "v=0\r\n"
2978 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n"
2979 "s=-\r\n"
2980 "t=0 0\r\n"
2981 "m=video 3457 RTP/SAVPF 120\r\n"
2982 "a=rtpmap:120 VP8/90000\r\n"
Donald Curtis0e07f922015-05-15 16:21:232983 "a=fmtp:120 x-google-min-bitrate=10;x-google-max-quantization=40\r\n";
2984
2985 // Deserialize
2986 SdpParseError error;
Donald Curtis144d0182015-05-15 20:14:242987 EXPECT_TRUE(
2988 webrtc::SdpDeserialize(kSdpWithFmtpString, &jdesc_output, &error));
Donald Curtis0e07f922015-05-15 16:21:232989
2990 const ContentInfo* vc = GetFirstVideoContent(jdesc_output.description());
2991 ASSERT_TRUE(vc != NULL);
2992 const VideoContentDescription* vcd =
2993 static_cast<const VideoContentDescription*>(vc->description);
2994 ASSERT_FALSE(vcd->codecs().empty());
2995 cricket::VideoCodec vp8 = vcd->codecs()[0];
2996 EXPECT_EQ("VP8", vp8.name);
2997 EXPECT_EQ(120, vp8.id);
2998 cricket::CodecParameterMap::iterator found =
2999 vp8.params.find("x-google-min-bitrate");
3000 ASSERT_TRUE(found != vp8.params.end());
3001 EXPECT_EQ(found->second, "10");
3002 found = vp8.params.find("x-google-max-quantization");
3003 ASSERT_TRUE(found != vp8.params.end());
3004 EXPECT_EQ(found->second, "40");
3005}
3006
johan2d8d23e2016-06-03 08:22:423007TEST_F(WebRtcSdpTest, DeserializeVideoFmtpWithSprops) {
3008 JsepSessionDescription jdesc_output(kDummyString);
3009
3010 const char kSdpWithFmtpString[] =
3011 "v=0\r\n"
3012 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n"
3013 "s=-\r\n"
3014 "t=0 0\r\n"
3015 "m=video 49170 RTP/AVP 98\r\n"
3016 "a=rtpmap:98 H264/90000\r\n"
3017 "a=fmtp:98 profile-level-id=42A01E; "
3018 "sprop-parameter-sets=Z0IACpZTBYmI,aMljiA==\r\n";
3019
3020 // Deserialize.
3021 SdpParseError error;
3022 EXPECT_TRUE(
3023 webrtc::SdpDeserialize(kSdpWithFmtpString, &jdesc_output, &error));
3024
3025 const ContentInfo* vc = GetFirstVideoContent(jdesc_output.description());
3026 ASSERT_TRUE(vc != NULL);
3027 const VideoContentDescription* vcd =
3028 static_cast<const VideoContentDescription*>(vc->description);
3029 ASSERT_TRUE(vcd != NULL);
3030 ASSERT_FALSE(vcd->codecs().empty());
3031 cricket::VideoCodec h264 = vcd->codecs()[0];
3032 EXPECT_EQ("H264", h264.name);
3033 EXPECT_EQ(98, h264.id);
3034 cricket::CodecParameterMap::const_iterator found =
3035 h264.params.find("profile-level-id");
3036 ASSERT_TRUE(found != h264.params.end());
3037 EXPECT_EQ(found->second, "42A01E");
3038 found = h264.params.find("sprop-parameter-sets");
3039 ASSERT_TRUE(found != h264.params.end());
3040 EXPECT_EQ(found->second, "Z0IACpZTBYmI,aMljiA==");
3041}
3042
Donald Curtis0e07f922015-05-15 16:21:233043TEST_F(WebRtcSdpTest, DeserializeVideoFmtpWithSpace) {
3044 JsepSessionDescription jdesc_output(kDummyString);
3045
3046 const char kSdpWithFmtpString[] =
3047 "v=0\r\n"
3048 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n"
3049 "s=-\r\n"
3050 "t=0 0\r\n"
3051 "m=video 3457 RTP/SAVPF 120\r\n"
3052 "a=rtpmap:120 VP8/90000\r\n"
3053 "a=fmtp:120 x-google-min-bitrate=10; x-google-max-quantization=40\r\n";
henrike@webrtc.org28e20752013-07-10 00:45:363054
3055 // Deserialize
3056 SdpParseError error;
3057 EXPECT_TRUE(webrtc::SdpDeserialize(kSdpWithFmtpString, &jdesc_output,
3058 &error));
3059
3060 const ContentInfo* vc = GetFirstVideoContent(jdesc_output.description());
3061 ASSERT_TRUE(vc != NULL);
3062 const VideoContentDescription* vcd =
3063 static_cast<const VideoContentDescription*>(vc->description);
3064 ASSERT_FALSE(vcd->codecs().empty());
3065 cricket::VideoCodec vp8 = vcd->codecs()[0];
3066 EXPECT_EQ("VP8", vp8.name);
3067 EXPECT_EQ(120, vp8.id);
3068 cricket::CodecParameterMap::iterator found =
3069 vp8.params.find("x-google-min-bitrate");
3070 ASSERT_TRUE(found != vp8.params.end());
3071 EXPECT_EQ(found->second, "10");
3072 found = vp8.params.find("x-google-max-quantization");
3073 ASSERT_TRUE(found != vp8.params.end());
3074 EXPECT_EQ(found->second, "40");
3075}
3076
ossuaa4b0772017-01-30 15:41:183077TEST_F(WebRtcSdpTest, SerializeAudioFmtpWithUnknownParameter) {
3078 AudioContentDescription* acd = static_cast<AudioContentDescription*>(
3079 GetFirstAudioContent(&desc_)->description);
3080
3081 cricket::AudioCodecs codecs = acd->codecs();
3082 codecs[0].params["unknown-future-parameter"] = "SomeFutureValue";
3083 acd->set_codecs(codecs);
3084
3085 ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(),
3086 jdesc_.session_id(),
3087 jdesc_.session_version()));
3088 std::string message = webrtc::SdpSerialize(jdesc_, false);
3089 std::string sdp_with_fmtp = kSdpFullString;
3090 InjectAfter("a=rtpmap:111 opus/48000/2\r\n",
3091 "a=fmtp:111 unknown-future-parameter=SomeFutureValue\r\n",
3092 &sdp_with_fmtp);
3093 EXPECT_EQ(sdp_with_fmtp, message);
3094}
3095
3096TEST_F(WebRtcSdpTest, SerializeAudioFmtpWithKnownFmtpParameter) {
3097 AudioContentDescription* acd = static_cast<AudioContentDescription*>(
3098 GetFirstAudioContent(&desc_)->description);
3099
3100 cricket::AudioCodecs codecs = acd->codecs();
3101 codecs[0].params["stereo"] = "1";
3102 acd->set_codecs(codecs);
3103
3104 ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(),
3105 jdesc_.session_id(),
3106 jdesc_.session_version()));
3107 std::string message = webrtc::SdpSerialize(jdesc_, false);
3108 std::string sdp_with_fmtp = kSdpFullString;
3109 InjectAfter("a=rtpmap:111 opus/48000/2\r\n",
3110 "a=fmtp:111 stereo=1\r\n",
3111 &sdp_with_fmtp);
3112 EXPECT_EQ(sdp_with_fmtp, message);
3113}
3114
3115TEST_F(WebRtcSdpTest, SerializeAudioFmtpWithPTimeAndMaxPTime) {
3116 AudioContentDescription* acd = static_cast<AudioContentDescription*>(
3117 GetFirstAudioContent(&desc_)->description);
3118
3119 cricket::AudioCodecs codecs = acd->codecs();
3120 codecs[0].params["ptime"] = "20";
3121 codecs[0].params["maxptime"] = "120";
3122 acd->set_codecs(codecs);
3123
3124 ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(),
3125 jdesc_.session_id(),
3126 jdesc_.session_version()));
3127 std::string message = webrtc::SdpSerialize(jdesc_, false);
3128 std::string sdp_with_fmtp = kSdpFullString;
3129 InjectAfter("a=rtpmap:104 ISAC/32000\r\n",
3130 "a=maxptime:120\r\n" // No comma here. String merging!
3131 "a=ptime:20\r\n",
3132 &sdp_with_fmtp);
3133 EXPECT_EQ(sdp_with_fmtp, message);
3134}
3135
henrike@webrtc.org28e20752013-07-10 00:45:363136TEST_F(WebRtcSdpTest, SerializeVideoFmtp) {
3137 VideoContentDescription* vcd = static_cast<VideoContentDescription*>(
3138 GetFirstVideoContent(&desc_)->description);
3139
3140 cricket::VideoCodecs codecs = vcd->codecs();
3141 codecs[0].params["x-google-min-bitrate"] = "10";
3142 vcd->set_codecs(codecs);
3143
3144 ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(),
3145 jdesc_.session_id(),
3146 jdesc_.session_version()));
deadbeef9d3584c2016-02-17 01:54:103147 std::string message = webrtc::SdpSerialize(jdesc_, false);
henrike@webrtc.org28e20752013-07-10 00:45:363148 std::string sdp_with_fmtp = kSdpFullString;
3149 InjectAfter("a=rtpmap:120 VP8/90000\r\n",
3150 "a=fmtp:120 x-google-min-bitrate=10\r\n",
3151 &sdp_with_fmtp);
3152 EXPECT_EQ(sdp_with_fmtp, message);
3153}
3154
3155TEST_F(WebRtcSdpTest, DeserializeSdpWithIceLite) {
3156 JsepSessionDescription jdesc_with_icelite(kDummyString);
3157 std::string sdp_with_icelite = kSdpFullString;
3158 EXPECT_TRUE(SdpDeserialize(sdp_with_icelite, &jdesc_with_icelite));
3159 cricket::SessionDescription* desc = jdesc_with_icelite.description();
3160 const cricket::TransportInfo* tinfo1 =
3161 desc->GetTransportInfoByName("audio_content_name");
3162 EXPECT_EQ(cricket::ICEMODE_FULL, tinfo1->description.ice_mode);
3163 const cricket::TransportInfo* tinfo2 =
3164 desc->GetTransportInfoByName("video_content_name");
3165 EXPECT_EQ(cricket::ICEMODE_FULL, tinfo2->description.ice_mode);
3166 InjectAfter(kSessionTime,
3167 "a=ice-lite\r\n",
3168 &sdp_with_icelite);
3169 EXPECT_TRUE(SdpDeserialize(sdp_with_icelite, &jdesc_with_icelite));
3170 desc = jdesc_with_icelite.description();
3171 const cricket::TransportInfo* atinfo =
3172 desc->GetTransportInfoByName("audio_content_name");
3173 EXPECT_EQ(cricket::ICEMODE_LITE, atinfo->description.ice_mode);
3174 const cricket::TransportInfo* vtinfo =
3175 desc->GetTransportInfoByName("video_content_name");
3176 EXPECT_EQ(cricket::ICEMODE_LITE, vtinfo->description.ice_mode);
3177}
3178
3179// Verifies that the candidates in the input SDP are parsed and serialized
3180// correctly in the output SDP.
3181TEST_F(WebRtcSdpTest, RoundTripSdpWithSctpDataChannelsWithCandidates) {
3182 std::string sdp_with_data = kSdpString;
3183 sdp_with_data.append(kSdpSctpDataChannelWithCandidatesString);
3184 JsepSessionDescription jdesc_output(kDummyString);
3185
3186 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output));
deadbeef9d3584c2016-02-17 01:54:103187 EXPECT_EQ(sdp_with_data, webrtc::SdpSerialize(jdesc_output, false));
henrike@webrtc.org28e20752013-07-10 00:45:363188}
sergeyu@chromium.org0be6aa02013-08-23 23:21:253189
3190TEST_F(WebRtcSdpTest, SerializeDtlsSetupAttribute) {
3191 AddFingerprint();
3192 TransportInfo audio_transport_info =
3193 *(desc_.GetTransportInfoByName(kAudioContentName));
3194 EXPECT_EQ(cricket::CONNECTIONROLE_NONE,
3195 audio_transport_info.description.connection_role);
3196 audio_transport_info.description.connection_role =
3197 cricket::CONNECTIONROLE_ACTIVE;
3198
3199 TransportInfo video_transport_info =
3200 *(desc_.GetTransportInfoByName(kVideoContentName));
3201 EXPECT_EQ(cricket::CONNECTIONROLE_NONE,
3202 video_transport_info.description.connection_role);
3203 video_transport_info.description.connection_role =
3204 cricket::CONNECTIONROLE_ACTIVE;
3205
3206 desc_.RemoveTransportInfoByName(kAudioContentName);
3207 desc_.RemoveTransportInfoByName(kVideoContentName);
3208
3209 desc_.AddTransportInfo(audio_transport_info);
3210 desc_.AddTransportInfo(video_transport_info);
3211
3212 ASSERT_TRUE(jdesc_.Initialize(desc_.Copy(),
3213 jdesc_.session_id(),
3214 jdesc_.session_version()));
deadbeef9d3584c2016-02-17 01:54:103215 std::string message = webrtc::SdpSerialize(jdesc_, false);
sergeyu@chromium.org0be6aa02013-08-23 23:21:253216 std::string sdp_with_dtlssetup = kSdpFullString;
3217
3218 // Fingerprint attribute is necessary to add DTLS setup attribute.
3219 InjectAfter(kAttributeIcePwdVoice,
3220 kFingerprint, &sdp_with_dtlssetup);
3221 InjectAfter(kAttributeIcePwdVideo,
3222 kFingerprint, &sdp_with_dtlssetup);
3223 // Now adding |setup| attribute.
3224 InjectAfter(kFingerprint,
3225 "a=setup:active\r\n", &sdp_with_dtlssetup);
3226 EXPECT_EQ(sdp_with_dtlssetup, message);
3227}
3228
3229TEST_F(WebRtcSdpTest, DeserializeDtlsSetupAttribute) {
3230 JsepSessionDescription jdesc_with_dtlssetup(kDummyString);
3231 std::string sdp_with_dtlssetup = kSdpFullString;
3232 InjectAfter(kSessionTime,
3233 "a=setup:actpass\r\n",
3234 &sdp_with_dtlssetup);
3235 EXPECT_TRUE(SdpDeserialize(sdp_with_dtlssetup, &jdesc_with_dtlssetup));
3236 cricket::SessionDescription* desc = jdesc_with_dtlssetup.description();
3237 const cricket::TransportInfo* atinfo =
3238 desc->GetTransportInfoByName("audio_content_name");
3239 EXPECT_EQ(cricket::CONNECTIONROLE_ACTPASS,
3240 atinfo->description.connection_role);
3241 const cricket::TransportInfo* vtinfo =
3242 desc->GetTransportInfoByName("video_content_name");
3243 EXPECT_EQ(cricket::CONNECTIONROLE_ACTPASS,
3244 vtinfo->description.connection_role);
3245}
jiayl@webrtc.orge7d47a12014-08-05 19:19:053246
3247// Verifies that the order of the serialized m-lines follows the order of the
3248// ContentInfo in SessionDescription, and vise versa for deserialization.
3249TEST_F(WebRtcSdpTest, MediaContentOrderMaintainedRoundTrip) {
3250 JsepSessionDescription jdesc(kDummyString);
3251 const std::string media_content_sdps[3] = {
3252 kSdpAudioString,
3253 kSdpVideoString,
3254 kSdpSctpDataChannelString
3255 };
3256 const cricket::MediaType media_types[3] = {
3257 cricket::MEDIA_TYPE_AUDIO,
3258 cricket::MEDIA_TYPE_VIDEO,
3259 cricket::MEDIA_TYPE_DATA
3260 };
3261
3262 // Verifies all 6 permutations.
3263 for (size_t i = 0; i < 6; ++i) {
3264 size_t media_content_in_sdp[3];
3265 // The index of the first media content.
3266 media_content_in_sdp[0] = i / 2;
3267 // The index of the second media content.
3268 media_content_in_sdp[1] = (media_content_in_sdp[0] + i % 2 + 1) % 3;
3269 // The index of the third media content.
3270 media_content_in_sdp[2] = (media_content_in_sdp[0] + (i + 1) % 2 + 1) % 3;
3271
3272 std::string sdp_string = kSdpSessionString;
3273 for (size_t i = 0; i < 3; ++i)
3274 sdp_string += media_content_sdps[media_content_in_sdp[i]];
3275
3276 EXPECT_TRUE(SdpDeserialize(sdp_string, &jdesc));
3277 cricket::SessionDescription* desc = jdesc.description();
3278 EXPECT_EQ(3u, desc->contents().size());
3279
3280 for (size_t i = 0; i < 3; ++i) {
3281 const cricket::MediaContentDescription* mdesc =
3282 static_cast<const cricket::MediaContentDescription*>(
3283 desc->contents()[i].description);
3284 EXPECT_EQ(media_types[media_content_in_sdp[i]], mdesc->type());
3285 }
3286
deadbeef9d3584c2016-02-17 01:54:103287 std::string serialized_sdp = webrtc::SdpSerialize(jdesc, false);
jiayl@webrtc.orge7d47a12014-08-05 19:19:053288 EXPECT_EQ(sdp_string, serialized_sdp);
3289 }
3290}
deadbeef9d3584c2016-02-17 01:54:103291
deadbeef25ed4352016-12-13 02:37:363292TEST_F(WebRtcSdpTest, DeserializeBundleOnlyAttribute) {
3293 MakeBundleOnlyDescription();
3294 JsepSessionDescription deserialized_description(kDummyString);
deadbeef12771a12017-01-03 21:53:473295 ASSERT_TRUE(
deadbeef25ed4352016-12-13 02:37:363296 SdpDeserialize(kBundleOnlySdpFullString, &deserialized_description));
3297 EXPECT_TRUE(CompareSessionDescription(jdesc_, deserialized_description));
3298}
3299
deadbeef12771a12017-01-03 21:53:473300// The semantics of "a=bundle-only" are only defined when it's used in
3301// combination with a 0 port on the m= line. We should ignore it if used with a
3302// nonzero port.
3303TEST_F(WebRtcSdpTest, IgnoreBundleOnlyWithNonzeroPort) {
3304 // Make the base bundle-only description but unset the bundle-only flag.
3305 MakeBundleOnlyDescription();
3306 jdesc_.description()->contents()[1].bundle_only = false;
3307
3308 std::string modified_sdp = kBundleOnlySdpFullString;
3309 Replace("m=video 0", "m=video 9", &modified_sdp);
3310 JsepSessionDescription deserialized_description(kDummyString);
3311 ASSERT_TRUE(SdpDeserialize(modified_sdp, &deserialized_description));
3312 EXPECT_TRUE(CompareSessionDescription(jdesc_, deserialized_description));
deadbeef25ed4352016-12-13 02:37:363313}
3314
3315TEST_F(WebRtcSdpTest, SerializeBundleOnlyAttribute) {
3316 MakeBundleOnlyDescription();
3317 TestSerialize(jdesc_, false);
3318}
3319
deadbeef9d3584c2016-02-17 01:54:103320TEST_F(WebRtcSdpTest, DeserializePlanBSessionDescription) {
3321 MakePlanBDescription();
3322
3323 JsepSessionDescription deserialized_description(kDummyString);
3324 EXPECT_TRUE(SdpDeserialize(kPlanBSdpFullString, &deserialized_description));
3325
3326 EXPECT_TRUE(CompareSessionDescription(jdesc_, deserialized_description));
3327}
3328
3329TEST_F(WebRtcSdpTest, SerializePlanBSessionDescription) {
3330 MakePlanBDescription();
3331 TestSerialize(jdesc_, false);
3332}
3333
Taylor Brandstetter5de6b752016-03-10 01:02:303334// Some WebRTC endpoints include the msid in both the Plan B and Unified Plan
3335// ways, to make SDP that's compatible with both Plan B and Unified Plan (to
3336// some extent). If we parse this, the Plan B msid attribute (which is more
3337// specific, since it's at the SSRC level) should take priority.
3338TEST_F(WebRtcSdpTest, DeserializePlanBSessionDescriptionWithMsid) {
3339 MakePlanBDescription();
3340
3341 JsepSessionDescription deserialized_description(kDummyString);
3342 EXPECT_TRUE(
3343 SdpDeserialize(kPlanBSdpFullStringWithMsid, &deserialized_description));
3344
3345 EXPECT_TRUE(CompareSessionDescription(jdesc_, deserialized_description));
3346}
3347
deadbeef9d3584c2016-02-17 01:54:103348TEST_F(WebRtcSdpTest, DeserializeUnifiedPlanSessionDescription) {
3349 MakeUnifiedPlanDescription();
3350
3351 JsepSessionDescription deserialized_description(kDummyString);
3352 EXPECT_TRUE(
3353 SdpDeserialize(kUnifiedPlanSdpFullString, &deserialized_description));
3354
3355 EXPECT_TRUE(CompareSessionDescription(jdesc_, deserialized_description));
3356}
3357
3358TEST_F(WebRtcSdpTest, SerializeUnifiedPlanSessionDescription) {
3359 MakeUnifiedPlanDescription();
3360 TestSerialize(jdesc_, true);
3361}
deadbeef7e146cb2016-09-28 17:04:343362
3363// Regression test for heap overflow bug:
3364// https://bugs.chromium.org/p/chromium/issues/detail?id=647916
3365TEST_F(WebRtcSdpTest, DeserializeSctpPortInVideoDescription) {
deadbeef7e146cb2016-09-28 17:04:343366 // The issue occurs when the sctp-port attribute is found in a video
3367 // description. The actual heap overflow occurs when parsing the fmtp line.
deadbeef7bcdb692017-01-20 20:43:583368 static const char kSdpWithSctpPortInVideoDescription[] =
deadbeef7e146cb2016-09-28 17:04:343369 "v=0\r\n"
3370 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n"
3371 "s=-\r\n"
3372 "t=0 0\r\n"
3373 "m=video 9 UDP/DTLS/SCTP 120\r\n"
3374 "a=sctp-port 5000\r\n"
3375 "a=fmtp:108 foo=10\r\n";
3376
3377 ExpectParseFailure(std::string(kSdpWithSctpPortInVideoDescription),
3378 "sctp-port");
3379}
deadbeefb2362572016-12-14 00:37:063380
3381// Regression test for integer overflow bug:
3382// https://bugs.chromium.org/p/chromium/issues/detail?id=648071
3383TEST_F(WebRtcSdpTest, DeserializeLargeBandwidthLimit) {
deadbeefb2362572016-12-14 00:37:063384 // Bandwidth attribute is the max signed 32-bit int, which will get
3385 // multiplied by 1000 and cause int overflow if not careful.
deadbeef7bcdb692017-01-20 20:43:583386 static const char kSdpWithLargeBandwidth[] =
deadbeefb2362572016-12-14 00:37:063387 "v=0\r\n"
3388 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n"
3389 "s=-\r\n"
3390 "t=0 0\r\n"
3391 "m=video 3457 RTP/SAVPF 120\r\n"
3392 "b=AS:2147483647\r\n"
3393 "foo=fail\r\n";
3394
3395 ExpectParseFailure(std::string(kSdpWithLargeBandwidth), "foo=fail");
3396}
deadbeef7bcdb692017-01-20 20:43:583397
3398// Test that "ufrag"/"pwd" in the candidate line itself are ignored, and only
3399// the "a=ice-ufrag"/"a=ice-pwd" attributes are used.
3400// Regression test for:
3401// https://bugs.chromium.org/p/chromium/issues/detail?id=681286
3402TEST_F(WebRtcSdpTest, IceCredentialsInCandidateStringIgnored) {
3403 // Important piece is "ufrag foo pwd bar".
3404 static const char kSdpWithIceCredentialsInCandidateString[] =
3405 "v=0\r\n"
3406 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n"
3407 "s=-\r\n"
3408 "t=0 0\r\n"
3409 "m=audio 9 RTP/SAVPF 111\r\n"
3410 "c=IN IP4 0.0.0.0\r\n"
3411 "a=rtcp:9 IN IP4 0.0.0.0\r\n"
3412 "a=ice-ufrag:ufrag_voice\r\na=ice-pwd:pwd_voice\r\n"
3413 "a=rtpmap:111 opus/48000/2\r\n"
3414 "a=candidate:a0+B/1 1 udp 2130706432 192.168.1.5 1234 typ host "
3415 "generation 2 ufrag foo pwd bar\r\n";
3416
3417 JsepSessionDescription jdesc_output(kDummyString);
3418 EXPECT_TRUE(
3419 SdpDeserialize(kSdpWithIceCredentialsInCandidateString, &jdesc_output));
3420 const IceCandidateCollection* candidates = jdesc_output.candidates(0);
3421 ASSERT_NE(nullptr, candidates);
3422 ASSERT_EQ(1, candidates->count());
3423 cricket::Candidate c = candidates->at(0)->candidate();
3424 EXPECT_EQ("ufrag_voice", c.username());
3425 EXPECT_EQ("pwd_voice", c.password());
3426}
deadbeef90f1e1e2017-02-10 20:35:053427
3428// Test that SDP with an invalid port number in "a=candidate" lines is
3429// rejected, without crashing.
3430// Regression test for:
3431// https://bugs.chromium.org/p/chromium/issues/detail?id=677029
3432TEST_F(WebRtcSdpTest, DeserializeInvalidPortInCandidateAttribute) {
3433 static const char kSdpWithInvalidCandidatePort[] =
3434 "v=0\r\n"
3435 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n"
3436 "s=-\r\n"
3437 "t=0 0\r\n"
3438 "m=audio 9 RTP/SAVPF 111\r\n"
3439 "c=IN IP4 0.0.0.0\r\n"
3440 "a=rtcp:9 IN IP4 0.0.0.0\r\n"
3441 "a=ice-ufrag:ufrag_voice\r\na=ice-pwd:pwd_voice\r\n"
3442 "a=rtpmap:111 opus/48000/2\r\n"
3443 "a=candidate:a0+B/1 1 udp 2130706432 192.168.1.5 12345678 typ host "
3444 "generation 2 raddr 192.168.1.1 rport 87654321\r\n";
3445
3446 JsepSessionDescription jdesc_output(kDummyString);
3447 EXPECT_FALSE(SdpDeserialize(kSdpWithInvalidCandidatePort, &jdesc_output));
3448}
deadbeefa4549d62017-02-11 01:26:223449
3450// Test that "a=msid" with a missing track ID is rejected and doesn't crash.
3451// Regression test for:
3452// https://bugs.chromium.org/p/chromium/issues/detail?id=686405
3453TEST_F(WebRtcSdpTest, DeserializeMsidAttributeWithMissingTrackId) {
3454 static const char kSdpWithMissingTrackId[] =
3455 "v=0\r\n"
3456 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n"
3457 "s=-\r\n"
3458 "t=0 0\r\n"
3459 "m=audio 9 RTP/SAVPF 111\r\n"
3460 "c=IN IP4 0.0.0.0\r\n"
3461 "a=rtpmap:111 opus/48000/2\r\n"
3462 "a=msid:stream_id \r\n";
3463
3464 JsepSessionDescription jdesc_output(kDummyString);
3465 EXPECT_FALSE(SdpDeserialize(kSdpWithMissingTrackId, &jdesc_output));
3466}
3467
3468TEST_F(WebRtcSdpTest, DeserializeMsidAttributeWithMissingStreamId) {
3469 static const char kSdpWithMissingStreamId[] =
3470 "v=0\r\n"
3471 "o=- 18446744069414584320 18446462598732840960 IN IP4 127.0.0.1\r\n"
3472 "s=-\r\n"
3473 "t=0 0\r\n"
3474 "m=audio 9 RTP/SAVPF 111\r\n"
3475 "c=IN IP4 0.0.0.0\r\n"
3476 "a=rtpmap:111 opus/48000/2\r\n"
3477 "a=msid: track_id\r\n";
3478
3479 JsepSessionDescription jdesc_output(kDummyString);
3480 EXPECT_FALSE(SdpDeserialize(kSdpWithMissingStreamId, &jdesc_output));
3481}