mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-22 05:56:31 +00:00
stream: release lock while pushing out packets
Keep a cache of the transports and use this to iterate the transport while pushing packets. This allows us to release the lock early. See https://bugzilla.gnome.org/show_bug.cgi?id=725898
This commit is contained in:
parent
faf0b31cbb
commit
50ca10e751
1 changed files with 29 additions and 4 deletions
|
@ -119,6 +119,8 @@ struct _GstRTSPStreamPrivate
|
||||||
/* transports we stream to */
|
/* transports we stream to */
|
||||||
guint n_active;
|
guint n_active;
|
||||||
GList *transports;
|
GList *transports;
|
||||||
|
gboolean tr_changed;
|
||||||
|
GList *tr_cache;
|
||||||
|
|
||||||
gint dscp_qos;
|
gint dscp_qos;
|
||||||
|
|
||||||
|
@ -1442,6 +1444,14 @@ on_timeout (GObject * session, GObject * source, GstRTSPStream * stream)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clear_tr_cache (GstRTSPStreamPrivate * priv)
|
||||||
|
{
|
||||||
|
g_list_foreach (priv->tr_cache, (GFunc) g_object_unref, NULL);
|
||||||
|
g_list_free (priv->tr_cache);
|
||||||
|
priv->tr_cache = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
handle_new_sample (GstAppSink * sink, gpointer user_data)
|
handle_new_sample (GstAppSink * sink, gpointer user_data)
|
||||||
{
|
{
|
||||||
|
@ -1450,6 +1460,7 @@ handle_new_sample (GstAppSink * sink, gpointer user_data)
|
||||||
GstSample *sample;
|
GstSample *sample;
|
||||||
GstBuffer *buffer;
|
GstBuffer *buffer;
|
||||||
GstRTSPStream *stream;
|
GstRTSPStream *stream;
|
||||||
|
gboolean is_rtp;
|
||||||
|
|
||||||
sample = gst_app_sink_pull_sample (sink);
|
sample = gst_app_sink_pull_sample (sink);
|
||||||
if (!sample)
|
if (!sample)
|
||||||
|
@ -1459,18 +1470,28 @@ handle_new_sample (GstAppSink * sink, gpointer user_data)
|
||||||
priv = stream->priv;
|
priv = stream->priv;
|
||||||
buffer = gst_sample_get_buffer (sample);
|
buffer = gst_sample_get_buffer (sample);
|
||||||
|
|
||||||
|
is_rtp = GST_ELEMENT_CAST (sink) == priv->appsink[0];
|
||||||
|
|
||||||
g_mutex_lock (&priv->lock);
|
g_mutex_lock (&priv->lock);
|
||||||
|
if (priv->tr_changed) {
|
||||||
|
clear_tr_cache (priv);
|
||||||
for (walk = priv->transports; walk; walk = g_list_next (walk)) {
|
for (walk = priv->transports; walk; walk = g_list_next (walk)) {
|
||||||
GstRTSPStreamTransport *tr = (GstRTSPStreamTransport *) walk->data;
|
GstRTSPStreamTransport *tr = (GstRTSPStreamTransport *) walk->data;
|
||||||
|
priv->tr_cache = g_list_prepend (priv->tr_cache, g_object_ref (tr));
|
||||||
|
}
|
||||||
|
priv->tr_changed = FALSE;
|
||||||
|
}
|
||||||
|
g_mutex_unlock (&priv->lock);
|
||||||
|
|
||||||
if (GST_ELEMENT_CAST (sink) == priv->appsink[0]) {
|
for (walk = priv->tr_cache; walk; walk = g_list_next (walk)) {
|
||||||
|
GstRTSPStreamTransport *tr = (GstRTSPStreamTransport *) walk->data;
|
||||||
|
|
||||||
|
if (is_rtp) {
|
||||||
gst_rtsp_stream_transport_send_rtp (tr, buffer);
|
gst_rtsp_stream_transport_send_rtp (tr, buffer);
|
||||||
} else {
|
} else {
|
||||||
gst_rtsp_stream_transport_send_rtcp (tr, buffer);
|
gst_rtsp_stream_transport_send_rtcp (tr, buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_mutex_unlock (&priv->lock);
|
|
||||||
|
|
||||||
gst_sample_unref (sample);
|
gst_sample_unref (sample);
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
@ -1777,6 +1798,8 @@ gst_rtsp_stream_leave_bin (GstRTSPStream * stream, GstBin * bin,
|
||||||
/* all transports must be removed by now */
|
/* all transports must be removed by now */
|
||||||
g_return_val_if_fail (priv->transports == NULL, FALSE);
|
g_return_val_if_fail (priv->transports == NULL, FALSE);
|
||||||
|
|
||||||
|
clear_tr_cache (priv);
|
||||||
|
|
||||||
GST_INFO ("stream %p leaving bin", stream);
|
GST_INFO ("stream %p leaving bin", stream);
|
||||||
|
|
||||||
gst_pad_unlink (priv->srcpad, priv->send_rtp_sink);
|
gst_pad_unlink (priv->srcpad, priv->send_rtp_sink);
|
||||||
|
@ -2090,6 +2113,7 @@ update_transport (GstRTSPStream * stream, GstRTSPStreamTransport * trans,
|
||||||
g_signal_emit_by_name (priv->udpsink[1], "remove", dest, max, NULL);
|
g_signal_emit_by_name (priv->udpsink[1], "remove", dest, max, NULL);
|
||||||
priv->transports = g_list_remove (priv->transports, trans);
|
priv->transports = g_list_remove (priv->transports, trans);
|
||||||
}
|
}
|
||||||
|
priv->tr_changed = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GST_RTSP_LOWER_TRANS_TCP:
|
case GST_RTSP_LOWER_TRANS_TCP:
|
||||||
|
@ -2100,6 +2124,7 @@ update_transport (GstRTSPStream * stream, GstRTSPStreamTransport * trans,
|
||||||
GST_INFO ("removing TCP %s", tr->destination);
|
GST_INFO ("removing TCP %s", tr->destination);
|
||||||
priv->transports = g_list_remove (priv->transports, trans);
|
priv->transports = g_list_remove (priv->transports, trans);
|
||||||
}
|
}
|
||||||
|
priv->tr_changed = TRUE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goto unknown_transport;
|
goto unknown_transport;
|
||||||
|
|
Loading…
Reference in a new issue