Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/CeeblueTV/wrts-client/llms.txt

Use this file to discover all available pages before exploring further.

HTTPSource is a straightforward HTTP streaming source that opens a single persistent HTTP connection and streams media data in one continuous response body. It does not implement adaptive bitrate switching, rendition management, or sequence skipping. Unlike HTTPAdaptiveSource, it uses the Connect.Type.DIRECT_STREAMING connection type rather than the WRTS manifest-based approach, making it suited for fixed-quality streams or as a starting point for custom HTTP transport implementations.
HTTPAdaptiveSource is generally preferred for live streams. It provides adaptive bitrate switching, frame skipping, sequence recovery, and CMCD telemetry. Use HTTPSource when you need a simple, non-adaptive HTTP connection — for example, when working with fixed-quality streams or when building a custom source on top of the base HTTP infrastructure.See api/source for the full list of inherited properties and methods from the Source base class.

Import

import { HTTPSource } from '@ceeblue/wrts-client';

Registration

HTTPSource is not registered for any protocol via @Source.registerClass. It will not be selected automatically by the Player — you must pass it explicitly as the second constructor argument.

Constructor

constructor(playing: IPlaying, params: Connect.Params)
Creates a new HTTPSource. Internally calls super(playing, 'https', params, Connect.Type.DIRECT_STREAMING). The DIRECT_STREAMING connection type means the URL is built directly from the endpoint without the WRTS manifest path rewriting that HTTPAdaptiveSource performs.
playing
IPlaying
required
The playback context providing buffer state and the stop signal.
params
Connect.Params
required
Connection parameters including endPoint, streamName, mediaExt, and optional query parameters.

Usage

Pass HTTPSource as the second argument to the Player constructor to use it explicitly:
import { Player, HTTPSource } from '@ceeblue/wrts-client';

const player = new Player(videoElement, HTTPSource);
player.start({ endPoint: 'https://example.com/wrts/out+<id>/index.json' });

How It Works

Track Negotiation via Query Parameters

Before issuing the HTTP request, HTTPSource appends codec-preference query parameters to the URL:
  • ?audio=<id> — if a specific audio track is requested; otherwise aac,|bestbps (best-bitrate AAC track)
  • ?video=<id> — if a specific video track is requested; otherwise h264,|bestbps (best-bitrate H264 track)

Streaming Download Loop

HTTPSource enters a loop that:
  1. Calls fetchWithRTT(url, playing) to open the HTTP connection and measure round-trip time.
  2. On the first successful response, stores the measured RTT for use in live-time correction.
  3. Reads the response body in chunks using a ReadableStream reader.
  4. Passes each chunk directly to a Reader instance (created once via newReader()).
  5. On any network error, waits 500 ms and retries the request from the beginning.
  6. Continues until this.closed becomes true.
If the server returns an error response, HTTPSource closes with a SourceError of type 'Request error' and does not retry.

Live Time Correction

HTTPSource overrides readMetadata() to apply an RTT-based correction to the stream’s live clock:
metadata.liveTime += this._rtt / 2
This compensates for network latency so that the reported live position aligns with actual wall-clock time. The correction uses the RTT measured during the most recent successful HTTP request.

Behaviors That Differ from HTTPAdaptiveSource

reliable
boolean
Setting player.reliable = false (after it has been set to true) throws an error — HTTPSource does not support switching back to unreliable mode. Only reliable = true is accepted by setReliability(). The default value is false, and no error is thrown on startup.
trackSelectable
boolean
Returns true for HTTPSource because setTracks() is overridden — however, calling it throws:
HTTP doesn't support a dynamic track selection
This means player.videoTrack and player.audioTrack setters will throw at runtime. Track selection must be configured before playback starts via onMetadata.
cmcd
CMCD
Not supported. The base Source implementation throws if you attempt to set cmcd to any value other than undefined. CMCD telemetry is only available in HTTPAdaptiveSource.

Limitations

  • No adaptive bitrate — a single video/audio track pair is selected at startup and held for the entire session.
  • No sequence skipping — if the stream falls behind live, there is no mechanism to skip forward.
  • No track switching at runtimesetTracks() is overridden but throws; calling player.videoTrack or player.audioTrack setters will throw at runtime.
  • No CMCD — telemetry data is not attached to requests.
  • No protocol auto-registration — must be supplied explicitly to Player.

Usage Examples

import { Player, HTTPSource } from '@ceeblue/wrts-client';

const player = new Player(videoElement, HTTPSource);
player.start({ endPoint: 'https://example.com/wrts/out+<id>/index.json' });

Comparison with Other Sources

FeatureHTTPSourceHTTPAdaptiveSourceWSSource
TransportHTTP (single stream)HTTP/2 (multi-channel)WebSocket (push)
Protocol auto-registration❌ Nonehttps, httpwss, ws
Adaptive bitrate✅ Full MBR
CMCD telemetry✅ NONE / SHORT / FULL
Dynamic track selection❌ Throws
Unreliable mode❌ Throws❌ Throws
Sequence skipping
RTT-based live correction

Build docs developers (and LLMs) love