Documentation
¶
Overview ¶
Package protocol provides URL-based protocol detection and media stream utilities.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyTarget ¶ added in v0.0.20
CopyTarget parses a `copy://<upstream_stream_code>` URL and returns the upstream code. v1 grammar is strict: scheme must be exactly `copy`, host must be a non-empty stream code, no path / query / fragment / userinfo are allowed (those positions are reserved for future qualifiers like `copy://X/raw` or `copy://X/track_2` and rejecting them now keeps the surface clean for that extension).
Returns an error message that names the offending part so the API layer can surface it directly to the user without further interpretation.
func IsCopyURLError ¶ added in v0.0.20
IsCopyURLError reports whether err originated from CopyTarget.
func IsMixerURLError ¶ added in v0.0.22
IsMixerURLError reports whether err originated from MixerTargets.
func IsPushListen ¶
IsPushListen returns true when the URL signals that the server should accept incoming encoder connections (push mode) for a stream.
Two forms are recognised:
publish:// — the preferred, protocol-agnostic form. Encoders may push via RTMP or SRT; the stream code is the only routing key needed.
Legacy wildcard-host form — rtmp://0.0.0.0:port/... or srt://0.0.0.0:port/... Still recognised for backward compatibility.
Examples:
publish:// → true (preferred) rtmp://0.0.0.0:1935 → true (legacy) srt://0.0.0.0:9999 → true (legacy) rtmp://server.com → false (remote pull source)
func SplitTSPackets ¶
SplitTSPackets splits a raw byte slice into 188-byte MPEG-TS packets. Incomplete trailing bytes are discarded.
Types ¶
type Kind ¶
type Kind string
Kind classifies a stream URL into a transport category used internally by the ingestor to choose the right reader implementation.
const ( KindUDP Kind = "udp" // raw MPEG-TS over UDP (unicast or multicast) KindHLS Kind = "hls" // HLS playlist pull over HTTP/HTTPS KindFile Kind = "file" // local filesystem path KindRTMP Kind = "rtmp" // RTMP / RTMPS (pull or push-listen) KindRTSP Kind = "rtsp" // RTSP pull KindSRT Kind = "srt" // SRT (pull caller or push listener) KindPublish Kind = "publish" // accept any push protocol; stream code is the routing key KindCopy Kind = "copy" // re-stream another in-process stream's published output KindMixer Kind = "mixer" // combine video from one in-process stream with audio from another KindUnknown Kind = "unknown" )
Kind constants classify ingest URLs; see Detect.
func Detect ¶
Detect returns the protocol Kind for the given URL. All classification is done purely from the scheme and URL structure — the caller never needs to specify the protocol manually.
rtmp://... → KindRTMP rtmps://... → KindRTMP srt://... → KindSRT udp://... → KindUDP rtsp:// or rtsps://... → KindRTSP http(s)://...*.m3u8 → KindHLS file:// or /absolute/path → KindFile publish:// → KindPublish (push-listen, any protocol) copy://<stream_code> → KindCopy (re-stream another in-process stream) mixer://<video>,<audio> → KindMixer (replace audio of one stream with another)
type MixerSpec ¶ added in v0.0.22
MixerSpec is the parsed result of a `mixer://` URL.
Video / Audio — upstream stream codes (host part, comma-separated)
AudioFailureContinue — when true, the mixer keeps forwarding video-only
after the audio upstream goes away. When false
(default) audio failure aborts the whole stream
(video failure ALWAYS aborts).
func MixerTargets ¶ added in v0.0.22
MixerTargets parses a `mixer://<video_code>,<audio_code>[?audio_failure=continue]` URL. v1 grammar:
- scheme exactly "mixer"
- host is `<video>,<audio>` — both codes non-empty, no `:` (no port)
- no path / fragment / userinfo
- only one query parameter accepted: `audio_failure=continue` (default omitted)
Returns an error message naming the offending part so the API layer can surface it directly to the user.