Skip to content

Commit

Permalink
feat(HLS): allow customize live segments delay (shaka-project#4585)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad committed Oct 17, 2022
1 parent 7a039c5 commit 1f558a8
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions demo/common/message_ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ shakaDemo.MessageIds = {
LCEVC_DYNAMIC_PERFORMANCE_SCALING: 'DEMO_LCEVC_DYNAMIC_PERFORMANCE_SCALING',
LCEVC_LOG_LEVEL: 'DEMO_LCEVC_LOG_LEVEL',
LCEVC_SECTION_HEADER: 'DEMO_LCEVC_SECTION_HEADER',
LIVE_SEGMENTS_DELAY: 'DEMO_LIVE_SEGMENTS_DELAY',
LOG_LEVEL: 'DEMO_LOG_LEVEL',
LOG_LEVEL_DEBUG: 'DEMO_LOG_LEVEL_DEBUG',
LOG_LEVEL_INFO: 'DEMO_LOG_LEVEL_INFO',
Expand Down
2 changes: 2 additions & 0 deletions demo/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ shakaDemo.Config = class {
'manifest.hls.ignoreManifestProgramDateTime')
.addBoolInput_(MessageIds.USE_SAFARI_BEHAVIOR_FOR_LIVE,
'manifest.hls.useSafariBehaviorForLive')
.addNumberInput_(MessageIds.LIVE_SEGMENTS_DELAY,
'manifest.hls.liveSegmentsDelay')
.addNumberInput_(MessageIds.AVAILABILITY_WINDOW_OVERRIDE,
'manifest.availabilityWindowOverride',
/* canBeDecimal= */ true,
Expand Down
1 change: 1 addition & 0 deletions demo/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
"DEMO_LICENSE_SERVER_URL": "Custom License Server URL",
"DEMO_LIVE": "Live",
"DEMO_LIVE_SEARCH": "Live",
"DEMO_LIVE_SEGMENTS_DELAY": "Live segments delay",
"DEMO_LOG_LEVEL": "Log Level",
"DEMO_LOG_LEVEL_DEBUG": "Debug",
"DEMO_LOG_LEVEL_INFO": "Info",
Expand Down
4 changes: 4 additions & 0 deletions demo/locales/source.json
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,10 @@
"description": "A header on a search field that filters by whether the asset is live or not.",
"message": "Live"
},
"DEMO_LIVE_SEGMENTS_DELAY": {
"description": "The name of a configuration value.",
"message": "Live segments delay"
},
"DEMO_LOG_LEVEL": {
"description": "The name of a configuration value.",
"message": "Log Level"
Expand Down
7 changes: 6 additions & 1 deletion externs/shaka/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,8 @@ shaka.extern.DashManifestConfiguration;
* defaultVideoCodec: string,
* ignoreManifestProgramDateTime: boolean,
* mediaPlaylistFullMimeType: string,
* useSafariBehaviorForLive: boolean
* useSafariBehaviorForLive: boolean,
* liveSegmentsDelay: number
* }}
*
* @property {boolean} ignoreTextStreamFailures
Expand Down Expand Up @@ -865,6 +866,10 @@ shaka.extern.DashManifestConfiguration;
* segments, but the seek window will be zero-sized, to be consistent with
* Safari. If this is false, the seek window will be the entire duration.
* <i>Defaults to <code>true</code>.</i>
* @property {number} liveSegmentsDelay
* 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>
* @exportDoc
*/
shaka.extern.HlsManifestConfiguration;
Expand Down
3 changes: 2 additions & 1 deletion lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2123,7 +2123,8 @@ shaka.hls.HlsParser = class {
} else if (this.lowLatencyPresentationDelay_) {
presentationDelay = this.lowLatencyPresentationDelay_;
} else {
presentationDelay = this.maxTargetDuration_ * 3;
const numberOfSegments = this.config_.hls.liveSegmentsDelay;
presentationDelay = this.maxTargetDuration_ * numberOfSegments;
}

this.presentationTimeline_.setPresentationStartTime(0);
Expand Down
1 change: 1 addition & 0 deletions lib/util/player_configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ shaka.util.PlayerConfiguration = class {
mediaPlaylistFullMimeType:
'video/mp2t; codecs="avc1.42E01E, mp4a.40.2"',
useSafariBehaviorForLive: true,
liveSegmentsDelay: 3,
},
};

Expand Down

0 comments on commit 1f558a8

Please sign in to comment.