dart_cast library

A Dart package for casting media to Chromecast, AirPlay, and DLNA devices.

Classes

AirPlayClient
Low-level HTTP client for AirPlay video casting endpoints.
AirPlayDiscoveryProvider
Discovers AirPlay devices via mDNS (_airplay._tcp.local).
AirPlayFeatures
Parses and exposes AirPlay feature flags from mDNS TXT records.
AirPlayMediaController
Controls AirPlay video playback (play, pause, seek, stop, etc.) over an existing HapSession.
AirPlayPairSetup
Orchestrates the AirPlay HAP pair-setup flow (4 HTTP requests).
AirPlayPairVerify
Orchestrates the AirPlay HAP pair-verify flow (2 HTTP requests).
AirPlaySession
AirPlay 1 cast session with playback control and position polling.
CastDevice
Represents a discovered cast-capable device on the network.
CastLogger
Simple logger with pluggable callback.
CastMedia
Represents media to be cast to a device.
CastService
Unified entry point for casting to Chromecast, AirPlay, and DLNA devices.
CastSession
Abstract base class for protocol-specific cast sessions.
CastSubtitle
Represents a subtitle track for cast media.
ChromecastDiscoveryProvider
Discovers Chromecast devices via mDNS (_googlecast._tcp.local).
ChromecastSession
A casting session with a Chromecast device.
DefaultMediaTransformer
Default transformer that handles common casting scenarios.
DeviceDiscoveryProvider
Abstract interface for protocol-specific device discovery.
DiscoveryManager
Manages device discovery across multiple protocol providers.
DlnaDeviceDescription
Parsed DLNA device description with extracted service control URLs.
DlnaDiscoveryProvider
Discovers DLNA (UPnP) media renderers via SSDP M-SEARCH.
DlnaHttpClient
HTTP client for sending SOAP actions to DLNA devices.
DlnaServiceType
Service type URNs for DLNA SOAP actions.
DlnaSession
A DLNA casting session that controls playback on a DLNA renderer.
DlnaSoapBuilder
Builds SOAP XML envelopes for DLNA/UPnP actions.
DlnaSoapParser
Parses SOAP XML responses from DLNA devices.
HapCredentials
Persistent credentials produced by HAP pair-setup.
HapHttpResponse
A parsed HTTP response from the HAP encrypted channel.
HapSession
HAP encrypted session layer for AirPlay.
HapSrp
Implements SRP-6a with HAP-specific parameters for AirPlay pair-setup.
HlsParser
HLS playlist parser with URL rewriting for proxy support.
HlsStreamHandler
Handles fetching an HLS playlist and streaming its segments as a continuous MPEG-TS byte stream.
MdnsDiscovery
Constants and utilities for mDNS-based device discovery.
MdnsServiceInfo
Represents a discovered mDNS service with its TXT records.
MediaProxy
Local HTTP proxy server for casting.
MediaSource
A byte payload the proxy can serve without knowing where it came from.
MediaTransformer
Transforms CastMedia into a proxy URL ready for casting.
NetworkUtils
Network utility methods for casting.
PairVerifyResult
Result of a pair-verify exchange.
PlaybackError
An error reported by the receiver inside a /playback-info response.
PlaybackInfo
Parsed AirPlay playback info.
PlistCodec
Parses Apple plist responses from AirPlay devices.
PositionInfo
Parsed position info from a GetPositionInfo SOAP response.
ServerInfo
Parsed AirPlay server info.
SessionStateMachine
Manages valid state transitions for a cast session.
SsdpConstants
Constants for SSDP multicast discovery.
SsdpMessage
Static methods for formatting and parsing SSDP messages.
SsdpResponse
Parsed SSDP response containing extracted header values.
SubtitleConverter
Converts between subtitle formats (SRT <-> VTT).
Tlv8
TLV8 (Tag-Length-Value with 8-bit length) encoder and decoder.
TransformedMedia
Result of transforming media for casting.
TsHlsMediaTransformer
Media transformer that wraps local MPEG-TS files in HLS playlists.

Enums

CastMediaType
Media type for casting.
CastProtocol
Protocol types supported for casting.
SessionState
Possible states of a cast session.

Functions

deriveEventKeys(Uint8List sharedSecret) Future<({Uint8List inputKey, Uint8List outputKey})>
Derives event channel encryption keys from an X25519 shared secret.
deriveHapSessionKeys(Uint8List sharedSecret) Future<({Uint8List inputKey, Uint8List outputKey})>
Derives the HAP session encryption keys from an X25519 shared secret.

Typedefs

HttpFetcher = Future<String> Function(String url)
Function type for fetching a URL and returning its body.
LogCallback = void Function(String level, String message)
Callback type for log messages.
MdnsLookup = Stream<MdnsServiceInfo> Function(String serviceType)
Function type for performing mDNS service discovery.
MediaSourceReader = FutureOr<Stream<List<int>>> Function(int start, int end)
Reads a byte range from a MediaSource.
RawDatagramSocketFactory = Future<RawDatagramSocket> Function(dynamic host, int port)
Function type for creating a UDP socket for SSDP discovery.
SessionFactory = CastSession Function(CastDevice device)
Factory function for creating protocol-specific sessions.

Exceptions / Errors

AirPlayAuthException
Exception thrown during AirPlay HAP authentication.
AirPlayClientException
Exception thrown when an AirPlay HTTP request fails.
CastException
Base exception for all casting errors.
ConnectionLostException
Thrown when the connection to a device is lost unexpectedly.
DeviceUnreachableException
Thrown when a device cannot be reached on the network.
DiscoveryException
Thrown when device discovery encounters an error.
HapSessionException
Exception thrown when the HAP encrypted session encounters an error.
MediaLoadFailedException
Thrown when media fails to load on the cast device.
NeedsPairingException
Thrown when an AirPlay device requires HAP pairing (PIN entry).
PlaybackException
Thrown when playback fails after trying all available formats.
ProtocolException
Thrown when a protocol-specific error occurs.
ProxyUpstreamException
Thrown when the media proxy encounters an upstream error.
UnsupportedFeatureException
Thrown when a device does not support the requested feature.