qa-pad-wrapper: adds stub class for pad QA wrapper
authorThiago Santos <thiago.sousa.santos@collabora.com>
Tue, 9 Jul 2013 19:52:02 +0000 (16:52 -0300)
committerThiago Santos <thiago.sousa.santos@collabora.com>
Tue, 9 Jul 2013 19:52:02 +0000 (16:52 -0300)
Also fixes _new functions to ref the elements intead of
ownership transfers

validate/gst/qa/Makefile.am
validate/gst/qa/gst-qa-element-wrapper.c
validate/gst/qa/gst-qa-pad-wrapper.c [new file with mode: 0644]
validate/gst/qa/gst-qa-pad-wrapper.h [new file with mode: 0644]
validate/gst/qa/gst-qa-runner.c

index 36767db..f1c1964 100644 (file)
@@ -4,6 +4,7 @@ public_headers = \
 c_sources = \
        gst-qa-runner.c \
        gst-qa-element-wrapper.c \
+       gst-qa-pad-wrapper.c \
        gst-qa-wrapper-factory.c
 
 noinst_HEADERS = 
index 6b06990..9a3ebd3 100644 (file)
@@ -79,7 +79,7 @@ gst_qa_element_wrapper_init (GstQaElementWrapper * element_wrapper)
 
 /**
  * gst_qa_element_wrapper_new:
- * @element: (transfer-full): a #GstElement to run QA on
+ * @element: (transfer-none): a #GstElement to run QA on
  */
 GstQaElementWrapper *
 gst_qa_element_wrapper_new (GstElement * element)
@@ -89,7 +89,7 @@ gst_qa_element_wrapper_new (GstElement * element)
 
   g_return_val_if_fail (element != NULL, NULL);
 
-  wrapper->element = element;
+  wrapper->element = gst_object_ref (element);
   return wrapper;
 }
 
diff --git a/validate/gst/qa/gst-qa-pad-wrapper.c b/validate/gst/qa/gst-qa-pad-wrapper.c
new file mode 100644 (file)
index 0000000..2d7d25d
--- /dev/null
@@ -0,0 +1,97 @@
+/* GStreamer
+ * Copyright (C) 2013 Thiago Santos <thiago.sousa.santos@collabora.com>
+ *
+ * gst-qa-pad_wrapper.c - QA PadWrapper class
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "gst-qa-pad-wrapper.h"
+
+/**
+ * SECTION:gst-qa-pad-wrapper
+ * @short_description: Class that wraps a #GstPad for QA checks
+ *
+ * TODO
+ */
+
+GST_DEBUG_CATEGORY_STATIC (gst_qa_pad_wrapper_debug);
+#define GST_CAT_DEFAULT gst_qa_pad_wrapper_debug
+
+#define _do_init \
+  GST_DEBUG_CATEGORY_INIT (gst_qa_pad_wrapper_debug, "qa_pad_wrapper", 0, "QA PadWrapper");
+#define gst_qa_pad_wrapper_parent_class parent_class
+G_DEFINE_TYPE_WITH_CODE (GstQaPadWrapper, gst_qa_pad_wrapper,
+    G_TYPE_OBJECT, _do_init);
+
+
+static void
+gst_qa_pad_wrapper_dispose (GObject * object)
+{
+  GstQaPadWrapper *wrapper = GST_QA_PAD_WRAPPER_CAST (object);
+
+  if (wrapper->pad)
+    gst_object_unref (wrapper->pad);
+
+  G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+
+static void
+gst_qa_pad_wrapper_class_init (GstQaPadWrapperClass * klass)
+{
+  GObjectClass *gobject_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+
+  gobject_class->dispose = gst_qa_pad_wrapper_dispose;
+}
+
+static void
+gst_qa_pad_wrapper_init (GstQaPadWrapper * pad_wrapper)
+{
+  pad_wrapper->setup = FALSE;
+}
+
+/**
+ * gst_qa_pad_wrapper_new:
+ * @pad: (transfer-none): a #GstPad to run QA on
+ */
+GstQaPadWrapper *
+gst_qa_pad_wrapper_new (GstPad * pad)
+{
+  GstQaPadWrapper *wrapper =
+      g_object_new (GST_TYPE_QA_PAD_WRAPPER, NULL);
+
+  g_return_val_if_fail (pad != NULL, NULL);
+
+  wrapper->pad = gst_object_ref (pad);
+  return wrapper;
+}
+
+gboolean
+gst_qa_pad_wrapper_setup (GstQaPadWrapper * wrapper)
+{
+  if (wrapper->setup)
+    return TRUE;
+
+  GST_DEBUG_OBJECT (wrapper, "Setting up wrapper for pad %" GST_PTR_FORMAT,
+      wrapper->pad);
+
+  wrapper->setup = TRUE;
+  return TRUE;
+}
+
diff --git a/validate/gst/qa/gst-qa-pad-wrapper.h b/validate/gst/qa/gst-qa-pad-wrapper.h
new file mode 100644 (file)
index 0000000..18bb909
--- /dev/null
@@ -0,0 +1,77 @@
+/* GStreamer
+ * Copyright (C) 2013 Thiago Santos <thiago.sousa.santos@collabora.com>
+ *
+ * gst-qa-pad_wrapper.h - QA PadWrapper class
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GST_QA_PAD_WRAPPER_H__
+#define __GST_QA_PAD_WRAPPER_H__
+
+#include <glib-object.h>
+#include <gst/gst.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_QA_PAD_WRAPPER                        (gst_qa_pad_wrapper_get_type ())
+#define GST_IS_QA_PAD_WRAPPER(obj)             (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_QA_PAD_WRAPPER))
+#define GST_IS_QA_PAD_WRAPPER_CLASS(klass)     (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_QA_PAD_WRAPPER))
+#define GST_QA_PAD_WRAPPER_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_QA_PAD_WRAPPER, GstQaPadWrapperClass))
+#define GST_QA_PAD_WRAPPER(obj)                        (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_QA_PAD_WRAPPER, GstQaPadWrapper))
+#define GST_QA_PAD_WRAPPER_CLASS(klass)                (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_QA_PAD_WRAPPER, GstQaPadWrapperClass))
+#define GST_QA_PAD_WRAPPER_CAST(obj)            ((GstQaPadWrapper*)(obj))
+#define GST_QA_PAD_WRAPPER_CLASS_CAST(klass)    ((GstQaPadWrapperClass*)(klass))
+
+typedef struct _GstQaPadWrapper GstQaPadWrapper;
+typedef struct _GstQaPadWrapperClass GstQaPadWrapperClass;
+
+/**
+ * GstQaPadWrapper:
+ *
+ * GStreamer QA PadWrapper class.
+ *
+ * Class that wraps a #GstPad for QA checks
+ */
+struct _GstQaPadWrapper {
+  GObject       object;
+
+  gboolean       setup;
+  GstPad        *pad;
+
+  /*< private >*/
+};
+
+/**
+ * GstQaPadWrapperClass:
+ * @parent_class: parent
+ *
+ * GStreamer QA PadWrapper object class.
+ */
+struct _GstQaPadWrapperClass {
+  GObjectClass parent_class;
+};
+
+/* normal GObject stuff */
+GType          gst_qa_pad_wrapper_get_type             (void);
+
+GstQaPadWrapper *   gst_qa_pad_wrapper_new      (GstPad * pad);
+gboolean            gst_qa_pad_wrapper_setup    (GstQaPadWrapper * pad_wrapper);
+
+G_END_DECLS
+
+#endif /* __GST_QA_PAD_WRAPPER_H__ */
+
index e79f1f0..e1d140a 100644 (file)
@@ -68,7 +68,7 @@ gst_qa_runner_init (GstQaRunner * runner)
 
 /**
  * gst_qa_runner_new:
- * @pipeline: (transfer-full): a #GstElement to run QA on
+ * @pipeline: (transfer-none): a #GstElement to run QA on
  */
 GstQaRunner *
 gst_qa_runner_new (GstElement * pipeline)
@@ -77,7 +77,7 @@ gst_qa_runner_new (GstElement * pipeline)
 
   g_return_val_if_fail (pipeline != NULL, NULL);
 
-  runner->pipeline = pipeline;
+  runner->pipeline = gst_object_ref (pipeline);
   return runner;
 }