mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-02 21:48:55 +00:00
rtspclientsink: Use write_messages() API to send buffer lists in one go
And to write messages with multiple memories also via writev().
This commit is contained in:
parent
b578628dc1
commit
c4653ef38b
1 changed files with 49 additions and 27 deletions
|
@ -1906,6 +1906,26 @@ gst_rtsp_client_sink_connection_send (GstRTSPClientSink * sink,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstRTSPResult
|
||||||
|
gst_rtsp_client_sink_connection_send_messages (GstRTSPClientSink * sink,
|
||||||
|
GstRTSPConnInfo * conninfo, GstRTSPMessage * messages, guint n_messages,
|
||||||
|
GTimeVal * timeout)
|
||||||
|
{
|
||||||
|
GstRTSPResult ret;
|
||||||
|
|
||||||
|
if (conninfo->connection) {
|
||||||
|
g_mutex_lock (&conninfo->send_lock);
|
||||||
|
ret =
|
||||||
|
gst_rtsp_connection_send_messages (conninfo->connection, messages,
|
||||||
|
n_messages, timeout);
|
||||||
|
g_mutex_unlock (&conninfo->send_lock);
|
||||||
|
} else {
|
||||||
|
ret = GST_RTSP_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static GstRTSPResult
|
static GstRTSPResult
|
||||||
gst_rtsp_client_sink_connection_receive (GstRTSPClientSink * sink,
|
gst_rtsp_client_sink_connection_receive (GstRTSPClientSink * sink,
|
||||||
GstRTSPConnInfo * conninfo, GstRTSPMessage * message, GTimeVal * timeout)
|
GstRTSPConnInfo * conninfo, GstRTSPMessage * message, GTimeVal * timeout)
|
||||||
|
@ -2792,25 +2812,27 @@ no_user_pass:
|
||||||
|
|
||||||
static GstRTSPResult
|
static GstRTSPResult
|
||||||
gst_rtsp_client_sink_try_send (GstRTSPClientSink * sink,
|
gst_rtsp_client_sink_try_send (GstRTSPClientSink * sink,
|
||||||
GstRTSPConnInfo * conninfo, GstRTSPMessage * request,
|
GstRTSPConnInfo * conninfo, GstRTSPMessage * requests,
|
||||||
GstRTSPMessage * response, GstRTSPStatusCode * code)
|
guint n_requests, GstRTSPMessage * response, GstRTSPStatusCode * code)
|
||||||
{
|
{
|
||||||
GstRTSPResult res;
|
GstRTSPResult res;
|
||||||
GstRTSPStatusCode thecode;
|
GstRTSPStatusCode thecode;
|
||||||
gchar *content_base = NULL;
|
gchar *content_base = NULL;
|
||||||
gint try = 0;
|
gint try = 0;
|
||||||
|
|
||||||
|
g_assert (n_requests == 1 || response == NULL);
|
||||||
|
|
||||||
again:
|
again:
|
||||||
GST_DEBUG_OBJECT (sink, "sending message");
|
GST_DEBUG_OBJECT (sink, "sending message");
|
||||||
|
|
||||||
if (sink->debug)
|
if (sink->debug && n_requests == 1)
|
||||||
gst_rtsp_message_dump (request);
|
gst_rtsp_message_dump (&requests[0]);
|
||||||
|
|
||||||
g_mutex_lock (&sink->send_lock);
|
g_mutex_lock (&sink->send_lock);
|
||||||
|
|
||||||
res =
|
res =
|
||||||
gst_rtsp_client_sink_connection_send (sink, conninfo, request,
|
gst_rtsp_client_sink_connection_send_messages (sink, conninfo, requests,
|
||||||
sink->ptcp_timeout);
|
n_requests, sink->ptcp_timeout);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
g_mutex_unlock (&sink->send_lock);
|
g_mutex_unlock (&sink->send_lock);
|
||||||
goto send_error;
|
goto send_error;
|
||||||
|
@ -2998,7 +3020,7 @@ gst_rtsp_client_sink_send (GstRTSPClientSink * sink, GstRTSPConnInfo * conninfo,
|
||||||
method = request->type_data.request.method;
|
method = request->type_data.request.method;
|
||||||
|
|
||||||
if ((res =
|
if ((res =
|
||||||
gst_rtsp_client_sink_try_send (sink, conninfo, request, response,
|
gst_rtsp_client_sink_try_send (sink, conninfo, request, 1, response,
|
||||||
&int_code)) < 0)
|
&int_code)) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
@ -3826,25 +3848,15 @@ do_send_data (GstBuffer * buffer, guint8 channel,
|
||||||
GstRTSPClientSink *sink = context->parent;
|
GstRTSPClientSink *sink = context->parent;
|
||||||
GstRTSPMessage message = { 0 };
|
GstRTSPMessage message = { 0 };
|
||||||
GstRTSPResult res = GST_RTSP_OK;
|
GstRTSPResult res = GST_RTSP_OK;
|
||||||
GstMapInfo map_info;
|
|
||||||
guint8 *data;
|
|
||||||
guint usize;
|
|
||||||
|
|
||||||
gst_rtsp_message_init_data (&message, channel);
|
gst_rtsp_message_init_data (&message, channel);
|
||||||
|
|
||||||
/* FIXME, need some sort of iovec RTSPMessage here */
|
gst_rtsp_message_set_body_buffer (&message, buffer);
|
||||||
if (!gst_buffer_map (buffer, &map_info, GST_MAP_READ))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
gst_rtsp_message_take_body (&message, map_info.data, map_info.size);
|
|
||||||
|
|
||||||
res =
|
res =
|
||||||
gst_rtsp_client_sink_try_send (sink, &sink->conninfo, &message,
|
gst_rtsp_client_sink_try_send (sink, &sink->conninfo, &message, 1,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
|
||||||
gst_rtsp_message_steal_body (&message, &data, &usize);
|
|
||||||
gst_buffer_unmap (buffer, &map_info);
|
|
||||||
|
|
||||||
gst_rtsp_message_unset (&message);
|
gst_rtsp_message_unset (&message);
|
||||||
|
|
||||||
gst_rtsp_stream_transport_message_sent (context->stream_transport);
|
gst_rtsp_stream_transport_message_sent (context->stream_transport);
|
||||||
|
@ -3856,21 +3868,31 @@ static gboolean
|
||||||
do_send_data_list (GstBufferList * buffer_list, guint8 channel,
|
do_send_data_list (GstBufferList * buffer_list, guint8 channel,
|
||||||
GstRTSPStreamContext * context)
|
GstRTSPStreamContext * context)
|
||||||
{
|
{
|
||||||
gboolean ret = TRUE;
|
GstRTSPClientSink *sink = context->parent;
|
||||||
|
GstRTSPResult res = GST_RTSP_OK;
|
||||||
guint i, n = gst_buffer_list_length (buffer_list);
|
guint i, n = gst_buffer_list_length (buffer_list);
|
||||||
|
GstRTSPMessage *messages = g_newa (GstRTSPMessage, n);
|
||||||
|
|
||||||
|
memset (messages, 0, n * sizeof (GstRTSPMessage));
|
||||||
|
|
||||||
/* TODO: Needs support for a) queueing up multiple messages on the
|
|
||||||
* GstRTSPWatch in do_send_data() above and b) for one message having a body
|
|
||||||
* consisting of multiple parts here */
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
GstBuffer *buffer = gst_buffer_list_get (buffer_list, i);
|
GstBuffer *buffer = gst_buffer_list_get (buffer_list, i);
|
||||||
|
|
||||||
ret = do_send_data (buffer, channel, context);
|
gst_rtsp_message_init_data (&messages[i], channel);
|
||||||
if (!ret)
|
|
||||||
break;
|
gst_rtsp_message_set_body_buffer (&messages[i], buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
res =
|
||||||
|
gst_rtsp_client_sink_try_send (sink, &sink->conninfo, messages, n,
|
||||||
|
NULL, NULL);
|
||||||
|
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
gst_rtsp_message_unset (&messages[i]);
|
||||||
|
gst_rtsp_stream_transport_message_sent (context->stream_transport);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res == GST_RTSP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstRTSPResult
|
static GstRTSPResult
|
||||||
|
|
Loading…
Reference in a new issue