Git Product home page Git Product logo

gstwebrtc-demos's Introduction

GStreamer WebRTC demos

All demos use the same signalling server in the signalling/ directory

Downloading GStreamer

The GStreamer WebRTC implementation has now been merged upstream, and is in the GStreamer 1.14 release. Binaries can be found here:

https://gstreamer.freedesktop.org/download/

Building GStreamer from source

If you don't want to use the binaries provided by GStreamer or on your Linux distro, you can build GStreamer from source.

The easiest way to build the webrtc plugin and all the plugins it needs, is to use Cerbero. These instructions should work out of the box for all platforms, including cross-compiling for iOS and Android.

One thing to note is that it's written in Python 2, so you may need to replace all instances of ./cerbero-uninstalled (or cerbero) with python2 cerbero-uninstalled or whatever Python 2 is called on your platform.

Building GStreamer manually from source

For hacking on the webrtc plugin, you may want to build manually using the git repositories:

You can build these with either Autotools gst-uninstalled:

https://arunraghavan.net/2014/07/quick-start-guide-to-gst-uninstalled-1-x/

Or with Meson gst-build:

https://cgit.freedesktop.org/gstreamer/gst-build/

You may need to install the following packages using your package manager:

json-glib, libsoup, libnice, libnice-gstreamer1 (the gstreamer plugin for libnice, called gstreamer1.0-nice Debian)

Filing bugs

Please only file bugs about the demos here. Bugs about GStreamer's WebRTC implementation should be filed on the GStreamer bugzilla.

You can also find us on IRC by joining #gstreamer @ FreeNode.

Documentation

Currently, the best way to understand the API is to read the examples. This post breaking down the API should help with that:

http://blog.nirbheek.in/2018/02/gstreamer-webrtc.html

Examples

sendrecv: Send and receive audio and video

  • Serve the js/ directory on the root of your website, or open https://webrtc.nirbheek.in

    • The JS code assumes the signalling server is on port 8443 of the same server serving the HTML
  • Open the website in a browser and ensure that the status is "Registered with server, waiting for call", and note the id too.

Running the C version

  • Build the sources in the gst/ directory on your machine
$ gcc webrtc-sendrecv.c $(pkg-config --cflags --libs gstreamer-webrtc-1.0 gstreamer-sdp-1.0 libsoup-2.4 json-glib-1.0) -o webrtc-sendrecv
  • Run webrtc-sendrecv --peer-id=ID with the id from the browser. You will see state changes and an SDP exchange.

Running the Python version

  • python3 -m pip install --user websockets
  • run python3 sendrecv/gst/webrtc-sendrecv.py ID with the id from the browser. You will see state changes and an SDP exchange.

The python version requires at least version 1.14.2 of gstreamer and its plugins.

Running the Rust version

  • Install a recent Rust toolchain, e.g. via rustup.
  • Run cargo build for building the executable.
  • Run cargo run -- --peer-id=ID with the id from the browser. You will see state changes and an SDP exchange.

With all versions, you will see a bouncing ball + hear red noise in the browser, and your browser's webcam + mic in the gst app.

You can pass a --server argument to all versions, for example --server=wss://127.0.0.1:8443.

multiparty-sendrecv: Multiparty audio conference with N peers

  • Build the sources in the gst/ directory on your machine
$ gcc mp-webrtc-sendrecv.c $(pkg-config --cflags --libs gstreamer-webrtc-1.0 gstreamer-sdp-1.0 libsoup-2.4 json-glib-1.0) -o mp-webrtc-sendrecv
  • Run mp-webrtc-sendrecv --room-id=ID with ID as a room name. The peer will connect to the signalling server and setup a conference room.
  • Run this as many times as you like, each will spawn a peer that sends red noise and outputs the red noise it receives from other peers.
    • To change what a peer sends, find the audiotestsrc element in the source and change the wave property.
    • You can, of course, also replace audiotestsrc itself with autoaudiosrc (any platform) or pulsesink (on linux).
  • TODO: implement JS to do the same, derived from the JS for the sendrecv example.

TODO: Selective Forwarding Unit (SFU) example

  • Server routes media between peers
  • Participant sends 1 stream, receives n-1 streams

TODO: Multipoint Control Unit (MCU) example

  • Server mixes media from all participants
  • Participant sends 1 stream, receives 1 stream

gstwebrtc-demos's People

Contributors

nirbheek avatar mathieuduponchelle avatar sdroege avatar tp-m avatar maxmcd avatar matthew1000 avatar ebail avatar heftig avatar sawchord avatar ystreet avatar skilb avatar thiblahute avatar meldron avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.