diff --git a/.gitignore b/.gitignore index ade03841..45104823 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,5 @@ tags cover.out *.sw[poe] *.wasm +examples/sfu-ws/cert.pem +examples/sfu-ws/key.pem diff --git a/examples/README.md b/examples/README.md index ae6f51b9..8232cf6f 100644 --- a/examples/README.md +++ b/examples/README.md @@ -11,7 +11,8 @@ We've build an extensive collection of examples covering common use-cases. You c * [Gstreamer Send Offer](gstreamer-send-offer): Example gstreamer-send-offer is a variant of gstreamer-send that initiates the WebRTC connection by sending an offer. * [Save to Disk](save-to-disk): The save-to-disk example shows how to record your webcam and save the footage to disk on the server side. * [Janus Gateway](janus-gateway): Example janus-gateway is a collection of examples showing how to use Pion WebRTC with [janus-gateway](https://github.com/meetecho/janus-gateway). -* [SFU](sfu): The SFU 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. +* [SFU Minimal](sfu-minimal): The SFU 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. +* [SFU Websocket](sfu-websocket): The SFU 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. #### Data Channel API * [Data Channels](data-channels): The data-channels example shows how you can send/recv DataChannel messages from a web browser. @@ -26,7 +27,7 @@ We've build an extensive collection of examples covering common use-cases. You c ### Usage -We've made it easy to run the browser based examples on your local machine. +We've made it easy to run the browser based examples on your local machine. 1. Build and run the example server: ``` sh @@ -34,7 +35,7 @@ We've made it easy to run the browser based examples on your local machine. cd $GOPATH/src/github.com/pions/webrtc/examples go run examples.go ``` - + 2. Browse to [localhost](http://localhost) to browse through the examples. Note that you can change the port of the server using the ``--address`` flag. @@ -48,4 +49,4 @@ Some of our examples have support for WebAssembly. The same examples server docu GOOS=js GOARCH=wasm go build -o demo.wasm ``` 3. Start the example server. Refer to the [usage](#usage) section for how you can build the example server. -4. Browse to [localhost](http://localhost). The page should now give you the option to run the example using the WebAssembly binary. \ No newline at end of file +4. Browse to [localhost](http://localhost). The page should now give you the option to run the example using the WebAssembly binary. diff --git a/examples/sfu-minimal/README.md b/examples/sfu-minimal/README.md new file mode 100644 index 00000000..75fe0e3a --- /dev/null +++ b/examples/sfu-minimal/README.md @@ -0,0 +1,32 @@ +# sfu-minimal +sfu-minimal is a pion-WebRTC application that demonstrates how to broadcast a video to many peers, while only requiring the broadcaster to upload once. + +This could serve as the building block to building conferencing software, and other applications where publishers are bandwidth constrained. + +## Instructions +### Download sfu-minimal +``` +go get github.com/pions/webrtc/examples/sfu-minimal +``` + +### Open sfu-minimal example page +[jsfiddle.net](https://jsfiddle.net/5cwx0rns/11/) You should see two buttons 'Publish a Broadcast' and 'Join a Broadcast' + +### Run SFU Minimal +#### Linux/macOS +Run `sfu-minimal` OR run `main.go` in `github.com/pions/webrtc/examples/sfu-minimal` + +### Start a publisher + +* Click `Publish a Broadcast` +* `curl localhost:8080/sdp -d "YOUR SDP"`. The `sfu-minimal` application will respond with an offer, paste this into the second input field. Then press `Start Session` + +### Join the broadcast +* Click `Join a Broadcast` +* `curl localhost:8080/sdp -d "YOUR SDP"`. The `sfu-minimal` application will respond with an offer, paste this into the second input field. Then press `Start Session` + +You can change the listening port using `-port 8011` + +You can `Join the broadcast` as many times as you want. The `sfu-minimal` Golang application is relaying all traffic, so your browser only has to upload once. + +Congrats, you have used pion-WebRTC! Now start building something cool diff --git a/examples/sfu/jsfiddle/demo.css b/examples/sfu-minimal/jsfiddle/demo.css similarity index 100% rename from examples/sfu/jsfiddle/demo.css rename to examples/sfu-minimal/jsfiddle/demo.css diff --git a/examples/sfu/jsfiddle/demo.details b/examples/sfu-minimal/jsfiddle/demo.details similarity index 100% rename from examples/sfu/jsfiddle/demo.details rename to examples/sfu-minimal/jsfiddle/demo.details diff --git a/examples/sfu/jsfiddle/demo.html b/examples/sfu-minimal/jsfiddle/demo.html similarity index 100% rename from examples/sfu/jsfiddle/demo.html rename to examples/sfu-minimal/jsfiddle/demo.html diff --git a/examples/sfu/jsfiddle/demo.js b/examples/sfu-minimal/jsfiddle/demo.js similarity index 100% rename from examples/sfu/jsfiddle/demo.js rename to examples/sfu-minimal/jsfiddle/demo.js diff --git a/examples/sfu/main.go b/examples/sfu-minimal/main.go similarity index 100% rename from examples/sfu/main.go rename to examples/sfu-minimal/main.go diff --git a/examples/sfu/README.md b/examples/sfu/README.md deleted file mode 100644 index b00c6207..00000000 --- a/examples/sfu/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# sfu -sfu is a pion-WebRTC application that demonstrates how to broadcast a video to many peers, while only requiring the broadcaster to upload once. - -This could serve as the building block to building conferencing software, and other applications where publishers are bandwidth constrained. - -## Instructions -### Download sfu -``` -go get github.com/pions/webrtc/examples/sfu -``` - -### Open sfu example page -[jsfiddle.net](https://jsfiddle.net/5cwx0rns/11/) You should see two buttons 'Publish a Broadcast' and 'Join a Broadcast' - -### Run SFU -#### Linux/macOS -Run `sfu` OR run `main.go` in `github.com/pions/webrtc/examples/sfu` - -### Start a publisher - -* Click `Publish a Broadcast` -* `curl localhost:8080/sdp -d "YOUR SDP"`. The `sfu` application will respond with an offer, paste this into the second input field. Then press `Start Session` - -### Join the broadcast -* Click `Join a Broadcast` -* `curl localhost:8080/sdp -d "YOUR SDP"`. The `sfu` application will respond with an offer, paste this into the second input field. Then press `Start Session` - -You can change the listening port using `-port 8011` - -You can `Join the broadcast` as many times as you want. The `sfu` Golang application is relaying all traffic, so your browser only has to upload once. - -Congrats, you have used pion-WebRTC! Now start building something cool