From: Tim-Philipp Müller Date: Tue, 9 Sep 2014 08:42:15 +0000 (+0100) Subject: udpsrc: track max packet size and save allocator negotiated by GstBaseSrc X-Git-Tag: 1.6.0~939 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=305e4c2f467fb2bc024828cf0d9e0a50e244d774;p=platform%2Fupstream%2Fgst-plugins-good.git udpsrc: track max packet size and save allocator negotiated by GstBaseSrc --- diff --git a/gst/udp/gstudpsrc.c b/gst/udp/gstudpsrc.c index 98cb209..cfde461 100644 --- a/gst/udp/gstudpsrc.c +++ b/gst/udp/gstudpsrc.c @@ -182,6 +182,7 @@ static GstFlowReturn gst_udpsrc_create (GstPushSrc * psrc, GstBuffer ** buf); static gboolean gst_udpsrc_close (GstUDPSrc * src); static gboolean gst_udpsrc_unlock (GstBaseSrc * bsrc); static gboolean gst_udpsrc_unlock_stop (GstBaseSrc * bsrc); +static gboolean gst_udpsrc_negotiate (GstBaseSrc * basesrc); 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_stop = gst_udpsrc_unlock_stop; gstbasesrc_class->get_caps = gst_udpsrc_getcaps; + gstbasesrc_class->negotiate = gst_udpsrc_negotiate; gstpushsrc_class->create = gst_udpsrc_create; } @@ -390,6 +392,32 @@ gst_udpsrc_getcaps (GstBaseSrc * src, GstCaps * filter) 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 gst_udpsrc_create (GstPushSrc * psrc, GstBuffer ** buf) { @@ -507,6 +535,10 @@ no_select: 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 */ if (G_UNLIKELY (udpsrc->skip_first_bytes != 0)) { if (G_UNLIKELY (readsize < udpsrc->skip_first_bytes)) @@ -997,6 +1029,11 @@ gst_udpsrc_open (GstUDPSrc * src) g_object_unref (addr); } + src->allocator = NULL; + gst_allocation_params_init (&src->params); + + src->max_size = 0; + return TRUE; /* ERRORS */ @@ -1102,6 +1139,11 @@ gst_udpsrc_close (GstUDPSrc * src) src->addr = NULL; } + if (src->allocator != NULL) { + gst_object_unref (src->allocator); + src->allocator = NULL; + } + return TRUE; } diff --git a/gst/udp/gstudpsrc.h b/gst/udp/gstudpsrc.h index c631e35..5258881 100644 --- a/gst/udp/gstudpsrc.h +++ b/gst/udp/gstudpsrc.h @@ -61,12 +61,19 @@ struct _GstUDPSrc { gboolean auto_multicast; gboolean reuse; + /* stats */ + guint max_size; + /* our sockets */ GSocket *used_socket; GCancellable *cancellable; GInetSocketAddress *addr; gboolean external_socket; + /* memory management */ + GstAllocator *allocator; + GstAllocationParams params; + gchar *uri; };