[gstreamermm] Gst::CapsFeatures: improve construction methods
- From: Marcin Kolny <mkolny src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gstreamermm] Gst::CapsFeatures: improve construction methods
- Date: Thu, 27 Aug 2015 19:03:44 +0000 (UTC)
commit 49b4652de040fb437881ea8087e3bddfe08efb2e
Author: Marcin Kolny <marcin kolny gmail com>
Date: Thu Aug 27 17:39:30 2015 +0000
Gst::CapsFeatures: improve construction methods
* gstreamer/src/capsfeatures.{ccg|hg}: wrap create_any() and
create_from_string() using _WRAP_METHOD macro, use
std::initializer_list in constructor. Also comment for
Gst::CapsFeatures class has been added.
* gstreamer/src/gst_extra_object.defs: add CapsFeatures to
extra-objects list.
* tests/test-capsfeatures.cc: build fix test.
* tools/m4/convert_gst.m4: add conversion definition
(GstCapsFeatures* -> Gst::CapsFeatures).
gstreamer/src/capsfeatures.ccg | 25 +++++----------
gstreamer/src/capsfeatures.hg | 55 +++++++++++++++++++++------------
gstreamer/src/gst_extra_objects.defs | 6 ++++
tests/test-capsfeatures.cc | 2 +-
tools/m4/convert_gst.m4 | 1 +
5 files changed, 51 insertions(+), 38 deletions(-)
---
diff --git a/gstreamer/src/capsfeatures.ccg b/gstreamer/src/capsfeatures.ccg
index b79193f..d3df7cc 100644
--- a/gstreamer/src/capsfeatures.ccg
+++ b/gstreamer/src/capsfeatures.ccg
@@ -21,27 +21,18 @@
namespace Gst
{
-
-CapsFeatures::CapsFeatures()
+CapsFeatures::CapsFeatures(std::initializer_list<Glib::ustring> features)
+ : CapsFeatures()
{
- gobject_ = gst_caps_features_new_empty();
+ for (auto feature : features)
+ {
+ gst_caps_features_add(gobject_, feature.c_str());
+ }
}
-CapsFeatures::CapsFeatures(const Glib::ustring& feature1)
+Glib::ustring CapsFeatures::memory_system_memory()
{
- gobject_ = gst_caps_features_new(feature1.c_str(), nullptr);
+ return GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY;
}
-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
index 279c4dc..aea72dc 100644
--- a/gstreamer/src/capsfeatures.hg
+++ b/gstreamer/src/capsfeatures.hg
@@ -24,41 +24,52 @@ _DEFS(gstreamermm,gst)
namespace Gst
{
+/**
+ * A set of features in caps
+ *
+ * Gst::CapsFeatures can optionally be set on a Gst::Caps to add requirements
+ * for additional features for a specific Gst::Structure. Caps structures with
+ * the same name but with a non-equal set of caps features are not compatible.
+ * If a pad supports multiple sets of features it has to add multiple equal
+ * structures with different feature sets to the caps.
+ *
+ * Empty Gst::CapsFeatures are equivalent with the Gst::CapsFeatures that only
+ * contain Gst::CapsFeatures::memory_system_memory(). ANY Gst::CapsFeatures as
+ * created by Gst::CapsFeatures::create_any() are equal to any other Gst::CapsFeatures
+ * and can be used to specify that any Gst::CapsFeatures would be supported, e.g.
+ * for elements that don't touch buffer memory. Gst::Caps with ANY Gst::CapsFeatures
+ * are considered non-fixed and during negotiation some Gst::CapsFeatures have
+ * to be selected.
+ *
+ * Examples for caps features would be the requirement of a specific Gst::Memory
+ * types or the requirement of having a specific Gst::Meta on the buffer. Features
+ * are given as a string of the format "memory:GstMemoryTypeName" or
+ * "meta:GstMetaAPIName".
+ *
+ * Since: 1.2
+ */
class CapsFeatures
{
- _CLASS_BOXEDTYPE(CapsFeatures, GstCapsFeatures, NONE, gst_caps_features_copy, gst_caps_features_free)
+ _CLASS_BOXEDTYPE(CapsFeatures, GstCapsFeatures, gst_caps_features_new_empty, 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_new_empty)
_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.
+ * Creates a new Gst::CapsFeatures with the given features.
*
- * @param feature1 name of first feature to set.
+ * @param features name of features to set.
*/
- explicit CapsFeatures(const Glib::ustring& feature1);
+ explicit CapsFeatures(std::initializer_list<Glib::ustring> features);
- /**
- * 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)
+ _WRAP_METHOD(static Gst::CapsFeatures create_any(), gst_caps_features_new_any)
- static CapsFeatures create_from_string(const Glib::ustring& features);
- _IGNORE(gst_caps_features_from_string)
+ _WRAP_METHOD(static Gst::CapsFeatures create_from_string(const Glib::ustring& features),
gst_caps_features_from_string)
_WRAP_METHOD(Glib::ustring to_string() const, gst_caps_features_to_string)
@@ -85,6 +96,10 @@ public:
_WRAP_METHOD(void remove(const Glib::ustring& feature), gst_caps_features_remove)
_WRAP_METHOD(void remove(GQuark feature), gst_caps_features_remove_id)
+
+ /** Constant for system memory feature name.
+ */
+ static Glib::ustring memory_system_memory();
};
}
diff --git a/gstreamer/src/gst_extra_objects.defs b/gstreamer/src/gst_extra_objects.defs
index 8a32fec..667c35c 100644
--- a/gstreamer/src/gst_extra_objects.defs
+++ b/gstreamer/src/gst_extra_objects.defs
@@ -29,6 +29,12 @@
(gtype-id "GST_TYPE_CAPS")
)
+(define-object CapsFeatures
+ (in-module "Gst")
+ (c-name "GstCapsFeatures")
+ (gtype-id "GST_TYPE_CAPS_FEATURES")
+)
+
(define-object Iterator
(in-module "Gst")
(c-name "GstIterator")
diff --git a/tests/test-capsfeatures.cc b/tests/test-capsfeatures.cc
index ac8af40..12b7d69 100644
--- a/tests/test-capsfeatures.cc
+++ b/tests/test-capsfeatures.cc
@@ -18,7 +18,7 @@ TEST(CapsFeaturesTest, ShouldCorrectCreateEmptyFeature)
TEST(CapsFeaturesTest, AddRemoveFeaturesShouldWorkProperly)
{
- CapsFeatures features (GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY);
+ CapsFeatures features {GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY};
ASSERT_EQ(1u, 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);
diff --git a/tools/m4/convert_gst.m4 b/tools/m4/convert_gst.m4
index 175a524..c0530a3 100644
--- a/tools/m4/convert_gst.m4
+++ b/tools/m4/convert_gst.m4
@@ -123,6 +123,7 @@ _CONVERSION(`Glib::RefPtr<Gst::Caps>&&',`GstCaps*',`($3) ? $3.release()->gobj()
dnl CapsFeatures
_CONVERSION(`const Gst::CapsFeatures&',`const GstCapsFeatures*',`$3.gobj()')
+_CONVERSION(`GstCapsFeatures*',`Gst::CapsFeatures',`CapsFeatures($3, false)')
dnl Clock
_CONVERSION(`GstClock*',`Glib::RefPtr<Gst::Clock>',`Glib::wrap($3)')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]