[gstreamermm/wip/jtojnar/build-fixes: 2/3] Add support for g_value holding G_TYPE_ARRAY




commit 5eb8722380d8bb41f7c69fc5cae6bcb42484d926
Author: Jan Tojnar <jtojnar gmail com>
Date:   Tue May 3 02:31:01 2022 +0200

    Add support for g_value holding G_TYPE_ARRAY
    
    Mostly modelled after Gst::ValueList

 gstreamer/gstreamermm.h      |  1 +
 gstreamer/src/filelist.am    |  1 +
 gstreamer/src/valuearray.ccg | 63 ++++++++++++++++++++++++++++++++++++++
 gstreamer/src/valuearray.hg  | 73 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 138 insertions(+)
---
diff --git a/gstreamer/gstreamermm.h b/gstreamer/gstreamermm.h
index fc3b355..73904da 100644
--- a/gstreamer/gstreamermm.h
+++ b/gstreamer/gstreamermm.h
@@ -114,6 +114,7 @@
 #include <gstreamermm/typefindfactory.h>
 #include <gstreamermm/urihandler.h>
 #include <gstreamermm/value.h>
+#include <gstreamermm/valuearray.h>
 #include <gstreamermm/valuelist.h>
 
 // Core library base includes
diff --git a/gstreamer/src/filelist.am b/gstreamer/src/filelist.am
index d9d750f..b2648a9 100644
--- a/gstreamer/src/filelist.am
+++ b/gstreamer/src/filelist.am
@@ -95,6 +95,7 @@ files_hg  =                     \
         typefind.hg             \
         urihandler.hg           \
         value.hg                \
+        valuearray.hg           \
         valuelist.hg            \
         videochroma.hg          \
         videoformat.hg          \
diff --git a/gstreamer/src/valuearray.ccg b/gstreamer/src/valuearray.ccg
new file mode 100644
index 0000000..ab06488
--- /dev/null
+++ b/gstreamer/src/valuearray.ccg
@@ -0,0 +1,63 @@
+/* gstreamermm - a C++ wrapper for gstreamer
+ *
+ * Copyright 2008 The gstreamermm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+namespace Gst
+{
+
+ValueArray::ValueArray()
+{}
+
+// static
+GType ValueArray::get_type()
+{
+  return GST_TYPE_ARRAY;
+}
+
+guint ValueArray::size() const
+{
+  return gst_value_array_get_size(gobj());
+}
+
+bool ValueArray::get(guint index, Glib::ValueBase& value) const
+{
+  const GValue* g_value = gst_value_array_get_value(gobj(), index);
+
+  if(g_value)
+  {
+    value.init(g_value);
+    return true;
+  }
+  else
+    return false;
+}
+
+Gst::ValueArray& ValueArray::append(const Glib::ValueBase& value)
+{
+  gst_value_array_append_value(gobj(), value.gobj());
+  return *this;
+}
+
+Gst::ValueArray& ValueArray::prepend(const Glib::ValueBase& value)
+{
+  gst_value_array_prepend_value(gobj(), value.gobj());
+  return *this;
+}
+
+
+} // Glib namespace
diff --git a/gstreamer/src/valuearray.hg b/gstreamer/src/valuearray.hg
new file mode 100644
index 0000000..3e79282
--- /dev/null
+++ b/gstreamer/src/valuearray.hg
@@ -0,0 +1,73 @@
+/* gstreamermm - a C++ wrapper for gstreamer
+ *
+ * Copyright 2008 The gstreamermm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gst/gst.h>
+#include <gst/gstvalue.h>
+#include <glibmm/value.h>
+#include <glibmm/value_custom.h>
+
+_DEFS(gstreamermm,gst)
+
+namespace Gst
+{
+
+class ValueArray : public Glib::ValueBase
+{
+public:
+  /** Default constructor.
+   */
+  ValueArray();
+
+  /** Get the GType for this class, for use with the underlying GObject type system.
+   */
+  static GType get_type() G_GNUC_CONST;
+
+public:
+
+  /** Gets the number of values contained in the array.
+   *
+   * @return The number of values.
+   */
+  guint size() const;
+  
+  /** Sets @a value to the value is the member of the array
+   * at the index @a index.
+   *
+   * @param index Index of value to get from the array.
+   * @param value The value at the given index.
+   * @return Whether the array contains a value at given index.
+   */
+  bool get(guint index, Glib::ValueBase& value) const;
+
+  /** Appends @a value to the ValueArray.
+   *
+   * @param value The value to append.
+   */
+  Gst::ValueArray& append(const Glib::ValueBase& value);
+
+  /** Prepends @a value to the ValueArray.
+   *
+   * @param value The value to prepend.
+   */
+  Gst::ValueArray& prepend(const Glib::ValueBase& value);
+
+};
+
+} //namespace Gst
+


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]