Skip to content

Commit

Permalink
Merge pull request #1275 from klatoszewski-oke/checking_dolby_atmos
Browse files Browse the repository at this point in the history
Implement checking Dolby Atmos
  • Loading branch information
peaBerberian committed Sep 22, 2023
2 parents 832d524 + 2771422 commit c7b0dea
Show file tree
Hide file tree
Showing 14 changed files with 76 additions and 2 deletions.
11 changes: 11 additions & 0 deletions doc/api/Miscellaneous/Local_Contents.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ For audio tracks, it can looks like:
bitrate: 200000,
mimeType: "audio/mp4",
codecs: "mp4a.40.5",
isSpatialAudio: false,
index: {
loadInitSegment(callbacks) { /* ... */ },
loadSegment(segment, callbacks) { /* ... */,
Expand Down Expand Up @@ -470,6 +471,16 @@ We'll now explain what each property is for, before going deeper into the
- height (`number|undefined`): When relevant (mostly video contents), the
height of the media, in pixels
- isSpatialAudio (`boolean|undefined`): When relevant (mostly audio contents),
it can be set to `true` if the corresponding media is linked to a spatial
audio technology, for example a content relying on Dolby Atmos technology.
If set to `false`, it means that it is known that this media does not contain
any spatial audio.
For cases where you don't know and for cases where no audio is contained, this
can just be left undefined.
- index (`object`): Object allowing the RxPlayer to know the list of segments
as well as to fetch them. Described in the next chapter.
Expand Down
3 changes: 3 additions & 0 deletions doc/api/Player_Errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ contains the following properties:
- `codec` (`string|undefined`): The audio codec the Representation is
in, as announced in the corresponding Manifest.

- `isSpatialAudio` (`Boolean|undefined`): If set to `true`, this Representation
has spatial audio.

##### For text tracks

When `trackInfo.type` is set to `"text"`, `track` describes a text track. It
Expand Down
3 changes: 3 additions & 0 deletions doc/api/Track_Selection/getAudioTrack.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ return an object with the following properties:
- `codec` (`string|undefined`): The audio codec the Representation is
in, as announced in the corresponding Manifest.

- `isSpatialAudio` (`Boolean|undefined`): If set to `true`, this Representation
has spatial audio.

`undefined` if no audio content has been loaded yet or if its information is
unknown.

Expand Down
3 changes: 3 additions & 0 deletions doc/api/Track_Selection/getAvailableAudioTracks.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ Each of the objects in the returned array have the following properties:
- `codec` (`string|undefined`): The audio codec the Representation is
in, as announced in the corresponding Manifest.

- `isSpatialAudio` (`Boolean|undefined`): If set to `true`, this Representation
has spatial audio.

<div class="note">
Note for multi-Period contents:
<br>
Expand Down
21 changes: 19 additions & 2 deletions src/manifest/representation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ class Representation {
*/
public frameRate? : string;

/**
* `true` if this `Representation` is linked to a spatial audio technology.
* For example, it may be set to `true` if the Representation relies on the
* "Dolby Atmos". technology.
*
* `false` if it is known that this `Representation` does not contain any
* spatial audio.
*
* `undefined` if we do not know whether this `Representation` contains
* spatial audio or not.
*/
public isSpatialAudio? : boolean | undefined;

/**
* A string describing the codec used for this Representation.
* undefined if we do not know.
Expand Down Expand Up @@ -148,6 +161,10 @@ class Representation {
this.bitrate = args.bitrate;
this.codec = args.codecs;

if (args.isSpatialAudio !== undefined) {
this.isSpatialAudio = args.isSpatialAudio;
}

if (args.height !== undefined) {
this.height = args.height;
}
Expand Down Expand Up @@ -370,8 +387,8 @@ class Representation {
* @returns {Object}
*/
public toAudioRepresentation(): IAudioRepresentation {
const { id, bitrate, codec } = this;
return { id, bitrate, codec };
const { id, isSpatialAudio, bitrate, codec } = this;
return { id, isSpatialAudio, bitrate, codec };
}

/**
Expand Down
10 changes: 10 additions & 0 deletions src/parsers/manifest/dash/common/parse_representations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,16 @@ export default function parseRepresentations(
index: representationIndex,
id: representationID };

if (
representation.children.supplementalProperties !== undefined &&
arrayFind(representation.children.supplementalProperties, r =>
r.schemeIdUri === "tag:dolby.com,2018:dash:EC3_ExtensionType:2018" &&
r.value === "JOC"
)
) {
parsedRepresentation.isSpatialAudio = true;
}

// Add optional attributes
let codecs : string|undefined;
if (representation.attributes.codecs != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ function parseRepresentationChildren(
contentProtections.push(contentProtection);
}
break;
case "SupplementalProperty":
if (children.supplementalProperties == null) {
children.supplementalProperties = [parseScheme(currentElement)];
} else {
children.supplementalProperties.push(parseScheme(currentElement));
}
break;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/parsers/manifest/dash/node_parser_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ export interface IRepresentationChildren {
segmentBase? : ISegmentBaseIntermediateRepresentation;
segmentList? : ISegmentListIntermediateRepresentation;
segmentTemplate? : ISegmentTemplateIntermediateRepresentation;
supplementalProperties? : IScheme[] | undefined;
}

/* Intermediate representation for A Representation node's attributes. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ export function generateRepresentationChildrenParser(
break;
}

case TagName.SupplementalProperty: {
const supplementalProperty = {};
if (childrenObj.supplementalProperties === undefined) {
childrenObj.supplementalProperties = [];
}
childrenObj.supplementalProperties.push(supplementalProperty);
const attributeParser = generateSchemeAttrParser(supplementalProperty,
linearMemory);
parsersStack.pushParsers(nodeId, noop, attributeParser);
break;
}

case TagName.SegmentBase: {
const segmentBaseObj = {};
childrenObj.segmentBase = segmentBaseObj;
Expand Down
1 change: 1 addition & 0 deletions src/parsers/manifest/local/parse_local_manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ function parseRepresentation(
height: representation.height,
width: representation.width,
codecs: representation.codecs,
isSpatialAudio: representation.isSpatialAudio,
mimeType: representation.mimeType,
index: new LocalRepresentationIndex(representation.index, id),
contentProtections };
Expand Down
2 changes: 2 additions & 0 deletions src/parsers/manifest/local/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ export interface ILocalRepresentation {
height? : number;
/** Interface allowing to retrieve media segments for this quality. */
index : ILocalIndex;
/** `true` if audio has Dolby Atmos. */
isSpatialAudio? : boolean;
}

/** A "track"" of a "local" Manifest. */
Expand Down
1 change: 1 addition & 0 deletions src/parsers/manifest/metaplaylist/metaplaylist_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ function createManifest(
mimeType: currentRepresentation.mimeType,
frameRate: currentRepresentation.frameRate,
codecs: currentRepresentation.codec,
isSpatialAudio: currentRepresentation.isSpatialAudio,
contentProtections: currentRepresentation.contentProtections,
});
}
Expand Down
2 changes: 2 additions & 0 deletions src/parsers/manifest/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ export interface IParsedRepresentation {
* Information about the HDR characteristic of a content.
*/
hdrInfo?: IHDRInformation | undefined;
/** `true` if audio has Dolby Atmos. */
isSpatialAudio?: boolean | undefined;
}

/** Every possible types an Adaptation can have. */
Expand Down
1 change: 1 addition & 0 deletions src/public_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,7 @@ export interface IBifObject { fileFormat : string;
* RxPlayer.
*/
export interface IAudioRepresentation { id : string|number;
isSpatialAudio? : boolean | undefined;
bitrate : number;
codec? : string | undefined; }

Expand Down

0 comments on commit c7b0dea

Please sign in to comment.