@ceeblue/wrts-client
    Preparing search index...

    Class HTTPAdaptiveSource

    HTTP Adaptive Streaming

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    log: ILog

    Start a log

    a Log object with the levels of log to call

    Accessors

    • get audioPerSecond(): number

      Get the number of audio frame per second currently decoding

      Returns number

    • get audioSelected(): number | undefined

      Index of the manual audio selection, undefined indicates automatic mode and -1 disable manually the track

      Returns number | undefined

    • get audioTrack(): number | undefined

      Index of the effective audio track, can be undefined on start and -1 means track disabled

      Returns number | undefined

    • set audioTrack(idx: number | undefined): void

      Select a audio track to the index provided, or indicates automatic with undefined

      Parameters

      • idx: number | undefined

      Returns void

    • get closed(): boolean

      True when source is closed

      Returns boolean

    • get cmcdSid(): string

      The CMCD session ID

      Returns string

    • set cmcdSid(value: string | undefined): void

      Set the CMCD session ID, if undefined reset to empty string

      Parameters

      • value: string | undefined

      Returns void

    • get dataSelected(): Set<number> | undefined

      Index of the manual data selection, undefined indicates all tracks

      Returns Set<number> | undefined

    • get dataTrack(): Set<number> | undefined

      Index of the data track being received, can be undefined on start

      Returns Set<number> | undefined

    • set dataTrack(idx: number | Set<number> | number[] | undefined): void

      Select a or multiple data track to the index provided. When set to undefined it selects all data tracks available.

      Parameters

      • idx: number | Set<number> | number[] | undefined

      Returns void

    • get skippedAudio(): number

      Get the total duration of audio skipped in milliseconds

      Returns number

    • get skippedVideo(): number

      Get the total duration of video skipped in milliseconds

      Returns number

    • get streamName(): string

      Stream name, for example as+bc3f535f-37f3-458b-8171-b4c5e77a6137

      Returns string

    • get tracksCombinable(): boolean

      Indicates whether tracks can be combined in the same request, by default tracks are combinable to optimize the number of requests

      Returns boolean

    • set tracksCombinable(value: boolean): void

      Set whether tracks can be combined in the same request, by default tracks are combinable to optimize the number of requests

      Parameters

      • value: boolean

      Returns void

    • get trackSelectable(): boolean

      Returns true if manual track selection is supported by the source implementation

      Returns boolean

    • get videoPerSecond(): number

      Get the number of video sample per second currently decoding

      Returns number

    • get videoSelected(): number | undefined

      Index of the manual video selection, undefined indicates automatic mode and -1 disable manually the track

      Returns number | undefined

    • get videoTrack(): number | undefined

      Index of the effective video track, can be undefined on start and -1 means track disabled

      Returns number | undefined

    • set videoTrack(idx: number | undefined): void

      Selects a video track based on the provided index, or enables automatic selection if set to undefined.

      Parameters

      • idx: number | undefined

      Returns void

      Manually setting a track disables any Adaptive Bitrate algorithm.

    Methods

    • Fetches a resource in a compliant way by invoking finalizeRequest during preparation.

      Parameters

      • url: URL

        the URL to fetch

      • Optionalinit: RequestInit

        optional fetch configuration

      Returns Promise<Response & { error?: string }>

      the fetched response

    • Fetch a media object with CMCD if enabled

      Parameters

      • url: URL

        full URL of the media object

      • trackIds: number[]
      • options: RequestInit = {}

      Returns Promise<Response & { error?: string }>

    • Fetches a resource and measures the RTT (round-trip time) in a compliant way by invoking finalizeRequest during preparation.

      Parameters

      • url: URL

        the URL to fetch

      • Optionalinit: RequestInit

        optional fetch configuration

      Returns Promise<Response & { error?: string; rtt: number }>

      the fetched response (including RTT metadata)

    • Prepares a request, exposing the user-interception onFinalizeRequest to modify it if needed.

      Parameters

      • url: URL

        URL to adjust if need

      • headers: Headers

        HTTP headers to tweak as desired

      Returns URL

      the finalized URL

    • Initializes the tracks to be received.

      This method must be called first to declare which tracks should be negotiated and received.

      Audio / Video:

      • undefined or -1 → Track disabled
      • = 0 → Receive the specified track index.

      Data:

      • undefined → Receive all data tracks.
      • Set → Receive only the specified data track indexes.

      Parameters

      • tracks: Tracks

        Track selection configuration.

      Returns void

    • Create a Reader usable to feed the Source and matching mediaExt Can throw an exception if no demuxer is found for the related media extension

      Parameters

      • params: { isStream: boolean } = ...

      Returns Reader

    • Event unsubscription

      Parameters

      • name:
            | "audio"
            | "video"
            | "data"
            | "Data"
            | "Audio"
            | "Video"
            | "close"
            | "metadata"
            | "Metadata"
            | "Close"
            | "TrackChange"
            | "FinalizeRequest"
            | "trackchange"
            | "finalizerequest"

        Name of event without the 'on' prefix (ex: 'log' to 'onLog' event declared)

      • event: Function

        Unsubscriber Function, must be the one passed to on or once subscription methods

      Returns boolean

    • Event subscription

      Parameters

      • name:
            | "audio"
            | "video"
            | "data"
            | "Data"
            | "Audio"
            | "Video"
            | "close"
            | "metadata"
            | "Metadata"
            | "Close"
            | "TrackChange"
            | "FinalizeRequest"
            | "trackchange"
            | "finalizerequest"

        Name of event without the on prefix (ex: log to onLog event declared)

      • event: Function

        Subscriber Function

      • Optionaloptions: { signal?: AbortSignal }
        • Optionalsignal?: AbortSignal

          Optional AbortSignal to stop this or multiple subscriptions in same time

      Returns void

    • Event subscription only one time, once time fired it's automatically unsubscribe

      Parameters

      • name:
            | "audio"
            | "video"
            | "data"
            | "Data"
            | "Audio"
            | "Video"
            | "close"
            | "metadata"
            | "Metadata"
            | "Close"
            | "TrackChange"
            | "FinalizeRequest"
            | "trackchange"
            | "finalizerequest"

        Name of event without the on prefix (ex: log to onLog event declared)

      • event: Function

        Subscriber Function

      • Optionaloptions: { signal?: AbortSignal }
        • Optionalsignal?: AbortSignal

          Optional AbortSignal to stop this or multiple subscriptions in same time

      Returns void

    • Utility dispatcher that forwards a media sample to the appropriate reader (readAudio, readVideo, or readData) based on its type.

      This is a convenience method — callers may invoke readAudio, readVideo, or readData directly if the media type is already known.

      Parameters

      • type: Media.Type

        Media type (AUDIO, VIDEO, DATA)

      • trackId: number

        Track identifier

      • sample: Sample

        Media sample to process

      Returns void

    • Ingest video sample for trackId, if sample is undefined it only changes the tracks If sample.duration is negative, it will extend the sample until the currentTime to repair synchronization

      Parameters

      Returns void

    • Retrieves the Source class registered for the specified protocol.

      Parameters

      • protocol: string

        The name of the protocol (e.g., 'wss', 'https', 'http').

      Returns SourceType | undefined

      The registered Source class implementation for the protocol, or undefined if not found.

    • Registers a Source class for one or multiple protocols, see getClass to retrieve the registered Source class.

      Parameters

      • ...protocols: [string, ...string[]]

        One or more protocol names (e.g., 'wss', 'https', 'http'), at least one protocol is required.

      Returns <Class extends SourceType>(SourceClass: Class, context?: unknown) => Class

      A decorator that registers the given Source class under the specified protocols.

      *@Source.registerClass('wss', 'ws')*
      export class MySource extends Source {
      constructor(playing: IPlaying, params: Connect.Params) {
      super(playing, 'wss', params);
      }
      }

    Events

    • Fired when the URL and headers can be finalized before sending the request to the server.

      Parameters

      • url: URL

        the request URL to finalize or modify if needed

      • headers: Headers

        the request headers to adjust if needed

      Returns void

    • Event fired when metadata is available in the stream.

      On the first occurrence, the optional return value allows specifying which track to use when starting the stream. By default, the middle-quality track is selected.

      Note that this differs from using videoTrack or audioTrack, where a specific track is fixed, which disables any Adaptive Bitrate algorithm.

      Parameters

      • metadata: Metadata

        The metadata received from the stream.

      Returns void | Tracks

      Optional tracks to use for initializing the stream.

      // Set the initial video track to the highest quality; MBR will adjust it later based on network conditions.
      player.onMetadata = (metadata) => ({ video: metadata.videoTracks[0].id });

      // Alternatively, disable MBR and lock the video track to the highest available quality.
      player.onMetadata = (metadata) => player.videoTrack = metadata.videoTracks[0].id;
    • Fire on a track change

      Parameters

      • audioTrack: number
      • videoTrack: number
      • dataTrack: Set<number>

      Returns void