From: Matthew Waters Date: Thu, 18 Jun 2020 15:31:02 +0000 (+1000) Subject: webrtc: update for move to gst-examples X-Git-Tag: 1.19.3~487^2~51 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e1c3dad25812f94669584bc0d97e4f78ad134ed8;p=platform%2Fupstream%2Fgstreamer.git webrtc: update for move to gst-examples - Integrate with the build system. - Some README updates. Part-of: --- diff --git a/meson.build b/meson.build index 9ac22b0..7178b2a 100644 --- a/meson.build +++ b/meson.build @@ -3,6 +3,12 @@ project('gst-examples', 'c', version : '1.17.1.1', license : 'LGPL') cc = meson.get_compiler('c') m_dep = cc.find_library('m', required : false) +if cc.get_id() == 'msvc' + add_project_arguments( + cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8 + language : 'c') +endif + glib_dep = dependency('glib-2.0', version: '>= 2.38', fallback: ['glib', 'libglib_dep']) gio_dep = dependency('gio-2.0', @@ -18,6 +24,11 @@ gstplayer_dep = dependency('gstreamer-player-1.0', version: '>= 1.7.1.1', fallback: ['gst-plugins-bad', 'gstplayer_dep']) gsttag_dep = dependency('gstreamer-tag-1.0', fallback: ['gst-plugins-base', 'tag_dep']) +gstwebrtc_dep = dependency('gstreamer-webrtc-1.0', version: '>= 1.14.0', + fallback: ['gst-plugins-bad', 'gstwebrtc_dep']) +gstsdp_dep = dependency('gstreamer-webrtc-1.0', + fallback : ['gst-plugins-bad', 'gstwebrtc_dep']) subdir('playback') subdir('network') +subdir('webrtc') diff --git a/webrtc/README.md b/webrtc/README.md index 59bec73..d9e728f 100644 --- a/webrtc/README.md +++ b/webrtc/README.md @@ -14,39 +14,35 @@ If you don't want to use the binaries provided by GStreamer or on your Linux dis The easiest way to build the webrtc plugin and all the plugins it needs, is to [use Cerbero](https://gstreamer.freedesktop.org/documentation/installing/building-from-source-using-cerbero.html). 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 -Here are the commands for Ubuntu 18.04. - -``` -sudo apt-get install -y gstreamer1.0-tools gstreamer1.0-nice gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-plugins-good libgstreamer1.0-dev git libglib2.0-dev libgstreamer-plugins-bad1.0-dev libsoup2.4-dev libjson-glib-dev -``` - For hacking on the webrtc plugin, you may want to build manually using the git repositories: - - http://cgit.freedesktop.org/gstreamer/gstreamer - - http://cgit.freedesktop.org/gstreamer/gst-plugins-base - - http://cgit.freedesktop.org/gstreamer/gst-plugins-good - - http://cgit.freedesktop.org/gstreamer/gst-plugins-bad - - http://cgit.freedesktop.org/libnice/libnice - -You can build these with either Autotools gst-uninstalled: - -https://arunraghavan.net/2014/07/quick-start-guide-to-gst-uninstalled-1-x/ + - http://gitlab.freedesktop.org/gstreamer/gstreamer + - http://gitlab.freedesktop.org/gstreamer/gst-plugins-base + - http://gitlab.freedesktop.org/gstreamer/gst-plugins-good + - http://gitlab.freedesktop.org/gstreamer/gst-plugins-bad + - http://gitlab.freedesktop.org/libnice/libnice Or with Meson gst-build: -https://cgit.freedesktop.org/gstreamer/gst-build/ +https://gitlab.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) +### Ubuntu 18.04 + +Here are the commands for Ubuntu 18.04. + +``` +sudo apt-get install -y gstreamer1.0-tools gstreamer1.0-nice gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-plugins-good libgstreamer1.0-dev git libglib2.0-dev libgstreamer-plugins-bad1.0-dev libsoup2.4-dev libjson-glib-dev +``` + ## Filing bugs -Please only file bugs about the demos here. Bugs about GStreamer's WebRTC implementation should be filed on the [GStreamer bugzilla](https://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer&component=gst-plugins-bad). +Please only file bugs about the demos here. Bugs about GStreamer's WebRTC implementation should be filed on the [GStreamer gitlab](https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/new). You can also find us on IRC by joining #gstreamer @ FreeNode. @@ -58,6 +54,18 @@ http://blog.nirbheek.in/2018/02/gstreamer-webrtc.html ## Examples +### Building + +Most of the examples that require a build process can be built using the meson build system in the top-level gst-examples directory by using the following commands: + +```console +cd /path/to/gst-examples +meson _builddir +ninja -C _builddir +``` + +Build outputs will be placed in the directory `_builddir`. + ### sendrecv: Send and receive audio and video * Serve the `js/` directory on the root of your website, or open https://webrtc.nirbheek.in @@ -67,12 +75,6 @@ http://blog.nirbheek.in/2018/02/gstreamer-webrtc.html #### Running the C version -* Build the sources in the `gst/` directory on your machine. Use `make` or - -```console -$ 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 @@ -104,13 +106,7 @@ You can optionally specify the server URL too (it defaults to wss://webrtc.nirbh ### multiparty-sendrecv: Multiparty audio conference with N peers -* Build the sources in the `gst/` directory on your machine - -```console -$ 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 `_builddir/multiparty-sendrecv/gst/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). diff --git a/webrtc/check/meson.build b/webrtc/check/meson.build index dfca6eb..a7f6456 100644 --- a/webrtc/check/meson.build +++ b/webrtc/check/meson.build @@ -2,14 +2,17 @@ tests = [ ['basic', 'basic.py'], ] -test_deps = [certs] +if openssl.found() + test_deps = [certs] -foreach elem : tests - test(elem.get(0), - py3, - depends: test_deps, - args : files(elem.get(1)), - env : ['PYTHONPATH=' + join_paths(meson.source_root(), 'sendrecv', 'gst') + ':' + join_paths(meson.source_root(), 'signalling'), - 'TEST_HTML_SOURCE=' + join_paths(meson.source_root(), 'sendrecv', 'js'), - 'TEST_CA_CERT_PATH=' + join_paths(meson.build_root(), 'signalling')]) -endforeach + foreach elem : tests + test(elem.get(0), + py3, + depends: test_deps, + args : files(elem.get(1)), + # XXX: This PYTHONPATH hack is fun + env : ['PYTHONPATH=' + join_paths(meson.source_root(), 'sendrecv', 'gst') + ':' + join_paths(meson.source_root(), 'signalling'), + 'TEST_HTML_SOURCE=' + join_paths(meson.source_root(), 'sendrecv', 'js'), + 'TEST_CA_CERT_PATH=' + join_paths(meson.build_root(), 'signalling')]) + endforeach +endif diff --git a/webrtc/meson.build b/webrtc/meson.build index db32d48..05fa6a4 100644 --- a/webrtc/meson.build +++ b/webrtc/meson.build @@ -1,31 +1,12 @@ -project('gstwebrtc-demo', 'c', - meson_version : '>= 0.48', - license: 'BSD-2-Clause', - default_options : [ 'warning_level=1', - 'buildtype=debug' ]) - -cc = meson.get_compiler('c') - -if cc.get_id() == 'msvc' - add_project_arguments( - cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8 - language : 'c') -endif - gst_req = '>= 1.14.0' -gst_dep = dependency('gstreamer-1.0', version : gst_req, - fallback : ['gstreamer', 'gst_dep']) gstsdp_dep = dependency('gstreamer-sdp-1.0', version : gst_req, fallback : ['gst-plugins-base', 'sdp_dep']) -gstwebrtc_dep = dependency('gstreamer-webrtc-1.0', version : gst_req, - fallback : ['gst-plugins-bad', 'gstwebrtc_dep']) libsoup_dep = dependency('libsoup-2.4', version : '>=2.48', fallback : ['libsoup', 'libsoup_dep']) json_glib_dep = dependency('json-glib-1.0', fallback : ['json-glib', 'json_glib_dep']) - py3_mod = import('python3') py3 = py3_mod.find_python() diff --git a/webrtc/signalling/generate_cert.sh b/webrtc/signalling/generate_cert.sh index 7f4084f..53745d5 100755 --- a/webrtc/signalling/generate_cert.sh +++ b/webrtc/signalling/generate_cert.sh @@ -7,4 +7,10 @@ if [ $# -eq 1 ]; then OUTDIR=$1/ fi -openssl req -x509 -newkey rsa:4096 -keyout ${OUTDIR}key.pem -out ${OUTDIR}cert.pem -days 365 -nodes -subj "/CN=example.com" +output=$(openssl req -x509 -newkey rsa:4096 -keyout ${OUTDIR}key.pem -out ${OUTDIR}cert.pem -days 365 -nodes -subj "/CN=example.com" 2>&1) + +ret=$? +if [ ! $ret -eq 0 ]; then + echo "${output}" 1>&2 + exit $ret +fi diff --git a/webrtc/signalling/meson.build b/webrtc/signalling/meson.build index 43a53bf..76501c1 100644 --- a/webrtc/signalling/meson.build +++ b/webrtc/signalling/meson.build @@ -1,8 +1,12 @@ -generate_certs = find_program('generate_cert.sh') -certs = custom_target( +simple_server = files('simple_server.py') + +openssl = find_program ('openssl', required : false) +if openssl.found() + # TODO: a better cert generation algorithm that doesn't rely on calling openssl + generate_certs = find_program('generate_cert.sh') + certs = custom_target( 'generate-certs', command: [generate_certs, '@OUTDIR@'], output : ['key.pem', 'cert.pem'] -) - -simple_server = files('simple_server.py') + ) +endif