Pion WebRTC examples

Data Channels

The data-channels example shows how you can send/recv DataChannel messages from a web browser.

Run JavaScript

Data Channels Detach

The data-channels-detach is an example that shows how you can detach a data channel.

Data Channels Flow Control

The data-channels-detach data-channels-flow-control shows how to use the DataChannel API efficiently. You can measure the amount the rate at which the remote peer is receiving data, and structure your application accordingly

Reflect

The reflect example demonstrates how to have Pion send back to the user exactly what it receives using the same PeerConnection.

Run JavaScript

Pion to Pion

Example pion-to-pion is an example of two pion instances communicating directly! It therefore has no corresponding web page.

Play from Disk

The play-from-disk example demonstrates how to send video to your browser from a file saved to disk.

Run JavaScript

Play from Disk Renegotiation

The play-from-disk-renegotiation example is an extension of the play-from-disk example, but demonstrates how you can add/remove video tracks from an already negotiated PeerConnection.

Run JavaScript

Insertable Streams

The insertable-streams example demonstrates how Pion can be used to send E2E encrypted video and decrypt via insertable streams in the browser.

Run JavaScript

Save to Disk

The save-to-disk example shows how to record your webcam and save the footage to disk on the server side.

Run JavaScript

Broadcast

The broadcast example demonstrates how to broadcast a video to multiple peers. A broadcaster uploads the video once and the server forwards it to all other peers.

Run JavaScript

RTP Forwarder

The rtp-forwarder example demonstrates how to forward your audio/video streams using RTP.

Run JavaScript

RTP to WebRTC

The rtp-to-webrtc example demonstrates how to take RTP packets sent to a Pion process into your browser.

Custom Logger

Example custom-logger demonstrates how the user can override the logging and process messages instead of printing to stdout. It has no corresponding web page.

Simulcast

Example simulcast demonstrates how to accept and demux 1 Track that contains 3 Simulcast streams. It then returns the media as 3 independent Tracks back to the sender.

Run JavaScript

ICE Restart

Example ice-restart demonstrates how a WebRTC connection can roam between networks. This example restarts ICE in a loop and prints the new addresses it uses each time.

ICE Single Port

Example ice-single-port demonstrates how multiple WebRTC connections can be served from a single port. By default Pion listens on a new port for every PeerConnection. Pion can be configured to use a single port for multiple connections.

ICE TCP

Example ice-tcp demonstrates how a WebRTC connection can be made over TCP instead of UDP. By default Pion only does UDP. Pion can be configured to use a TCP port, and this TCP port can be used for many connections.

Swap Tracks

The swap-tracks example demonstrates deeper usage of the Pion Media API. The server accepts 3 media streams, and then dynamically routes them back as a single stream to the user.

Run JavaScript

VNet

The vnet example demonstrates Pion's network virtualisation library. This example connects two PeerConnections over a virtual network and prints statistics about the data traveling over it.

rtcp-processing

The rtcp-processing example demonstrates Pion's RTCP APIs. This allow access to media statistics and control information.

Run JavaScript

trickle-ice

The trickle-ice example demonstrates Pion WebRTC's Trickle ICE APIs.