summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a06605e)
raw | patch | inline | side by side (parent: a06605e)
author | David Schleef <ds@schleef.org> | |
Sun, 11 Jan 2004 22:11:35 +0000 (22:11 +0000) | ||
committer | David Schleef <ds@schleef.org> | |
Sun, 11 Jan 2004 22:11:35 +0000 (22:11 +0000) |
Original commit message from CVS:
* 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.
* 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.
diff --git a/ChangeLog b/ChangeLog
index fd93d8babce488093886b18315c92e5977d245e4..acdfc8cc03b90d5a16fa2af6e83592e3e163613a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2004-01-11 David Schleef <ds@schleef.org>
+
+ * 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 <in7y118@public.uni-hamburg.de>
* gst/elements/gstbufferstore.c:
index adb2d81c71472bb88117fc9b3a5358e9b3649029..452acf9a5d2e98c5cdacf2419e792d3af0b2c6d4 100644 (file)
@@ -345,7 +345,7 @@ gst_filesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamS
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));
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;
diff --git a/gst/gstbuffer.c b/gst/gstbuffer.c
index 7efa693b0a6b3cc4ce277cb7c4ea0b1cbfb8febb..2c9e43e8101c036d0359343d28c49fd2a0c96ec9 100644 (file)
--- a/gst/gstbuffer.c
+++ b/gst/gstbuffer.c
#include "gstinfo.h"
GType _gst_buffer_type;
-GType _gst_buffer_pool_type;
#ifndef GST_DISABLE_TRACE
/* #define GST_WITH_ALLOC_TRACE */
(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
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;
*
* 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)
* @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.
*/
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;
}
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;
}
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));
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) {
/* 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));
}
/* 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);
return newbuf;
}
-GType
-gst_buffer_pool_get_type (void)
-{
- return _gst_buffer_pool_type;
-}
-
diff --git a/gst/gstbuffer.h b/gst/gstbuffer.h
index 7e9a88b0e524f9dc4667888c1602f6d662c0efbd..c75398229e1872b2f1bd46393632d45bb383ee6c 100644 (file)
--- a/gst/gstbuffer.h
+++ b/gst/gstbuffer.h
typedef struct _GstBuffer GstBuffer;
+typedef void (*GstBufferFreeDataFunc) (GstBuffer *buffer);
+
#define GST_BUFFER_TRACE_NAME "GstBuffer"
extern GType _gst_buffer_type;
#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)
#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)
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;
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];
};
diff --git a/gst/gstqueue.c b/gst/gstqueue.c
index fd9d69fbbeead89a64123aaa055ade4c19790396..5f0940801530c0394a8ccea5c3bb1fac8a0cfbaf 100644 (file)
--- a/gst/gstqueue.c
+++ b/gst/gstqueue.c
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
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);
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)
{
diff --git a/gst/gstqueue.h b/gst/gstqueue.h
index 5e87b899e52424643f7023d28d1cd9fb9345cd50..0066eddaf91f3fc89c2aa9fc31521542b9623602 100644 (file)
--- a/gst/gstqueue.h
+++ b/gst/gstqueue.h
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 {
index adb2d81c71472bb88117fc9b3a5358e9b3649029..452acf9a5d2e98c5cdacf2419e792d3af0b2c6d4 100644 (file)
@@ -345,7 +345,7 @@ gst_filesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamS
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));
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 fd9d69fbbeead89a64123aaa055ade4c19790396..5f0940801530c0394a8ccea5c3bb1fac8a0cfbaf 100644 (file)
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
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);
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 5e87b899e52424643f7023d28d1cd9fb9345cd50..0066eddaf91f3fc89c2aa9fc31521542b9623602 100644 (file)
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 {