From 90b85e8c7a5bf92405d2a07fde0069bcfd3ab526 Mon Sep 17 00:00:00 2001 From: backkem Date: Fri, 8 Mar 2019 13:10:12 +0100 Subject: [PATCH] WASM: Document WASM support Resolves #501 --- README.md | 4 ++- examples/README.md | 68 ++++++++++++++++++++++++++++++++-------------- 2 files changed, 50 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 952885f7c4b..3bfc982ea89 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,9 @@ Now go forth and build some awesome apps! Here are some **ideas** to get your cr * Record your webcam and do special effects server side. * Build a conferencing application that processes audio/video and make decisions off of it. +### WebAssembly +Pion WebRTC can be used when compiled to WebAssembly, also known as WASM. In this case the library will act as a wrapper around the JavaScript WebRTC API. This allows you to use WebRTC from Go in both server and browser side code with little to no changes. Check out the **[example applications](examples/README.md#webassembly)** for instructions on how to compile and run the WebAssembly examples. + ### Roadmap The library is in active development, please refer to the [roadmap](https://github.com/pions/webrtc/issues/9) to track our major milestones. @@ -55,7 +58,6 @@ If you need commercial support or don't want to use public methods you can conta ### Related projects * [pions/turn](https://github.com/pions/turn): A simple extendable Golang TURN server * [WIP] [pions/media-server](https://github.com/pions/media-server): A Pion WebRTC powered media server, providing the building blocks for anything RTC. -* [WIP] [pions/dcnet](https://github.com/pions/dcnet): A package providing Golang [net](https://godoc.org/net) interfaces around Pion WebRTC data channels. ### Contributing Check out the **[contributing wiki](https://github.com/pions/webrtc/wiki/Contributing)** to join the group of amazing people making this project possible: diff --git a/examples/README.md b/examples/README.md index 855af96c2b8..ae6f51b9bdd 100644 --- a/examples/README.md +++ b/examples/README.md @@ -2,24 +2,50 @@ Examples -We've build an extensive collection of examples covering common use-cases. Modify and extend these examples to quickly get started. - -* [gstreamer-receive](gstreamer-receive/README.md): Play video and audio from your Webcam live using GStreamer -* [gstreamer-send](gstreamer-send/README.md): Send video generated from GStreamer to your browser -* [save-to-disk](save-to-disk/README.md): Save video from your Webcam to disk -* [data-channels](data-channels/README.md): Use data channels to send text between Pion WebRTC and your browser -* [data-channels-create](data-channels/README.md): Similar to data channels but now Pion initiates the creation of the data channel. -* [sfu](sfu/README.md): Broadcast a video to many peers, while only requiring the broadcaster to upload once -* [pion-to-pion](pion-to-pion/README.md): An example of two Pion instances communicating directly. - -All examples can be executed on your local machine. - -### Install -``` sh -go get github.com/pions/webrtc -cd $GOPATH/src/github.com/pions/webrtc/examples -go run examples.go -``` -Note: you can change the port of the server using the ``--address`` flag. - -Finally, browse to [localhost](http://localhost) to browse through the examples. +We've build an extensive collection of examples covering common use-cases. You can modify and extend these examples to quickly get started. + +### Overview +#### Media API +* [Gstreamer Receive](gstreamer-receive): The gstreamer-receive example shows how to receive media from the browser and play it live. This example uses GStreamer for rendering. +* [Gstreamer Send](gstreamer-send): Example gstreamer-send shows how to send video to your browser. This example uses GStreamer to process the video. +* [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. + +#### Data Channel API +* [Data Channels](data-channels): The data-channels example shows how you can send/recv DataChannel messages from a web browser. +* [Data Channels Create](data-channels-create): Example data-channels-create shows how you can send/recv DataChannel messages from a web browser. The difference with the data-channels example is that the data channel is initialized from the server side in this example. +* [Data Channels Close](data-channels-close): Example data-channels-close is a variant of data-channels that allow playing with the life cycle of data channels. +* [Data Channels Detach](data-channels-detach): The data-channels-detach example shows how you can send/recv DataChannel messages using the underlying DataChannel implementation directly. This provides a more idiomatic way of interacting with Data Channels. +* [Data Channels Detach Create](data-channels-detach-create): Example data-channels-detach-create shows how you can send/recv DataChannel messages using the underlying DataChannel implementation directly. This provides a more idiomatic way of interacting with Data Channels. The difference with the data-channels-detach example is that the data channel is initialized in this example. +* [Pion to Pion](pion-to-pion): Example pion-to-pion is an example of two pion instances communicating directly! It therefore has no corresponding web page. +* [ORTC](ortc): Example ortc shows how you an use the ORTC API for DataChannel communication. +* [ORTC QUIC](ortc-quic): Example ortc-quic shows how you an use the ORTC API for QUIC DataChannel communication. +* [Pion to Pion](pion-to-pion): Example pion-to-pion is an example of two pion instances communicating directly! It therefore has no corresponding web page. + + +### Usage +We've made it easy to run the browser based examples on your local machine. + +1. Build and run the example server: + ``` sh + go get github.com/pions/webrtc + 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. + +### WebAssembly +Some of our examples have support for WebAssembly. The same examples server documented above can be used to run the WebAssembly examples. However, you have to compile them first. This is done as follows: + +1. If the example supports WebAssembly it will contain a `main.go` file under the `jsfiddle` folder. +2. Build this `main.go` file as follows: + ``` + 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