summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2011-02-26 14:22:46 +0100
committerWim Taymans <wim.taymans@collabora.co.uk>2011-02-28 12:06:57 +0100
commitc6859960fa56b10cd0a0385fd8036187952f683d (patch)
tree070f0a84d9e4e217a65b6c8ccc150f32816b71f1
parentcbb7fa570142d9e0dffcc45c1cb781fad49f9060 (diff)
miniobject: port rsndvd
-rw-r--r--ext/resindvd/rsnparsetter.c16
-rw-r--r--ext/resindvd/rsnwrappedbuffer.c124
-rw-r--r--ext/resindvd/rsnwrappedbuffer.h41
3 files changed, 67 insertions, 114 deletions
diff --git a/ext/resindvd/rsnparsetter.c b/ext/resindvd/rsnparsetter.c
index a4206aaf8..374e43419 100644
--- a/ext/resindvd/rsnparsetter.c
+++ b/ext/resindvd/rsnparsetter.c
@@ -123,13 +123,16 @@ static GstFlowReturn
rsn_parsetter_chain (GstPad * pad, GstBuffer * buf)
{
RsnParSetter *parset = RSN_PARSETTER (GST_OBJECT_PARENT (pad));
+ RsnMetaWrapped *meta;
+
+ meta = RSN_META_WRAPPED_GET (buf, FALSE);
/* If this is a buffer we wrapped up earlier, unwrap it now */
- if (RSN_IS_WRAPPEDBUFFER (buf)) {
- RsnWrappedBuffer *wrap_buf = RSN_WRAPPEDBUFFER (buf);
+ if (meta != NULL) {
+ GstBuffer *wrap_buf = buf;
- if (wrap_buf->owner == GST_ELEMENT (parset)) {
- buf = rsn_wrappedbuffer_unwrap_and_unref (wrap_buf);
+ if (meta->owner == GST_ELEMENT (parset)) {
+ buf = rsn_meta_wrapped_unwrap_and_unref (wrap_buf, meta);
GST_DEBUG_OBJECT (parset, "Unwrapping %p yields buffer %p with caps %"
GST_PTR_FORMAT, wrap_buf, buf, GST_BUFFER_CAPS (buf));
}
@@ -378,15 +381,12 @@ rsn_parsetter_sink_bufferalloc (GstPad * pad, guint64 offset, guint size,
if (ret != GST_FLOW_OK)
return ret;
- outbuf = (GstBuffer *) rsn_wrapped_buffer_new (orig_buf);
+ outbuf = rsn_wrapped_buffer_new (orig_buf, GST_ELEMENT_CAST (parset));
if (!outbuf) {
/* FIXME: Throw error */
return GST_FLOW_ERROR;
}
- rsn_wrapped_buffer_set_owner (RSN_WRAPPEDBUFFER (outbuf),
- GST_ELEMENT (parset));
-
gst_buffer_set_caps (outbuf, caps);
GST_LOG_OBJECT (parset,
diff --git a/ext/resindvd/rsnwrappedbuffer.c b/ext/resindvd/rsnwrappedbuffer.c
index 6e2579c67..cb25a7e63 100644
--- a/ext/resindvd/rsnwrappedbuffer.c
+++ b/ext/resindvd/rsnwrappedbuffer.c
@@ -26,53 +26,19 @@
#include "rsnwrappedbuffer.h"
-G_DEFINE_TYPE (RsnWrappedBuffer, rsn_wrappedbuffer, GST_TYPE_BUFFER);
-
-static gboolean
-rsn_wrapped_buffer_default_release (GstElement * owner, RsnWrappedBuffer * buf);
-
-static void rsn_wrapped_buffer_finalize (RsnWrappedBuffer * wrap_buf);
-
-static void
-rsn_wrappedbuffer_class_init (RsnWrappedBufferClass * klass)
-{
- GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (klass);
-
- mini_object_class->finalize = (GstMiniObjectFinalizeFunction)
- rsn_wrapped_buffer_finalize;
-}
-
-static void
-rsn_wrappedbuffer_init (RsnWrappedBuffer * self)
-{
- self->release = rsn_wrapped_buffer_default_release;
-}
-
-static void
-rsn_wrapped_buffer_finalize (RsnWrappedBuffer * wrap_buf)
+GstBuffer *
+rsn_wrapped_buffer_new (GstBuffer * buf_to_wrap, GstElement * owner)
{
- if (wrap_buf->release) {
- /* Release might increment the refcount to recycle and return TRUE,
- * in which case, exit without chaining up */
- if (wrap_buf->release (wrap_buf->owner, wrap_buf))
- return;
- }
-
- GST_MINI_OBJECT_CLASS (rsn_wrappedbuffer_parent_class)->finalize
- (GST_MINI_OBJECT (wrap_buf));
-}
+ GstBuffer *buf;
+ RsnMetaWrapped *meta;
-RsnWrappedBuffer *
-rsn_wrapped_buffer_new (GstBuffer * buf_to_wrap)
-{
- RsnWrappedBuffer *buf;
g_return_val_if_fail (buf_to_wrap, NULL);
- buf = (RsnWrappedBuffer *) gst_mini_object_new (RSN_TYPE_WRAPPEDBUFFER);
- if (buf == NULL)
- return NULL;
+ buf = gst_buffer_new ();
+ meta = RSN_META_WRAPPED_GET (buf, TRUE);
- buf->wrapped_buffer = buf_to_wrap;
+ meta->wrapped_buffer = buf_to_wrap;
+ meta->owner = gst_object_ref (owner);
GST_BUFFER_DATA (buf) = GST_BUFFER_DATA (buf_to_wrap);
GST_BUFFER_SIZE (buf) = GST_BUFFER_SIZE (buf_to_wrap);
@@ -86,52 +52,29 @@ rsn_wrapped_buffer_new (GstBuffer * buf_to_wrap)
}
void
-rsn_wrapped_buffer_set_owner (RsnWrappedBuffer * wrapped_buf,
- GstElement * owner)
+rsn_meta_wrapped_set_owner (RsnMetaWrapped * meta, GstElement * owner)
{
- g_return_if_fail (wrapped_buf != NULL);
+ g_return_if_fail (meta != NULL);
- if (wrapped_buf->owner)
- gst_object_unref (wrapped_buf->owner);
+ if (meta->owner)
+ gst_object_unref (meta->owner);
if (owner)
- wrapped_buf->owner = gst_object_ref (owner);
- else
- wrapped_buf->owner = NULL;
-}
+ gst_object_ref (owner);
-void
-rsn_wrapped_buffer_set_releasefunc (RsnWrappedBuffer * wrapped_buf,
- RsnWrappedBufferReleaseFunc release_func)
-{
- g_return_if_fail (wrapped_buf != NULL);
-
- wrapped_buf->release = release_func;
-}
-
-static gboolean
-rsn_wrapped_buffer_default_release (GstElement * owner, RsnWrappedBuffer * buf)
-{
- g_return_val_if_fail (buf != NULL, FALSE);
- g_return_val_if_fail (buf->wrapped_buffer != NULL, FALSE);
-
- gst_buffer_unref (buf->wrapped_buffer);
- if (buf->owner)
- gst_object_unref (buf->owner);
-
- return FALSE;
+ meta->owner = owner;
}
GstBuffer *
-rsn_wrappedbuffer_unwrap_and_unref (RsnWrappedBuffer * wrap_buf)
+rsn_meta_wrapped_unwrap_and_unref (GstBuffer * wrap_buf, RsnMetaWrapped * meta)
{
GstBuffer *buf;
gboolean is_readonly;
g_return_val_if_fail (wrap_buf != NULL, NULL);
- g_return_val_if_fail (wrap_buf->wrapped_buffer != NULL, NULL);
+ g_return_val_if_fail (meta->wrapped_buffer != NULL, NULL);
- buf = gst_buffer_ref (wrap_buf->wrapped_buffer);
+ buf = gst_buffer_ref (meta->wrapped_buffer);
/* Copy changed metadata back to the wrapped buffer from the wrapper,
* except the the read-only flag and the caps. */
@@ -141,7 +84,38 @@ rsn_wrappedbuffer_unwrap_and_unref (RsnWrappedBuffer * wrap_buf)
if (!is_readonly)
GST_BUFFER_FLAG_UNSET (buf, GST_BUFFER_FLAG_READONLY);
- gst_buffer_unref (GST_BUFFER (wrap_buf));
+ gst_buffer_unref (wrap_buf);
return buf;
}
+
+static void
+rsn_meta_wrapped_init (RsnMetaWrapped * meta, GstBuffer * buffer)
+{
+ meta->owner = NULL;
+}
+
+static void
+rsn_meta_wrapped_free (RsnMetaWrapped * meta, GstBuffer * buffer)
+{
+ gst_buffer_unref (meta->wrapped_buffer);
+ if (meta->owner)
+ gst_object_unref (meta->owner);
+}
+
+const GstMetaInfo *
+rsn_meta_wrapped_get_info (void)
+{
+ static const GstMetaInfo *meta_info = NULL;
+
+ if (meta_info == NULL) {
+ meta_info = gst_meta_register ("RsnMetaWrapped", "RsnMetaWrapped",
+ sizeof (RsnMetaWrapped),
+ (GstMetaInitFunction) rsn_meta_wrapped_init,
+ (GstMetaFreeFunction) rsn_meta_wrapped_free,
+ (GstMetaCopyFunction) NULL,
+ (GstMetaSubFunction) NULL,
+ (GstMetaSerializeFunction) NULL, (GstMetaDeserializeFunction) NULL);
+ }
+ return meta_info;
+}
diff --git a/ext/resindvd/rsnwrappedbuffer.h b/ext/resindvd/rsnwrappedbuffer.h
index 7c6a0e735..db716e0c4 100644
--- a/ext/resindvd/rsnwrappedbuffer.h
+++ b/ext/resindvd/rsnwrappedbuffer.h
@@ -24,45 +24,24 @@
G_BEGIN_DECLS
-#define RSN_TYPE_WRAPPEDBUFFER (rsn_wrappedbuffer_get_type())
-#define RSN_WRAPPEDBUFFER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), RSN_TYPE_WRAPPEDBUFFER, \
- RsnWrappedBuffer))
-#define RSN_WRAPPEDBUFFER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), RSN_TYPE_WRAPPEDBUFFER, \
- RsnWrappedBufferClass))
-#define RSN_IS_WRAPPEDBUFFER(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), RSN_TYPE_WRAPPEDBUFFER))
-#define RSN_IS_WRAPPEDBUFFER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), RSN_TYPE_WRAPPEDBUFFER))
+typedef struct _RsnMetaWrapped RsnMetaWrapped;
-typedef struct _RsnWrappedBuffer RsnWrappedBuffer;
-typedef struct _RsnWrappedBufferClass RsnWrappedBufferClass;
-
-typedef gboolean (*RsnWrappedBufferReleaseFunc)(GstElement *owner,
- RsnWrappedBuffer *buf);
-
-struct _RsnWrappedBuffer {
- GstBuffer buffer;
+struct _RsnMetaWrapped {
+ GstMeta meta;
GstBuffer *wrapped_buffer;
GstElement *owner;
- RsnWrappedBufferReleaseFunc release;
};
-struct _RsnWrappedBufferClass
-{
- GstBufferClass parent_class;
-};
+GstBuffer *rsn_wrapped_buffer_new (GstBuffer *buf_to_wrap, GstElement *owner);
+
+GstBuffer *rsn_meta_wrapped_unwrap_and_unref (GstBuffer *wrap_buf, RsnMetaWrapped *meta);
+
+void rsn_meta_wrapped_set_owner (RsnMetaWrapped *meta, GstElement *owner);
-RsnWrappedBuffer *rsn_wrapped_buffer_new (GstBuffer *buf_to_wrap);
-GstBuffer *rsn_wrappedbuffer_unwrap_and_unref (RsnWrappedBuffer *wrap_buf);
-void rsn_wrapped_buffer_set_owner (RsnWrappedBuffer *wrapped_buf,
- GstElement *owner);
-void rsn_wrapped_buffer_set_releasefunc (RsnWrappedBuffer *wrapped_buf,
- RsnWrappedBufferReleaseFunc release_func);
+const GstMetaInfo * rsn_meta_wrapped_get_info (void);
-GType rsn_wrappedbuffer_get_type (void);
+#define RSN_META_WRAPPED_GET(buf,create) ((RsnMetaWrapped *)gst_buffer_get_meta(buf,rsn_meta_wrapped_get_info(),create))
G_END_DECLS