Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

srtp/gnutls aren't included in gst-build, which makes it hard to build the demos with meson #2

Open
nh2 opened this issue Feb 4, 2018 · 13 comments
Assignees

Comments

@nh2
Copy link

nh2 commented Feb 4, 2018

Hey, thanks for your work on this.

Could you make the running instructions a bit more concrete? E.g. how to precisely continue after having built gstreamer with gst-build.

I've built all gstreamer libraries with gst-build, and then this project with the following script:

% cat build.sh
#!/usr/bin/env bash

set -euo pipefail

# Needed deps on Ubuntu 16.04:
#
# libsoup2.4-dev
# libjson-glib-dev

set -x
gcc -O2 webrtc-sendrecv.c $(PKG_CONFIG_PATH=$HOME/src/gstreamer-webrtc/gst-build/build/subprojects/gstreamer/pkgconfig:$HOME/src/gstreamer-webrtc/gst-build/build/subprojects/gst-plugins-base/pkgconfig:$HOME/src/gstreamer-webrtc/gst-build/build/subprojects/gst-plugins-good/pkgconfig:$HOME/src/gstreamer-webrtc/gst-build/build/subprojects/gst-plugins-bad/pkgconfig:$HOME/src/gstreamer-webrtc/gst-build/build/subprojects/gst-plugins-ugly/pkgconfig pkg-config --cflags --libs gstreamer-webrtc-1.0 gstreamer-sdp-1.0 libsoup-2.4 json-glib-1.0) -o webrtc-sendrecv
set +x

And I'm running it via this script:

% cat run.sh
#!/usr/bin/env bash

LD_LIBRARY_PATH=$HOME/src/gstreamer-webrtc/gst-build/build/subprojects/gstreamer/lib:$HOME/src/gstreamer-webrtc/gst-build/build/subprojects/gst-plugins-base/lib:$HOME/src/gstreamer-webrtc/gst-build/build/subprojects/gst-plugins-good/lib:$HOME/src/gstreamer-webrtc/gst-build/build/subprojects/gst-plugins-bad/lib:$HOME/src/gstreamer-webrtc/gst-build/build/subprojects/gst-plugins-ugly/lib:$HOME/src/gstreamer-webrtc/gst-build/build/subprojects/gst-plugins-bad/gst-libs/gst/webrtc ./webrtc-sendrecv $@

E.g. ./run.sh --peer-id=1234.

In my case I get

Connecting to server...
> GET  HTTP/1.1
> Soup-Debug-Timestamp: 1517748888
> Soup-Debug: SoupSession 1 (0x107a130), SoupMessage 1 (0x185c8e0), SoupSocket 1 (0xec5360)
> Host: webrtc.nirbheek.in:8443
> Upgrade: websocket
> Connection: Upgrade
> Sec-WebSocket-Key: Oti+mMzdeB36pTwsz3jf7A==
> Sec-WebSocket-Version: 13
> Accept-Encoding: gzip, deflate
> Connection: Keep-Alive
  
< HTTP/1.1 101 Switching Protocols
< Soup-Debug-Timestamp: 1517748888
< Soup-Debug: SoupMessage 1 (0x185c8e0)
< Server: Python/3.5 websockets/3.3
< Upgrade: WebSocket
< Connection: Upgrade
< Sec-WebSocket-Accept: M0XbTOzizq93wC4ZweM1TyzRWhU=
  
Connected to signalling server
Registering id 5701 with server
Registered with server
Setting up signalling server call with 7883
Failed to parse launch: no element "webrtcbin"
ERROR: failed to start pipeline

(webrtc-sendrecv:10998): GStreamer-CRITICAL **: gst_element_set_state: assertion 'GST_IS_ELEMENT (element)' failed
Pipeline stopped

(webrtc-sendrecv:10998): GStreamer-CRITICAL **: gst_object_unref: assertion 'object != NULL' failed

Is my way to build correct, could it be easier?

Given that I get no element "webrtcbin", assume something is not in a location it's looking for?

Thanks!

@nh2
Copy link
Author

nh2 commented Feb 4, 2018

I got a bit further:

The problem was that libnice-dev wasn't installed on my Ubuntu 16.04, and when building with gst-build with that library missing, it would just NOT build the webrtcbin shared object (./build/subprojects/gst-plugins-bad/ext/webrtc/libgstwebrtc.so would be missing).

Even installing it wasn't enough, I needed a newer version than Ubuntu 16.04 could provide. Some notes from myself:

# Needed for gstreamer to actually build webrtcbin:
#
# libnice-dev
#   This gets us
#     Native dependency nice found: NO found '0.1.13' but need: '>=0.1.14'
#   Handled it with
#     wget https://nice.freedesktop.org/releases/libnice-0.1.14.tar.gz
#     tar xaf libnice-0.1.14.tar.gz
#     cd libnice-0.1.14
#     ./configure --prefix=$HOME/opt/libnice
#     make -j4 install
#   And then in `gst-build`:
#     ~/.local/bin/meson build && PKG_CONFIG_PATH=$HOME/opt/libnice/lib/pkgconfig ninja -C build/ reconfigure
#     ~/.local/bin/meson build && PKG_CONFIG_PATH=$HOME/opt/libnice/lib/pkgconfig ninja -C build/
#   Then finally I can see:
#     % find . -name '*libgstweb*'
#     ./build/subprojects/gst-plugins-bad/ext/webrtc/libgstwebrtc.so
#   which wasn't there before.
#   PATH=$HOME/.local/bin:$PATH ./gst-uninstalled.py zsh
#   Now when running the example I get:
#     no element "vp8enc"
#     no element "opusenc"
#   Looking at meson-log.txt I see e.g. `Dependency opus found: NO`, so those are missing in the gstreamer build.
#   Solved by installing
#     libopus-dev
#     libvpx-dev

However, now I'm hitting this error:

Connected to signalling server
Registering id 3955 with server
Registered with server
Setting up signalling server call with 4978
0:00:00.389309207 16525      0x23d1410 ERROR           GST_PIPELINE grammar.y:726:gst_parse_perform_link: could not link queue1 to sendrecv, sendrecv can't handle caps application/x-rtp, media=(string)video, encoding-name=(string)VP8, payload=(int)96
0:00:00.389888029 16525      0x23d1410 ERROR           GST_PIPELINE grammar.y:726:gst_parse_perform_link: could not link queue3 to sendrecv, sendrecv can't handle caps application/x-rtp, media=(string)audio, encoding-name=(string)OPUS, payload=(int)97
Failed to parse launch: could not link queue1 to sendrecv, sendrecv can't handle caps application/x-rtp, media=(string)video, encoding-name=(string)VP8, payload=(int)96
ERROR: failed to start pipeline

Not sure what to do about this could not link queue1 to sendrecv, sendrecv can't handle caps application/x-rtp, media=(string)video, encoding-name=(string)VP8, payload=(int)96.

@nh2
Copy link
Author

nh2 commented Feb 4, 2018

Running with GST_DEBUG="*:3" ./webrtc-sendrecv --peer-id=4079 for more error output:

Setting up signalling server call with 4079
0:00:00.232857566  6750      0x19e3410 WARN               webrtcbin gstwebrtcbin.c:2989:gst_webrtc_bin_request_new_pad:<sendrecv> error: libnice elements are not available
0:00:00.232954955  6750      0x19e3410 ERROR           GST_PIPELINE grammar.y:726:gst_parse_perform_link: could not link queue1 to sendrecv, sendrecv can't handle caps application/x-rtp, media=(string)video, encoding-name=(string)VP8, payload=(int)96
0:00:00.233546238  6750      0x19e3410 WARN               webrtcbin gstwebrtcbin.c:2989:gst_webrtc_bin_request_new_pad:<sendrecv> error: libnice elements are not available
0:00:00.233595194  6750      0x19e3410 ERROR           GST_PIPELINE grammar.y:726:gst_parse_perform_link: could not link queue3 to sendrecv, sendrecv can't handle caps application/x-rtp, media=(string)audio, encoding-name=(string)OPUS, payload=(int)97
Failed to parse launch: could not link queue1 to sendrecv, sendrecv can't handle caps application/x-rtp, media=(string)video, encoding-name=(string)VP8, payload=(int)96
ERROR: failed to start pipeline

error: libnice elements are not available sounds like a problem. Why is this only a WARN, when the internal bit says error?

Also, how can I fix it?

@nh2
Copy link
Author

nh2 commented Feb 4, 2018

Should there be output of gst-inspect-1.0 | grep nice? Because it is empty.

Despite meson-log.txt

Doing ldd ./build/subprojects/gst-plugins-bad/ext/webrtc/libgstwebrtc.so showed libnice.so.10 => /usr/lib/x86_64-linux-gnu/libnice.so.10 being linked against my systemd one despite me having given /.local/bin/meson build && PKG_CONFIG_PATH=$HOME/opt/libnice/lib/pkgconfig ninja -C build/. But I think here's the problem: I set the env var just for ninja, not for meson.

Removing libnice10 and libnice-dev from my computer revealed in meson that libwebrtc-audio-processing-dev was also missing. Installing it, I got

Native dependency webrtc-audio-processing found: NO found '0.1' but need: '>= 0.2' ; matched: '< 0.4'

So a newer version was needed. I downloaded version 0.3, installed it into a prefix, but got

Meson encountered an error in file subprojects/gst-plugins-bad/ext/webrtc/meson.build, line 16, column 0:
Could not generate cargs for nice:

Debugging further:

% PKG_CONFIG_PATH=$HOME/opt/libnice/lib/pkgconfig:$HOME/opt/webrtc-audio-processing/lib/pkgconfig bash -c 'pkg-config --cflags --libs nice'   
Package gupnp-igd-1.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gupnp-igd-1.0.pc'
to the PKG_CONFIG_PATH environment variable
Package 'gupnp-igd-1.0', required by 'nice', not found

So I installed package libgupnp-igd-1.0-dev.

After that, the pkgconfig worked.

I also had to patch ./subprojects/gst-plugins-bad/ext/webrtcdsp/gstwebrtcdsp.cpp to add C++11 flags to fix a newly appearing compiler error, like:

diff --git a/ext/webrtcdsp/meson.build b/ext/webrtcdsp/meson.build
index 0bc53c5bd..41243cee0 100644
--- a/ext/webrtcdsp/meson.build
+++ b/ext/webrtcdsp/meson.build
@@ -8,7 +8,7 @@ webrtc_dep = dependency('webrtc-audio-processing', version : ['>= 0.2', '< 0.4']
 if webrtc_dep.found()
   gstwebrtcdsp = library('gstwebrtcdsp',
     webrtc_sources,
-    cpp_args : gst_plugins_bad_args,
+    cpp_args : gst_plugins_bad_args + ['-std=c++11'],
     link_args : noseh_link_args,
     include_directories : [configinc],
     dependencies : [gstbase_dep, gstaudio_dep, webrtc_dep],

When finally running webrtc-sendrecv, I got

0:00:00.018166160  9467      0x22a9ec0 WARN      GST_PLUGIN_LOADING gstplugin.c:527:gst_plugin_register_func: plugin "/home/niklas/src/gstreamer-webrtc/gst-build/build/subprojects/gst-devtools/validate/plugins/ssim/libgstvalidatessim.so" failed to initialise
0:00:00.026208311  9467      0x22a9ec0 WARN      GST_PLUGIN_LOADING gstplugin.c:792:_priv_gst_plugin_load_file_for_registry: module_open failed: libwebrtc_audio_processing.so.1: cannot open shared object file: No such file or directory

(gst-plugin-scanner:9467): GStreamer-WARNING **: Failed to load plugin '/home/niklas/src/gstreamer-webrtc/gst-build/build/subprojects/gst-plugins-bad/ext/webrtcdsp/libgstwebrtcdsp.so': libwebrtc_audio_processing.so.1: cannot open shared object file: No such file or directory
0:00:00.258188175  9467      0x22a9ec0 WARN      GST_PLUGIN_LOADING gstplugin.c:527:gst_plugin_register_func: plugin "/home/niklas/src/gstreamer-webrtc/gst-build/build/subprojects/gst-devtools/validate/plugins/ssim/libgstvalidatessim.so" failed to initialise
0:00:00.258957963  9467      0x22a9ec0 WARN      GST_PLUGIN_LOADING gstplugin.c:792:_priv_gst_plugin_load_file_for_registry: module_open failed: libwebrtc_audio_processing.so.1: cannot open shared object file: No such file or directory

(gst-plugin-scanner:9467): GStreamer-WARNING **: Failed to load plugin '/home/niklas/src/gstreamer-webrtc/gst-build/build/subprojects/gst-plugins-bad/ext/webrtcdsp/libgstwebrtcdsp.so': libwebrtc_audio_processing.so.1: cannot open shared object file: No such file or directory
0:00:00.268704361  9467      0x22a9ec0 WARN      GST_PLUGIN_LOADING gstplugin.c:527:gst_plugin_register_func: plugin "/home/niklas/src/gstreamer-webrtc/gst-build/build/subprojects/gst-devtools/validate/plugins/ssim/libgstvalidatessim.so" failed to initialise
0:00:00.269764886  9467      0x22a9ec0 WARN      GST_PLUGIN_LOADING gstplugin.c:792:_priv_gst_plugin_load_file_for_registry: module_open failed: libwebrtc_audio_processing.so.1: cannot open shared object file: No such file or directory

and adding the relevant path to the LD_LIBRARY_PATH fixed that (e.g. LD_LIBRARY_PATH=$HOME/opt/libnice/lib:$HOME/opt/libnice/lib/gstreamer-1.0:$HOME/opt/webrtc-audio-processing/lib:$LD_LIBRARY_PATH bash -c './build-in-uninstalled.sh && GST_DEBUG="*:3" ./webrtc-sendrecv --peer-id=5817').

Nevertheless, I still got error: libnice elements are not available.

Uninstalling libnice as mentioned above (with aptitude to get an automatic suggestion what other packages to remove as a result, which I'll reinstall later) brought me forward with that, but not without ./gst-uninstalled.py failing with

OSError: [Errno 7] Argument list too long

Looks like this approach doesn't work well for passing the 1629 (!) paths in GST_PLUGIN_PATH ... they exceed my getconf ARG_MAX 2 MB limit on Linux.

Doing a quick split and sort on these, it also shows how each path is redundantly passed in 8 times :-/

And of course there's O(n²) quadratic appends going on in prepend_env_var() ... :(

I hacked around the 8x duplication of paths using

    env['GST_PLUGIN_PATH'] = os.pathsep.join(list(set(env['GST_PLUGIN_PATH'].split(os.pathsep))))

A bit later I figured that the important bit was to add GST_PLUGIN_PATH=$HOME/opt/libnice/lib/gstreamer-1.0:$GST_PLUGIN_PATH so that the nicesrc gstreamer plugin provided by libnice could be found.

I confirmed this was the reason with:

% GST_PLUGIN_PATH=$HOME/opt/libnice/lib/gstreamer-1.0 gst-inspect-1.0 | grep nice
nice:  nicesrc: ICE source
nice:  nicesink: ICE sink

And finally managed to launch using:

LD_LIBRARY_PATH=$HOME/opt/libnice/lib:$HOME/opt/libnice/lib/gstreamer-1.0:$LD_LIBRARY_PATH GST_PLUGIN_PATH=$HOME/opt/libnice/lib/gstreamer-1.0:$GST_PLUGIN_PATH bash -c './build-in-uninstalled.sh && GST_DEBUG="*:3" ./webrtc-sendrecv --peer-id=8573'

And I can see myself in the stream and the white ball circling on black background.

Quite an effort to get this to work on Ubuntu 16.04.

@nirbheek
Copy link
Contributor

nirbheek commented Feb 5, 2018

Apologies for how difficult it was to get things working, and thanks for your patience!

We're working improving the meson build setup in gst-build to be more self-contained so this sort of thing isn't a problem. It was just merged, so thanks for testing and helping us find build issues. I'll work on fixing the problems you've pointed out.

We're hoping that we can make things work better before the 1.13.1 pre-release, and things will definitely be easier once 1.14 is released and binaries are available (+ it reaches distros).

@landersson
Copy link

Big thanks to @nh2 for your post. I just got the demo working, but would probably have given up long ago if I didn't have these notes to lead me in the right direction. Btw, one additional (Ubuntu 16.04) package I had to install to make it work was 'libsrtp-dev'.

@r4zzz4k
Copy link

r4zzz4k commented Mar 5, 2018

@nh2, huge thanks for sharing your adventure journals!
My 5 cents. After gst-build pass with meson 0.45.0 I got following error when building example:

In file included from webrtc-sendrecv.c:9:0:
/opt/gstreamer/gst-build/subprojects/gstreamer/pkgconfig/../gst/gst.h:31:30: fatal error: gst/gstenumtypes.h: No such file or directory

Downgrading to 0.44.1 helped -- got an error on C++11 stuff mentioned above, further path was the same.

Now I'm stuck with the following: running demo app (via run.sh) throws errors like this one:

gstplugin.c:748:_priv_gst_plugin_load_file_for_registry: module_open failed: /opt/gstreamer/gst-build/build/subprojects/gst-plugins-bad/ext/webrtc/libgstwebrtc.so: undefined symbol: gst_element_foreach_pad

I'm not sure why as I believe it should be reachable:

> ldd ./webrtc-sendrecv
...
	libgstwebrtc-1.0.so.0 => /opt/gstreamer/gst-build/build/subprojects/gst-plugins-bad/gst-libs/gst/webrtc/libgstwebrtc-1.0.so.0 (0x00007f0c000cd000)
	libgstreamer-1.0.so.0 => /opt/gstreamer/gst-build/build/subprojects/gstreamer/gst/libgstreamer-1.0.so.0 (0x00007f0bffd91000)
...
> nm /opt/gstreamer/gst-build/build/subprojects/gstreamer/gst/libgstreamer-1.0.so.0 | grep gst_element_foreach_pad
0000000000063a80 T gst_element_foreach_pad

I will probably continue investigation tomorrow. Quite excited to have WebRTC support in GStreamer, and hoping it would work for me at some point (and for everyone after official release of course).

@grokker001
Copy link

grokker001 commented Mar 9, 2018

Thanks to @nh2 ! I also got mine working. I built it with the gst-uninstalled tool. Before built everything, I downloaded libnice-0.1.14.tar.gz just like you did, and built it using "./configure --prefix=$HOME/gst/master/prefix" so that the gst-uninstalled tool can include this library to build other plugins.
After the build is completed, when you enter the gst-uninstalled environment, just add the "$HOME/gst/master/prefix/..." into your "GST_PLUGIN_PATH" like this:
export GST_PLUGIN_PATH=$GST_PLUGIN_PATH:$HOME/gst/master/prefix/lib/gstreamer-1.0

Then you should be able to run the ./webrtc-sendrecv --peer-id=PEER_ID directly.

@maxmcd
Copy link
Contributor

maxmcd commented Mar 17, 2018

For anyone (like me) who hadn't considered cerbero. I found it considerably easier to build.

Here's a working dockerfile: https://github.com/maxmcd/gstreamer-docker/blob/master/1.14/cerbero/Dockerfile

On docker hub as: maxmcd/gstreamer:1.14-cerbero

@nirbheek nirbheek changed the title More detailed running instructions libnice isn't included in gst-build, which makes it hard to build the demos with meson Mar 31, 2018
@nirbheek
Copy link
Contributor

README.md now recommends using the binary releases and Cerbero, so what's left now is fixing the meson build.

@nirbheek
Copy link
Contributor

@nirbheek nirbheek self-assigned this Mar 31, 2018
@xiaoyongaz
Copy link

I'm able to build and run the sample using gstreamer 1.14 release on mac. However when I build it on Mac OS high sierra both git-build and cerbero doesn't work. Cerbero almost works but cannot build libgstsoup because of some issue in intltool script where regex syntax error of literal { derailed the checking. git-build keeps complaining about bison even after installed using brew.
I also have difficulties building on raspberry pi 3 where libnice only has 0.1.13 release and I have to build it myself and I got tons of error of cast-align in gtype.h as show in this link https://phabricator.freedesktop.org/T7742
Have anyone successfully build gstreamer on either Mac or Raspberry pi?

thanks
Joe

@maxmcd maxmcd mentioned this issue May 31, 2018
@nirbheek
Copy link
Contributor

nirbheek commented Jun 7, 2018

@xiaoyongaz if you have issues with cerbero or gst-build, please file them upstream at https://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer so that they can be fixed.

@nirbheek nirbheek changed the title libnice isn't included in gst-build, which makes it hard to build the demos with meson srtp/gnutls aren't included in gst-build, which makes it hard to build the demos with meson Jun 7, 2018
@razvanphp
Copy link

thanks @nh2 maybe for some folks like me this could not link error is easily solved by:

sudo apt install gstreamer1.0-nice

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants