rtspclientsink hangs on gst_element_set_state() when trying to stop an empty pipeline
Nothing was sent to udpsrc , RTSP server is alive, I am trying to close pipeline and hang on pipeline state change to GST_STATE_NULL. When data sent to 127.0.0.1:5555 - pipeline was closed without problem.
Platform: Ubuntu
Example Compilation:
gcc -Wall main.c -o main $(pkg-config --cflags --libs gstreamer-1.0)
My current pipeline is as following:
udpsrc address=127.0.0.1 port=5555 name=udpsrcVideo caps="application/x-rtp,media=video,encoding-name=VP8" ! rtpjitterbuffer name=rtpjitterbufferVideo ! rtpvp8depay name=rtpvp8depayVideo ! queue name=queueVideo ! rtspclientsink name=rtspClientSinkVideo protocols=GST_RTSP_LOWER_TRANS_TCP tcp-timeout=3000000 location="rtsp://127.0.0.1:1935/videoapp/videostream" latency=0
Backtrace output of the main thread:
[New LWP 27726]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
__lll_lock_wait () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135
135 ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: No such file or directory.
(gdb) bt
#0 0x00007fcedc5c81fd in __lll_lock_wait () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135
#1 0x00007fcedc5c10f4 in __GI___pthread_mutex_lock (mutex=0x5555fcc24f80) at ../nptl/pthread_mutex_lock.c:115
#2 0x00007fced9286ac8 in () at /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstrtspclientsink.so
#3 0x00007fceddb3dd5e in gst_element_change_state () at /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
#4 0x00007fceddb3e499 in () at /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
#5 0x00007fceddb1ba02 in () at /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
#6 0x00007fceddb63ed2 in () at /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
#7 0x00007fceddb3dd5e in gst_element_change_state () at /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
#8 0x00007fceddb3e045 in gst_element_change_state () at /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
#9 0x00007fceddb3ddb6 in gst_element_change_state () at /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
#10 0x00007fceddb3e499 in () at /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
#11 0x00005555fc1b7b59 in main ()
Code Example:
#include <stdio.h>
#include <gst/gst.h>
#include <glib.h>
#define MAX_STRING_LEN 2048
int main (int argc, char *argv[])
{
GError *error = NULL;
/* Initialisation */
gst_init (&argc, &argv);
char launchString[MAX_STRING_LEN];
snprintf(launchString, sizeof(launchString),
"udpsrc address=127.0.0.1 port=5555 name=udpsrcVideo "
" caps=\"application/x-rtp,media=video,encoding-name=VP8\" !"
" rtpjitterbuffer name=rtpjitterbufferVideo ! rtpvp8depay name=rtpvp8depayVideo ! queue name=queueVideo ! "
" rtspclientsink name=rtspClientSinkVideo protocols=GST_RTSP_LOWER_TRANS_TCP tcp-timeout=3000000 "
" location=\"rtsp://127.0.0.1:1935/videoapp/videostream\" latency=0");
g_print ("pipeline: %s\n", launchString);
GstElement *pipeline = gst_parse_launch(launchString, &error);
g_clear_error(&error);
/* Set the pipeline to "playing" state*/
g_print ("Now set pipeline to GST_STATE_PLAYING\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_print ("Running...\n");
g_usleep(6000000); //6s
/* Out of the main loop, clean up nicely */
g_print ("Returned from sleep, try set pipeline to state: GST_STATE_NULL\n");
gst_element_set_state (pipeline, GST_STATE_NULL);
g_print ("Deleting VIDEO pipeline\n");
gst_object_unref (GST_OBJECT (pipeline));
g_clear_error(&error);
return 0;
}
Edited by Pavel D.