Skip to content
This repository has been archived by the owner on Mar 16, 2022. It is now read-only.

Commit

Permalink
WASM: Document WASM support
Browse files Browse the repository at this point in the history
Resolves pion#501
  • Loading branch information
backkem committed Mar 8, 2019
1 parent 0f1ddf0 commit 90b85e8
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 22 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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:
Expand Down
68 changes: 47 additions & 21 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,50 @@
Examples
</h1>

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.

0 comments on commit 90b85e8

Please sign in to comment.