Streampunk / sdpoker

CLI tool and library for testing SMPTE ST2110 SDP files.
Apache License 2.0
37 stars 4 forks source link

Crash when SDP does not have exactframerate param #1

Closed simonrankine closed 6 years ago

simonrankine commented 6 years ago

When parsing the following SDP file:

v=0 o=- 1522057132 1522057132 IN IP4 172.29.82.49 s=IP Studio Stream t=0 0 m=video 5000 RTP/AVP 103 c=IN IP4 232.102.25.39/32 a=source-filter: incl IN IP4 232.102.25.39 172.29.82.49 a=ts-refclk:ptp=IEEE1588-2008:08-00-11-ff-fe-21-e1-b0 a=rtpmap:103 raw/90000 a=fmtp:103 sampling=YCbCr-4:2:2; width=1920; height=1080; depth=10; SSN=ST2110-20:2017; colorimetry=BT709; PM=2110GPM; TCS=SDR; a=mediaclk:direct=0 rate=90000 a=framerate:30 a=extmap:1 urn:x-nmos:rtp-hdrext:origin-timestamp a=extmap:2 urn:ietf:params:rtp-hdrext:smpte-tc 3e+03@90000/30 a=extmap:3 urn:x-nmos:rtp-hdrext:flow-id a=extmap:4 urn:x-nmos:rtp-hdrext:source-id a=extmap:5 urn:x-nmos:rtp-hdrext:grain-flags a=extmap:7 urn:x-nmos:rtp-hdrext:sync-timestamp a=extmap:9 urn:x-nmos:rtp-hdrext:grain-duration

sdpoker crashes with the following error message:

TypeError: Cannot read property 'match' of undefined at test_20_72_3 (/home/simonra/temp/sdpoker/checkST2110.js:542:43) at tests.map.t (/home/simonra/temp/sdpoker/checkST2110.js:1000:32) at Array.map () at section_20_72 (/home/simonra/temp/sdpoker/checkST2110.js:1000:23) at sections.map.s (/home/simonra/temp/sdpoker/checkST2110.js:1054:35) at Array.map () at allSections (/home/simonra/temp/sdpoker/checkST2110.js:1054:26) at test (/home/simonra/temp/sdpoker/sdpoker.js:78:24) at

This bug seems to originate here:

https://github.com/Streampunk/sdpoker/blob/388fd4cc8f3cc6ee5db49cf27f18b559978906e3/checkST2110.js#L541

Which should instead read:

if (typeof stream.exactframerate !== undefined && stream.exactframerate) {

As per:

https://stackoverflow.com/questions/13335873/how-can-i-check-whether-a-variable-is-defined-in-node-js

While I agree the SMPTE 2110-20 files should have exactframerate attribute the expected behaviour would be a warning in the program output rather than a crash.

sparkpunkd commented 6 years ago

Thanks for pointing that out. Should have been ...

if (typeof stream.exactframerate !== 'undefined')

... as typeof returns a string. Fixed in just published v0.0.9.