Skip to content

Commit

Permalink
feat(HLS): Add new config for allow LL-HLS byterange optimization (#5877
Browse files Browse the repository at this point in the history
)
  • Loading branch information
avelad committed Nov 13, 2023
1 parent f5777e5 commit 3e91e8e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions demo/config.js
Expand Up @@ -211,6 +211,8 @@ shakaDemo.Config = class {
'manifest.hls.ignoreManifestTimestampsInSegmentsMode')
.addBoolInput_('Disable codec guessing',
'manifest.hls.disableCodecGuessing')
.addBoolInput_('Allow LL-HLS byterange optimization',
'manifest.hls.allowLowLatencyByteRangeOptimization')
.addNumberInput_('Availability Window Override',
'manifest.availabilityWindowOverride',
/* canBeDecimal= */ true,
Expand Down
8 changes: 7 additions & 1 deletion externs/shaka/player.js
Expand Up @@ -934,7 +934,8 @@ shaka.extern.DashManifestConfiguration;
* liveSegmentsDelay: number,
* sequenceMode: boolean,
* ignoreManifestTimestampsInSegmentsMode: boolean,
* disableCodecGuessing: boolean
* disableCodecGuessing: boolean,
* allowLowLatencyByteRangeOptimization: boolean
* }}
*
* @property {boolean} ignoreTextStreamFailures
Expand Down Expand Up @@ -994,6 +995,11 @@ shaka.extern.DashManifestConfiguration;
* As a consequence, lazy-loading media playlists won't be possible for this
* use case, which may result in longer video startup times.
* <i>Defaults to <code>false</code>.</i>
* @property {boolean} allowLowLatencyByteRangeOptimization
* If set to true, the HLS parser will optimize operation with LL and partial
* byte range segments. More info in
* https://www.akamai.com/blog/performance/-using-ll-hls-with-byte-range-addressing-to-achieve-interoperabi
* <i>Defaults to <code>true</code>.</i>
* @exportDoc
*/
shaka.extern.HlsManifestConfiguration;
Expand Down
3 changes: 2 additions & 1 deletion lib/hls/hls_parser.js
Expand Up @@ -2941,7 +2941,8 @@ shaka.hls.HlsParser = class {

if (this.lowLatencyMode_ && hlsSegment.partialSegments.length) {
const byterangeOptimizationSupport = (stream.mimeType == 'video/mp4' ||
stream.mimeType == 'audio/mp4') && window.ReadableStream;
stream.mimeType == 'audio/mp4') && window.ReadableStream &&
this.config_.hls.allowLowLatencyByteRangeOptimization;

let partialSyncTime = syncTime;
for (let i = 0; i < hlsSegment.partialSegments.length; i++) {
Expand Down
1 change: 1 addition & 0 deletions lib/util/player_configuration.js
Expand Up @@ -150,6 +150,7 @@ shaka.util.PlayerConfiguration = class {
sequenceMode: shaka.util.Platform.supportsSequenceMode(),
ignoreManifestTimestampsInSegmentsMode: false,
disableCodecGuessing: false,
allowLowLatencyByteRangeOptimization: true,
},
mss: {
manifestPreprocessor: (element) => {
Expand Down

0 comments on commit 3e91e8e

Please sign in to comment.