examples

command
v2.1.5 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2019 License: MIT Imports: 9 Imported by: 0

README

Examples

We've build an extensive collection of examples covering common use-cases. You can modify and extend these examples to quickly get started.

For more full featured examples that use 3rd party libraries see our example-webrtc-applications repo.

Overview

Media API

  • Reflect: The reflect example demonstrates how to have Pion send back to the user exactly what it receives using the same PeerConnection.
  • Play from disk: The play-from-disk example demonstrates how to send video to your browser from a file saved 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.
  • 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.

Data Channel API

  • Data Channels: The data-channels example shows how you can send/recv DataChannel messages from a web browser.
  • 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: Example data-channels-close is a variant of data-channels that allow playing with the life cycle of data channels.
  • 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: 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.
  • ORTC: Example ortc shows how you an use the ORTC API for DataChannel communication.
  • ORTC QUIC: Example ortc-quic shows how you an use the ORTC API for QUIC DataChannel communication.
  • Pion to Pion: Example pion-to-pion is an example of two pion instances communicating directly! It therefore has no corresponding web page.

Miscellaneous

  • Custom Logger The custom-logger demonstrates how the user can override the logging and process messages instead of printing to stdout. It 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:

    GO111MODULE=on go get github.com/pion/webrtc/v2
    cd $GOPATH/src/github.com/pion/webrtc/examples
    go run examples.go
    
  2. Browse to 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 section for how you can build the example server.
  4. Browse to localhost. The page should now give you the option to run the example using the WebAssembly binary.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
signal
Package signal contains helpers to exchange the SDP session description between examples.
Package signal contains helpers to exchange the SDP session description between examples.
pion-to-pion
pion-to-pion-trickle

Jump to

Keyboard shortcuts

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