mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-20 04:56:24 +00:00
udpsrc: track max packet size and save allocator negotiated by GstBaseSrc
This commit is contained in:
parent
8e28994207
commit
305e4c2f46
2 changed files with 49 additions and 0 deletions
|
@ -182,6 +182,7 @@ static GstFlowReturn gst_udpsrc_create (GstPushSrc * psrc, GstBuffer ** buf);
|
||||||
static gboolean gst_udpsrc_close (GstUDPSrc * src);
|
static gboolean gst_udpsrc_close (GstUDPSrc * src);
|
||||||
static gboolean gst_udpsrc_unlock (GstBaseSrc * bsrc);
|
static gboolean gst_udpsrc_unlock (GstBaseSrc * bsrc);
|
||||||
static gboolean gst_udpsrc_unlock_stop (GstBaseSrc * bsrc);
|
static gboolean gst_udpsrc_unlock_stop (GstBaseSrc * bsrc);
|
||||||
|
static gboolean gst_udpsrc_negotiate (GstBaseSrc * basesrc);
|
||||||
|
|
||||||
static void gst_udpsrc_finalize (GObject * object);
|
static void gst_udpsrc_finalize (GObject * object);
|
||||||
|
|
||||||
|
@ -294,6 +295,7 @@ gst_udpsrc_class_init (GstUDPSrcClass * klass)
|
||||||
gstbasesrc_class->unlock = gst_udpsrc_unlock;
|
gstbasesrc_class->unlock = gst_udpsrc_unlock;
|
||||||
gstbasesrc_class->unlock_stop = gst_udpsrc_unlock_stop;
|
gstbasesrc_class->unlock_stop = gst_udpsrc_unlock_stop;
|
||||||
gstbasesrc_class->get_caps = gst_udpsrc_getcaps;
|
gstbasesrc_class->get_caps = gst_udpsrc_getcaps;
|
||||||
|
gstbasesrc_class->negotiate = gst_udpsrc_negotiate;
|
||||||
|
|
||||||
gstpushsrc_class->create = gst_udpsrc_create;
|
gstpushsrc_class->create = gst_udpsrc_create;
|
||||||
}
|
}
|
||||||
|
@ -390,6 +392,32 @@ gst_udpsrc_getcaps (GstBaseSrc * src, GstCaps * filter)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_udpsrc_negotiate (GstBaseSrc * basesrc)
|
||||||
|
{
|
||||||
|
gboolean ret;
|
||||||
|
|
||||||
|
/* just chain up to the default implementation, we just want to
|
||||||
|
* retrieve the allocator at the end of it (if there is one) */
|
||||||
|
ret = GST_BASE_SRC_CLASS (parent_class)->negotiate (basesrc);
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
GstUDPSrc *src;
|
||||||
|
|
||||||
|
src = GST_UDPSRC (basesrc);
|
||||||
|
|
||||||
|
if (src->allocator != NULL) {
|
||||||
|
gst_object_unref (src->allocator);
|
||||||
|
src->allocator = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
gst_base_src_get_allocator (basesrc, &src->allocator, &src->params);
|
||||||
|
GST_INFO_OBJECT (src, "allocator: %" GST_PTR_FORMAT, src->allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_udpsrc_create (GstPushSrc * psrc, GstBuffer ** buf)
|
gst_udpsrc_create (GstPushSrc * psrc, GstBuffer ** buf)
|
||||||
{
|
{
|
||||||
|
@ -507,6 +535,10 @@ no_select:
|
||||||
goto receive_error;
|
goto receive_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* remember maximum packet size */
|
||||||
|
if (res > udpsrc->max_size)
|
||||||
|
udpsrc->max_size = res;
|
||||||
|
|
||||||
/* patch offset and size when stripping off the headers */
|
/* patch offset and size when stripping off the headers */
|
||||||
if (G_UNLIKELY (udpsrc->skip_first_bytes != 0)) {
|
if (G_UNLIKELY (udpsrc->skip_first_bytes != 0)) {
|
||||||
if (G_UNLIKELY (readsize < udpsrc->skip_first_bytes))
|
if (G_UNLIKELY (readsize < udpsrc->skip_first_bytes))
|
||||||
|
@ -997,6 +1029,11 @@ gst_udpsrc_open (GstUDPSrc * src)
|
||||||
g_object_unref (addr);
|
g_object_unref (addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
src->allocator = NULL;
|
||||||
|
gst_allocation_params_init (&src->params);
|
||||||
|
|
||||||
|
src->max_size = 0;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
|
@ -1102,6 +1139,11 @@ gst_udpsrc_close (GstUDPSrc * src)
|
||||||
src->addr = NULL;
|
src->addr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (src->allocator != NULL) {
|
||||||
|
gst_object_unref (src->allocator);
|
||||||
|
src->allocator = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,12 +61,19 @@ struct _GstUDPSrc {
|
||||||
gboolean auto_multicast;
|
gboolean auto_multicast;
|
||||||
gboolean reuse;
|
gboolean reuse;
|
||||||
|
|
||||||
|
/* stats */
|
||||||
|
guint max_size;
|
||||||
|
|
||||||
/* our sockets */
|
/* our sockets */
|
||||||
GSocket *used_socket;
|
GSocket *used_socket;
|
||||||
GCancellable *cancellable;
|
GCancellable *cancellable;
|
||||||
GInetSocketAddress *addr;
|
GInetSocketAddress *addr;
|
||||||
gboolean external_socket;
|
gboolean external_socket;
|
||||||
|
|
||||||
|
/* memory management */
|
||||||
|
GstAllocator *allocator;
|
||||||
|
GstAllocationParams params;
|
||||||
|
|
||||||
gchar *uri;
|
gchar *uri;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue