I wanted to change the volume in the first tutorial.
So I added the following lines.
But nil is thrown back to me.
pipeline = gst_parse_launch("playbin uri=https://gstreamer.freedesktop.org/data/media/sintel_trailer-480p.webm", NULL);
// new lines
GstElement *volume;
volume = gst_bin_get_by_name (GST_BIN (pipeline), "volume0");
if (volume == NULL) {
g_print ("Please give a pipeline with a 'volume' element in it\n");
return 1;
}
In the example you linked, there is an explicit volume element in the pipeline, and it looks that up using gst_bin_get_by_name() and sets the volume on it.
While playbin provides a mechanism to set the volume of the audio stream, it does not guarantee that it will do so using a volume element. For example, on Linux, you might use pulsesink by default, and that allows you to set the volume on the stream using the PulseAudio API instead.
You want to use the GstStreamVolume interface that is provided by playbin, which will make it use whatever underlying mechanism makes sense for your pipeline.
// gcc main.c -o main `pkg-config --cflags --libs gstreamer-1.0`
#include <gst/gst.h>
#include <gst/audio/streamvolume.h>
int main () {
GstElement * pipeline = gst_pipeline_new("audio-player");
gst_bin_get_by_interface(GST_BIN( pipeline), GST_TYPE_STREAM_VOLUME);
}
With this code it at least compiles.
But the linker is still complaining.
gcc main.c -o main `pkg-config --cflags --libs gstreamer-1.0 gstreamer-1.0`
/usr/bin/ld: /tmp/ccN7xvZQ.o: in function `main':
main.c:(.text+0x21): undefined reference to `gst_stream_volume_get_type'
collect2: error: ld returned 1 exit status
I also have the appropriate lib on the PC
ls /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstvolume.so
/usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstvolume.so
So I tried the following, with a -lgstvolume, but it doesn’t find it.
gcc main.c -o main `pkg-config --cflags --libs gstreamer-1.0` -lgstvolume
/usr/bin/ld: -lgstvolume cannot be found: File or directory not found
collect2: error: ld returned 1 exit status