mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
webrtc: Add properties to change the socket buffer sizes to ice object
libnice doesn't touch the kernel buffer sizes. When dealing with RTP data, it's generally advisable to increase them to avoid dropping packets locally. This is especially important when running multiple higher bitrate streams at the same time. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1366>
This commit is contained in:
parent
5f9897745b
commit
da2bd55177
3 changed files with 105 additions and 2 deletions
|
@ -192,6 +192,12 @@ gst_webrtc_ice_stream_gather_candidates (GstWebRTCICEStream * stream)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
for (l = stream->priv->transports; l; l = l->next) {
|
||||
GstWebRTCNiceTransport *trans = l->data;
|
||||
|
||||
gst_webrtc_nice_transport_update_buffer_size (trans);
|
||||
}
|
||||
|
||||
g_object_unref (agent);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include "nicetransport.h"
|
||||
#include "icestream.h"
|
||||
|
||||
#include <gio/gnetworking.h>
|
||||
|
||||
#define GST_CAT_DEFAULT gst_webrtc_nice_transport_debug
|
||||
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
||||
|
||||
|
@ -37,6 +39,8 @@ enum
|
|||
{
|
||||
PROP_0,
|
||||
PROP_STREAM,
|
||||
PROP_SEND_BUFFER_SIZE,
|
||||
PROP_RECEIVE_BUFFER_SIZE
|
||||
};
|
||||
|
||||
//static guint gst_webrtc_nice_transport_signals[LAST_SIGNAL] = { 0 };
|
||||
|
@ -44,6 +48,9 @@ enum
|
|||
struct _GstWebRTCNiceTransportPrivate
|
||||
{
|
||||
gboolean running;
|
||||
|
||||
gint send_buffer_size;
|
||||
gint receive_buffer_size;
|
||||
};
|
||||
|
||||
#define gst_webrtc_nice_transport_parent_class parent_class
|
||||
|
@ -115,6 +122,14 @@ gst_webrtc_nice_transport_set_property (GObject * object, guint prop_id,
|
|||
gst_object_unref (nice->stream);
|
||||
nice->stream = g_value_dup_object (value);
|
||||
break;
|
||||
case PROP_SEND_BUFFER_SIZE:
|
||||
nice->priv->send_buffer_size = g_value_get_int (value);
|
||||
gst_webrtc_nice_transport_update_buffer_size (nice);
|
||||
break;
|
||||
case PROP_RECEIVE_BUFFER_SIZE:
|
||||
nice->priv->receive_buffer_size = g_value_get_int (value);
|
||||
gst_webrtc_nice_transport_update_buffer_size (nice);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -131,6 +146,12 @@ gst_webrtc_nice_transport_get_property (GObject * object, guint prop_id,
|
|||
case PROP_STREAM:
|
||||
g_value_set_object (value, nice->stream);
|
||||
break;
|
||||
case PROP_SEND_BUFFER_SIZE:
|
||||
g_value_set_int (value, nice->priv->send_buffer_size);
|
||||
break;
|
||||
case PROP_RECEIVE_BUFFER_SIZE:
|
||||
g_value_set_int (value, nice->priv->receive_buffer_size);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -147,6 +168,51 @@ gst_webrtc_nice_transport_finalize (GObject * object)
|
|||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
void
|
||||
gst_webrtc_nice_transport_update_buffer_size (GstWebRTCNiceTransport * nice)
|
||||
{
|
||||
GstWebRTCICETransport *ice = GST_WEBRTC_ICE_TRANSPORT (nice);
|
||||
NiceAgent *agent = NULL;
|
||||
GPtrArray *sockets;
|
||||
guint i;
|
||||
|
||||
g_object_get (nice->stream->ice, "agent", &agent, NULL);
|
||||
g_assert (agent != NULL);
|
||||
|
||||
sockets = nice_agent_get_sockets (agent, nice->stream->stream_id,
|
||||
ice->component + 1);
|
||||
if (sockets == NULL) {
|
||||
g_object_unref (agent);
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < sockets->len; i++) {
|
||||
GSocket *gsocket = g_ptr_array_index (sockets, i);
|
||||
#ifdef SO_SNDBUF
|
||||
if (nice->priv->send_buffer_size != 0) {
|
||||
GError *gerror = NULL;
|
||||
if (!g_socket_set_option (gsocket, SOL_SOCKET, SO_SNDBUF,
|
||||
nice->priv->send_buffer_size, &gerror))
|
||||
GST_WARNING_OBJECT (nice, "Could not set send buffer size : %s",
|
||||
gerror->message);
|
||||
g_clear_error (&gerror);
|
||||
}
|
||||
#endif
|
||||
#ifdef SO_RCVBUF
|
||||
if (nice->priv->receive_buffer_size != 0) {
|
||||
GError *gerror = NULL;
|
||||
if (!g_socket_set_option (gsocket, SOL_SOCKET, SO_RCVBUF,
|
||||
nice->priv->receive_buffer_size, &gerror))
|
||||
GST_WARNING_OBJECT (nice, "Could not set send receive size : %s",
|
||||
gerror->message);
|
||||
g_clear_error (&gerror);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
g_ptr_array_unref (sockets);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_on_new_selected_pair (NiceAgent * agent, guint stream_id,
|
||||
NiceComponentType component, NiceCandidate * lcandidate,
|
||||
|
@ -245,6 +311,34 @@ gst_webrtc_nice_transport_class_init (GstWebRTCNiceTransportClass * klass)
|
|||
"WebRTC ICE Stream", "ICE stream associated with this transport",
|
||||
GST_TYPE_WEBRTC_ICE_STREAM,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* GstWebRTCNiceTransport:send-buffer-size:
|
||||
*
|
||||
* Size of the kernel send buffer in bytes, 0=default
|
||||
*
|
||||
* Since: 1.20
|
||||
*/
|
||||
|
||||
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
||||
PROP_SEND_BUFFER_SIZE, g_param_spec_int ("send-buffer-size",
|
||||
"Send Buffer Size",
|
||||
"Size of the kernel send buffer in bytes, 0=default", 0, G_MAXINT, 0,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* GstWebRTCNiceTransport:receive-buffer-size:
|
||||
*
|
||||
* Size of the kernel receive buffer in bytes, 0=default
|
||||
*
|
||||
* Since: 1.20
|
||||
*/
|
||||
|
||||
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
||||
PROP_RECEIVE_BUFFER_SIZE, g_param_spec_int ("receive-buffer-size",
|
||||
"Receive Buffer Size",
|
||||
"Size of the kernel receive buffer in bytes, 0=default", 0, G_MAXINT,
|
||||
0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -50,8 +50,11 @@ struct _GstWebRTCNiceTransportClass
|
|||
GstWebRTCICETransportClass parent_class;
|
||||
};
|
||||
|
||||
GstWebRTCNiceTransport * gst_webrtc_nice_transport_new (GstWebRTCICEStream * stream,
|
||||
GstWebRTCICEComponent component);
|
||||
GstWebRTCNiceTransport * gst_webrtc_nice_transport_new (GstWebRTCICEStream * stream,
|
||||
GstWebRTCICEComponent component);
|
||||
|
||||
void gst_webrtc_nice_transport_update_buffer_size (GstWebRTCNiceTransport * nice);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
Loading…
Reference in a new issue