handoff

package module
v0.0.0-...-14813e4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 10 Imported by: 0

README


Pion Handoff

Create WebRTC session in the browser—run it somewhere else

join us on Discord Follow us on Bluesky Twitter Widget


Why

WebRTC is the real-time communication technology used for real-time media streaming. Used for things like Google Meet, Discord and Zoom on the web. With Handoff you create your WebRTC session in the browser, but then move it to a process you control. This lets you do a few interesting things.

  • Record - Join the Zoom call via handoff and save media as it passes through.
  • Send - Use FFmpeg or send an external source. Not limited by browser quality/capture code.
  • Reverse Engineer - Capture ICE/DTLS and decrypted RTP/RTCP/SCTP traffic
sequenceDiagram
    participant Handoff
    participant Browser
    participant Website

    Browser->>Website: Authenticate and use the site normally
    Website->>Browser: WebRTC Signaling
    Note over Browser: WebRTC API is mocked
    Browser->>Handoff: Forward Signaling
    Handoff->>Website: Establish WebRTC session

Usage

See examples directory. examples/datachannel shows a normal page with an optional override, examples/media-save saves VP8 video on the backend while still showing it in the browser, examples/media-send forwards VP8 RTP from the backend into the browser, and examples/greasemonkey generates a userscript that overrides RTCPeerConnection automatically.

Typically you will install the greasemonkey script and then run one of the examples.

Example

Below is an example of sending a users webcam to a WebRTC service, but replacing outgoing video with a ffmpeg testsrc. Handoff sits between the users so it can replace with any arbitrary video.

Example

Community

Pion has an active community on the Discord.

Follow the Pion Bluesky or Pion Twitter for project updates and important WebRTC news.

We are always looking to support your projects. Please reach out if you have something to build! If you need commercial support or don't want to use public methods you can contact us at team@pion.ly

Contributing

Check out the contributing wiki to join the group of amazing people making this project possible

License

MIT License - see LICENSE for full text

Documentation

Overview

Package handoff proxies RTCPeerConnection operations from the browser to backend-owned Pion peer connections.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JavaScript

func JavaScript() string

Types

type Option

type Option func(*Server)

func WithMessageLogger

func WithMessageLogger(logger *log.Logger) Option

type Server

type Server struct {
	OnPeerConnection     func(*webrtc.PeerConnection)
	OnDataChannel        func(*webrtc.DataChannel)
	OnDataChannelMessage func(webrtc.DataChannelMessage) bool
	// contains filtered or unexported fields
}

func NewServer

func NewServer(options ...Option) *Server

func (*Server) SetupHandlers

func (server *Server) SetupHandlers(mux *http.ServeMux)

Directories

Path Synopsis
examples
datachannel command
datachannel demonstrates serving a static HTML page over HTTP.
datachannel demonstrates serving a static HTML page over HTTP.
greasemonkey command
media-save command
media-send command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL