pi-webrtc

IPC Messages

Send data both ways between the browser and a program on the device: AI events, sensor values, or remote-control commands. pi-webrtc passes the messages between a WebRTC DataChannel and a Unix socket on the device.

This works with --use-mqtt and --use-livekit.

Two channels

With --enable-ipc, pi-webrtc opens two extra channels:

ChannelUse it for
LossyMessages where old data can be dropped, such as live sensor values
ReliableMessages that must arrive, such as commands

The client chooses the channel for each message. client-sdk-js uses the reliable channel by default.

Note

With --use-livekit, messages go to everyone in the room. IPC messages in a LiveKit room

Try it

  1. Start pi-webrtc with --enable-ipc:

    ./pi-webrtc --camera=libcamera:0 ... --use-mqtt ... --enable-ipc
  2. On the device, run the unix_socket_client.py example. It prints every message that goes through pi-webrtc:

    python3 examples/unix_socket_client.py
  3. In the browser, use onMessage() to receive messages, and sendText() or sendData() to send them.

The Unix socket is /tmp/pi-webrtc-ipc.sock by default. Change it with --socket-path.

Edit on GitHub

On this page