mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 07:58:51 +00:00
srt: Refactor gst_srt_*_sink_send_buffer, extract send
https://bugzilla.gnome.org/show_bug.cgi?id=793503
This commit is contained in:
parent
7463a93620
commit
8a5dab1c06
2 changed files with 44 additions and 18 deletions
|
@ -167,6 +167,22 @@ gst_srt_client_sink_start (GstBaseSink * sink)
|
||||||
return (priv->sock != SRT_INVALID_SOCK);
|
return (priv->sock != SRT_INVALID_SOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
send_buffer_internal (GstSRTBaseSink * sink,
|
||||||
|
const GstMapInfo * mapinfo, gpointer user_data)
|
||||||
|
{
|
||||||
|
SRTSOCKET sock = GPOINTER_TO_INT (user_data);
|
||||||
|
|
||||||
|
if (srt_sendmsg2 (sock, (char *) mapinfo->data, mapinfo->size,
|
||||||
|
0) == SRT_ERROR) {
|
||||||
|
GST_ELEMENT_ERROR (sink, RESOURCE, WRITE, NULL,
|
||||||
|
("%s", srt_getlasterror_str ()));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_srt_client_sink_send_buffer (GstSRTBaseSink * sink,
|
gst_srt_client_sink_send_buffer (GstSRTBaseSink * sink,
|
||||||
const GstMapInfo * mapinfo)
|
const GstMapInfo * mapinfo)
|
||||||
|
@ -174,14 +190,7 @@ gst_srt_client_sink_send_buffer (GstSRTBaseSink * sink,
|
||||||
GstSRTClientSink *self = GST_SRT_CLIENT_SINK (sink);
|
GstSRTClientSink *self = GST_SRT_CLIENT_SINK (sink);
|
||||||
GstSRTClientSinkPrivate *priv = GST_SRT_CLIENT_SINK_GET_PRIVATE (self);
|
GstSRTClientSinkPrivate *priv = GST_SRT_CLIENT_SINK_GET_PRIVATE (self);
|
||||||
|
|
||||||
if (srt_sendmsg2 (priv->sock, (char *) mapinfo->data, mapinfo->size,
|
return send_buffer_internal (sink, mapinfo, GINT_TO_POINTER (priv->sock));
|
||||||
0) == SRT_ERROR) {
|
|
||||||
GST_ELEMENT_ERROR (self, RESOURCE, WRITE, NULL,
|
|
||||||
("%s", srt_getlasterror_str ()));
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
|
@ -390,6 +390,21 @@ failed:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
send_buffer_internal (GstSRTBaseSink * sink,
|
||||||
|
const GstMapInfo * mapinfo, gpointer user_data)
|
||||||
|
{
|
||||||
|
SRTClient *client = user_data;
|
||||||
|
|
||||||
|
if (srt_sendmsg2 (client->sock, (char *) mapinfo->data, mapinfo->size,
|
||||||
|
0) == SRT_ERROR) {
|
||||||
|
GST_WARNING_OBJECT (sink, "%s", srt_getlasterror_str ());
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_srt_server_sink_send_buffer (GstSRTBaseSink * sink,
|
gst_srt_server_sink_send_buffer (GstSRTBaseSink * sink,
|
||||||
const GstMapInfo * mapinfo)
|
const GstMapInfo * mapinfo)
|
||||||
|
@ -403,17 +418,19 @@ gst_srt_server_sink_send_buffer (GstSRTBaseSink * sink,
|
||||||
SRTClient *client = clients->data;
|
SRTClient *client = clients->data;
|
||||||
clients = clients->next;
|
clients = clients->next;
|
||||||
|
|
||||||
if (srt_sendmsg2 (client->sock, (char *) mapinfo->data, mapinfo->size,
|
|
||||||
0) == SRT_ERROR) {
|
|
||||||
GST_WARNING_OBJECT (self, "%s", srt_getlasterror_str ());
|
|
||||||
|
|
||||||
priv->clients = g_list_remove (priv->clients, client);
|
if (!send_buffer_internal (sink, mapinfo, client))
|
||||||
GST_OBJECT_UNLOCK (sink);
|
goto err;
|
||||||
g_signal_emit (self, signals[SIG_CLIENT_REMOVED], 0, client->sock,
|
|
||||||
client->sockaddr);
|
continue;
|
||||||
srt_client_free (client);
|
|
||||||
GST_OBJECT_LOCK (sink);
|
err:
|
||||||
}
|
priv->clients = g_list_remove (priv->clients, client);
|
||||||
|
GST_OBJECT_UNLOCK (sink);
|
||||||
|
g_signal_emit (self, signals[SIG_CLIENT_REMOVED], 0, client->sock,
|
||||||
|
client->sockaddr);
|
||||||
|
srt_client_free (client);
|
||||||
|
GST_OBJECT_LOCK (sink);
|
||||||
}
|
}
|
||||||
GST_OBJECT_UNLOCK (sink);
|
GST_OBJECT_UNLOCK (sink);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue