-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use SCTE-214 supplemental codec instead of base codec if it's supported
* parse supplemental codec * add a property isSupplementalCoded supported and update getMimeType * add documentation for isSupplementalCodecSupported property * parse supplementalCodec in the adaptation set * return the codec that will be played if both supplemental codec is supported * parse multiple supplemental codec separated by white space * avoid unecessary call to iseCodecSupported if supplementalCodec is true * remove test file that shouldn't have been add * remplace == with isNullOrUndefined function * update regex to match more unexpected whitespace * code review * update rust WASM parser to parse supplementalCodecs * doc: update rfc number that obsoletes rfc4281 * move codec converting logic in "common" to convert from any parser * code review * set the codec to supplementalCodec if supported and remove supplementalCodec in the representation * handle case for subtitle * move code to another folder * reset unchanged file * remove staged file
- Loading branch information
1 parent
2a9efe7
commit 491945b
Showing
13 changed files
with
144 additions
and
23 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
37 changes: 37 additions & 0 deletions
37
src/parsers/manifest/dash/common/__tests__/convert_supplemental_codecs.test.ts
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,37 @@ | ||
import { convertSupplementalCodecsToRFC6381 } from "../convert_supplemental_codecs"; | ||
|
||
describe("parseSupplementalCodec", () => { | ||
it("should return the codec unchanged if there is only one codec", () => { | ||
expect(convertSupplementalCodecsToRFC6381("avc1.4d400d")) | ||
.toEqual("avc1.4d400d"); | ||
}); | ||
it("should trim starting and ending whitespace", () => { | ||
expect( | ||
convertSupplementalCodecsToRFC6381(" avc1.4d400d ")) | ||
.toEqual("avc1.4d400d"); | ||
}); | ||
it("should return comma-separated list if input is whitespace-separated", () => { | ||
expect( | ||
convertSupplementalCodecsToRFC6381("avc1.4d400d avc1.4d4015")) | ||
.toEqual("avc1.4d400d, avc1.4d4015"); | ||
}); | ||
it("should return comma-separated value if input is already comma-separated", () => { | ||
expect( | ||
convertSupplementalCodecsToRFC6381("avc1.4d400d, avc1.4d4015")) | ||
.toEqual("avc1.4d400d, avc1.4d4015"); | ||
}); | ||
|
||
it("should return comma-separated value if input as missplaced whitespace", () => { | ||
expect( | ||
convertSupplementalCodecsToRFC6381("avc1.4d400d , avc1.4d4015 ")) | ||
.toEqual("avc1.4d400d, avc1.4d4015"); | ||
}); | ||
|
||
it(`should return comma-separated value if input is mix of comma and | ||
whitespace separated list` | ||
, () => { | ||
expect( | ||
convertSupplementalCodecsToRFC6381("avc1.4d400d avc1.4d4015, avc1.4d401f")) | ||
.toEqual("avc1.4d400d, avc1.4d4015, avc1.4d401f"); | ||
}); | ||
}); |
32 changes: 32 additions & 0 deletions
32
src/parsers/manifest/dash/common/convert_supplemental_codecs.ts
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,32 @@ | ||
import isNonEmptyString from "../../../../utils/is_non_empty_string"; | ||
|
||
const supplementalCodecSeparator = /[, ]+/g; | ||
/** | ||
* Converts SCTE 214 supplemental codec string into RFC4281 codec string | ||
* | ||
* The returned value is a codec string respecting RFC6381 | ||
* | ||
* SCTE 214 defines supplemental codecs as a whitespace-separated multiple list of | ||
* codec strings | ||
* | ||
* RFC6381 defines codecs as a comma-separated list of codec strings. | ||
* | ||
* This two syntax differs and this parser is used to convert SCTE214 | ||
* to be compliant with what MSE APIs expect | ||
* | ||
* @param {string} val - The codec string to parse | ||
* @returns { Array.<string | undefined | null>} | ||
*/ | ||
export function convertSupplementalCodecsToRFC6381( | ||
val: string | ||
) : string { | ||
|
||
if (isNonEmptyString(val)) { | ||
return val | ||
.trim() | ||
.replace(supplementalCodecSeparator, ", "); | ||
} | ||
return ""; | ||
} | ||
|
||
|
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
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
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
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
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