Home Reference Source
import StreamController from 'hls.js/src/controller/stream-controller.js'
public class | source

StreamController

Extends:

EventHandlerTaskLoop → StreamController

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public
public
public
public
public
public

config: *

public get
public

demuxer: *

public
public
public
public
public
public
public
public
public
public

level: *

public
public

levels: *

public set
public get
public
public

media: *

public
public get
public get
public
public
public
public
public
public
public
public
public
public
public
public
public set
public get

state: *

public

stats: *

public
Private Members
private
private

_state: *

Method Summary

Public Methods
public

computeLivePosition(sliding: *, levelDetails: *): *

public

doTick()

public

flushMainBuffer(startOffset: *, endOffset: *)

public

followingBufferedFrag(frag: *): *

public

getBufferedFrag(position: *): *

public
public

on immediate level switch end, after new fragment has been buffered:

  • nudge video decoder by slightly adjusting video currentTime (if currentTime buffered)
  • resume the playback if needed
public

try to switch ASAP without breaking video playback: in order to ensure smooth but quick level switching, we need to find the next flushable buffer range we should take into account new segment fetch time

public
public
public

onBufferAppended(data: *)

public

onBufferCreated(data: *)

public
public

onError(data: *)

public
public

onFragLoaded(data: *)

public

onFragParsed(data: *)

public
public
public
public
public
public

onLevelLoaded(data: *)

public
public

onManifestParsed(data: *)

public

onMediaAttached(data: *)

public
public
public
public
public

startLoad(startPosition: *)

public
public
Private Methods
private
private

Checks the health of the buffer and attempts to resolve playback stalls.

private
private
private

_ensureFragmentAtLivePoint(levelDetails: *, bufferEnd: *, start: *, end: *, fragPrevious: *, fragments: *, fragLen: *): *

private

_fetchPayloadOrEos(pos: *, bufferInfo: *, levelDetails: *)

private

_findFragment(start: *, fragPrevious: *, fragLen: *, fragments: *, bufferEnd: *, end: *, levelDetails: *): *

private

_loadFragment(frag: *)

private

_loadKey(frag: *)

private
private

_reportStall(bufferLen: *)

Triggers a BUFFER_STALLED_ERROR event, but only once per stall period.

private

Seeks to the set startPosition if not equal to the mediaElement's current time.

private

_tryFixBufferStall(bufferInfo: *, stalledDuration: *)

Detects and attempts to fix known buffer stalling issues.

private

Attempts to fix buffer stalls by advancing the mediaElement's current time by a small amount.

private

_trySkipBufferHole(partial: *)

Attempts to fix buffer stalls by jumping over known gaps caused by partial fragments

Inherited Summary

From class EventHandler
public
public

hls: *

public
public
public
public

onEvent(event: *, data: *)

arguments: event (string), data (any)

public

onEventGeneric(event: *, data: *)

public
public
public
public
From class TaskLoop
private
private
private
private
public
public
public abstract

doTick()

For subclass to implement task logic

public
public
public
public
public

tick()

Will call the subclass doTick implementation in this main loop tick or in the next one (via setTimeout(,0)) in case it has already been called in this tick (in case this is a re-entrant call).

Public Constructors

public constructor() source

Override:

TaskLoop#constructor

Public Members

public altAudio: boolean source

public appended: boolean source

public audioCodecSwap: boolean source

public audioCodecSwitch: * source

public bitrateTest: boolean source

public config: * source

public get currentLevel: * source

public demuxer: * source

public forceStartLoad: boolean source

public fragCurrent: * source

public fragLastKbps: * source

public fragLoadError: number source

public fragPlaying: * source

public fragPrevious: * source

public fragmentTracker: * source

public immediateSwitch: boolean source

public lastCurrentTime: * source

public level: * source

public levelLastLoaded: * source

public levels: * source

public set liveSyncPosition source

public get liveSyncPosition: * source

public loadedmetadata: boolean source

public media: * source

public mediaBuffer: * source

public get nextBufferedFrag: * source

public get nextLevel: * source

public nextLoadPosition: * source

public nudgeRetry: number source

public onvended: * source

public onvseeked: * source

public onvseeking: * source

public pendingBuffering: boolean source

public previouslyPaused: * source

public retryDate: * source

public stallReported: boolean source

public stalled: boolean source

public startFragRequested: boolean source

public startPosition: * source

public set state source

public get state: * source

public stats: * source

public videoBuffer: * source

Private Members

private _liveSyncPosition: * source

private _state: * source

Public Methods

public computeLivePosition(sliding: *, levelDetails: *): * source

Params:

NameTypeAttributeDescription
sliding *
levelDetails *

Return:

*

public doTick() source

For subclass to implement task logic

Override:

TaskLoop#doTick

public flushMainBuffer(startOffset: *, endOffset: *) source

Params:

NameTypeAttributeDescription
startOffset *
endOffset *

public followingBufferedFrag(frag: *): * source

Params:

NameTypeAttributeDescription
frag *

Return:

*

public getBufferedFrag(position: *): * source

Params:

NameTypeAttributeDescription
position *

Return:

*

public immediateLevelSwitch() source

public immediateLevelSwitchEnd() source

on immediate level switch end, after new fragment has been buffered:

  • nudge video decoder by slightly adjusting video currentTime (if currentTime buffered)
  • resume the playback if needed

public nextLevelSwitch() source

try to switch ASAP without breaking video playback: in order to ensure smooth but quick level switching, we need to find the next flushable buffer range we should take into account new segment fetch time

public onAudioTrackSwitched(data: *) source

Params:

NameTypeAttributeDescription
data *

public onAudioTrackSwitching(data: *) source

Params:

NameTypeAttributeDescription
data *

public onBufferAppended(data: *) source

Params:

NameTypeAttributeDescription
data *

public onBufferCreated(data: *) source

Params:

NameTypeAttributeDescription
data *

public onBufferFlushed() source

public onError(data: *) source

Params:

NameTypeAttributeDescription
data *

public onFragLoadEmergencyAborted() source

public onFragLoaded(data: *) source

Params:

NameTypeAttributeDescription
data *

public onFragParsed(data: *) source

Params:

NameTypeAttributeDescription
data *

public onFragParsingData(data: *) source

Params:

NameTypeAttributeDescription
data *

public onFragParsingInitSegment(data: *) source

Params:

NameTypeAttributeDescription
data *

public onHandlerDestroyed() source

Override:

EventHandler#onHandlerDestroyed

public onHandlerDestroying() source

Override:

TaskLoop#onHandlerDestroying

public onKeyLoaded() source

public onLevelLoaded(data: *) source

Params:

NameTypeAttributeDescription
data *

public onManifestLoading() source

public onManifestParsed(data: *) source

Params:

NameTypeAttributeDescription
data *

public onMediaAttached(data: *) source

Params:

NameTypeAttributeDescription
data *

public onMediaDetaching() source

public onMediaEnded() source

public onMediaSeeked() source

public onMediaSeeking() source

public startLoad(startPosition: *) source

Params:

NameTypeAttributeDescription
startPosition *

public stopLoad() source

public swapAudioCodec() source

Private Methods

private _checkAppendedParsed() source

private _checkBuffer() source

Checks the health of the buffer and attempts to resolve playback stalls.

private _checkFragmentChanged() source

private _doTickIdle() source

private _ensureFragmentAtLivePoint(levelDetails: *, bufferEnd: *, start: *, end: *, fragPrevious: *, fragments: *, fragLen: *): * source

Params:

NameTypeAttributeDescription
levelDetails *
bufferEnd *
start *
end *
fragPrevious *
fragments *
fragLen *

Return:

*

private _fetchPayloadOrEos(pos: *, bufferInfo: *, levelDetails: *) source

Params:

NameTypeAttributeDescription
pos *
bufferInfo *
levelDetails *

private _findFragment(start: *, fragPrevious: *, fragLen: *, fragments: *, bufferEnd: *, end: *, levelDetails: *): * source

Params:

NameTypeAttributeDescription
start *
fragPrevious *
fragLen *
fragments *
bufferEnd *
end *
levelDetails *

Return:

*

private _loadFragment(frag: *) source

Params:

NameTypeAttributeDescription
frag *

private _loadKey(frag: *) source

Params:

NameTypeAttributeDescription
frag *

private _reduceMaxBufferLength(minLength: *): boolean source

Params:

NameTypeAttributeDescription
minLength *

Return:

boolean

private _reportStall(bufferLen: *) source

Triggers a BUFFER_STALLED_ERROR event, but only once per stall period.

Params:

NameTypeAttributeDescription
bufferLen *

The playhead distance from the end of the current buffer segment.

private _seekToStartPos() source

Seeks to the set startPosition if not equal to the mediaElement's current time.

private _tryFixBufferStall(bufferInfo: *, stalledDuration: *) source

Detects and attempts to fix known buffer stalling issues.

Params:

NameTypeAttributeDescription
bufferInfo *

The properties of the current buffer.

stalledDuration *

The amount of time Hls.js has been stalling for.

private _tryNudgeBuffer() source

Attempts to fix buffer stalls by advancing the mediaElement's current time by a small amount.

private _trySkipBufferHole(partial: *) source

Attempts to fix buffer stalls by jumping over known gaps caused by partial fragments

Params:

NameTypeAttributeDescription
partial *

The partial fragment found at the current time (where playback is stalling).