Skip to content

kevmo314/whep-to-whip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

whep-to-whip

Want to send a WebRTC WHEP publisher to a WebRTC WHIP subscriber? This is the tool for you! It's sort of like a proxy, but doesn't actually need to proxy data.

This binary is so simple that it's more of a concept demonstration than to be included in applications.

Motivation

One of the neat tricks that you can do with WebRTC signalling is proxy the offer/answer session descriptions to another client. This means that if we request data from a WHEP source, we can forward it on to a WHIP sink and the data will flow directly from the source to the sink. Once signalling is done, we can disconnect completely from the source and sink and the data will still flow.

Suppose, for example, you have a video source that publishes WHEP and you want to stream it to a service like Millicast. With other protocols such as RTMP, SRT, or RTSP, you'll need to proxy the traffic like with rtmpsuck or srt-live-transmit. Bandwidth is expensive, though! Soon, your proxy will be eating up gigabytes of bandwidth and you'll be paying for it.

Run this tool and you can stream the source direct to Millicast without needing to proxy the traffic, incurring no video bandwidth costs for the proxy.

Usage

go run main.go <source> <sink>

Example

There aren't many real-world WHEP publishers right now. Therefore, I've included a simple WHEP server that publishes a test stream.

There are more WHIP subscribers, such as LiveKit and Millicast, but I've also included an example subscriber.

To run a full end-to-end example, run the following commands in separate terminals:

PORT=8080 go run example/publisher/main.go
PORT=8081 go run example/subscriber/main.go
go run main.go http://localhost:8080 http://localhost:8081

Note that when you run the third command, it exits completely but the data will still flow from the publisher to the subscriber. Wow!

Limitations

Unfortunately, because both the publisher and subscriber are expect the other side to renegotiate when necessary, if there is a connection break neither side will know how to perform an ICE restart and the session will be lost. Fortunately, the publisher and subscriber should be relatively robust (otherwise they wouldn't be offering WHIP/WHEP!) so this should be very rare.

About

A WHEP to WHIP demonstration

Resources

Stars

Watchers

Forks

Languages