Home > hls.js > BaseStreamController

BaseStreamController class

Signature:

export default class BaseStreamController extends TaskLoop implements NetworkComponentAPI 

Extends: TaskLoop

Implements: NetworkComponentAPI

Constructors

Constructor

Modifiers

Description

(constructor)(hls, fragmentTracker, keyLoader, logPrefix, playlistType)

Constructs a new instance of the BaseStreamController class

Properties

Property

Modifiers

Type

Description

_state

protected

(typeof State)[keyof typeof State]

backtrackFragment

protected

Fragment | undefined

Get backtrack fragment. Returns null in base class. Override in stream-controller to return actual backtrack fragment.

bitrateTest

protected

boolean

buffering

protected

boolean

bufferingEnabled

readonly

boolean

config

protected

HlsConfig

couldBacktrack

protected

boolean

Get could backtrack flag. Returns false in base class. Override in stream-controller to return actual value.

decrypter

protected

Decrypter

fragCurrent

protected

Fragment | null

fragmentLoader

protected

FragmentLoader

fragmentTracker

protected

FragmentTracker

fragPlaying

protected

Fragment | null

fragPrevious

protected

MediaFragment | null

hls

protected

Hls

inFlightFrag

readonly

InFlightData

initPTS

protected

TimestampOffset[]

keyLoader

protected

KeyLoader

lastCurrentTime

protected

number

levelLastLoaded

protected

Level | null

levels

protected

Array<Level> | null

loadingParts

protected

boolean

media

protected

HTMLMediaElement | null

mediaBuffer

protected

Bufferable | null

nextLoadPosition

protected

number

onMediaEnded

protected

() => void

onMediaSeeking

protected

() => void

playlistType

protected

PlaylistLevelType

primaryPrefetch

protected

readonly

boolean

retryDate

protected

number

startFragRequested

protected

boolean

startPosition

protected

number

startPositionValue

readonly

number

startTimeOffset

protected

number | null

state

(typeof State)[keyof typeof State]

timelineOffset

protected

readonly

number

transmuxer

protected

TransmuxerInterface | null

Methods

Method

Modifiers

Description

_doFragLoad(frag, level, targetBufferTime, progressCallback)

protected

_handleFragmentLoadComplete(fragLoadedEndData)

protected

_handleFragmentLoadProgress(frag)

protected

_handleTransmuxerFlush(chunkMeta)

protected

_loadInitSegment(fragment, level)

protected

_streamEnded(bufferInfo, levelDetails)

protected

abortCurrentFrag()

protected

Aborts the current fragment loading and resets state Can be overridden by subclasses for specific behavior

afterBufferFlushed(media, bufferType)

protected

alignPlaylists(details, previousDetails, switchDetails)

protected

bufferFragmentData(data, frag, part, chunkMeta, noBacktracking)

protected

calculateOptimalSwitchPoint(nextLevel, bufferInfo)

protected

Calculate optimal switch point by considering fetch delays and buffer info to avoid causing playback interruption

checkFragmentChanged()

protected

checkLiveUpdate(details)

protected

checkRetryDate()

protected

cleanupBackBuffer()

protected

Handle back-buffer cleanup during track switching

clearTrackerIfNeeded(frag)

protected

doTick()

protected

filterReplacedPrimary(frag, details)

protected

flushBufferGap(frag)

protected

flushMainBuffer(startOffset, endOffset, type)

protected

followingBufferedFrag(frag)

protected

Gets the next buffered fragment following the given fragment

fragBufferedComplete(frag, part)

protected

fragContextChanged(frag)

protected

getAppendedFrag(position)

protected

getBufferedFrag(position)

protected

Gets buffered fragment at the specified position

getBufferOutput()

protected

getCurrentContext(chunkMeta)

protected

getFragmentAtPosition(bufferEnd, end, levelDetails)

protected

getFwdBufferInfo(bufferable, type)

protected

getFwdBufferInfoAtPos(bufferable, pos, type, maxBufferHole)

protected

getInitialLiveFragment(levelDetails)

protected

getLevelDetails()

getLoadPosition()

protected

getMaxBufferLength(levelBitrate)

protected

getNextFragment(pos, levelDetails)

protected

getNextFragmentLoopLoading(frag, levelDetails, bufferInfo, playlistType, maxBufLen)

protected

getNextPart(partList, frag, targetBufferTime)

isLoopLoading(frag, targetBufferTime)

protected

loadFragment(frag, level, targetBufferTime)

protected

mapToInitFragWhenRequired(frag)

nextLevelSwitch()

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

onError(event, data)

protected

onFragmentOrKeyLoadError(filterType, data)

protected

onHandlerDestroyed()

protected

onHandlerDestroying()

protected

onManifestLoaded(event, data)

protected

onManifestLoading()

protected

onMediaAttached(event, data)

protected

onMediaDetaching(event, data)

protected

onTickEnd()

protected

pauseBuffering()

recoverWorkerError(data)

protected

reduceLengthAndFlushBuffer(data)

protected

reduceMaxBufferLength(threshold, fragDuration)

protected

registerListeners()

protected

removeUnbufferedFrags(start)

protected

resetFragmentErrors(filterType)

protected

resetFragmentLoading(frag)

protected

resetLoadingState()

protected

resetTransmuxer()

protected

resetWhenMissingContext(chunkMeta)

protected

resumeBuffering()

scheduleTrackSwitch(bufferInfo, fetchdelay, okToFlushForwardBuffer)

protected

Generic track switching scheduler that prevents buffering interruptions by finding optimal flush points in the buffer This method can be overridden by subclasses with specific implementation details

setStartPosition(details, sliding)

protected

startLoad(startPosition)

stopLoad()

unhandledEncryptionError(initSegment, frag)

protected

unregisterListeners()

protected

waitForCdnTuneIn(details)

protected

waitForLive(levelInfo)

protected