[gstreamermm] Gst::Caps: fixed transfer-full parameters passing in a few methods
- From: Marcin Kolny <mkolny src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gstreamermm] Gst::Caps: fixed transfer-full parameters passing in a few methods
- Date: Fri, 14 Nov 2014 14:01:20 +0000 (UTC)
commit 5fbc721ad93f0ae454695c29164f57ed65817330
Author: Marcin Kolny <marcin kolny flytronic pl>
Date: Fri Nov 14 14:57:14 2014 +0100
Gst::Caps: fixed transfer-full parameters passing in a few methods
* gstreamer/src/caps.{ccg|hg}: added handcrafted implementation of
gst_caps_merge and gst_caps_append wrappers because of transfer-full
parameters in this methods.
* tests/test-caps.cc: added test for merge method, which checks
reference count of objects, checking reference count in append test
method.
gstreamer/src/caps.ccg | 17 +++++++++++++++++
gstreamer/src/caps.hg | 22 ++++++++++++++++++++--
tests/test-caps.cc | 10 ++++++++++
3 files changed, 47 insertions(+), 2 deletions(-)
---
diff --git a/gstreamer/src/caps.ccg b/gstreamer/src/caps.ccg
index f50cbc7..eef5a72 100644
--- a/gstreamer/src/caps.ccg
+++ b/gstreamer/src/caps.ccg
@@ -111,4 +111,21 @@ Caps::set_simple(const Glib::ustring& name, const char* data)
set_simple(name, std::string(data));
}
+Glib::RefPtr<Gst::Caps> Caps::merge(Glib::RefPtr<Gst::Caps>& caps)
+{
+ GstCaps *c1 = gobj(), *c2 = Glib::unwrap(caps);
+ caps->reference(); caps.reset();
+ reference();
+ return Glib::wrap(gst_caps_merge(c1, c2));
+}
+
+void Caps::append(Glib::RefPtr<Gst::Caps>& caps)
+{
+ caps->reference();
+ GstCaps *c_caps = Glib::unwrap(caps);
+ caps.reset();
+ gst_caps_append(gobj(), c_caps);
+}
+
+
} //namespace Gst
diff --git a/gstreamer/src/caps.hg b/gstreamer/src/caps.hg
index 1b3a5a6..80477c3 100644
--- a/gstreamer/src/caps.hg
+++ b/gstreamer/src/caps.hg
@@ -95,8 +95,26 @@ public:
Glib::RefPtr<Gst::Caps> copy() const;
_WRAP_METHOD(Glib::RefPtr<Gst::Caps> copy_nth(guint nth) const, gst_caps_copy_nth)
- _WRAP_METHOD(void append(const Glib::RefPtr<Gst::Caps>& caps), gst_caps_append)
- _WRAP_METHOD(Glib::RefPtr<Gst::Caps> merge(const Glib::RefPtr<Gst::Caps>& caps), gst_caps_merge)
+
+ /** Appends the structures contained in @a caps to this object. The structures in
+ * @a caps are not copied -- they are transferred to this object, and then @a caps is
+ * freed. If either caps is ANY, the resulting caps will be ANY.
+ *
+ * @param caps The Gst::Caps to append.
+ */
+ void append(Glib::RefPtr<Gst::Caps>& caps);
+ _IGNORE(gst_caps_append)
+
+ /** Appends the structures contained in @a caps to an object if they are not yet
+ * expressed by this object. The structures in @a caps are not copied -- they are
+ * transferred to a writable copy of this object, and then @a caps is freed.
+ * If either caps is ANY, the resulting caps will be ANY.
+ *
+ * @param caps The Gst::Caps to merge in.
+ * @return The merged caps.
+ */
+ Glib::RefPtr<Gst::Caps> merge(Glib::RefPtr<Gst::Caps>& caps);
+ _IGNORE(gst_caps_merge)
/** Appends a structure to caps.
*
diff --git a/tests/test-caps.cc b/tests/test-caps.cc
index 9197a6d..f3bed1d 100644
--- a/tests/test-caps.cc
+++ b/tests/test-caps.cc
@@ -88,6 +88,7 @@ TEST_F(CapsTest, AppendCapsToCaps)
CheckCaps("width", width, 1);
CheckCaps("framerate", framerate);
+ ASSERT_FALSE(new_caps);
}
TEST_F(CapsTest, GetNonExistingValue)
@@ -111,3 +112,12 @@ TEST_F(CapsTest, SetCapsToElement)
ASSERT_STREQ(str_caps, caps->to_string().c_str());
}
+
+TEST_F(CapsTest, MergeCaps)
+{
+ Glib::RefPtr<Caps> tmp = Caps::create_from_string("video/x-raw, format=RGBA");
+ Glib::RefPtr<Caps> tmp2 = Caps::create_from_string("video/x-raw, format=RGB");
+ tmp = tmp->merge(tmp2);
+ ASSERT_EQ(1, tmp->get_refcount());
+ ASSERT_FALSE(tmp2);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]