-
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.
- Loading branch information
Showing
4 changed files
with
33 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
"libauth", | ||
"mindmeld", | ||
"mkdir", | ||
"mline", | ||
"multistream", | ||
"munge", | ||
"ndarray", | ||
|
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,17 @@ | ||
import { MediaLine, RtpMapLine } from './lines'; | ||
import { AvMediaDescription } from './model'; | ||
import { hasCodec } from './utils'; | ||
|
||
describe('hasCodec', () => { | ||
it('should return true only if the codec is present', () => { | ||
expect.hasAssertions(); | ||
const mLine = new AvMediaDescription( | ||
new MediaLine('video', 9, 'UDP/TLS/RTP/SAVPF', ['96', '97', '98', '99', '100', '101', '127']) | ||
); | ||
mLine.addLine(new RtpMapLine(96, 'h264', 9000)); | ||
|
||
expect(hasCodec('h264', mLine)).toBe(true); | ||
expect(hasCodec('H264', mLine)).toBe(true); | ||
expect(hasCodec('vp8', mLine)).toBe(false); | ||
}); | ||
}); |
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,14 @@ | ||
import { AvMediaDescription, CodecInfo } from './model'; | ||
|
||
/** | ||
* Check if the given codec is present in the given mline. | ||
* | ||
* @param codecName - The string name of the codec to check for (case insensitive). | ||
* @param mLine - The mline to search for the given codec. | ||
* @returns True if the codec is present, false otherwise. | ||
*/ | ||
export function hasCodec(codecName: string, mLine: AvMediaDescription): boolean { | ||
return [...mLine.codecs.values()].some( | ||
(ci: CodecInfo) => ci.name?.toLowerCase() === codecName.toLowerCase() | ||
); | ||
} |