Xiu Documentation

website·Indexed 31 days ago

https://www.rustxiu.com/

A live streaming media framework written in pure Rust. Xiu supports protocol conversions between RTMP, HTTP-FLV, HLS, RTSP, and WebRTC, and provides features for recording, authentication algorithms, HTTP callbacks, and a dedicated HTTP API for stream management.

Tokens
5.4K
Snippets
37
Records
48
Agent score
54%

What's inside Xiu

  1. Overview of Xiu live streaming media framework

    Xiu is a live streaming media framework written in pure Rust designed for building live streaming media services. It provides out-of-the-box support for RTMP, HTTP-FLV, and HLS, and is extensible for other protocols. It is cross-platform, supporting Linux, MacOS, and Windows.
  2. Overview of Xiu HTTP Callbacks

    Xiu supports notifying external services of push-pull stream events via HTTP callbacks. When a push or pull stream request is received, Xiu calls a configured HTTP interface to pass relevant stream information.
  3. Overview of RustXiu system features

    RustXiu is a media service written in Rust, designed for stability, robustness, and high concurrency. It supports both command-line and configuration file deployment. The system provides out-of-the-box support for multiple media protocols, including RTMP, HLS, HTTP-FLV, RTSP, WHIP, and WHEP. It is built on the Tokio asynchronous library to handle high-concurrency workloads.
  4. Query specific stream information

    Retrieve detailed information about a specific stream, including publisher details (audio/video codecs, bitrate, resolution) and subscriber information. You can filter the results by providing an identifier and optionally a uuid.

    • If both identifier and a subscriber's uuid are provided, only that specific subscriber's data is returned.
    • If both identifier and the publisher's uuid are provided, all subscriber information is filtered out of the response.
    # Query a specific stream and a specific subscriber
    curl -X POST -H "Content-Type: application/json" -d '{
         "identifier": {
                    "rtmp": {
                        "app_name": "live",
                        "stream_name": "source"
                    }
                },
         "uuid": "17105458497472"
    }' http://localhost:8000/api/query_stream
  5. Pull a remote RTSP stream into XIU for remuxing

    XIU can pull an RTSP stream from a remote camera and remux it into other protocols such as RTMP, HTTP-FLV, or HLS. To achieve this:

    1. Enable the RTSP relay switch in the configuration file.
    2. Add the necessary protocol configurations for the target remux format (RTMP/HTTP-FLV/HLS) to the configuration file.
    3. Use the HTTP-API to start and stop the pulling tasks.
  6. Play a WebRTC live stream using WHEP

    To play a live stream on the web using the WHEP protocol, follow these steps:

    1. Copy the client files located in xiu/protocol/webrtc/src/clients/ to the same directory as the xiu binary file.
    2. Open your browser and navigate to the WebRTC listening port (e.g., http://localhost:8900).
    3. Enter the corresponding app name, stream name, and token used during the push process to start playback.
  7. Implement User-defined Authentication via HTTP Notify and Kickoff

    For custom authentication logic, Xiu supports a combination of httpnotify and the kickoff client. In this flow, Xiu informs an external business system of push/pull stream events via HTTP callbacks. The external system verifies the token and parameters; if verification fails, the system calls the Kickoff API to terminate the stream connection.
  8. Install xiu using Docker

    Run xiu as a Docker container using the harlancn/xiu:latest image. By default, log files are stored in /app/logs inside the container. You can mount a host directory to this path to persist or view logs more easily. To modify configurations, enter the container to edit config.toml and then restart the container.
    # Basic run command
    docker run -d -it --net=host --name xiu --privileged=true harlancn/xiu:latest /app/start.sh /app/config.toml 
    
    # Run with host directory mounted for logs
    docker run -d -it --net=host --name xiu --privileged=true -v $your_own_local_full_path:/app/logs harlancn/xiu:latest /app/start.sh /app/config.toml 
    
    # Enter the container to edit config.toml
    docker exec -it xiu bash
    
    # Restart the container to apply config changes
    docker restart xiu
  9. Configure OBS for RTMP pushing

    When using OBS for live streaming, ensure the RTMP URL is split correctly between the Server and Stream Key/Bearer Token fields. For a URL like rtmp://127.0.0.1:1935/live/test?token=123, the server address and the stream name/token must be entered into their respective fields in the OBS configuration rather than as a single string.