...
 
Commits (4)
  • George Kiagiadakis's avatar
    udpsrc: receive multiple messages from the kernel at once · 5a48c822
    George Kiagiadakis authored
    This allows udpsrc to handle better the case of streaming high
    bitrates using very small packets, which otherwise it fails to do
    properly (a lot of packets are lost because we are not emptying
    the kernel buffer fast enough)
    
    In order to enable this functionality, the functionality of
    automatically adjusting memory allocation to the packet size
    has been dropped, as it is not efficient to implement it for
    an array of buffers. The caller should set the "mtu" property
    according to the application's needs. Note that a higher mtu
    value is not a problem, it will just waste a bit of RAM.
    
    The default max-read-packets value of 150 was chosen to allow
    reading the entire kernel buffer (208KB by default) in one call,
    when using 1500-byte packets.
    
    This change probably has an impact only on linux, as it assumes
    that g_socket_receive_messages() internally calls recvmmsg(),
    which is a linux-specific system call. On other platforms it will
    sequentially call g_socket_receive_message() and therefore it
    doesn't have a significant gain.
    
    Note that g_socket_receive_messages() requires GLib 2.48
    5a48c822
  • George Kiagiadakis's avatar
    udpsrc: read buffers from the kernel in a separate thread to increase throughput · 57fdaeab
    George Kiagiadakis authored
    As it turns out, when we have to read a vast amount of small packets,
    it's very important to return execution to recvmmsg() as fast as possible,
    otherwise we can still lose packets. This patch enables this to happen
    in a separate thread so that other GStreamer operations don't affect it.
    57fdaeab
  • George Kiagiadakis's avatar
    udpsrc: use a buffer pool · 7e6c77e0
    George Kiagiadakis authored
    This allows us to avoid new allocations, most of the time,
    in the receiver thread, which increases our chances of returning
    execution to recvmmsg() as fast as possible.
    7e6c77e0
  • George Kiagiadakis's avatar
    udpsrc: avoid doing select() if there are messages available · 9c42c06d
    George Kiagiadakis authored
    Again, the rule of thumb: return execution to recvmmsg() as fast as possible.
    There is no need to select() when there are already packets available!
    9c42c06d
This diff is collapsed.
......@@ -62,9 +62,8 @@ struct _GstUDPSrc {
gboolean reuse;
gboolean loop;
gboolean retrieve_sender_address;
/* stats */
guint max_size;
gint mtu;
gint max_read_packets;
/* our sockets */
GSocket *used_socket;
......@@ -74,15 +73,17 @@ struct _GstUDPSrc {
gboolean made_cancel_fd;
GCancellable *cancellable;
/* memory management */
GstAllocator *allocator;
GstAllocationParams params;
GstMemory *mem;
GstMapInfo map;
GstMemory *mem_max;
GstMapInfo map_max;
GInputVector vec[2];
/* receive thread */
GstTask *receive_task;
GRecMutex receive_task_lock;
GMutex lock;
GCond cond;
GstFlowReturn last_return;
/* buffers */
GstAtomicQueue *buffer_queue;
GArray *input_msgs;
GArray *input_msgs_data;
gchar *uri;
};
......