Jitsi Videobridge

repository·master·Indexed 25 days ago

https://github.com/jitsi/jitsi-videobridge

A WebRTC-compatible Selective Forwarding Unit (SFU) that acts as a multimedia router and core backend component of the Jitsi Meet stack. Documentation covers installation on Debian/Ubuntu, custom builds via Maven, JVM tuning, and HOCON-based configuration using Lightbend Config. It includes detailed specifications for ReceiverVideoConstraints and SenderSourceConstraints for managing bandwidth allocation, video resolution, and frame rates via signaling.

Tokens
16.9K
Snippets
42
Records
81
Agent score
84%

What's inside jitsi-videobridge

  1. Understand Jitsi Videobridge HTTP(S) interfaces

    master

    Jitsi Videobridge provides two distinct HTTP(S) interfaces for different communication purposes:

    1. Private Interface: Used for internal infrastructure communication (e.g., signaling servers). It exposes endpoints such as:
      • COLIBRI control interface: /colibri/
      • Health-check interface: /about/health
      • Version interface: /about/version
    2. Public Interface: Used for Colibri Web Sockets that clients connect to directly.
  2. Configure XMPP server for MUC mode

    master

    When using the XMPP API, Jitsi Videobridge (JVB) uses an XMPP client connection to advertise presence in a Multi-User Chat (MUC) room. You can provision a single user account on your XMPP server (e.g., Prosody) to be shared across all JVB instances.

    It is recommended to use a separate XMPP domain that is not accessible by anonymous users.

    prosodyctl register jvb $DOMAIN $PASSWORD
  3. Configure Nginx proxy for Colibri and Secure-Octo WebSockets

    master

    If using an HTTP proxy, ensure it supports WebSockets. Below is an example nginx configuration for two bridges (jvb1 on port 9090 and jvb2 on port 9091) running without TLS locally.

    Colibri (JVB) WebSocket proxying:

       # colibri (JVB) websockets for jvb1
       location ~ ^/colibri-ws/jvb1/(.*) {
           proxy_pass http://127.0.0.1:9090/colibri-ws/jvb1/$1$is_args$args;
           proxy_http_version 1.1;
           proxy_set_header Upgrade $http_upgrade;
           proxy_set_header Connection "upgrade";
           tcp_nodelay on;
       }
       location ~ ^/colibri-ws/jvb2/(.*) {
           proxy_pass http://127.0.0.1:9091/colibri-ws/jvb2/$1$is_args$args;
           proxy_http_version 1.1;
           proxy_set_header Upgrade $http_upgrade;
           proxy_set_header Connection "upgrade";
           proxy_set_header Host alpha.jitsi.net;
           tcp_nodelay on;
       }

    Secure-Octo Relay WebSocket proxying:

       # colibri secure-octo relay websockets for jvb1
       location ~ ^/colibri-relay-ws/jvb1/(.*) {
           proxy_pass http://127.0.0.1:9090/colibri-relay-ws/jvb1/$1$is_args$args;
           proxy_http_version 1.1;
           proxy_set_header Upgrade $http_upgrade;
           proxy_set_header Connection "upgrade";
           tcp_nodelay on;
       }
       location ~ ^/colibri-relay-ws/jvb2/(.*) {
           proxy_pass http://127.0.0.1:9091/colibri-relay-ws/jvb2/$1$is_args$args;
           proxy_http_version 1.1;
           proxy_set_header Upgrade $http_upgrade;
           proxy_set_header Connection "upgrade";
           proxy_set_header Host alpha.jitsi.net;
           tcp_nodelay on;
       }
    location ~ ^/colibri-ws/jvb1/(.*) {
           proxy_pass http://127.0.0.1:9090/colibri-ws/jvb1/$1$is_args$args;
           proxy_http_version 1.1;
           proxy_set_header Upgrade $http_upgrade;
           proxy_set_header Connection "upgrade";
           tcp_nodelay on;
       }
  4. VP8 Temporal Scalability and Sequence Number Management

    master

    When using VP8 temporal scalability, the SFU may drop frames to achieve lower frame rates. This requires the SFU to manage the sequence number space for the egress (receiver) leg by generating sequence numbers for every egress packet of a frame, rather than applying a fixed delta.

    Key Implications:

    • Irreversibility: If the SFU skips a frame, it cannot retroactively change that decision because the sequence number space is already allocated.
    • Gap Management: In cases of packet re-ordering or loss, the SFU must immediately decide how much of a gap to leave in the projected sequence numbers to allow delayed packets to be transmitted.
    • False Packet Loss: If the SFU leaves gaps for packets it hasn't received yet, and those packets turn out to be frames the SFU intended to drop anyway, the receiver may interpret these gaps as packet loss. Warning: Bandwidth estimation algorithms (specifically REMB-based ones) must be designed not to reduce bandwidth estimates based on this 'false' packet loss.
  5. Install ktlint for code linting and formatting

    master

    Jitsi RTP uses ktlint for linting and autoformatting Kotlin code. You can install it via the following methods:

    Linux/Generic:

    curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.34.2/ktlint && chmod a+x ktlint && sudo mv ktlint /usr/local/bin/

    macOS (Homebrew):

    brew install ktlint
    curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.34.2/ktlint && chmod a+x ktlint && sudo mv ktlint /usr/local/bin/
  6. Run Jitsi Videobridge locally with Maven

    master

    To run Jitsi Videobridge locally, you must first create a configuration file at ~/.jvb/jvb.conf. You can refer to jvb/src/main/resources/reference.conf for available configuration options.

    Use the following command to execute the bridge, ensuring you set the JVB_HOME variable to your cloned repository path.

    JVB_HOME="/path/to/the/cloned/repo"
    JVB_CONFIG_DIR_LOCATION="~/"
    JVB_CONFIG_DIR_NAME=".jvb"
    JVB_CONFIG_FILE="$JVB_CONFIG_DIR_LOCATION/$JVB_CONFIG_DIR_NAME/jvb.conf"
    
    mvn compile exec:exec -Dexec.executable=java -Dexec.args="-cp %classpath org.jitsi.videobridge.MainKt -Djava.library.path=$JVB_HOME/lib/native/linux-64 -Djava.util.logging.config.file=$JVB_HOME/lib/logging.properties -Dnet.java.sip.communicator.SC_HOME_DIR_LOCATION=$JVB_CONFIG_DIR_LOCATION -Dnet.java.sip.communicator.SC_HOME_DIR_NAME=$JVB_CONFIG_DIR_NAME -Dconfig.file=$JVB_CONFIG_FILE"
  7. Save RTP/RTCP traffic to PCAP

    master

    Enable saving RTP and RTCP traffic for a specific endpoint to a PCAP file in /tmp/.

    Prerequisite: This feature is disabled by default and requires the bridge to be explicitly configured to allow it. Set jmt.debug.pcap.enabled=true in your /etc/jitsi/videobridge/jvb.conf file.

    POST /debug/features/endpoint/CONFERENCE_ID/ENDPOINT_ID/pcap-dump/true
    POST /debug/features/endpoint/CONFERENCE_ID/ENDPOINT_ID/pcap-dump/false
  8. Send JSON messages via EndpointMessage

    master

    Clients can use EndpointMessage to send JSON objects to specific participants or broadcast them to the entire conference.

    When sending a message, the payload must be a valid JSON string. To broadcast a message, set the to field to an empty string (""). To target a specific participant, set to to their <ENDPOINT-ID>.

    Note that Jitsi Videobridge will automatically append a from property containing the sender's <ENDPOINT-ID> before forwarding the message to the recipient(s).