From: David S. <ds...@pd...> - 2004-01-11 22:10:41
|
CVS Root: /home/cvs/gstreamer Module: gstreamer Changes by: ds Date: Sun Jan 11 2004 14:11:47 PST Log message: * gst/elements/gstfilesrc.c: (gst_filesrc_free_parent_mmap), (gst_filesrc_map_region): * gst/gstbuffer.c: (_gst_buffer_initialize), (_gst_buffer_sub_free), (gst_buffer_default_copy), (gst_buffer_new), (gst_buffer_create_sub), (gst_buffer_is_span_fast), (gst_buffer_span): * gst/gstbuffer.h: Change GstBuffer private structure element names. (all files) * gst/gstqueue.c: (gst_queue_init), (gst_queue_getcaps), (gst_queue_link): * gst/gstqueue.h: Implement getcaps/pad_link functions that handle the case where there are data in the queue. Modified files: . : ChangeLog gst : gstbuffer.c gstbuffer.h gstqueue.c gstqueue.h gst/elements : gstfilesrc.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/ChangeLog.diff?r1=1.81&r2=1.82 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/gstbuffer.c.diff?r1=1.75&r2=1.76 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/gstbuffer.h.diff?r1=1.64&r2=1.65 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/gstqueue.c.diff?r1=1.86&r2=1.87 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/gstqueue.h.diff?r1=1.20&r2=1.21 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/elements/gstfilesrc.c.diff?r1=1.69&r2=1.70 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /home/cvs/gstreamer/gstreamer/ChangeLog,v retrieving revision 1.81 retrieving revision 1.82 diff -u -d -r1.81 -r1.82 --- ChangeLog 11 Jan 2004 18:23:48 -0000 1.81 +++ ChangeLog 11 Jan 2004 22:11:34 -0000 1.82 @@ -1,3 +1,19 @@ +2004-01-11 David Schleef <ds...@sc...> + + * gst/elements/gstfilesrc.c: (gst_filesrc_free_parent_mmap), + (gst_filesrc_map_region): + * gst/gstbuffer.c: (_gst_buffer_initialize), + (_gst_buffer_sub_free), (gst_buffer_default_copy), + (gst_buffer_new), (gst_buffer_create_sub), + (gst_buffer_is_span_fast), (gst_buffer_span): + * gst/gstbuffer.h: + Change GstBuffer private structure element names. (all files) + * gst/gstqueue.c: (gst_queue_init), (gst_queue_getcaps), + (gst_queue_link): + * gst/gstqueue.h: + Implement getcaps/pad_link functions that handle the case where + there are data in the queue. + 2004-01-11 Benjamin Otte <in...@pu...> * gst/elements/gstbufferstore.c: Index: gstfilesrc.c =================================================================== RCS file: /home/cvs/gstreamer/gstreamer/gst/elements/gstfilesrc.c,v retrieving revision 1.69 retrieving revision 1.70 diff -u -d -r1.69 -r1.70 --- gstfilesrc.c 8 Jan 2004 04:10:18 -0000 1.69 +++ gstfilesrc.c 11 Jan 2004 22:11:35 -0000 1.70 @@ -345,7 +345,7 @@ static void gst_filesrc_free_parent_mmap (GstBuffer *buf) { - GstFileSrc *src = GST_FILESRC (GST_BUFFER_POOL_PRIVATE (buf)); + GstFileSrc *src = GST_FILESRC (GST_BUFFER_PRIVATE (buf)); GST_LOG_OBJECT (src, "freeing mmap()d buffer at %"G_GUINT64_FORMAT"+%u", GST_BUFFER_OFFSET (buf), GST_BUFFER_SIZE (buf)); @@ -418,7 +418,7 @@ GST_BUFFER_MAXSIZE (buf) = size; GST_BUFFER_OFFSET (buf) = offset; GST_BUFFER_TIMESTAMP (buf) = GST_CLOCK_TIME_NONE; - GST_BUFFER_POOL_PRIVATE (buf) = src; + GST_BUFFER_PRIVATE (buf) = src; g_object_ref (src); GST_BUFFER_FREE_FUNC (buf) = (GstDataFreeFunction) gst_filesrc_free_parent_mmap; Index: gstbuffer.c =================================================================== RCS file: /home/cvs/gstreamer/gstreamer/gst/gstbuffer.c,v retrieving revision 1.75 retrieving revision 1.76 diff -u -d -r1.75 -r1.76 --- gstbuffer.c 22 Dec 2003 01:39:34 -0000 1.75 +++ gstbuffer.c 11 Jan 2004 22:11:35 -0000 1.76 @@ -29,7 +29,6 @@ #include "gstinfo.h" GType _gst_buffer_type; -GType _gst_buffer_pool_type; #ifndef GST_DISABLE_TRACE /* #define GST_WITH_ALLOC_TRACE */ @@ -47,10 +46,6 @@ (GBoxedCopyFunc) gst_data_ref, (GBoxedFreeFunc) gst_data_unref); - _gst_buffer_pool_type = g_boxed_type_register_static ("GstBufferPool", - (GBoxedCopyFunc) gst_data_ref, - (GBoxedFreeFunc) gst_data_unref); - #ifndef GST_DISABLE_TRACE _gst_buffer_trace = gst_alloc_trace_register (GST_BUFFER_TRACE_NAME); #endif @@ -70,7 +65,7 @@ static void _gst_buffer_sub_free (GstBuffer *buffer) { - gst_data_unref (GST_DATA (buffer->pool_private)); + gst_data_unref (GST_DATA (buffer->buffer_private)); GST_BUFFER_DATA (buffer) = NULL; GST_BUFFER_SIZE (buffer) = 0; @@ -89,7 +84,6 @@ * * Frees the memory associated with the buffer including the buffer data, * unless the GST_BUFFER_DONTFREE flags was set or the buffer data is NULL. - * This function is used by buffer pools. */ void gst_buffer_default_free (GstBuffer *buffer) @@ -136,7 +130,6 @@ * @buffer: a #GstBuffer to make a copy of. * * Make a full newly allocated copy of the given buffer, data and all. - * This function is used by buffer pools. * * Returns: the new #GstBuffer. */ @@ -166,8 +159,8 @@ GST_BUFFER_MAXSIZE (copy) = GST_BUFFER_SIZE (buffer); gst_buffer_stamp (copy, buffer); - GST_BUFFER_BUFFERPOOL (copy) = NULL; - GST_BUFFER_POOL_PRIVATE (copy) = NULL; + GST_BUFFER_FREE_DATA_FUNC (copy) = NULL; + GST_BUFFER_PRIVATE (copy) = NULL; return copy; } @@ -204,8 +197,8 @@ GST_BUFFER_DURATION (newbuf) = GST_CLOCK_TIME_NONE; GST_BUFFER_OFFSET (newbuf) = GST_BUFFER_OFFSET_NONE; GST_BUFFER_OFFSET_END (newbuf) = GST_BUFFER_OFFSET_NONE; - GST_BUFFER_BUFFERPOOL (newbuf) = NULL; - GST_BUFFER_POOL_PRIVATE (newbuf) = NULL; + GST_BUFFER_FREE_DATA_FUNC (newbuf) = NULL; + GST_BUFFER_PRIVATE (newbuf) = NULL; return newbuf; } @@ -261,7 +254,7 @@ buffer_data = parent->data + offset; /* make sure we're child not child from a child buffer */ while (GST_BUFFER_FLAG_IS_SET (parent, GST_BUFFER_SUBBUFFER)) { - parent = GST_BUFFER (parent->pool_private); + parent = GST_BUFFER (parent->buffer_private); } /* ref the real parent */ gst_data_ref (GST_DATA (parent)); @@ -287,8 +280,8 @@ GST_BUFFER_DATA (buffer) = buffer_data; GST_BUFFER_SIZE (buffer) = size; GST_BUFFER_MAXSIZE (buffer) = size; - GST_BUFFER_BUFFERPOOL (buffer) = NULL; - GST_BUFFER_POOL_PRIVATE (buffer) = parent; + GST_BUFFER_FREE_DATA_FUNC (buffer) = NULL; + GST_BUFFER_PRIVATE (buffer) = parent; /* we can copy the timestamp and offset if the new buffer starts at * offset 0 */ if (offset == 0) { @@ -356,7 +349,7 @@ /* it's only fast if we have subbuffers of the same parent */ return ((GST_BUFFER_FLAG_IS_SET (buf1, GST_BUFFER_SUBBUFFER)) && (GST_BUFFER_FLAG_IS_SET (buf2, GST_BUFFER_SUBBUFFER)) && - (buf1->pool_private == buf2->pool_private) && + (buf1->buffer_private == buf2->buffer_private) && ((buf1->data + buf1->size) == buf2->data)); } @@ -393,7 +386,7 @@ /* if the two buffers have the same parent and are adjacent */ if (gst_buffer_is_span_fast (buf1, buf2)) { - GstBuffer *parent = GST_BUFFER (buf1->pool_private); + GstBuffer *parent = GST_BUFFER (buf1->buffer_private); /* we simply create a subbuffer of the common parent */ newbuf = gst_buffer_create_sub (parent, buf1->data - parent->data + offset, len); @@ -434,9 +427,3 @@ return newbuf; } -GType -gst_buffer_pool_get_type (void) -{ - return _gst_buffer_pool_type; -} - Index: gstbuffer.h =================================================================== RCS file: /home/cvs/gstreamer/gstreamer/gst/gstbuffer.h,v retrieving revision 1.64 retrieving revision 1.65 diff -u -d -r1.64 -r1.65 --- gstbuffer.h 22 Dec 2003 01:39:34 -0000 1.64 +++ gstbuffer.h 11 Jan 2004 22:11:35 -0000 1.65 @@ -31,6 +31,8 @@ typedef struct _GstBuffer GstBuffer; +typedef void (*GstBufferFreeDataFunc) (GstBuffer *buffer); + #define GST_BUFFER_TRACE_NAME "GstBuffer" extern GType _gst_buffer_type; @@ -39,7 +41,6 @@ #define GST_BUFFER(buf) ((GstBuffer *)(buf)) #define GST_IS_BUFFER(buf) (GST_DATA_TYPE(buf) == GST_TYPE_BUFFER) -#define GST_IS_BUFFER_POOL(buf) (GST_DATA_TYPE(buf) == GST_TYPE_BUFFER_POOL) #define GST_BUFFER_REFCOUNT(buf) GST_DATA_REFCOUNT(buf) #define GST_BUFFER_REFCOUNT_VALUE(buf) GST_DATA_REFCOUNT_VALUE(buf) @@ -59,8 +60,8 @@ #define GST_BUFFER_FORMAT(buf) (GST_BUFFER(buf)->format) #define GST_BUFFER_OFFSET(buf) (GST_BUFFER(buf)->offset) #define GST_BUFFER_OFFSET_END(buf) (GST_BUFFER(buf)->offset_end) -#define GST_BUFFER_BUFFERPOOL(buf) (GST_BUFFER(buf)->pool) -#define GST_BUFFER_POOL_PRIVATE(buf) (GST_BUFFER(buf)->pool_private) +#define GST_BUFFER_FREE_DATA_FUNC(buf) (GST_BUFFER(buf)->free_data) +#define GST_BUFFER_PRIVATE(buf) (GST_BUFFER(buf)->buffer_private) #define GST_BUFFER_OFFSET_NONE ((guint64)-1) #define GST_BUFFER_MAXSIZE_NONE ((guint)0) @@ -76,9 +77,8 @@ GST_BUFFER_SUBBUFFER = GST_DATA_FLAG_LAST, GST_BUFFER_ORIGINAL, GST_BUFFER_DONTFREE, - GST_BUFFER_DISCONTINUOUS, GST_BUFFER_KEY_UNIT, - GST_BUFFER_PREROLL, + GST_BUFFER_DONTKEEP, GST_BUFFER_FLAG_LAST = GST_DATA_FLAG_LAST + 8 } GstBufferFlag; @@ -105,9 +105,9 @@ guint64 offset_end; /* this is a pointer to the buffer pool (if any) */ - gpointer pool; + GstBufferFreeDataFunc free_data; /* pointer to pool private data of parent buffer in case of a subbuffer */ - gpointer pool_private; + gpointer buffer_private; gpointer _gst_reserved[GST_PADDING]; }; Index: gstqueue.c =================================================================== RCS file: /home/cvs/gstreamer/gstreamer/gst/gstqueue.c,v retrieving revision 1.86 retrieving revision 1.87 diff -u -d -r1.86 -r1.87 --- gstqueue.c 11 Jan 2004 17:55:10 -0000 1.86 +++ gstqueue.c 11 Jan 2004 22:11:35 -0000 1.87 @@ -90,6 +90,10 @@ static gboolean gst_queue_handle_src_event (GstPad *pad, GstEvent *event); +static GstCaps *gst_queue_getcaps (GstPad *pad); +static GstPadLinkReturn + gst_queue_link (GstPad *pad, + const GstCaps *caps); static void gst_queue_locked_flush (GstQueue *queue); static GstElementStateReturn @@ -247,15 +251,15 @@ queue->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); gst_pad_set_chain_function (queue->sinkpad, GST_DEBUG_FUNCPTR (gst_queue_chain)); gst_element_add_pad (GST_ELEMENT (queue), queue->sinkpad); - gst_pad_set_link_function (queue->sinkpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_pad_link)); - gst_pad_set_getcaps_function (queue->sinkpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps)); + gst_pad_set_link_function (queue->sinkpad, GST_DEBUG_FUNCPTR (gst_queue_link)); + gst_pad_set_getcaps_function (queue->sinkpad, GST_DEBUG_FUNCPTR (gst_queue_getcaps)); gst_pad_set_active (queue->sinkpad, TRUE); queue->srcpad = gst_pad_new ("src", GST_PAD_SRC); gst_pad_set_get_function (queue->srcpad, GST_DEBUG_FUNCPTR (gst_queue_get)); gst_element_add_pad (GST_ELEMENT (queue), queue->srcpad); - gst_pad_set_link_function (queue->srcpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_pad_link)); - gst_pad_set_getcaps_function (queue->srcpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps)); + gst_pad_set_link_function (queue->srcpad, GST_DEBUG_FUNCPTR (gst_queue_link)); + gst_pad_set_getcaps_function (queue->srcpad, GST_DEBUG_FUNCPTR (gst_queue_getcaps)); gst_pad_set_event_function (queue->srcpad, GST_DEBUG_FUNCPTR (gst_queue_handle_src_event)); gst_pad_set_active (queue->srcpad, TRUE); @@ -311,6 +315,46 @@ G_OBJECT_CLASS (parent_class)->dispose (object); } +static GstCaps * +gst_queue_getcaps (GstPad *pad) +{ + GstQueue *queue; + + queue = GST_QUEUE (gst_pad_get_parent (pad)); + + if (queue->queue->length > 0) { + return gst_caps_copy (queue->negotiated_caps); + } + + return gst_pad_proxy_getcaps (pad); +} + +static GstPadLinkReturn +gst_queue_link (GstPad *pad, const GstCaps *caps) +{ + GstQueue *queue; + GstPadLinkReturn link_ret; + + queue = GST_QUEUE (gst_pad_get_parent (pad)); + + if (queue->queue->length > 0) { + if (gst_caps_is_equal_fixed (caps, queue->negotiated_caps)) { + return GST_PAD_LINK_OK; + } + return GST_PAD_LINK_REFUSED; + } + + link_ret = gst_pad_proxy_pad_link (pad, caps); + + if (GST_PAD_LINK_SUCCESSFUL (link_ret)) { + /* we store an extra copy of the negotiated caps, just in case + * the pads become unnegotiated while we have buffers */ + gst_caps_replace (&queue->negotiated_caps, gst_caps_copy (caps)); + } + + return link_ret; +} + static void gst_queue_locked_flush (GstQueue *queue) { Index: gstqueue.h =================================================================== RCS file: /home/cvs/gstreamer/gstreamer/gst/gstqueue.h,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- gstqueue.h 13 Dec 2003 17:12:46 -0000 1.20 +++ gstqueue.h 11 Jan 2004 22:11:35 -0000 1.21 @@ -88,7 +88,9 @@ GTimeVal *timeval; /* the timeout for the queue locking */ GQueue *events; /* upstream events get decoupled here */ - gpointer _gst_reserved[GST_PADDING]; + GstCaps *negotiated_caps; + + gpointer _gst_reserved[GST_PADDING - 1]; }; struct _GstQueueClass { |