dora-gst-webrtc-sink

Crates.iodora-gst-webrtc-sink
lib.rsdora-gst-webrtc-sink
version0.2.0
created_at2025-10-03 06:19:05.764376+00
updated_at2025-10-03 06:25:31.058471+00
descriptionWebRTC sink node for dora-rs with multi-camera support
homepage
repositoryhttps://github.com/dieu-detruit/dora-gst-webrtc-sink
max_upload_size
id1866219
size171,120
Takafumi Watanabe (dieu-detruit)

documentation

README

dora-gst-webrtc-sink

License: MIT Rust

A WebRTC sink node for dora-rs that streams video via WebRTC with built-in signaling server. Supports multiple video sources and multiple clients per source.

Features

  • πŸŽ₯ Stream RGB8 format video from dora-rs inputs
  • πŸ“‘ Built-in WebRTC signaling server (no external server needed)
  • πŸ”„ Real-time streaming with latest frame priority (buffer size 1)
  • πŸ“Ή Multiple video sources: Handle multiple cameras/video streams simultaneously
  • πŸ‘₯ Multiple clients per source: Each video source can serve multiple WebRTC clients
  • πŸ”§ Dynamic video source management
  • βš™οΈ Configurable signaling server port via environment variable
  • πŸ”’ Optional TLS/SSL support for secure WebSocket connections

Prerequisites

  • Rust 1.70+
  • GStreamer 1.16+ with WebRTC plugins
  • dora-rs

Installing GStreamer

Ubuntu/Debian

sudo apt-get update
sudo apt-get install \
    libgstreamer1.0-dev \
    libgstreamer-plugins-base1.0-dev \
    libgstreamer-plugins-bad1.0-dev \
    gstreamer1.0-plugins-good \
    gstreamer1.0-plugins-bad \
    gstreamer1.0-plugins-ugly \
    gstreamer1.0-libav

macOS

brew install gstreamer gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly

Windows

Download and install from GStreamer official website

Installation

git clone https://github.com/yourusername/dora-gst-webrtc-sink.git
cd dora-gst-webrtc-sink
cargo build --release

Usage

Quick Start

  1. Run the example demo:
cd example
./run_demo.sh
  1. Open example/webrtc-viewer.html in your web browser
  2. The viewer will automatically connect to both camera streams

Environment Variables

  • SIGNALING_PORT: WebSocket signaling server port (default: 8080)
  • SSL_CERT_PATH: Path to SSL certificate file for TLS (optional)
  • SSL_KEY_PATH: Path to SSL private key file for TLS (optional)
  • RUST_LOG: Log level (default: info)

Note: Both SSL_CERT_PATH and SSL_KEY_PATH must be set to enable TLS. If either is missing, the server will run without TLS.

Input Format

The node supports two input formats:

  1. Legacy format (backward compatible):

    • Input ID: image
    • Maps to the default video source
  2. Multi-camera format:

    • Input ID: <video_id>/frame
    • Example: camera1/frame, camera2/frame, front_camera/frame
    • Each unique video_id creates a separate video stream

All inputs expect:

  • Format: RGB8
  • Resolution: Automatically detected from input frame size
  • Framerate: Automatically detected from input timing
  • Encoding parameter: "rgb8"

WebRTC Client Connection

Connect to the WebSocket signaling server at:

Without TLS:

ws://localhost:8080/<video_id>

With TLS:

wss://localhost:8080/<video_id>

Example URLs:

  • ws://localhost:8080/camera1 - First camera (without TLS)
  • ws://localhost:8080/camera2 - Second camera (without TLS)
  • wss://localhost:8080/camera1 - First camera (with TLS)
  • ws://localhost:8080/default - Legacy support

Example Dataflow Configuration

Single Camera (Legacy)

nodes:
  - id: camera
    path: camera-node
    outputs:
      - image
  
  - id: webrtc-sink
    path: dora-gst-webrtc-sink
    inputs:
      image: camera/image

Multiple Cameras

nodes:
  - id: camera1
    path: camera-node
    outputs:
      - frame
  
  - id: camera2
    path: camera-node
    outputs:
      - frame
  
  - id: webrtc-sink
    path: dora-gst-webrtc-sink
    inputs:
      camera1/frame: camera1/frame
      camera2/frame: camera2/frame

Web Client

The included webrtc-viewer.html provides:

  • Automatic connection to multiple video streams
  • Dynamic addition/removal of video streams
  • Individual connection control per stream
  • Real-time status and logging

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Camera Node │────▢│ dora-gst-webrtc  │────▢│ Web Browser β”‚
β”‚   (RGB8)    β”‚     β”‚      -sink       β”‚     β”‚  (WebRTC)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚                  β”‚     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”‚  β”‚  Signaling  β”‚ β”‚     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Camera Node │────▢│  β”‚   Server    β”‚ │────▢│ Web Browser β”‚
β”‚   (RGB8)    β”‚     β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚     β”‚  (WebRTC)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Development

Building from Source

cargo build --release

Running Tests

cargo test

Code Structure

  • src/main.rs - Main entry point and dora node integration
  • src/webrtc_server.rs - WebRTC server implementation
  • src/peer_connection.rs - Individual peer connection management
  • src/video_source_manager.rs - Multiple video source management
  • src/signaling.rs - WebRTC signaling protocol messages

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • dora-rs - Dataflow-oriented robotics architecture
  • GStreamer - Multimedia framework
  • webrtcbin - GStreamer WebRTC implementation

Troubleshooting

GStreamer WebRTC plugin not found

Ensure GStreamer plugins are properly installed:

gst-inspect-1.0 webrtcbin

Connection issues

  1. Check firewall settings for port 8080 (signaling)
  2. Ensure STUN server is accessible (uses Google's public STUN by default)
  3. Check browser console for WebRTC errors
  4. If using TLS, ensure both certificate and key files exist at the specified paths
  5. For self-signed certificates, you may need to accept the certificate in your browser first

Performance issues

  • Adjust VP8 encoding parameters in create_pipeline()
  • Consider reducing resolution or framerate
  • Check CPU usage during encoding

Roadmap

  • H.264 codec support for better compatibility
  • TURN server support for NAT traversal
  • Connection quality metrics
  • Support for additional video formats (NV12, I420)

Contact

For questions, issues, or contributions, please use the GitHub issue tracker.

Commit count: 0

cargo fmt