-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make the fmtp params could be munged in firefox (#12)
* fix: make the fmtp params could be munged in firefox * fix: change the params type in FmtpLine and fmtParams type in CodecInfo as map Co-authored-by: Brown Zhang <weizha2@example.com>
- Loading branch information
Showing
4 changed files
with
126 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { parseFmtpParams } from './fmtp-line'; | ||
|
||
describe('parseFmtpParams', () => { | ||
it('normal case', async () => { | ||
expect.hasAssertions(); | ||
const expectedValue = { | ||
'level-asymmetry-allowed': '1', | ||
'max-br': '1000000', | ||
'max-dpb': '63600', | ||
'packetization-mode': '1', | ||
'profile-level-id': '420034', | ||
}; | ||
let fmtpParams = parseFmtpParams( | ||
'level-asymmetry-allowed=1;max-br=1000000;max-dpb=63600;packetization-mode=1;profile-level-id=420034' | ||
); | ||
expect(Object.fromEntries(fmtpParams)).toStrictEqual(expectedValue); | ||
fmtpParams = parseFmtpParams( | ||
'a=fmtp:97 level-asymmetry-allowed=1;max-br=1000000;max-dpb=63600;packetization-mode=1;profile-level-id=420034' // real Safari case. | ||
); | ||
expect(Object.fromEntries(fmtpParams)).toStrictEqual(expectedValue); | ||
}); | ||
it('exceptional case', async () => { | ||
expect.hasAssertions(); | ||
expect(() => { | ||
parseFmtpParams( | ||
'level-asymmetry-allowed=1;max-br=1000000max-dpb=63600;packetization-mode=1;profile-level-id=420034' // only lack semicolon | ||
); | ||
}).toThrow(Error); | ||
expect(() => { | ||
parseFmtpParams( | ||
'level-asymmetry-allowed=1;max-br=max-dpb=63600;packetization-mode=1;profile-level-id=420034' // lack semicolon and value | ||
); | ||
}).toThrow(Error); | ||
expect(() => { | ||
parseFmtpParams( | ||
'level-asymmetry-allowed=1;max-br;max-dpb=63600;packetization-mode=1;profile-level-id=420034' // lack semicolon, value and equals sign | ||
); | ||
}).toThrow(Error); | ||
expect(() => { | ||
parseFmtpParams( | ||
'level-asymmetry-allowed=1;max-br=1000000;;max-dpb=63600;packetization-mode=1;profile-level-id=420034' // lack semicolon, value, equals sign and key | ||
); | ||
}).toThrow(Error); | ||
expect(() => { | ||
parseFmtpParams( | ||
'level-asymmetry-allowed=1;max-br=;max-dpb=63600;packetization-mode=1;profile-level-id=420034' // only lack value | ||
); | ||
}).toThrow(Error); | ||
expect(() => { | ||
parseFmtpParams( | ||
'level-asymmetry-allowed=1;max-br;max-dpb=63600;packetization-mode=1;profile-level-id=420034' // lack value and equals sign | ||
); | ||
}).toThrow(Error); | ||
expect(() => { | ||
parseFmtpParams( | ||
'level-asymmetry-allowed=1;=1000000;max-dpb=63600;packetization-mode=1;profile-level-id=420034' // only lack key | ||
); | ||
}).toThrow(Error); | ||
expect(() => { | ||
parseFmtpParams( | ||
'level-asymmetry-allowed=1;=;max-dpb=63600;packetization-mode=1;profile-level-id=420034' // lack key and value | ||
); | ||
}).toThrow(Error); | ||
expect(() => { | ||
parseFmtpParams( | ||
'level-asymmetry-allowed=1;=max-dpb=63600;packetization-mode=1;profile-level-id=420034' // lack key, value and semicolon | ||
); | ||
}).toThrow(Error); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters