[gstreamermm] Gst::CapsFeatures: wrapped GstCapsFeatures boxed structure
- From: Marcin Kolny <mkolny src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gstreamermm] Gst::CapsFeatures: wrapped GstCapsFeatures boxed structure
- Date: Fri, 21 Nov 2014 13:10:59 +0000 (UTC)
commit 5564a4463a04de681b93b7c0cf87e5d2cfe21c80
Author: Marcin Kolny <marcin kolny flytronic pl>
Date: Fri Nov 21 13:26:02 2014 +0100
Gst::CapsFeatures: wrapped GstCapsFeatures boxed structure
* .gitignore: added capsfeatures generated files.
* gstreamer/gstreamermm.h: added capsfeatures header to main header
file.
* gstreamer/src/capsfeatures.{ccg|hg}: implementation of
GstCapsFeatures wrapper.
* gstreamer/src/filelist.hg: added new wrapper to a build file list.
* tests/Makefile.am: added capsfeatures class test file to a testfile
list.
* tests/test-capsfeatures.cc: added a few simple capsfeatures tests.
* tools/m4/convert_gst.m4: added conversions between GstCapsFeatures
and its wrapper.
.gitignore | 3 +
gstreamer/gstreamermm.h | 1 +
gstreamer/src/capsfeatures.ccg | 47 +++++++++++++++++++++
gstreamer/src/capsfeatures.hg | 90 ++++++++++++++++++++++++++++++++++++++++
gstreamer/src/filelist.am | 3 +-
tests/Makefile.am | 2 +
tests/test-capsfeatures.cc | 28 ++++++++++++
tools/m4/convert_gst.m4 | 3 +
8 files changed, 176 insertions(+), 1 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index b9c09b9..de26be5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -76,6 +76,8 @@ gstreamer/gstreamermm/bus.cc
gstreamer/gstreamermm/bus.h
gstreamer/gstreamermm/caps.cc
gstreamer/gstreamermm/caps.h
+gstreamer/gstreamermm/capsfeatures.cc
+gstreamer/gstreamermm/capsfeatures.h
gstreamer/gstreamermm/cddabasesrc.cc
gstreamer/gstreamermm/cddabasesrc.h
gstreamer/gstreamermm/childproxy.cc
@@ -488,6 +490,7 @@ tests/test-bin
tests/test-buffer
tests/test-bus
tests/test-caps
+tests/test-capsfeatures
tests/test-ghostpad
tests/test-init
tests/test-miniobject
diff --git a/gstreamer/gstreamermm.h b/gstreamer/gstreamermm.h
index 84b3b71..03819b8 100644
--- a/gstreamer/gstreamermm.h
+++ b/gstreamer/gstreamermm.h
@@ -71,6 +71,7 @@
#include <gstreamermm/bufferlist.h>
#include <gstreamermm/bus.h>
#include <gstreamermm/caps.h>
+#include <gstreamermm/capsfeatures.h>
#include <gstreamermm/childproxy.h>
#include <gstreamermm/clock.h>
#include <gstreamermm/context.h>
diff --git a/gstreamer/src/capsfeatures.ccg b/gstreamer/src/capsfeatures.ccg
new file mode 100644
index 0000000..0a2fccc
--- /dev/null
+++ b/gstreamer/src/capsfeatures.ccg
@@ -0,0 +1,47 @@
+/* gstreamermm - a C++ wrapper for gstreamer
+ *
+ * Copyright 2014 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 <gstreamermm/capsfeatures.h>
+
+namespace Gst
+{
+
+CapsFeatures::CapsFeatures()
+{
+ gobject_ = gst_caps_features_new_empty();
+}
+
+CapsFeatures::CapsFeatures(const Glib::ustring& feature1)
+{
+ gobject_ = gst_caps_features_new(feature1.c_str(), NULL);
+}
+
+CapsFeatures CapsFeatures::create_any()
+{
+ return CapsFeatures(gst_caps_features_new_any(), false);
+}
+
+
+CapsFeatures CapsFeatures::create_from_string(const Glib::ustring& features)
+{
+ return CapsFeatures(gst_caps_features_from_string(features.c_str()), false);
+}
+
+
+}
diff --git a/gstreamer/src/capsfeatures.hg b/gstreamer/src/capsfeatures.hg
new file mode 100644
index 0000000..279c4dc
--- /dev/null
+++ b/gstreamer/src/capsfeatures.hg
@@ -0,0 +1,90 @@
+/* gstreamermm - a C++ wrapper for gstreamer
+ *
+ * Copyright 2014 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>
+
+_DEFS(gstreamermm,gst)
+
+namespace Gst
+{
+
+class CapsFeatures
+{
+ _CLASS_BOXEDTYPE(CapsFeatures, GstCapsFeatures, NONE, gst_caps_features_copy, gst_caps_features_free)
+
+
+ _IGNORE(gst_caps_features_new_id_valist)
+ _IGNORE(gst_caps_features_new_valist)
+ _IGNORE(gst_caps_features_copy)
+ _IGNORE(gst_caps_features_free)
+
+public:
+ _CUSTOM_DEFAULT_CTOR
+
+ /**
+ * Creates a new, empty Gst::CapsFeatures.
+ */
+ CapsFeatures();
+ _IGNORE(gst_caps_features_new_empty)
+
+ /**
+ * Creates a new Gst::CapsFeatures with the given first feature.
+ *
+ * @param feature1 name of first feature to set.
+ */
+ explicit CapsFeatures(const Glib::ustring& feature1);
+
+ /**
+ * Creates a new, ANY Gst::CapsFeatures. This will be equal to any other
+ * Gst::CapsFeatures but caps with these are unfixed.
+ */
+ static CapsFeatures create_any();
+ _IGNORE(gst_caps_features_new_any)
+
+ static CapsFeatures create_from_string(const Glib::ustring& features);
+ _IGNORE(gst_caps_features_from_string)
+
+ _WRAP_METHOD(Glib::ustring to_string() const, gst_caps_features_to_string)
+
+ _WRAP_METHOD(bool set_parent_refcount(gint *refcount), gst_caps_features_set_parent_refcount)
+
+ _WRAP_METHOD(bool is_equal(const Gst::CapsFeatures& features2) const, gst_caps_features_is_equal)
+
+ _WRAP_METHOD(bool is_any() const, gst_caps_features_is_any)
+
+ _WRAP_METHOD(bool contains(const Glib::ustring& feature) const, gst_caps_features_contains)
+
+ _WRAP_METHOD(bool contains(GQuark feature) const, gst_caps_features_contains_id)
+
+ _WRAP_METHOD(guint get_size() const, gst_caps_features_get_size)
+
+ _WRAP_METHOD(Glib::ustring get_nth(guint i) const, gst_caps_features_get_nth)
+
+ _WRAP_METHOD(GQuark get_nth_id(guint i) const, gst_caps_features_get_nth_id)
+
+ _WRAP_METHOD(void add(const Glib::ustring& feature), gst_caps_features_add)
+
+ _WRAP_METHOD(void add(GQuark feature), gst_caps_features_add_id)
+
+ _WRAP_METHOD(void remove(const Glib::ustring& feature), gst_caps_features_remove)
+
+ _WRAP_METHOD(void remove(GQuark feature), gst_caps_features_remove_id)
+};
+
+}
diff --git a/gstreamer/src/filelist.am b/gstreamer/src/filelist.am
index 471fdc2..a953cfe 100644
--- a/gstreamer/src/filelist.am
+++ b/gstreamer/src/filelist.am
@@ -49,7 +49,7 @@ plugins_hg = \
giostreamsink.hg \
giostreamsrc.hg \
identity.hg \
- inputselector.hg \
+ inputselector.hg \
multiqueue.hg \
multisocketsink.hg \
oggdemux.hg \
@@ -103,6 +103,7 @@ files_hg = \
bufferlist.hg \
bus.hg \
caps.hg \
+ capsfeatures.hg \
childproxy.hg \
clock.hg \
context.hg \
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 33a442f..87cb244 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -22,6 +22,7 @@ LDADD = $(GSTREAMERMM_LIBS) $(local_libgstreamermm) -lgtest -lpthread
check_PROGRAMS = test-caps test-buffer test-bus test-caps test-pad \
test-allocator test-atomicqueue test-bin \
+ test-capsfeatures \
test-urihandler test-ghostpad test-init test-miniobject \
test-query test-structure test-taglist test-plugin-appsink \
test-plugin-appsrc test-plugin-register test-plugin-pushsrc \
@@ -39,6 +40,7 @@ test_allocator_SOURCES = test-allocator.cc $(TEST_MAIN_SOURCE)
test_atomicqueue_SOURCES = test-atomicqueue.cc $(TEST_MAIN_SOURCE)
test_bin_SOURCES = test-bin.cc $(TEST_MAIN_SOURCE)
test_caps_SOURCES = test-caps.cc $(TEST_MAIN_SOURCE)
+test_capsfeatures_SOURCES = test-capsfeatures.cc $(TEST_MAIN_SOURCE)
test_buffer_SOURCES = test-buffer.cc $(TEST_MAIN_SOURCE)
test_bus_SOURCES = test-bus.cc $(TEST_MAIN_SOURCE)
test_ghostpad_SOURCES = test-ghostpad.cc $(TEST_MAIN_SOURCE)
diff --git a/tests/test-capsfeatures.cc b/tests/test-capsfeatures.cc
new file mode 100644
index 0000000..5e14aa1
--- /dev/null
+++ b/tests/test-capsfeatures.cc
@@ -0,0 +1,28 @@
+/*
+ * test-capsfeatures.cc
+ *
+ * Created on: Nov 21, 2014
+ * Author: mkolny
+ */
+
+#include <gtest/gtest.h>
+#include <gstreamermm.h>
+
+using namespace Gst;
+
+TEST(CapsFeaturesTest, ShouldCorrectCreateEmptyFeature)
+{
+ CapsFeatures features;
+ ASSERT_EQ(0, features.get_size());
+}
+
+TEST(CapsFeaturesTest, AddRemoveFeaturesShouldWorkProperly)
+{
+ CapsFeatures features (GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY);
+ ASSERT_EQ(1, features.get_size());
+ ASSERT_STREQ(GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY, features.get_nth(0).c_str());
+ features.remove(GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY);
+ ASSERT_EQ(0, features.get_size());
+}
+
+
diff --git a/tools/m4/convert_gst.m4 b/tools/m4/convert_gst.m4
index c958dfd..01eaa66 100644
--- a/tools/m4/convert_gst.m4
+++ b/tools/m4/convert_gst.m4
@@ -93,6 +93,9 @@ _CONVERSION(`const Glib::RefPtr<const Gst::Caps>&',`GstCaps*', `const_cast<$2>(G
_CONVERSION(`const Glib::RefPtr<Gst::Caps>&',`const GstCaps*', `Glib::unwrap($3)')
_CONVERSION(`const Glib::RefPtr<const Gst::Caps>&',`const GstCaps*', `Glib::unwrap($3)')
+dnl CapsFeatures
+_CONVERSION(`const Gst::CapsFeatures&',`const GstCapsFeatures*',`$3.gobj()')
+
dnl Clock
_CONVERSION(`GstClock*',`Glib::RefPtr<Gst::Clock>',`Glib::wrap($3)')
_CONVERSION(`GstClock*',`Glib::RefPtr<const Gst::Clock>',`Glib::wrap($3)')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]