| 1 |
var fs = require('co-fs') |
| 2 |
, test = require('bandage') |
| 3 |
, main = require('..') |
| 4 |
, parse = main.parse |
| 5 |
, write = main.write |
| 6 |
, parseFmtpConfig = main.parseFmtpConfig |
| 7 |
, parseParams = main.parseParams |
| 8 |
, parseImageAttributes = main.parseImageAttributes |
| 9 |
, parseSimulcastStreamList = main.parseSimulcastStreamList |
| 10 |
; |
| 11 |
|
| 12 |
test('normalSdp', function *(t) { |
| 13 |
var sdp = yield fs.readFile(__dirname + '/normal.sdp', 'utf8'); |
| 14 |
|
| 15 |
var session = parse(sdp+''); |
| 16 |
t.ok(session, 'got session info'); |
| 17 |
var media = session.media; |
| 18 |
t.ok(media && media.length > 0, 'got media'); |
| 19 |
|
| 20 |
t.equal(session.origin.username, '-', 'origin username'); |
| 21 |
t.equal(session.origin.sessionId, 20518, 'origin sessionId'); |
| 22 |
t.equal(session.origin.sessionVersion, 0, 'origin sessionVersion'); |
| 23 |
t.equal(session.origin.netType, 'IN', 'origin netType'); |
| 24 |
t.equal(session.origin.ipVer, 4, 'origin ipVer'); |
| 25 |
t.equal(session.origin.address, '203.0.113.1', 'origin address'); |
| 26 |
|
| 27 |
t.equal(session.connection.ip, '203.0.113.1', 'session connect ip'); |
| 28 |
t.equal(session.connection.version, 4, 'session connect ip ver'); |
| 29 |
|
| 30 |
// global ICE and fingerprint |
| 31 |
t.equal(session.iceUfrag, 'F7gI', 'global ufrag'); |
| 32 |
t.equal(session.icePwd, 'x9cml/YzichV2+XlhiMu8g', 'global pwd'); |
| 33 |
|
| 34 |
var audio = media[0]; |
| 35 |
t.equal(audio.type, 'audio', 'audio type'); |
| 36 |
t.equal(audio.port, 54400, 'audio port'); |
| 37 |
t.equal(audio.protocol, 'RTP/SAVPF', 'audio protocol'); |
| 38 |
t.equal(audio.direction, 'sendrecv', 'audio direction'); |
| 39 |
t.equal(audio.rtp[0].payload, 0, 'audio rtp 0 payload'); |
| 40 |
t.equal(audio.rtp[0].codec, 'PCMU', 'audio rtp 0 codec'); |
| 41 |
t.equal(audio.rtp[0].rate, 8000, 'audio rtp 0 rate'); |
| 42 |
t.equal(audio.rtp[1].payload, 96, 'audio rtp 1 payload'); |
| 43 |
t.equal(audio.rtp[1].codec, 'opus', 'audio rtp 1 codec'); |
| 44 |
t.equal(audio.rtp[1].rate, 48000, 'audio rtp 1 rate'); |
| 45 |
t.deepEqual(audio.ext[0], { |
| 46 |
value: 1, |
| 47 |
uri: 'URI-toffset' |
| 48 |
}, 'audio extension 0'); |
| 49 |
t.deepEqual(audio.ext[1], { |
| 50 |
value: 2, |
| 51 |
direction: 'recvonly', |
| 52 |
uri: 'URI-gps-string' |
| 53 |
}, 'audio extension 1'); |
| 54 |
t.equal(audio.extmapAllowMixed, 'extmap-allow-mixed', 'extmap-allow-mixed present'); |
| 55 |
|
| 56 |
var video = media[1]; |
| 57 |
t.equal(video.type, 'video', 'video type'); |
| 58 |
t.equal(video.port, 55400, 'video port'); |
| 59 |
t.equal(video.protocol, 'RTP/SAVPF', 'video protocol'); |
| 60 |
t.equal(video.direction, 'sendrecv', 'video direction'); |
| 61 |
t.equal(video.rtp[0].payload, 97, 'video rtp 0 payload'); |
| 62 |
t.equal(video.rtp[0].codec, 'H264', 'video rtp 0 codec'); |
| 63 |
t.equal(video.rtp[0].rate, 90000, 'video rtp 0 rate'); |
| 64 |
t.equal(video.fmtp[0].payload, 97, 'video fmtp 0 payload'); |
| 65 |
var vidFmtp = parseFmtpConfig(video.fmtp[0].config); |
| 66 |
t.equal(vidFmtp['profile-level-id'], '4d0028', 'video fmtp 0 profile-level-id'); |
| 67 |
t.equal(vidFmtp['packetization-mode'], 1, 'video fmtp 0 packetization-mode'); |
| 68 |
t.equal(vidFmtp['sprop-parameter-sets'], 'Z0IAH5WoFAFuQA==,aM48gA==', |
| 69 |
'video fmtp 0 sprop-parameter-sets'); |
| 70 |
t.equal(video.fmtp[1].payload, 98, 'video fmtp 1 payload'); |
| 71 |
var vidFmtp2 = parseFmtpConfig(video.fmtp[1].config); |
| 72 |
t.equal(vidFmtp2.minptime, 10, 'video fmtp 1 minptime'); |
| 73 |
t.equal(vidFmtp2.useinbandfec, 1, 'video fmtp 1 useinbandfec'); |
| 74 |
t.equal(video.rtp[1].payload, 98, 'video rtp 1 payload'); |
| 75 |
t.equal(video.rtp[1].codec, 'VP8', 'video rtp 1 codec'); |
| 76 |
t.equal(video.rtp[1].rate, 90000, 'video rtp 1 rate'); |
| 77 |
t.equal(video.rtcpFb[0].payload, '*', 'video rtcp-fb 0 payload'); |
| 78 |
t.equal(video.rtcpFb[0].type, 'nack', 'video rtcp-fb 0 type'); |
| 79 |
t.equal(video.rtcpFb[1].payload, 98, 'video rtcp-fb 0 payload'); |
| 80 |
t.equal(video.rtcpFb[1].type, 'nack', 'video rtcp-fb 0 type'); |
| 81 |
t.equal(video.rtcpFb[1].subtype, 'rpsi', 'video rtcp-fb 0 subtype'); |
| 82 |
t.equal(video.rtcpFbTrrInt[0].payload, 98, 'video rtcp-fb trr-int 0 payload'); |
| 83 |
t.equal(video.rtcpFbTrrInt[0].value, 100, 'video rtcp-fb trr-int 0 value'); |
| 84 |
t.equal(video.crypto[0].id, 1, 'video crypto 0 id'); |
| 85 |
t.equal(video.crypto[0].suite, 'AES_CM_128_HMAC_SHA1_32', 'video crypto 0 suite'); |
| 86 |
t.equal(video.crypto[0].config, 'inline:keNcG3HezSNID7LmfDa9J4lfdUL8W1F7TNJKcbuy|2^20|1:32', 'video crypto 0 config'); |
| 87 |
t.equal(video.ssrcs.length, 3, 'video got 3 ssrc lines'); |
| 88 |
// test ssrc with attr:value |
| 89 |
t.deepEqual(video.ssrcs[0], { |
| 90 |
id: 1399694169, |
| 91 |
attribute: 'foo', |
| 92 |
value: 'bar' |
| 93 |
}, 'video 1st ssrc line attr:value'); |
| 94 |
// test ssrc with attr only |
| 95 |
t.deepEqual(video.ssrcs[1], { |
| 96 |
id: 1399694169, |
| 97 |
attribute: 'baz', |
| 98 |
}, 'video 2nd ssrc line attr only'); |
| 99 |
// test ssrc with at-tr:value |
| 100 |
t.deepEqual(video.ssrcs[2], { |
| 101 |
id: 1399694169, |
| 102 |
attribute: 'foo-bar', |
| 103 |
value: 'baz' |
| 104 |
}, 'video 3rd ssrc line attr with dash'); |
| 105 |
|
| 106 |
// ICE candidates (same for both audio and video in this case) |
| 107 |
[audio.candidates, video.candidates].forEach(function (cs, i) { |
| 108 |
var str = (i === 0) ? 'audio ' : 'video '; |
| 109 |
var port = (i === 0) ? 54400 : 55400; |
| 110 |
t.equal(cs.length, 4, str + 'got 4 candidates'); |
| 111 |
t.equal(cs[0].foundation, 0, str + 'ice candidate 0 foundation'); |
| 112 |
t.equal(cs[0].component, 1, str + 'ice candidate 0 component'); |
| 113 |
t.equal(cs[0].transport, 'UDP', str + 'ice candidate 0 transport'); |
| 114 |
t.equal(cs[0].priority, 2113667327, str + 'ice candidate 0 priority'); |
| 115 |
t.equal(cs[0].ip, '203.0.113.1', str + 'ice candidate 0 ip'); |
| 116 |
t.equal(cs[0].port, port, str + 'ice candidate 0 port'); |
| 117 |
t.equal(cs[0].type, 'host', str + 'ice candidate 0 type'); |
| 118 |
t.equal(cs[1].foundation, 1, str + 'ice candidate 1 foundation'); |
| 119 |
t.equal(cs[1].component, 2, str + 'ice candidate 1 component'); |
| 120 |
t.equal(cs[1].transport, 'UDP', str + 'ice candidate 1 transport'); |
| 121 |
t.equal(cs[1].priority, 2113667326, str + 'ice candidate 1 priority'); |
| 122 |
t.equal(cs[1].ip, '203.0.113.1', str + 'ice candidate 1 ip'); |
| 123 |
t.equal(cs[1].port, port+1, str + 'ice candidate 1 port'); |
| 124 |
t.equal(cs[1].type, 'host', str + 'ice candidate 1 type'); |
| 125 |
t.equal(cs[2].foundation, 2, str + 'ice candidate 2 foundation'); |
| 126 |
t.equal(cs[2].component, 1, str + 'ice candidate 2 component'); |
| 127 |
t.equal(cs[2].transport, 'UDP', str + 'ice candidate 2 transport'); |
| 128 |
t.equal(cs[2].priority, 1686052607, str + 'ice candidate 2 priority'); |
| 129 |
t.equal(cs[2].ip, '203.0.113.1', str + 'ice candidate 2 ip'); |
| 130 |
t.equal(cs[2].port, port+2, str + 'ice candidate 2 port'); |
| 131 |
t.equal(cs[2].type, 'srflx', str + 'ice candidate 2 type'); |
| 132 |
t.equal(cs[2].raddr, '192.168.1.145', str + 'ice candidate 2 raddr'); |
| 133 |
t.equal(cs[2].rport, port+2, str + 'ice candidate 2 rport'); |
| 134 |
t.equal(cs[2].generation, 0, str + 'ice candidate 2 generation'); |
| 135 |
t.equal(cs[2]['network-id'], 3, str + 'ice candidate 2 network-id'); |
| 136 |
t.equal(cs[2]['network-cost'], (i === 0 ? 10 : undefined), str + 'ice candidate 2 network-cost'); |
| 137 |
t.equal(cs[3].foundation, 3, str + 'ice candidate 3 foundation'); |
| 138 |
t.equal(cs[3].component, 2, str + 'ice candidate 3 component'); |
| 139 |
t.equal(cs[3].transport, 'UDP', str + 'ice candidate 3 transport'); |
| 140 |
t.equal(cs[3].priority, 1686052606, str + 'ice candidate 3 priority'); |
| 141 |
t.equal(cs[3].ip, '203.0.113.1', str + 'ice candidate 3 ip'); |
| 142 |
t.equal(cs[3].port, port+3, str + 'ice candidate 3 port'); |
| 143 |
t.equal(cs[3].type, 'srflx', str + 'ice candidate 3 type'); |
| 144 |
t.equal(cs[3].raddr, '192.168.1.145', str + 'ice candidate 3 raddr'); |
| 145 |
t.equal(cs[3].rport, port+3, str + 'ice candidate 3 rport'); |
| 146 |
t.equal(cs[3].generation, 0, str + 'ice candidate 3 generation'); |
| 147 |
t.equal(cs[3]['network-id'], 3, str + 'ice candidate 3 network-id'); |
| 148 |
t.equal(cs[3]['network-cost'], (i === 0 ? 10 : undefined), str + 'ice candidate 3 network-cost'); |
| 149 |
}); |
| 150 |
|
| 151 |
t.equal(media.length, 2, 'got 2 m-lines'); |
| 152 |
}); |
| 153 |
|
| 154 |
/* |
| 155 |
* Test for an sdp that started out as something from chrome |
| 156 |
* it's since been hacked to include tests for other stuff |
| 157 |
* ignore the name |
| 158 |
*/ |
| 159 |
test('hackySdp', function *(t) { |
| 160 |
var sdp = yield fs.readFile(__dirname + '/hacky.sdp', 'utf8'); |
| 161 |
|
| 162 |
var session = parse(sdp+''); |
| 163 |
t.ok(session, 'got session info'); |
| 164 |
var media = session.media; |
| 165 |
t.ok(media && media.length > 0, 'got media'); |
| 166 |
|
| 167 |
t.equal(session.origin.sessionId, '3710604898417546434', 'origin sessionId'); |
| 168 |
t.ok(session.groups, 'parsing session groups'); |
| 169 |
t.equal(session.groups.length, 1, 'one grouping'); |
| 170 |
t.equal(session.groups[0].type, 'BUNDLE', 'grouping is BUNDLE'); |
| 171 |
t.equal(session.groups[0].mids, 'audio video', 'bundling audio video'); |
| 172 |
t.ok(session.msidSemantic, 'have an msid semantic'); |
| 173 |
t.equal(session.msidSemantic.semantic, 'WMS', 'webrtc semantic'); |
| 174 |
t.equal(session.msidSemantic.token, 'Jvlam5X3SX1OP6pn20zWogvaKJz5Hjf9OnlV', 'semantic token'); |
| 175 |
|
| 176 |
// verify a=rtcp:65179 IN IP4 193.84.77.194 |
| 177 |
t.equal(media[0].rtcp.port, 1, 'rtcp port'); |
| 178 |
t.equal(media[0].rtcp.netType, 'IN', 'rtcp netType'); |
| 179 |
t.equal(media[0].rtcp.ipVer, 4, 'rtcp ipVer'); |
| 180 |
t.equal(media[0].rtcp.address, '0.0.0.0', 'rtcp address'); |
| 181 |
|
| 182 |
// verify ice tcp types |
| 183 |
t.equal(media[0].candidates[0].tcptype, undefined, 'no tcptype'); |
| 184 |
t.equal(media[0].candidates[1].tcptype, 'active', 'active tcptype'); |
| 185 |
t.equal(media[0].candidates[1].transport, 'tcp', 'tcp transport'); |
| 186 |
t.equal(media[0].candidates[1].generation, 0, 'generation 0'); |
| 187 |
t.equal(media[0].candidates[1].type, 'host', 'tcp host'); |
| 188 |
t.equal(media[0].candidates[2].generation, undefined, 'no generation'); |
| 189 |
t.equal(media[0].candidates[2].type, 'host', 'tcp host'); |
| 190 |
t.equal(media[0].candidates[2].tcptype, 'active', 'active tcptype'); |
| 191 |
t.equal(media[0].candidates[3].tcptype, 'passive', 'passive tcptype'); |
| 192 |
t.equal(media[0].candidates[4].tcptype, 'so', 'so tcptype'); |
| 193 |
// raddr + rport + tcptype + generation |
| 194 |
t.equal(media[0].candidates[5].type, 'srflx', 'tcp srflx'); |
| 195 |
t.equal(media[0].candidates[5].rport, 9, 'tcp rport'); |
| 196 |
t.equal(media[0].candidates[5].raddr, '10.0.1.1', 'tcp raddr'); |
| 197 |
t.equal(media[0].candidates[5].tcptype, 'active', 'active tcptype'); |
| 198 |
t.equal(media[0].candidates[6].tcptype, 'passive', 'passive tcptype'); |
| 199 |
t.equal(media[0].candidates[6].rport, 8998, 'tcp rport'); |
| 200 |
t.equal(media[0].candidates[6].raddr, '10.0.1.1', 'tcp raddr'); |
| 201 |
t.equal(media[0].candidates[6].generation, 5, 'tcp generation'); |
| 202 |
|
| 203 |
// and verify it works without specifying the ip |
| 204 |
t.equal(media[1].rtcp.port, 12312, 'rtcp port'); |
| 205 |
t.equal(media[1].rtcp.netType, undefined, 'rtcp netType'); |
| 206 |
t.equal(media[1].rtcp.ipVer, undefined, 'rtcp ipVer'); |
| 207 |
t.equal(media[1].rtcp.address, undefined, 'rtcp address'); |
| 208 |
|
| 209 |
// verify a=rtpmap:126 telephone-event/8000 |
| 210 |
var lastRtp = media[0].rtp.length-1; |
| 211 |
t.equal(media[0].rtp[lastRtp].codec, 'telephone-event', 'dtmf codec'); |
| 212 |
t.equal(media[0].rtp[lastRtp].rate, 8000, 'dtmf rate'); |
| 213 |
|
| 214 |
|
| 215 |
t.equal(media[0].iceOptions, 'google-ice', 'ice options parsed'); |
| 216 |
t.equal(media[0].ptime, 0.125, 'audio packet duration'); |
| 217 |
t.equal(media[0].maxptime, 60, 'maxptime parsed'); |
| 218 |
t.equal(media[0].rtcpMux, 'rtcp-mux', 'rtcp-mux present'); |
| 219 |
|
| 220 |
t.equal(media[0].rtp[0].codec, 'opus', 'audio rtp 0 codec'); |
| 221 |
t.equal(media[0].rtp[0].encoding, 2, 'audio rtp 0 encoding'); |
| 222 |
|
| 223 |
t.ok(media[0].ssrcs, 'have ssrc lines'); |
| 224 |
t.equal(media[0].ssrcs.length, 4, 'got 4 ssrc lines'); |
| 225 |
var ssrcs = media[0].ssrcs; |
| 226 |
t.deepEqual(ssrcs[0], { |
| 227 |
id: 2754920552, |
| 228 |
attribute: 'cname', |
| 229 |
value: 't9YU8M1UxTF8Y1A1' |
| 230 |
}, '1st ssrc line'); |
| 231 |
|
| 232 |
t.deepEqual(ssrcs[1], { |
| 233 |
id: 2754920552, |
| 234 |
attribute: 'msid', |
| 235 |
value: 'Jvlam5X3SX1OP6pn20zWogvaKJz5Hjf9OnlV Jvlam5X3SX1OP6pn20zWogvaKJz5Hjf9OnlVa0' |
| 236 |
}, '2nd ssrc line'); |
| 237 |
|
| 238 |
t.deepEqual(ssrcs[2], { |
| 239 |
id: 2754920552, |
| 240 |
attribute: 'mslabel', |
| 241 |
value: 'Jvlam5X3SX1OP6pn20zWogvaKJz5Hjf9OnlV' |
| 242 |
}, '3rd ssrc line'); |
| 243 |
|
| 244 |
t.deepEqual(ssrcs[3], { |
| 245 |
id: 2754920552, |
| 246 |
attribute: 'label', |
| 247 |
value: 'Jvlam5X3SX1OP6pn20zWogvaKJz5Hjf9OnlVa0' |
| 248 |
}, '4th ssrc line'); |
| 249 |
|
| 250 |
// verify a=sctpmap:5000 webrtc-datachannel 1024 |
| 251 |
t.ok(media[2].sctpmap, 'we have sctpmap'); |
| 252 |
t.equal(media[2].sctpmap.sctpmapNumber, 5000, 'sctpmap number is 5000'); |
| 253 |
t.equal(media[2].sctpmap.app, 'webrtc-datachannel', 'sctpmap app is webrtc-datachannel'); |
| 254 |
t.equal(media[2].sctpmap.maxMessageSize, 1024, 'sctpmap maxMessageSize is 1024'); |
| 255 |
|
| 256 |
// verify a=framerate:29.97 |
| 257 |
t.ok(media[2].framerate, 'we have framerate'); |
| 258 |
t.equal(media[2].framerate, 29.97, 'framerate is 29.97'); |
| 259 |
|
| 260 |
// verify a=label:1 |
| 261 |
t.ok(media[0].label, 'we have label'); |
| 262 |
t.equal(media[0].label, 1, 'label is 1'); |
| 263 |
}); |
| 264 |
|
| 265 |
test('iceliteSdp', function *(t) { |
| 266 |
var sdp = yield fs.readFile(__dirname + '/icelite.sdp', 'utf8'); |
| 267 |
|
| 268 |
var session = parse(sdp+''); |
| 269 |
t.ok(session, 'got session info'); |
| 270 |
t.equal(session.icelite, 'ice-lite', 'icelite parsed'); |
| 271 |
|
| 272 |
var rew = write(session); |
| 273 |
t.ok(rew.indexOf('a=ice-lite\r\n') >= 0, 'got ice-lite'); |
| 274 |
t.ok(rew.indexOf('m=') > rew.indexOf('a=ice-lite'), 'session level icelite'); |
| 275 |
}); |
| 276 |
|
| 277 |
test('invalidSdp', function *(t) { |
| 278 |
var sdp = yield fs.readFile(__dirname + '/invalid.sdp', 'utf8'); |
| 279 |
|
| 280 |
var session = parse(sdp+''); |
| 281 |
t.ok(session, 'got session info'); |
| 282 |
var media = session.media; |
| 283 |
t.ok(media && media.length > 0, 'got media'); |
| 284 |
|
| 285 |
// verify a=rtcp:65179 IN IP4 193.84.77.194 |
| 286 |
t.equal(media[0].rtcp.port, 1, 'rtcp port'); |
| 287 |
t.equal(media[0].rtcp.netType, 'IN', 'rtcp netType'); |
| 288 |
t.equal(media[0].rtcp.ipVer, 7, 'rtcp ipVer'); |
| 289 |
t.equal(media[0].rtcp.address, 'X', 'rtcp address'); |
| 290 |
t.equal(media[0].invalid.length, 1, 'found exactly 1 invalid line'); // f= lost |
| 291 |
t.equal(media[0].invalid[0].value, 'goo:hithere', 'copied verbatim'); |
| 292 |
}); |
| 293 |
|
| 294 |
test('jssipSdp', function *(t) { |
| 295 |
var sdp = yield fs.readFile(__dirname + '/jssip.sdp', 'utf8'); |
| 296 |
|
| 297 |
var session = parse(sdp+''); |
| 298 |
t.ok(session, 'got session info'); |
| 299 |
var media = session.media; |
| 300 |
t.ok(media && media.length > 0, 'got media'); |
| 301 |
|
| 302 |
var audio = media[0]; |
| 303 |
var audCands = audio.candidates; |
| 304 |
t.equal(audCands.length, 6, '6 candidates'); |
| 305 |
|
| 306 |
// testing ice optionals: |
| 307 |
t.deepEqual(audCands[0], |
| 308 |
{ |
| 309 |
foundation: 1162875081, |
| 310 |
component: 1, |
| 311 |
transport: 'udp', |
| 312 |
priority: 2113937151, |
| 313 |
ip: '192.168.34.75', |
| 314 |
port: 60017, |
| 315 |
type: 'host', |
| 316 |
generation: 0, |
| 317 |
}, |
| 318 |
'audio candidate 0' |
| 319 |
); |
| 320 |
t.deepEqual(audCands[2], |
| 321 |
{ |
| 322 |
foundation: 3289912957, |
| 323 |
component: 1, |
| 324 |
transport: 'udp', |
| 325 |
priority: 1845501695, |
| 326 |
ip: '193.84.77.194', |
| 327 |
port: 60017, |
| 328 |
type: 'srflx', |
| 329 |
raddr: '192.168.34.75', |
| 330 |
rport: 60017, |
| 331 |
generation: 0, |
| 332 |
}, |
| 333 |
'audio candidate 2 (raddr rport)' |
| 334 |
); |
| 335 |
t.deepEqual(audCands[4], |
| 336 |
{ |
| 337 |
foundation: 198437945, |
| 338 |
component: 1, |
| 339 |
transport: 'tcp', |
| 340 |
priority: 1509957375, |
| 341 |
ip: '192.168.34.75', |
| 342 |
port: 0, |
| 343 |
type: 'host', |
| 344 |
generation: 0 |
| 345 |
}, |
| 346 |
'audio candidate 4 (tcp)' |
| 347 |
); |
| 348 |
}); |
| 349 |
|
| 350 |
test('jsepSdp', function *(t) { |
| 351 |
var sdp = yield fs.readFile(__dirname + '/jsep.sdp', 'utf8'); |
| 352 |
|
| 353 |
var session = parse(sdp+''); |
| 354 |
t.ok(session, 'got session info'); |
| 355 |
var media = session.media; |
| 356 |
t.ok(media && media.length === 2, 'got media'); |
| 357 |
|
| 358 |
var video = media[1]; |
| 359 |
t.equal(video.ssrcGroups.length, 1, '1 ssrc grouping'); |
| 360 |
t.deepEqual(video.ssrcGroups[0], |
| 361 |
{ |
| 362 |
semantics: 'FID', |
| 363 |
ssrcs: '1366781083 1366781084' |
| 364 |
}, |
| 365 |
'ssrc-group' |
| 366 |
); |
| 367 |
|
| 368 |
t.equal(video.msid, |
| 369 |
'61317484-2ed4-49d7-9eb7-1414322a7aae f30bdb4a-5db8-49b5-bcdc-e0c9a23172e0' |
| 370 |
, 'msid' |
| 371 |
); |
| 372 |
|
| 373 |
t.ok(video.rtcpRsize, 'rtcp-rsize present'); |
| 374 |
t.ok(video.bundleOnly, 'bundle-only present'); |
| 375 |
|
| 376 |
// video contains 'a=end-of-candidates' |
| 377 |
// we want to ensure this comes after the candidate lines |
| 378 |
// so this is the only place we actually test the writer in here |
| 379 |
t.ok(video.endOfCandidates, 'have end of candidates marker'); |
| 380 |
var rewritten = write(session).split('\r\n'); |
| 381 |
var idx = rewritten.indexOf('a=end-of-candidates'); |
| 382 |
t.equal(rewritten[idx-1].slice(0, 11), 'a=candidate', 'marker after candidate'); |
| 383 |
}); |
| 384 |
|
| 385 |
test('alacSdp', function *(t) { |
| 386 |
var sdp = yield fs.readFile(__dirname + '/alac.sdp', 'utf8'); |
| 387 |
|
| 388 |
var session = parse(sdp+''); |
| 389 |
t.ok(session, 'got session info'); |
| 390 |
var media = session.media; |
| 391 |
t.ok(media && media.length > 0, 'got media'); |
| 392 |
|
| 393 |
var audio = media[0]; |
| 394 |
t.equal(audio.type, 'audio', 'audio type'); |
| 395 |
t.equal(audio.protocol, 'RTP/AVP', 'audio protocol'); |
| 396 |
t.equal(audio.fmtp[0].payload, 96, 'audio fmtp 0 payload'); |
| 397 |
t.equal(audio.fmtp[0].config, '352 0 16 40 10 14 2 255 0 0 44100', 'audio fmtp 0 config'); |
| 398 |
t.equal(audio.rtp[0].payload, 96, 'audio rtp 0 payload'); |
| 399 |
t.equal(audio.rtp[0].codec, 'AppleLossless', 'audio rtp 0 codec'); |
| 400 |
t.equal(audio.rtp[0].rate, undefined, 'audio rtp 0 rate'); |
| 401 |
t.equal(audio.rtp[0].encoding, undefined, 'audio rtp 0 encoding'); |
| 402 |
}); |
| 403 |
|
| 404 |
test('onvifSdp', function *(t) { |
| 405 |
var sdp = yield fs.readFile(__dirname + '/onvif.sdp', 'utf8'); |
| 406 |
|
| 407 |
var session = parse(sdp+''); |
| 408 |
t.ok(session, 'got session info'); |
| 409 |
var media = session.media; |
| 410 |
t.ok(media && media.length > 0, 'got media'); |
| 411 |
|
| 412 |
var audio = media[0]; |
| 413 |
t.equal(audio.type, 'audio', 'audio type'); |
| 414 |
t.equal(audio.port, 0, 'audio port'); |
| 415 |
t.equal(audio.protocol, 'RTP/AVP', 'audio protocol'); |
| 416 |
t.equal(audio.control, 'rtsp://example.com/onvif_camera/audio', 'audio control'); |
| 417 |
t.equal(audio.payloads, 0, 'audio payloads'); |
| 418 |
|
| 419 |
var video = media[1]; |
| 420 |
t.equal(video.type, 'video', 'video type'); |
| 421 |
t.equal(video.port, 0, 'video port'); |
| 422 |
t.equal(video.protocol, 'RTP/AVP', 'video protocol'); |
| 423 |
t.equal(video.control, 'rtsp://example.com/onvif_camera/video', 'video control'); |
| 424 |
t.equal(video.payloads, 26, 'video payloads'); |
| 425 |
|
| 426 |
var application = media[2]; |
| 427 |
t.equal(application.type, 'application', 'application type'); |
| 428 |
t.equal(application.port, 0, 'application port'); |
| 429 |
t.equal(application.protocol, 'RTP/AVP', 'application protocol'); |
| 430 |
t.equal(application.control, 'rtsp://example.com/onvif_camera/metadata', 'application control'); |
| 431 |
t.equal(application.payloads, 107, 'application payloads'); |
| 432 |
t.equal(application.direction, 'recvonly', 'application direction'); |
| 433 |
t.equal(application.rtp[0].payload, 107, 'application rtp 0 payload'); |
| 434 |
t.equal(application.rtp[0].codec, 'vnd.onvif.metadata', 'application rtp 0 codec'); |
| 435 |
t.equal(application.rtp[0].rate, 90000, 'application rtp 0 rate'); |
| 436 |
t.equal(application.rtp[0].encoding, undefined, 'application rtp 0 encoding'); |
| 437 |
}); |
| 438 |
|
| 439 |
test('ssrcSdp', function *(t) { |
| 440 |
var sdp = yield fs.readFile(__dirname + '/ssrc.sdp', 'utf8'); |
| 441 |
|
| 442 |
var session = parse(sdp+''); |
| 443 |
t.ok(session, 'got session info'); |
| 444 |
var media = session.media; |
| 445 |
t.ok(media && media.length > 0, 'got media'); |
| 446 |
|
| 447 |
var video = media[1]; |
| 448 |
t.equal(video.ssrcGroups.length, 2, 'video got 2 ssrc-group lines'); |
| 449 |
|
| 450 |
var expectedSsrc = [ |
| 451 |
{ semantics: 'FID', ssrcs: '3004364195 1126032854' }, |
| 452 |
{ semantics: 'FEC-FR', ssrcs: '3004364195 1080772241' } |
| 453 |
]; |
| 454 |
t.deepEqual(video.ssrcGroups, expectedSsrc, 'video ssrc-group obj'); |
| 455 |
}); |
| 456 |
|
| 457 |
test('simulcastSdp', function *(t) { |
| 458 |
var sdp = yield fs.readFile(__dirname + '/simulcast.sdp', 'utf8'); |
| 459 |
|
| 460 |
var session = parse(sdp+''); |
| 461 |
t.ok(session, 'got session info'); |
| 462 |
var media = session.media; |
| 463 |
t.ok(media && media.length > 0, 'got media'); |
| 464 |
|
| 465 |
var video = media[1]; |
| 466 |
t.equal(video.type, 'video', 'video type'); |
| 467 |
|
| 468 |
// test rid lines |
| 469 |
t.equal(video.rids.length, 5, 'video got 5 rid lines'); |
| 470 |
// test rid 1 |
| 471 |
t.deepEqual(video.rids[0], { |
| 472 |
id: 1, |
| 473 |
direction: 'send', |
| 474 |
params: 'pt=97;max-width=1280;max-height=720;max-fps=30' |
| 475 |
}, 'video 1st rid line'); |
| 476 |
// test rid 2 |
| 477 |
t.deepEqual(video.rids[1], { |
| 478 |
id: 2, |
| 479 |
direction: 'send', |
| 480 |
params: 'pt=98' |
| 481 |
}, 'video 2nd rid line'); |
| 482 |
// test rid 3 |
| 483 |
t.deepEqual(video.rids[2], { |
| 484 |
id: 3, |
| 485 |
direction: 'send', |
| 486 |
params: 'pt=99' |
| 487 |
}, 'video 3rd rid line'); |
| 488 |
// test rid 4 |
| 489 |
t.deepEqual(video.rids[3], { |
| 490 |
id: 4, |
| 491 |
direction: 'send', |
| 492 |
params: 'pt=100' |
| 493 |
}, 'video 4th rid line'); |
| 494 |
// test rid 5 |
| 495 |
t.deepEqual(video.rids[4], { |
| 496 |
id: 'c', |
| 497 |
direction: 'recv', |
| 498 |
params: 'pt=97' |
| 499 |
}, 'video 5th rid line'); |
| 500 |
// test rid 1 params |
| 501 |
var rid1Params = parseParams(video.rids[0].params); |
| 502 |
t.deepEqual(rid1Params, { |
| 503 |
'pt': 97, |
| 504 |
'max-width': 1280, |
| 505 |
'max-height': 720, |
| 506 |
'max-fps': 30 |
| 507 |
}, 'video 1st rid params'); |
| 508 |
// test rid 2 params |
| 509 |
var rid2Params = parseParams(video.rids[1].params); |
| 510 |
t.deepEqual(rid2Params, { |
| 511 |
'pt': 98 |
| 512 |
}, 'video 2nd rid params'); |
| 513 |
// test rid 3 params |
| 514 |
var rid3Params = parseParams(video.rids[2].params); |
| 515 |
t.deepEqual(rid3Params, { |
| 516 |
'pt': 99 |
| 517 |
}, 'video 3rd rid params'); |
| 518 |
// test rid 4 params |
| 519 |
var rid4Params = parseParams(video.rids[3].params); |
| 520 |
t.deepEqual(rid4Params, { |
| 521 |
'pt': 100 |
| 522 |
}, 'video 4th rid params'); |
| 523 |
// test rid 5 params |
| 524 |
var rid5Params = parseParams(video.rids[4].params); |
| 525 |
t.deepEqual(rid5Params, { |
| 526 |
'pt': 97 |
| 527 |
}, 'video 5th rid params'); |
| 528 |
|
| 529 |
// test imageattr lines |
| 530 |
t.equal(video.imageattrs.length, 5, 'video got 5 imageattr lines'); |
| 531 |
// test imageattr 1 |
| 532 |
t.deepEqual(video.imageattrs[0], { |
| 533 |
pt: 97, |
| 534 |
dir1: 'send', |
| 535 |
attrs1: '[x=1280,y=720]', |
| 536 |
dir2: 'recv', |
| 537 |
attrs2: '[x=1280,y=720] [x=320,y=180] [x=160,y=90]' |
| 538 |
}, 'video 1st imageattr line'); |
| 539 |
// test imageattr 2 |
| 540 |
t.deepEqual(video.imageattrs[1], { |
| 541 |
pt: 98, |
| 542 |
dir1: 'send', |
| 543 |
attrs1: '[x=320,y=180]' |
| 544 |
}, 'video 2nd imageattr line'); |
| 545 |
// test imageattr 3 |
| 546 |
t.deepEqual(video.imageattrs[2], { |
| 547 |
pt: 99, |
| 548 |
dir1: 'send', |
| 549 |
attrs1: '[x=160,y=90]' |
| 550 |
}, 'video 3rd imageattr line'); |
| 551 |
// test imageattr 4 |
| 552 |
t.deepEqual(video.imageattrs[3], { |
| 553 |
pt: 100, |
| 554 |
dir1: 'recv', |
| 555 |
attrs1: '[x=1280,y=720] [x=320,y=180]', |
| 556 |
dir2: 'send', |
| 557 |
attrs2: '[x=1280,y=720]' |
| 558 |
}, 'video 4th imageattr line'); |
| 559 |
// test imageattr 5 |
| 560 |
t.deepEqual(video.imageattrs[4], { |
| 561 |
pt: '*', |
| 562 |
dir1: 'recv', |
| 563 |
attrs1: '*' |
| 564 |
}, 'video 5th imageattr line'); |
| 565 |
// test imageattr 1 send params |
| 566 |
var imageattr1SendParams = parseImageAttributes(video.imageattrs[0].attrs1); |
| 567 |
t.deepEqual(imageattr1SendParams, [ |
| 568 |
{'x': 1280, 'y': 720} |
| 569 |
], 'video 1st imageattr send params'); |
| 570 |
// test imageattr 1 recv params |
| 571 |
var imageattr1RecvParams = parseImageAttributes(video.imageattrs[0].attrs2); |
| 572 |
t.deepEqual(imageattr1RecvParams, [ |
| 573 |
{'x': 1280, 'y': 720}, |
| 574 |
{'x': 320, 'y': 180}, |
| 575 |
{'x': 160, 'y': 90}, |
| 576 |
], 'video 1st imageattr recv params'); |
| 577 |
// test imageattr 2 send params |
| 578 |
var imageattr2SendParams = parseImageAttributes(video.imageattrs[1].attrs1); |
| 579 |
t.deepEqual(imageattr2SendParams, [ |
| 580 |
{'x': 320, 'y': 180} |
| 581 |
], 'video 2nd imageattr send params'); |
| 582 |
// test imageattr 3 send params |
| 583 |
var imageattr3SendParams = parseImageAttributes(video.imageattrs[2].attrs1); |
| 584 |
t.deepEqual(imageattr3SendParams, [ |
| 585 |
{'x': 160, 'y': 90} |
| 586 |
], 'video 3rd imageattr send params'); |
| 587 |
// test imageattr 4 recv params |
| 588 |
var imageattr4RecvParams = parseImageAttributes(video.imageattrs[3].attrs1); |
| 589 |
t.deepEqual(imageattr4RecvParams, [ |
| 590 |
{'x': 1280, 'y': 720}, |
| 591 |
{'x': 320, 'y': 180}, |
| 592 |
], 'video 4th imageattr recv params'); |
| 593 |
// test imageattr 4 send params |
| 594 |
var imageattr4SendParams = parseImageAttributes(video.imageattrs[3].attrs2); |
| 595 |
t.deepEqual(imageattr4SendParams, [ |
| 596 |
{'x': 1280, 'y': 720} |
| 597 |
], 'video 4th imageattr send params'); |
| 598 |
// test imageattr 5 recv params |
| 599 |
t.equal(video.imageattrs[4].attrs1, '*', 'video 5th imageattr recv params'); |
| 600 |
|
| 601 |
// test simulcast line |
| 602 |
t.deepEqual(video.simulcast, { |
| 603 |
dir1: 'send', |
| 604 |
list1: '1,~4;2;3', |
| 605 |
dir2: 'recv', |
| 606 |
list2: 'c' |
| 607 |
}, 'video simulcast line'); |
| 608 |
// test simulcast send streams |
| 609 |
var simulcastSendStreams = parseSimulcastStreamList(video.simulcast.list1); |
| 610 |
t.deepEqual(simulcastSendStreams, [ |
| 611 |
[ {scid: 1, paused: false}, {scid: 4, paused: true} ], |
| 612 |
[ {scid: 2, paused: false} ], |
| 613 |
[ {scid: 3, paused: false} ] |
| 614 |
], 'video simulcast send streams'); |
| 615 |
// test simulcast recv streams |
| 616 |
var simulcastRecvStreams = parseSimulcastStreamList(video.simulcast.list2); |
| 617 |
t.deepEqual(simulcastRecvStreams, [ |
| 618 |
[ {scid: 'c', paused: false} ] |
| 619 |
], 'video simulcast recv streams'); |
| 620 |
|
| 621 |
// test simulcast version 03 line |
| 622 |
// test simulcast line |
| 623 |
t.deepEqual(video.simulcast_03, { |
| 624 |
value: 'send rid=1,4;2;3 paused=4 recv rid=c' |
| 625 |
}, 'video simulcast draft 03 line'); |
| 626 |
}); |
| 627 |
|
| 628 |
test('ST2022-6', function *(t) { |
| 629 |
var sdp = yield fs.readFile(__dirname + '/st2022-6.sdp', 'utf8'); |
| 630 |
|
| 631 |
var session = parse(sdp+''); |
| 632 |
t.ok(session, 'got session info'); |
| 633 |
var media = session.media; |
| 634 |
t.ok(media && media.length > 0, 'got media'); |
| 635 |
|
| 636 |
var video = media[0]; |
| 637 |
var sourceFilter = video.sourceFilter; |
| 638 |
t.equal(sourceFilter.filterMode, 'incl', 'filter-mode is "incl"'); |
| 639 |
t.equal(sourceFilter.netType, 'IN', 'nettype is "IN"'); |
| 640 |
t.equal(sourceFilter.addressTypes, 'IP4', 'address-type is "IP4"'); |
| 641 |
t.equal(sourceFilter.destAddress, '239.0.0.1', 'dest-address is "239.0.0.1"'); |
| 642 |
t.equal(sourceFilter.srcList, '192.168.20.20', 'src-list is "192.168.20.20"'); |
| 643 |
}); |
| 644 |
|
| 645 |
test('ST2110-20', function* (t) { |
| 646 |
var sdp = yield fs.readFile(__dirname + '/st2110-20.sdp', 'utf8'); |
| 647 |
|
| 648 |
var session = parse(sdp + ''); |
| 649 |
t.ok(session, 'got session info'); |
| 650 |
var media = session.media; |
| 651 |
t.ok(media && media.length > 0, 'got media'); |
| 652 |
|
| 653 |
var video = media[0]; |
| 654 |
var sourceFilter = video.sourceFilter; |
| 655 |
t.equal(sourceFilter.filterMode, 'incl', 'filter-mode is "incl"'); |
| 656 |
t.equal(sourceFilter.netType, 'IN', 'nettype is "IN"'); |
| 657 |
t.equal(sourceFilter.addressTypes, 'IP4', 'address-type is "IP4"'); |
| 658 |
t.equal(sourceFilter.destAddress, '239.100.9.10', 'dest-address is "239.100.9.10"'); |
| 659 |
t.equal(sourceFilter.srcList, '192.168.100.2', 'src-list is "192.168.100.2"'); |
| 660 |
|
| 661 |
t.equal(video.type, 'video', 'video type'); |
| 662 |
var fmtp0Params = parseParams(video.fmtp[0].config); |
| 663 |
t.deepEqual(fmtp0Params, { |
| 664 |
sampling: 'YCbCr-4:2:2', |
| 665 |
width: 1280, |
| 666 |
height: 720, |
| 667 |
interlace: undefined, |
| 668 |
exactframerate: '60000/1001', |
| 669 |
depth: 10, |
| 670 |
TCS: 'SDR', |
| 671 |
colorimetry: 'BT709', |
| 672 |
PM: '2110GPM', |
| 673 |
SSN: 'ST2110-20:2017' |
| 674 |
}, 'video 5th rid params'); |
| 675 |
}); |
| 676 |
|
| 677 |
test('SCTP-DTLS-26', function* (t) { |
| 678 |
var sdp = yield fs.readFile(__dirname + '/sctp-dtls-26.sdp', 'utf8'); |
| 679 |
|
| 680 |
var session = parse(sdp + ''); |
| 681 |
t.ok(session, 'got session info'); |
| 682 |
var media = session.media; |
| 683 |
t.ok(media && media.length > 0, 'got media'); |
| 684 |
|
| 685 |
t.equal(session.origin.sessionId, '5636137646675714991', 'origin sessionId'); |
| 686 |
t.ok(session.groups, 'parsing session groups'); |
| 687 |
t.equal(session.groups.length, 1, 'one grouping'); |
| 688 |
t.equal(session.groups[0].type, 'BUNDLE', 'grouping is BUNDLE'); |
| 689 |
t.equal(session.groups[0].mids, 'data', 'bundling data'); |
| 690 |
t.ok(session.msidSemantic, 'have an msid semantic'); |
| 691 |
t.equal(session.msidSemantic.semantic, 'WMS', 'webrtc semantic'); |
| 692 |
|
| 693 |
// verify media is data application |
| 694 |
t.equal(media[0].type, 'application', 'media type application'); |
| 695 |
t.equal(media[0].mid, 'data', 'media id pplication'); |
| 696 |
|
| 697 |
// verify protocol and ports |
| 698 |
t.equal(media[0].protocol, 'UDP/DTLS/SCTP', 'protocol is UDP/DTLS/SCTP'); |
| 699 |
t.equal(media[0].port, 9, 'the UDP port value is 9'); |
| 700 |
t.equal(media[0].sctpPort, 5000, 'the offerer/answer SCTP port value is 5000'); |
| 701 |
|
| 702 |
// verify maxMessageSize |
| 703 |
t.equal(media[0].maxMessageSize, 10000, 'maximum message size is 10000'); |
| 704 |
}); |
| 705 |
|
| 706 |
test('extmapEncryptSdp', function *(t) { |
| 707 |
var sdp = yield fs.readFile(__dirname + '/extmap-encrypt.sdp', 'utf8'); |
| 708 |
|
| 709 |
var session = parse(sdp+''); |
| 710 |
t.ok(session, 'got session info'); |
| 711 |
var media = session.media; |
| 712 |
t.ok(media && media.length > 0, 'got media'); |
| 713 |
|
| 714 |
t.equal(session.origin.username, '-', 'origin username'); |
| 715 |
t.equal(session.origin.sessionId, 20518, 'origin sessionId'); |
| 716 |
t.equal(session.origin.sessionVersion, 0, 'origin sessionVersion'); |
| 717 |
t.equal(session.origin.netType, 'IN', 'origin netType'); |
| 718 |
t.equal(session.origin.ipVer, 4, 'origin ipVer'); |
| 719 |
t.equal(session.origin.address, '203.0.113.1', 'origin address'); |
| 720 |
|
| 721 |
t.equal(session.connection.ip, '203.0.113.1', 'session connect ip'); |
| 722 |
t.equal(session.connection.version, 4, 'session connect ip ver'); |
| 723 |
|
| 724 |
var audio = media[0]; |
| 725 |
t.equal(audio.type, 'audio', 'audio type'); |
| 726 |
t.equal(audio.port, 54400, 'audio port'); |
| 727 |
t.equal(audio.protocol, 'RTP/SAVPF', 'audio protocol'); |
| 728 |
t.equal(audio.rtp[0].payload, 96, 'audio rtp 0 payload'); |
| 729 |
t.equal(audio.rtp[0].codec, 'opus', 'audio rtp 0 codec'); |
| 730 |
t.equal(audio.rtp[0].rate, 48000, 'audio rtp 0 rate'); |
| 731 |
|
| 732 |
// extmap and encrypted extmap |
| 733 |
t.deepEqual(audio.ext[0], { |
| 734 |
value: 1, |
| 735 |
direction: 'sendonly', |
| 736 |
uri: 'URI-toffset' |
| 737 |
}, 'audio extension 0'); |
| 738 |
t.deepEqual(audio.ext[1], { |
| 739 |
value: 2, |
| 740 |
uri: 'urn:ietf:params:rtp-hdrext:toffset' |
| 741 |
}, 'audio extension 1'); |
| 742 |
t.deepEqual(audio.ext[2], { |
| 743 |
value: 3, |
| 744 |
'encrypt-uri': 'urn:ietf:params:rtp-hdrext:encrypt', |
| 745 |
uri: 'urn:ietf:params:rtp-hdrext:smpte-tc', |
| 746 |
config: '25@600/24' |
| 747 |
}, 'audio extension 2'); |
| 748 |
t.deepEqual(audio.ext[3], { |
| 749 |
value: 4, |
| 750 |
direction: 'recvonly', |
| 751 |
'encrypt-uri': 'urn:ietf:params:rtp-hdrext:encrypt', |
| 752 |
uri: 'URI-gps-string' |
| 753 |
}, 'audio extension 3'); |
| 754 |
|
| 755 |
t.equal(media.length, 1, 'got 1 m-lines'); |
| 756 |
}); |
| 757 |
|
| 758 |
test('dante-aes67', function *(t) { |
| 759 |
var sdp = yield fs.readFile(__dirname + '/dante-aes67.sdp', 'utf8'); |
| 760 |
|
| 761 |
var session = parse(sdp+''); |
| 762 |
t.ok(session, 'got session info'); |
| 763 |
var media = session.media; |
| 764 |
t.ok(media && media.length == 1, 'got single media'); |
| 765 |
|
| 766 |
t.equal(session.origin.username, '-', 'origin username'); |
| 767 |
t.equal(session.origin.sessionId, 1423986, 'origin sessionId'); |
| 768 |
t.equal(session.origin.sessionVersion, 1423994, 'origin sessionVersion'); |
| 769 |
t.equal(session.origin.netType, 'IN', 'origin netType'); |
| 770 |
t.equal(session.origin.ipVer, 4, 'origin ipVer'); |
| 771 |
t.equal(session.origin.address, '169.254.98.63', 'origin address'); |
| 772 |
|
| 773 |
t.equal(session.name, 'AOIP44-serial-1614 : 2', 'Session Name'); |
| 774 |
t.equal(session.keywords, 'Dante', 'Keywords'); |
| 775 |
|
| 776 |
t.equal(session.connection.ip, '239.65.125.63/32', 'session connect ip'); |
| 777 |
t.equal(session.connection.version, 4, 'session connect ip ver'); |
| 778 |
|
| 779 |
var audio = media[0]; |
| 780 |
t.equal(audio.type, 'audio', 'audio type'); |
| 781 |
t.equal(audio.port, 5004, 'audio port'); |
| 782 |
t.equal(audio.protocol, 'RTP/AVP', 'audio protocol'); |
| 783 |
t.equal(audio.direction, 'recvonly', 'audio direction'); |
| 784 |
t.equal(audio.description, '2 channels: TxChan 0, TxChan 1', 'audio description'); |
| 785 |
t.equal(audio.ptime, 1, 'audio packet duration'); |
| 786 |
t.equal(audio.rtp[0].payload, 97, 'audio rtp payload type'); |
| 787 |
t.equal(audio.rtp[0].codec, 'L24', 'audio rtp codec'); |
| 788 |
t.equal(audio.rtp[0].rate, 48000, 'audio sample rate'); |
| 789 |
t.equal(audio.rtp[0].encoding, 2, 'audio channels'); |
| 790 |
}); |
| 791 |
|
| 792 |
test('bfcp', function *(t) { |
| 793 |
var sdp = yield fs.readFile(__dirname + '/bfcp.sdp', 'utf8'); |
| 794 |
|
| 795 |
var session = parse(sdp+''); |
| 796 |
t.ok(session, 'got session info'); |
| 797 |
var media = session.media; |
| 798 |
t.ok(media && media.length == 4, 'got 4 media'); |
| 799 |
|
| 800 |
t.equal(session.origin.username, '-', 'origin username'); |
| 801 |
|
| 802 |
var audio = media[0]; |
| 803 |
t.equal(audio.type, 'audio', 'audio type'); |
| 804 |
|
| 805 |
var video = media[1]; |
| 806 |
t.equal(video.type, 'video', 'main video type'); |
| 807 |
t.equal(video.direction, 'sendrecv', 'main video direction'); |
| 808 |
t.equal(video.content, 'main', 'main video content'); |
| 809 |
t.equal(video.label, 1, 'main video label'); |
| 810 |
|
| 811 |
var app = media[2]; |
| 812 |
t.equal(app.type, 'application', 'application type'); |
| 813 |
t.equal(app.port, 3238, 'application port'); |
| 814 |
t.equal(app.protocol, 'UDP/BFCP', 'bfcp protocol'); |
| 815 |
t.equal(app.payloads, '*', 'bfcp payloads'); |
| 816 |
t.equal(app.connectionType, 'new', 'connection type'); |
| 817 |
t.equal(app.bfcpFloorCtrl, 's-only', 'bfcp Floor Control'); |
| 818 |
t.equal(app.bfcpConfId, 1, 'bfcp ConfId'); |
| 819 |
t.equal(app.bfcpUserId, 1, 'bfcp UserId'); |
| 820 |
t.equal(app.bfcpFloorId.id, 1, 'bfcp FloorId'); |
| 821 |
t.equal(app.bfcpFloorId.mStream, 3, 'bfcp Floor Stream'); |
| 822 |
|
| 823 |
var video2 = media[3]; |
| 824 |
t.equal(video2.type, 'video', '2nd video type'); |
| 825 |
t.equal(video2.direction, 'sendrecv', '2nd video direction'); |
| 826 |
t.equal(video2.content, 'slides', '2nd video content'); |
| 827 |
t.equal(video2.label, 3, '2nd video label'); |
| 828 |
}); |
| 829 |
|
| 830 |
test('tcp-active', function *(t) { |
| 831 |
var sdp = yield fs.readFile(__dirname + '/tcp-active.sdp', 'utf8'); |
| 832 |
|
| 833 |
var session = parse(sdp+''); |
| 834 |
t.ok(session, 'got session info'); |
| 835 |
var media = session.media; |
| 836 |
t.ok(media && media.length == 1, 'got single media'); |
| 837 |
|
| 838 |
t.equal(session.origin.username, '-', 'origin username'); |
| 839 |
t.equal(session.origin.sessionId, 1562876543, 'origin sessionId'); |
| 840 |
t.equal(session.origin.sessionVersion, 11, 'origin sessionVersion'); |
| 841 |
t.equal(session.origin.netType, 'IN', 'origin netType'); |
| 842 |
t.equal(session.origin.ipVer, 4, 'origin ipVer'); |
| 843 |
t.equal(session.origin.address, '192.0.2.3', 'origin address'); |
| 844 |
|
| 845 |
var image = media[0]; |
| 846 |
t.equal(image.type, 'image', 'image type'); |
| 847 |
t.equal(image.port, 9, 'port'); |
| 848 |
t.equal(image.connection.version, 4, 'Connection is IPv4'); |
| 849 |
t.equal(image.connection.ip, '192.0.2.3', 'Connection address'); |
| 850 |
t.equal(image.protocol, 'TCP', 'TCP protocol'); |
| 851 |
t.equal(image.payloads, 't38', 'TCP payload'); |
| 852 |
t.equal(image.setup, 'active', 'setup active'); |
| 853 |
t.equal(image.connectionType, 'new', 'new connection'); |
| 854 |
}); |
| 855 |
|
| 856 |
test('tcp-passive', function *(t) { |
| 857 |
var sdp = yield fs.readFile(__dirname + '/tcp-passive.sdp', 'utf8'); |
| 858 |
|
| 859 |
var session = parse(sdp+''); |
| 860 |
t.ok(session, 'got session info'); |
| 861 |
var media = session.media; |
| 862 |
t.ok(media && media.length == 1, 'got single media'); |
| 863 |
|
| 864 |
t.equal(session.origin.username, '-', 'origin username'); |
| 865 |
t.equal(session.origin.sessionId, 1562876543, 'origin sessionId'); |
| 866 |
t.equal(session.origin.sessionVersion, 11, 'origin sessionVersion'); |
| 867 |
t.equal(session.origin.netType, 'IN', 'origin netType'); |
| 868 |
t.equal(session.origin.ipVer, 4, 'origin ipVer'); |
| 869 |
t.equal(session.origin.address, '192.0.2.2', 'origin address'); |
| 870 |
|
| 871 |
var image = media[0]; |
| 872 |
t.equal(image.type, 'image', 'image type'); |
| 873 |
t.equal(image.port, 54111, 'port'); |
| 874 |
t.equal(image.connection.version, 4, 'Connection is IPv4'); |
| 875 |
t.equal(image.connection.ip, '192.0.2.2', 'Connection address'); |
| 876 |
t.equal(image.protocol, 'TCP', 'TCP protocol'); |
| 877 |
t.equal(image.payloads, 't38', 'TCP payload'); |
| 878 |
t.equal(image.setup, 'passive', 'setup passive'); |
| 879 |
t.equal(image.connectionType, 'existing', 'existing connection'); |
| 880 |
}); |
| 881 |
|
| 882 |
test('mediaclk-avbtp', function *(t) { |
| 883 |
var sdp = yield fs.readFile(__dirname + '/mediaclk-avbtp.sdp', 'utf8'); |
| 884 |
|
| 885 |
var session = parse(sdp+''); |
| 886 |
t.ok(session, 'got session info'); |
| 887 |
var media = session.media; |
| 888 |
t.ok(media && media.length == 1, 'got single media'); |
| 889 |
|
| 890 |
var audio = media[0]; |
| 891 |
t.equal(audio.mediaClk.mediaClockName, 'IEEE1722', 'IEEE1722 Media Clock'); |
| 892 |
t.equal(audio.mediaClk.mediaClockValue, '38-D6-6D-8E-D2-78-13-2F', 'AVB stream ID'); |
| 893 |
}); |
| 894 |
|
| 895 |
test('mediaclk-ptp-v2-w-rate', function *(t) { |
| 896 |
var sdp = yield fs.readFile(__dirname + '/mediaclk-ptp-v2-w-rate.sdp', 'utf8'); |
| 897 |
|
| 898 |
var session = parse(sdp+''); |
| 899 |
t.ok(session, 'got session info'); |
| 900 |
var media = session.media; |
| 901 |
t.ok(media && media.length == 1, 'got single media'); |
| 902 |
|
| 903 |
var audio = media[0]; |
| 904 |
t.equal(audio.mediaClk.mediaClockName, 'direct', 'Direct Media Clock'); |
| 905 |
t.equal(audio.mediaClk.mediaClockValue, 963214424, 'offset'); |
| 906 |
t.equal(audio.mediaClk.rateNumerator, 1000, 'rate numerator'); |
| 907 |
t.equal(audio.mediaClk.rateDenominator, 1001, 'rate denominator'); |
| 908 |
}); |
| 909 |
|
| 910 |
test('mediaclk-ptp-v2', function *(t) { |
| 911 |
var sdp = yield fs.readFile(__dirname + '/mediaclk-ptp-v2.sdp', 'utf8'); |
| 912 |
|
| 913 |
var session = parse(sdp+''); |
| 914 |
t.ok(session, 'got session info'); |
| 915 |
var media = session.media; |
| 916 |
t.ok(media && media.length == 1, 'got single media'); |
| 917 |
|
| 918 |
var audio = media[0]; |
| 919 |
t.equal(audio.mediaClk.mediaClockName, 'direct', 'Direct Media Clock'); |
| 920 |
t.equal(audio.mediaClk.mediaClockValue, 963214424, 'offset'); |
| 921 |
}); |
| 922 |
|
| 923 |
test('mediaclk-rtp', function *(t) { |
| 924 |
var sdp = yield fs.readFile(__dirname + '/mediaclk-rtp.sdp', 'utf8'); |
| 925 |
|
| 926 |
var session = parse(sdp+''); |
| 927 |
t.ok(session, 'got session info'); |
| 928 |
var media = session.media; |
| 929 |
t.ok(media && media.length == 1, 'got single media'); |
| 930 |
|
| 931 |
var audio = media[0]; |
| 932 |
t.equal(audio.mediaClk.id, 'MDA6NjA6MmI6MjA6MTI6MWY=', 'Media Clock ID'); |
| 933 |
t.equal(audio.mediaClk.mediaClockName, 'sender', 'sender type'); |
| 934 |
}); |
| 935 |
|
| 936 |
test('ts-refclk-media', function *(t) { |
| 937 |
var sdp = yield fs.readFile(__dirname + '/ts-refclk-media.sdp', 'utf8'); |
| 938 |
|
| 939 |
var session = parse(sdp+''); |
| 940 |
t.ok(session, 'got session info'); |
| 941 |
|
| 942 |
var sessTsRefClocks = session.tsRefClocks; |
| 943 |
t.ok(sessTsRefClocks && sessTsRefClocks.length == 1, 'got one TS Ref Clock'); |
| 944 |
t.equal(sessTsRefClocks[0].clksrc, 'local', 'local Clock Source at Session Level'); |
| 945 |
|
| 946 |
var media = session.media; |
| 947 |
t.ok(media && media.length == 2, 'got two media'); |
| 948 |
|
| 949 |
var audio = media[0]; |
| 950 |
var audTsRefClocks = audio.tsRefClocks; |
| 951 |
t.ok(audTsRefClocks && audTsRefClocks.length == 2, 'got two audio TS Ref Clocks'); |
| 952 |
|
| 953 |
var audTsRefClock1 = audTsRefClocks[0]; |
| 954 |
t.equal(audTsRefClock1.clksrc, 'ntp', 'NTP Clock Source'); |
| 955 |
t.equal(audTsRefClock1.clksrcExt, '203.0.113.10', 'IPv4 address'); |
| 956 |
|
| 957 |
var audTsRefClock2 = audTsRefClocks[1]; |
| 958 |
t.equal(audTsRefClock2.clksrc, 'ntp', 'NTP Clock Source'); |
| 959 |
t.equal(audTsRefClock2.clksrcExt, '198.51.100.22', 'IPv4 address'); |
| 960 |
|
| 961 |
var video = media[1]; |
| 962 |
var vidTsRefClocks = video.tsRefClocks; |
| 963 |
t.ok(vidTsRefClocks && vidTsRefClocks.length == 1, 'got one video TS Ref Clocks'); |
| 964 |
t.equal(vidTsRefClocks[0].clksrc, 'ptp', 'PTP Clock Source'); |
| 965 |
t.equal(vidTsRefClocks[0].clksrcExt, 'IEEE802.1AS-2011:39-A7-94-FF-FE-07-CB-D0', 'PTP config'); |
| 966 |
}); |
| 967 |
|
| 968 |
test('ts-refclk-sess', function *(t) { |
| 969 |
var sdp = yield fs.readFile(__dirname + '/ts-refclk-sess.sdp', 'utf8'); |
| 970 |
|
| 971 |
var session = parse(sdp+''); |
| 972 |
t.ok(session, 'got session info'); |
| 973 |
|
| 974 |
var sessTsRefClocks = session.tsRefClocks; |
| 975 |
t.ok(sessTsRefClocks && sessTsRefClocks.length == 1, 'got one TS Ref Clock at Session Level'); |
| 976 |
t.equal(sessTsRefClocks[0].clksrc, 'ntp', 'NTP Clock Source'); |
| 977 |
t.equal(sessTsRefClocks[0].clksrcExt, '/traceable/', 'traceable Clock Source'); |
| 978 |
}); |