Class: shaka.media.ContentWorkarounds

A collection of methods to work around content issues on various platforms.

Constructor

new ContentWorkarounds()

A collection of methods to work around content issues on various platforms.

Source:

Members

BOX_SIZE_64_OFFSET_ :number

Offset to a box's 64-bit size field, if it has one.
Type:
  • number
Source:

BOX_SIZE_OFFSET_ :number

Offset to a box's size field.
Type:
  • number
Source:

BOX_TYPE_AC_3_ :number

Box type for "ac-3".
Type:
  • number
Source:

BOX_TYPE_DAC3_ :number

Box type for "dac3".
Type:
  • number
Source:

BOX_TYPE_DEC3_ :number

Box type for "dec3".
Type:
  • number
Source:

BOX_TYPE_EC_3_ :number

Box type for "ec-3".
Type:
  • number
Source:

BOX_TYPE_ENCA_ :number

Box type for "enca".
Type:
  • number
Source:

BOX_TYPE_ENCV_ :number

Box type for "encv".
Type:
  • number
Source:

BOX_TYPE_OFFSET_ :number

Offset to a box's type field.
Type:
  • number
Source:

Methods

correctEnca(initSegmentBuffernon-null) → {Uint8Array}

For EAC-3 audio, the "enca" box ChannelCount field MUST always be set to 2. See ETSI TS 102 366 V1.2.1 Sec F.3 Clients SHOULD ignore this value; however, it has been discovered that some user agents don't, and instead, invalid values here can cause decoder failures to be thrown (this has been observed with Chromecast). Given that this value MUST be hard-coded to 2, and that clients "SHALL" ignore the value, it seems safe to manipulate the value to be 2 even when the packager has provided a different value.
Parameters:
Name Type Description
initSegmentBuffer BufferSource
Source:
Returns:
Type
Uint8Array

createEncryptionMetadata_(streamnon-null, initSegmentnon-null, sourceBox, metadataBoxType) → {Uint8Array}

Create an encryption metadata box ("encv" or "enca" box), based on the source box ("mp4a", "avc1", etc). Returns a new buffer containing the encryption metadata box.
Parameters:
Name Type Description
stream shaka.extern.Stream
initSegment Uint8Array
sourceBox shaka.extern.ParsedBox
metadataBoxType number
Source:
Returns:
Type
Uint8Array

fakeEC3(initSegmentBuffernon-null) → {Uint8Array}

Transform the init segment into a new init segment buffer that indicates EC-3 as audio codec instead of AC-3. Even though any EC-3 decoder should be able to decode AC-3 streams, there are platforms that do not accept AC-3 as codec. Should only be called for MP4 init segments, and only on platforms that need this workaround. Returns a new buffer containing the modified init segment.
Parameters:
Name Type Description
initSegmentBuffer BufferSource
Source:
Returns:
Type
Uint8Array

fakeEncryption(streamnon-null, initSegmentBuffernon-null, urinullable) → {Uint8Array}

Transform the init segment into a new init segment buffer that indicates encryption. If the init segment already indicates encryption, return the original init segment. Should only be called for MP4 init segments, and only on platforms that need this workaround.
Parameters:
Name Type Attributes Description
stream shaka.extern.Stream
initSegmentBuffer BufferSource
uri string <nullable>
Source:
See:
Returns:
Type
Uint8Array

fakeMediaEncryption(mediaSegmentBuffernon-null) → {Uint8Array}

Parameters:
Name Type Description
mediaSegmentBuffer BufferSource
Source:
Returns:
Type
Uint8Array

fakeMediaEncryptionInChunk_(chunknon-null) → {Uint8Array}

Parameters:
Name Type Description
chunk Uint8Array
Source:
Returns:
Type
Uint8Array

insertEncryptionMetadata_(streamnon-null, initSegmentnon-null, stsdBox, sourceBox, ancestorBoxesnon-null, metadataBoxType) → {Uint8Array}

Insert an encryption metadata box ("encv" or "enca" box) into the MP4 init segment, based on the source box ("mp4a", "avc1", etc). Returns a new buffer containing the modified init segment.
Parameters:
Name Type Description
stream shaka.extern.Stream
initSegment Uint8Array
stsdBox shaka.extern.ParsedBox
sourceBox shaka.extern.ParsedBox
ancestorBoxes Array.<shaka.extern.ParsedBox>
metadataBoxType number
Source:
Returns:
Type
Uint8Array

updateBoxSize_(dataArraynon-null, boxStart, newBoxSize)

Modify an MP4 box's size field in-place.
Parameters:
Name Type Description
dataArray Uint8Array
boxStart number The start position of the box in dataArray.
newBoxSize number The new size of the box.
Source: