FCast Documentation
repository·master·Indexed 20 days ago
https://github.com/futo-org/fcastFCast is an open-source wireless streaming protocol for audio and video (DASH, HLS, mp4) enabling interoperability between senders and receivers across Linux, Windows, MacOS, Android, Tizen OS, and WebOS. The documentation covers the sender-receiver model, reference implementations (Desktop, Terminal, Grayjay), and detailed build instructions for various receiver platforms and the Sender SDK for Kotlin, Swift, and Rust.
What's inside FCast
- FCast is an open source protocol designed for the wireless streaming of audio and video content between devices. It supports multiple stream types, including DASH, HLS, and mp4. Unlike proprietary protocols (e.g., Chromecast or AirPlay), FCast is open, allowing developers to build custom receivers or integrate the protocol into existing applications.
Overview of FCast Senders and Receivers
masterFCast provides several reference implementations for both sending and receiving content:
Receivers
- Android: Receiver implementation for Android devices.
- Desktop: Receiver implementation for desktop platforms.
Senders
- Desktop Sender: Used for mirroring screens or casting multimedia content to FCast receivers.
- Terminal Sender: A command-line interface (CLI) implementation of the FCast protocol.
- Grayjay: A multi-platform media application (available on Android and Desktop) that supports FCast.
Supported platforms for FCast Receiver
masterThe FCast Receiver is a receiver implementation that uses the FCast protocol to display multimedia content sent from FCast sender applications. It is currently available on the following platforms:
- Android (Native)
- Linux
- Windows
- MacOS
Receivers can be downloaded from https://fcast.org/#downloads.
Add casting capabilities using the FCast SDK
masterThe FCast SDK allows developers to integrate casting capabilities into their applications. It implements the proprietary FCast protocol and includes support for parts of the Google Cast protocol (specifically the Default Media Receiver).Supported FCast Sender Applications
masterThe FCast protocol is supported by several applications for different use cases:
FUTO Applications
- Grayjay: A media player that exposes multiple video websites as sources.
- Terminal: A command-line interface (CLI) sender for controlling FCast via terminal commands.
- Desktop: A sender for mirroring screens and casting local files from a file system.
Third-Party Applications
- CloudStream: An Android app for streaming and downloading media.
- CastLab: An app for casting gallery media via the DLNA protocol.
- ReFra: A Jetpack Compose-based media gallery app for Android.
Add casting capabilities using the FCast Sender SDK
masterThe FCast Sender SDK allows developers to integrate casting functionality into their applications. It is designed to work out of the box with several programming languages, enabling applications to act as senders in the FCast ecosystem.
Supported languages currently include:
- Kotlin
- Swift
- Rust
Additional language support is planned for future releases.
What is an FCast Sender?
masterAn FCast
senderis a device or software application responsible for discovering and communicating with an FCastreceiver(such as a TV, media top box, or desktop).Core Workflow:
- Discovery & Connection: The sender discovers a receiver and establishes a connection.
- Media Launch: The sender initiates media streaming by launching content on the receiver.
- Playback Control: Once media is playing, the sender can perform remote operations including:
- Pause
- Resume
- Seek
- Volume adjustment
How Screen Mirroring works via WebRTC
masterA sender can mirror its screen to a receiver using a WebRTC connection negotiated over the FCast control connection. The sender is the WebRTC offerer and the receiver is the answerer.
Negotiation Process
Negotiation is performed using two
Flatbufpackets containingMirroringSessionDescription:- Session Initiation: The sender allocates a
session_idand sendsStartMirroringSessionto the receiver. - SDP Offer: The sender gathers ICE candidates (non-trickle) and sends an SDP offer in a
MirroringSessionDescriptioncontaining thesession_id. - SDP Answer: The receiver replies with its own
MirroringSessionDescriptioncontaining the SDP answer and the samesession_id.
Note: A
MirroringSessionDescriptionwith a mismatchedsession_idis invalid. The reference implementation uses host candidates only (no STUN/TURN), so mirroring is intended for local networks.- Session Initiation: The sender allocates a
Target a receiver by IP or Name
masterWhen using the
fcastCLI, you must specify a target receiver. Use one of the following methods:- By IP address: Use the
-Hor--host <ip>flag. If omitted,127.0.0.1is assumed. - By advertised name: Use the
-nor--name <name>flag to target a receiver discovered via mDNS. - By name (default): If neither
--hostnor--nameis provided, the client attempts to connect to127.0.0.1.
# Target by name ./fcast --name "Living Room TV" play ... # Target by host IP ./fcast -H 127.0.0.1 play ...- By IP address: Use the
FCast Version 4 Protocol Overview
masterFCast Version 4 is a TCP-based protocol running on port
46899. The protocol uses a specific packet structure consisting of a 32-bit Little-Endian (LE) size field, an 8-bit opcode, and a variable-length body.Packet Structure
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Size (LE) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Opcode | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | : : Body : : | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+Constraints
- Size: 32 bits. This value represents the number of bytes following the Size field (Opcode + Body).
- Opcode: 8 bits.
- Body Size:
Size - 1(since the opcode is 1 byte). - Maximum Packet Size: 512 KiB (total opcode + body).
- Error Handling: If a party receives a packet where
Size = 0or the size exceeds 512 KiB, it must disconnect immediately.
Use the FCompanion protocol for media transfer
masterThe FCompanion protocol is used to transfer media data over an FCast connection using a custom binary format (little-endian). Media resources are identified by
fcomp://URLs.URL Format:
fcomp://<provider-id>.fcast/<resource-id><provider-id>: AU16rendered as ASCII decimal digits.<resource-id>: AU32rendered as ASCII decimal digits.
Workflow for Senders:
- Initialization: Send a
CompanionHelloRequestto the receiver. - ID Assignment: The receiver replies with a
CompanionHelloResponsecontaining aprovider_idassigned to that specific connection. - URL Construction: Construct
fcomp://URLs using the assignedprovider_idand include them in aMediaItem'ssource_urlfield. - Data Delivery: When the receiver requests data via
CompanionResourceInfoRequest/CompanionResourceRequest, the sender responds withCompanionResourceInfoResponseandResourcepackets.
Note: Receivers must support cases where a sender provides a companion URL belonging to a different connection's
provider_idto allow for developer flexibility.fcomp://<provider-id>.fcast/<resource-id>How device state synchronization works
masterFCast allows multiple senders to connect to a single receiver. To ensure all connected devices stay in sync (e.g., volume, playback state, track selection), the receiver acts as a relay for state-mutating messages.
Workflow:
- A sender (e.g., S1) sends a mutation message (e.g.,
VolumeChanged(50%)) to the receiver. - Once the receiver successfully applies the change, it relays that same message to all currently connected senders (including S1).
Supported synchronized actions include:
VolumeChangedLoadPlaybackStateChangedSpeedChangedQueueInsert/QueueRemoveQueueItemSelectedChangeTrack
- A sender (e.g., S1) sends a mutation message (e.g.,