Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to fail files which do not include any media descriptions #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ The parameters of the library are binary flags that match the command line optio
* `whitespace`: Strict check of adherence to whitespace rules.
* `should`: As well as shall, also check all should clauses.
* `noCopy`: Fail obvious copies of the ST 2110-10 SDP example.
* `noMedia`: Fail SDP files which do not include any media descriptions.
* `duplicate`: Expect duplicate streams aka ST 2022-7.
* `videoOnly`: Describes only SMPTE ST 2110-20 streams.
* `audioOnly`: Describes only SMPTE ST 2110-30 streams.
Expand Down
16 changes: 16 additions & 0 deletions checkRFC4566.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,24 @@ const section_57 = (sdp, params) => {
return concat(tests.map(s => s(sdp, params)));
};

// Test if SDP file is missing media descriptions
const no_media = sdp => {
let lines = splitLines(sdp.trim());
let hasMedia = false;
for ( let x = 0 ; x < lines.length ; x++ ) {
if (lines[x].startsWith('m=')) {
hasMedia = true;
break;
}
}
return hasMedia ? [] : [ new Error('SDP file does not include any "m=" media attributes.') ];
};

const allSections = (sdp, params) => {
let sections = [ section_50, section_51, section_52, section_57 ];
if (params.noMedia) {
sections.push(no_media);
}
return concat(sections.map(s => s(sdp, params)));
};

Expand Down
6 changes: 4 additions & 2 deletions sdpoker.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const args = yargs
.default('whitespace', false)
.default('should', false)
.default('noCopy', true)
.default('noMedia', true)
.default('duplicate', false)
.default('videoOnly', false)
.default('audioOnly', false)
Expand All @@ -34,8 +35,8 @@ const args = yargs
.default('multicast', false)
.default('unicast', false)
.default('shaping', false)
.boolean([ 'nmos', 'checkEndings', 'whitespace', 'should', 'noCopy', 'duplicate',
'videoOnly', 'audioOnly', 'channelOrder',
.boolean([ 'nmos', 'checkEndings', 'whitespace', 'should', 'noCopy', 'noMedia',
'duplicate', 'videoOnly', 'audioOnly', 'channelOrder',
'useIP4', 'useIP6', 'multicast', 'unicast', 'shaping' ])
.usage('Check an SDP file for conformance with RFC4566 and SMPTE ST 2110.\n' +
'Usage: $0 [options] <sdp_file or HTTP URL>')
Expand All @@ -44,6 +45,7 @@ const args = yargs
.describe('whitespace', 'Strict check of adherence to whitespace rules.')
.describe('should', 'As well as shall, also check all should clauses.')
.describe('noCopy', 'Fail obvious copies of the ST 2110-10 SDP example')
.describe('noMedia', 'Fail SDP files which do not include any media descriptions')
.describe('duplicate', 'Expect duplicate streams aka ST 2022-7.')
.describe('videoOnly', 'Describes only SMPTE ST 2110-20 streams.')
.describe('audioOnly', 'Describes only SMPTE ST 2110-30 streams.')
Expand Down