Skip to content

Commit

Permalink
feat(HLS): Add HLS support for non-sequence mode (#4623)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad authored Jan 30, 2023
1 parent 974f5dc commit 2b50b88
Show file tree
Hide file tree
Showing 23 changed files with 345 additions and 117 deletions.
3 changes: 2 additions & 1 deletion demo/common/message_ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ shakaDemo.MessageIds = {
CMCD_SECTION_HEADER: 'DEMO_CMCD_SECTION_HEADER',
CONNECTION_TIMEOUT: 'DEMO_CONNECTION_TIMEOUT',
CONTENT_ID: 'DEMO_CONTENT_ID',
DASH_SEQUENCE_MODE: 'DEMO_DASH_SEQUENCE_MODE',
DEFAULT_AUDIO_CODEC: 'DEMO_DEFAULT_AUDIO_CODEC',
DEFAULT_PRESENTATION_DELAY: 'DEMO_DEFAULT_PRESENTATION_DELAY',
DEFAULT_VIDEO_CODEC: 'DEMO_DEFAULT_VIDEO_CODEC',
Expand All @@ -195,6 +196,7 @@ shakaDemo.MessageIds = {
FORCE_TRANSMUX: 'DEMO_FORCE_TRANSMUX',
FUZZ_FACTOR: 'DEMO_FUZZ_FACTOR',
GAP_DETECTION_THRESHOLD: 'DEMO_GAP_DETECTION_THRESHOLD',
HLS_SEQUENCE_MODE: 'DEMO_HLS_SEQUENCE_MODE',
IGNORE_DASH_EMPTY_ADAPTATION_SET: 'DEMO_IGNORE_DASH_EMPTY_ADAPTATION_SET',
IGNORE_DASH_DRM: 'DEMO_IGNORE_DASH_DRM',
IGNORE_DASH_MAX_SEGMENT_DURATION: 'DEMO_IGNORE_DASH_MAX_SEGMENT_DURATION',
Expand Down Expand Up @@ -255,7 +257,6 @@ shakaDemo.MessageIds = {
SAFE_SEEK_OFFSET: 'DEMO_SAFE_SEEK_OFFSET',
SAFE_SKIP_DISTANCE: 'DEMO_SAFE_SKIP_DISTANCE',
SEGMENT_RELATIVE_VTT_TIMING: 'DEMO_SEGMENT_RELATIVE_VTT_TIMING',
SEQUENCE_MODE: 'DEMO_SEQUENCE_MODE',
SESSION_ID: 'DEMO_SESSION_ID',
SHAKA_CONTROLS: 'DEMO_SHAKA_CONTROLS',
SLOW_HALF_LIFE: 'DEMO_SLOW_HALF_LIFE',
Expand Down
4 changes: 3 additions & 1 deletion demo/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ shakaDemo.Config = class {
'manifest.hls.useSafariBehaviorForLive')
.addNumberInput_(MessageIds.LIVE_SEGMENTS_DELAY,
'manifest.hls.liveSegmentsDelay')
.addBoolInput_(MessageIds.HLS_SEQUENCE_MODE,
'manifest.hls.sequenceMode')
.addNumberInput_(MessageIds.AVAILABILITY_WINDOW_OVERRIDE,
'manifest.availabilityWindowOverride',
/* canBeDecimal= */ true,
Expand All @@ -239,7 +241,7 @@ shakaDemo.Config = class {
/* canBeDecimal= */ false,
/* canBeZero= */ false,
/* canBeUnset= */ true)
.addBoolInput_(MessageIds.SEQUENCE_MODE,
.addBoolInput_(MessageIds.DASH_SEQUENCE_MODE,
'manifest.dash.sequenceMode')
.addBoolInput_(MessageIds.DISABLE_AUDIO,
'manifest.disableAudio')
Expand Down
3 changes: 2 additions & 1 deletion demo/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"DEMO_CUSTOM_INTRO_TWO": "Press the button below to add a custom asset.",
"DEMO_DASH": "DASH",
"DEMO_DASH_IF": "DASH-IF",
"DEMO_DASH_SEQUENCE_MODE": "Enable DASH sequence mode",
"DEMO_DEFAULT_AUDIO_CODEC": "Default Audio Codec",
"DEMO_DEFAULT_PRESENTATION_DELAY": "Default Presentation Delay",
"DEMO_DEFAULT_VIDEO_CODEC": "Default Video Codec",
Expand Down Expand Up @@ -184,6 +185,7 @@
"DEMO_FAILURE_MISC": "Shaka Player failed to load! If you are using an ad blocker, try switching to compiled mode at the bottom of the page.",
"DEMO_FAILURE_NO_BROWSER_SUPPORT": "Your browser is not supported!",
"DEMO_HLS_FULL_MIME_TYPE": "Full Mime Type for Playing Media Playlists Directly",
"DEMO_HLS_SEQUENCE_MODE": "Enable HLS sequence mode",
"DEMO_PLAY": "Play",
"DEMO_PLAYREADY": "PlayReady DRM",
"DEMO_PREFER_FORCED_SUBS": "Prefer Forced Subs",
Expand All @@ -199,7 +201,6 @@
"DEMO_SAFE_SEEK_OFFSET": "Safe Seek Offset",
"DEMO_SAFE_SKIP_DISTANCE": "Safe Skip Distance",
"DEMO_SEGMENT_RELATIVE_VTT_TIMING": "Enable segment-relative VTT Timing",
"DEMO_SEQUENCE_MODE": "Enable sequence mode",
"DEMO_SESSION_ID": "Session ID",
"DEMO_SAVE_BUTTON": "Save",
"DEMO_SHAKA": "Shaka",
Expand Down
12 changes: 8 additions & 4 deletions demo/locales/source.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@
"description": "Text that describes an asset that comes from the Dash Industry Forum asset library.",
"message": "[PROPER_NAME:DASH-IF]"
},
"DEMO_DASH_SEQUENCE_MODE": {
"description": "The name of a configuration value.",
"message": "Enable DASH sequence mode"
},
"DEMO_DEFAULT_AUDIO_CODEC": {
"description": "The name of a configuration value.",
"message": "Default Audio Codec"
Expand Down Expand Up @@ -379,6 +383,10 @@
"description": "Text that describes an asset that is packaged in an HLS manifest.",
"message": "[PROPER_NAME:HLS]"
},
"DEMO_HLS_SEQUENCE_MODE": {
"description": "The name of a configuration value.",
"message": "Enable HLS sequence mode"
},
"DEMO_HLS_TAB": {
"description": "The header for a tab within the custom asset creation dialog.",
"message": "[PROPER_NAME:HLS]"
Expand Down Expand Up @@ -803,10 +811,6 @@
"description": "The name of a configuration value.",
"message": "Enable segment-relative VTT Timing"
},
"DEMO_SEQUENCE_MODE": {
"description": "The name of a configuration value.",
"message": "Enable sequence mode"
},
"DEMO_SESSION_ID": {
"description": "The name of a configuration value.",
"message": "Session ID"
Expand Down
6 changes: 5 additions & 1 deletion externs/shaka/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
* imageStreams: !Array.<shaka.extern.Stream>,
* offlineSessionIds: !Array.<string>,
* minBufferTime: number,
* sequenceMode: boolean
* sequenceMode: boolean,
* type: string
* }}
*
* @description
Expand Down Expand Up @@ -76,6 +77,9 @@
* @property {boolean} sequenceMode
* If true, we will append the media segments using sequence mode; that is to
* say, ignoring any timestamps inside the media files.
* @property {string} type
* Indicates the type of the manifest. It can be <code>'HLS'</code> or
* <code>'DASH'</code>.
*
* @exportDoc
*/
Expand Down
6 changes: 5 additions & 1 deletion externs/shaka/offline.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ shaka.extern.StoredContent;
* drmInfo: ?shaka.extern.DrmInfo,
* appMetadata: Object,
* isIncomplete: (boolean|undefined),
* sequenceMode: (boolean|undefined)
* sequenceMode: (boolean|undefined),
* type: (string|undefined)
* }}
*
* @property {number} creationTime
Expand Down Expand Up @@ -102,6 +103,9 @@ shaka.extern.StoredContent;
* @property {(boolean|undefined)} sequenceMode
* If true, we will append the media segments using sequence mode; that is to
* say, ignoring any timestamps inside the media files.
* @property {(string|undefined)} type
* Indicates the type of the manifest. It can be <code>'HLS'</code> or
* <code>'DASH'</code>.
*/
shaka.extern.ManifestDB;

Expand Down
12 changes: 9 additions & 3 deletions externs/shaka/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,13 +482,13 @@ shaka.extern.MetadataRawFrame;
/**
* @typedef {{
* key: string,
* data: (ArrayBuffer|string),
* data: (ArrayBuffer|string|number),
* description: string
* }}
*
* @description metadata frame parsed.
* @property {string} key
* @property {ArrayBuffer|string} data
* @property {ArrayBuffer|string|number} data
* @property {string} description
* @exportDoc
*/
Expand Down Expand Up @@ -840,7 +840,8 @@ shaka.extern.DashManifestConfiguration;
* ignoreManifestProgramDateTime: boolean,
* mediaPlaylistFullMimeType: string,
* useSafariBehaviorForLive: boolean,
* liveSegmentsDelay: number
* liveSegmentsDelay: number,
* sequenceMode: boolean
* }}
*
* @property {boolean} ignoreTextStreamFailures
Expand Down Expand Up @@ -881,6 +882,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 whose default value is <code>false</code>.
* @exportDoc
*/
shaka.extern.HlsManifestConfiguration;
Expand Down
1 change: 1 addition & 0 deletions lib/dash/dash_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ shaka.dash.DashParser = class {
offlineSessionIds: [],
minBufferTime: minBufferTime || 0,
sequenceMode: this.config_.dash.sequenceMode,
type: shaka.media.ManifestParser.DASH,
};

// We only need to do clock sync when we're using presentation start
Expand Down
19 changes: 8 additions & 11 deletions lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,8 @@ shaka.hls.HlsParser = class {
imageStreams,
offlineSessionIds: [],
minBufferTime: 0,
sequenceMode: true,
sequenceMode: this.config_.hls.sequenceMode,
type: shaka.media.ManifestParser.HLS,
};
this.playerInterface_.makeTextStreamsForClosedCaptions(this.manifest_);
}
Expand Down Expand Up @@ -3730,13 +3731,9 @@ shaka.hls.HlsParser.PresentationType_ = {
LIVE: 'LIVE',
};

if (!shaka.util.Platform.isTizen3() &&
!shaka.util.Platform.isTizen2() &&
!shaka.util.Platform.isWebOS3()) {
shaka.media.ManifestParser.registerParserByExtension(
'm3u8', () => new shaka.hls.HlsParser());
shaka.media.ManifestParser.registerParserByMime(
'application/x-mpegurl', () => new shaka.hls.HlsParser());
shaka.media.ManifestParser.registerParserByMime(
'application/vnd.apple.mpegurl', () => new shaka.hls.HlsParser());
}
shaka.media.ManifestParser.registerParserByExtension(
'm3u8', () => new shaka.hls.HlsParser());
shaka.media.ManifestParser.registerParserByMime(
'application/x-mpegurl', () => new shaka.hls.HlsParser());
shaka.media.ManifestParser.registerParserByMime(
'application/vnd.apple.mpegurl', () => new shaka.hls.HlsParser());
18 changes: 18 additions & 0 deletions lib/media/manifest_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,24 @@ shaka.media.ManifestParser = class {
};


/**
* @const {string}
*/
shaka.media.ManifestParser.HLS = 'HLS';


/**
* @const {string}
*/
shaka.media.ManifestParser.DASH = 'DASH';


/**
* @const {string}
*/
shaka.media.ManifestParser.UNKNOWN = 'UNKNOWN';


/**
* Contains the parser factory functions indexed by MIME type.
*
Expand Down
Loading

0 comments on commit 2b50b88

Please sign in to comment.