Skip to content

Commit

Permalink
feat(HLS): Add HLS support for non-sequence mode
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad committed Oct 26, 2022
1 parent 57ce56b commit 888c9d7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
8 changes: 7 additions & 1 deletion externs/shaka/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,8 @@ shaka.extern.DashManifestConfiguration;
* ignoreManifestProgramDateTime: boolean,
* mediaPlaylistFullMimeType: string,
* useSafariBehaviorForLive: boolean,
* liveSegmentsDelay: number
* liveSegmentsDelay: number,
* sequenceMode: boolean
* }}
*
* @property {boolean} ignoreTextStreamFailures
Expand Down Expand Up @@ -870,6 +871,11 @@ shaka.extern.DashManifestConfiguration;
* The default presentation delay will be calculated as a number of segments.
* This is the number of segments for this calculation..
* <i>Defaults to <code>3</code>.</i>
* @property {boolean} sequenceMode
* If true, the media segments are appended to the SourceBuffer in
* "sequence mode" (ignoring their internal timestamps).
* Defaults to <code>true</code> except on WebOS 3, Tizen 2,
* Tizen 3 and PlayStation 4 which defualt value is <code>false</code>.
* @exportDoc
*/
shaka.extern.HlsManifestConfiguration;
Expand Down
2 changes: 1 addition & 1 deletion lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ shaka.hls.HlsParser = class {
imageStreams,
offlineSessionIds: [],
minBufferTime: 0,
sequenceMode: true,
sequenceMode: this.config_.hls.sequenceMode,
};
this.playerInterface_.makeTextStreamsForClosedCaptions(this.manifest_);
}
Expand Down
10 changes: 8 additions & 2 deletions lib/media/media_source_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,14 @@ shaka.media.MediaSourceEngine = class {

const uint8ArrayData = shaka.util.BufferUtils.toUint8(data);
if (shaka.util.TsParser.probe(uint8ArrayData)) {
const metadata = new shaka.util.TsParser().parse(uint8ArrayData)
.getMetadata();
const tsParser = new shaka.util.TsParser().parse(uint8ArrayData);
const timestampOffset =
reference.startTime - tsParser.getStartTime()[contentType] || 0;
this.enqueueOperation_(contentType, () => this.abort_(contentType));
this.enqueueOperation_(
contentType,
() => this.setTimestampOffset_(contentType, timestampOffset));
const metadata = tsParser.getMetadata();
if (metadata.length) {
const timestampOffset =
this.sourceBuffers_[contentType].timestampOffset;
Expand Down
9 changes: 9 additions & 0 deletions lib/util/player_configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ shaka.util.PlayerConfiguration = class {
parseInbandPsshEnabled: shaka.util.Platform.isXboxOne(),
};

let supportsSequenceMode = true;
if (shaka.util.Platform.isTizen3() ||
shaka.util.Platform.isTizen2() ||
shaka.util.Platform.isWebOS3() ||
shaka.util.Platform.isPS4()) {
supportsSequenceMode = false;
}

const manifest = {
retryParameters: shaka.net.NetworkingEngine.defaultRetryParameters(),
availabilityWindowOverride: NaN,
Expand Down Expand Up @@ -132,6 +140,7 @@ shaka.util.PlayerConfiguration = class {
'video/mp2t; codecs="avc1.42E01E, mp4a.40.2"',
useSafariBehaviorForLive: true,
liveSegmentsDelay: 3,
sequenceMode: supportsSequenceMode,
},
};

Expand Down

0 comments on commit 888c9d7

Please sign in to comment.