Skip to content

rtsp-stream: prevent appsink blocking for shared media

Nikita Ovchinnikov requested to merge slowmathematician/gstreamer:main into main

Сall send_tcp_message() for RTP and RTCP in one iteration of send_func() loop.

When shared media is enabled and two or more transports are used (UDP, TCP), queue elements are added before sink elements (udpsink, appsink). If RTCP is enabled, handle_new_sample() will be called concurrently for RTP and RTCP from different threads because of the presence of queue elements. Here, a race condition occurs because after g_cond_signal(&priv->send_cond) call in handle_new_sample(), another thread may lock the send_lock mutex in handle_new_sample() before returning from g_cond_wait(&priv->send_cond, &priv->send_lock) in thread's send_func().

In case above, gst_app_sink_pull_sample() will be called only for RTCP. send_func() prioritizes RTCP over RTP so appsink for RTP will remain blocked and won't call handle_new_sample() for RTP because drop=false in appsink.

Fixes gst-rtsp-server#122

Merge request reports