gnomemm r1324 - in gstreamermm/trunk: . gstreamer/src tests



Author: jaalburqu
Date: Thu Feb  7 03:39:45 2008
New Revision: 1324
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1324&view=rev

Log:
2008-02-06  Josà Alburquerque  <jaalburqu svn gnome org>

	* gstreamer/src/caps.ccg:
	* gstreamer/src/caps.hg: Added create_simple() and set_simple() --
	methods that work with Caps with only one structure; made some minor
	method name changes (may have to be reviewed later)
	* tests/Makefile.am:
	* tests/test-caps.cc: Added Gst::Caps test (still needs to be
	finished)
	* tests/test-structure.cc: Use Glib::Quark in set_field() call as
	example


Added:
   gstreamermm/trunk/tests/test-caps.cc
Modified:
   gstreamermm/trunk/ChangeLog
   gstreamermm/trunk/gstreamer/src/caps.ccg
   gstreamermm/trunk/gstreamer/src/caps.hg
   gstreamermm/trunk/tests/Makefile.am
   gstreamermm/trunk/tests/test-structure.cc

Modified: gstreamermm/trunk/gstreamer/src/caps.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/caps.ccg	(original)
+++ gstreamermm/trunk/gstreamer/src/caps.ccg	Thu Feb  7 03:39:45 2008
@@ -7,20 +7,53 @@
 Glib::RefPtr<Caps>
 Caps::create()
 {
-  return Glib::wrap(gst_caps_new_empty(), false);
+  return Glib::wrap(gst_caps_new_empty());
 }
 
 Glib::RefPtr<Caps>
 Caps::create_any()
 {
-  return Glib::wrap(gst_caps_new_any(), false);
+  return Glib::wrap(gst_caps_new_any());
+}
+
+/*
+  This method is implemented because gst_caps_new_simple is a variable argument
+  function and cannot be wrapped.  In addition, because gst_caps_new_simple
+  creates a GstStructure for the GstCaps and will not be called, we must create
+  our own GstStructure here and append it to the GstCaps.
+*/
+Glib::RefPtr<Caps>
+Caps::create_simple(const Glib::ustring& media_type)
+{
+  Glib::RefPtr<Caps> result = Glib::wrap(gst_caps_new_empty());
+  GstStructure* gst_struct = gst_structure_empty_new(media_type.c_str());
+  gst_caps_append_structure(result->gobj(), gst_struct);
+  return result;
 }
 
 Glib::RefPtr<Caps>
 Caps::create_full(Structure& structure)
 {
-  return Glib::wrap(gst_caps_new_full(structure.gobj()), false);
+  return Glib::wrap(gst_caps_new_full(structure.gobj()));
 }
 
+/*
+  This method is implemented because gst_caps_set_simple is a variable argument
+  function and cannot be wrapped.  In addition, in order for
+  gst_caps_set_simple to work, this Caps must be "simple", ie, it must only
+  have one GstStructure (gst_caps_set_simple checks for this).  Here we must
+  set the field in the Structure ourselves so we must check for only one
+  Structure ourselves also (because we wont be calling gst_caps_set_simple)
+*/
+//Glib::RefPtr<Caps>
+void
+Caps::set_simple(const Glib::ustring& name, const Glib::ValueBase& value)
+{
+  //g_return_val_if_fail((gobj()->structs->len == 1), Glib::RefPtr<Caps>());
+  g_return_if_fail((gobj()->structs->len == 1));
+  gst_structure_set_value(gst_caps_get_structure(gobj(), 0), name.c_str(), value.gobj());
+
+  //return Glib::wrap(gobj(), true);
+}
 
 } //namespace Gst

Modified: gstreamermm/trunk/gstreamer/src/caps.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/caps.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/caps.hg	Thu Feb  7 03:39:45 2008
@@ -15,10 +15,12 @@
   //TODO: Why doesn't this use _WRAP_CREATE()?
   static Glib::RefPtr<Caps> create();
   static Glib::RefPtr<Caps> create_any();
+  static Glib::RefPtr<Caps> create_simple(const Glib::ustring& media_type);
+
+  //TODO: Parameter should be a list of Structures
   static Glib::RefPtr<Caps> create_full(Structure&);
 
   _WRAP_METHOD(Glib::RefPtr<Caps> copy() const, gst_caps_copy)
-
   _WRAP_METHOD(Glib::RefPtr<Caps> copy_nth(guint), gst_caps_copy_nth)
   _WRAP_METHOD(void append(const Glib::RefPtr<Caps>& caps), gst_caps_append)
   _WRAP_METHOD(void merge(const Glib::RefPtr<Caps>& caps), gst_caps_merge)
@@ -30,20 +32,29 @@
   _WRAP_METHOD(void remove_structure(guint idx), gst_caps_remove_structure)
   _WRAP_METHOD(guint get_size() const, gst_caps_get_size)
 
+  //TODO: Want to return RefPtr to Caps but using RefPtr in expressions such
+  //TODO: as 'caps->set_simple(name1, value1)->set_simple(name2, value2)' a
+  //TODO: causes Structure immutability warnings because the Caps is referenced
+  //TODO: more than once in the expression
+  void set_simple(const Glib::ustring& name, const Glib::ValueBase& value);
+
+  //TODO: Is this method useful? -Jose
   _WRAP_METHOD(void set_simple_valist(char* field, const va_list& varargs), gst_caps_set_simple_valist)
+
   _WRAP_METHOD(bool is_any() const, gst_caps_is_any)
-  _WRAP_METHOD(bool is_empty() const, gst_caps_is_empty)
-  _WRAP_METHOD(bool is_fixed() const, gst_caps_is_fixed)
-  _WRAP_METHOD(bool is_equal(const Glib::RefPtr<Caps>& other_caps) const, gst_caps_is_equal)
-  _WRAP_METHOD(bool is_equal_fixed(const Glib::RefPtr<Caps>& other_caps) const, gst_caps_is_equal_fixed)
-  _WRAP_METHOD(bool is_always_compatible(const Glib::RefPtr<Caps>& other_caps) const, gst_caps_is_always_compatible)
-  _WRAP_METHOD(bool is_subset(const Glib::RefPtr<Caps>& superset_caps) const, gst_caps_is_subset)
+  _WRAP_METHOD(bool empty() const, gst_caps_is_empty)
+  _WRAP_METHOD(bool fixed() const, gst_caps_is_fixed)
+  _WRAP_METHOD(bool equals(const Glib::RefPtr<Caps>& other_caps) const, gst_caps_is_equal)
+  _WRAP_METHOD(bool equals_fixed(const Glib::RefPtr<Caps>& other_caps) const, gst_caps_is_equal_fixed)
+  _WRAP_METHOD(bool always_compatible(const Glib::RefPtr<Caps>& other_caps) const, gst_caps_is_always_compatible)
+  _WRAP_METHOD(bool subset(const Glib::RefPtr<Caps>& superset_caps) const, gst_caps_is_subset)
   _WRAP_METHOD(Glib::RefPtr<Caps> intersect(const Glib::RefPtr<Caps>& other_caps) const, gst_caps_intersect)
+  //Not named union because it is a C++ keyword
   _WRAP_METHOD(Glib::RefPtr<Caps> unions(const Glib::RefPtr<Caps>& other_caps) const, gst_caps_union)
   _WRAP_METHOD(Glib::RefPtr<Caps> normalize(), gst_caps_normalize)
-  _WRAP_METHOD(bool do_simplify(), gst_caps_do_simplify)
-  _WRAP_METHOD(xmlNodePtr save_thyself(const xmlNodePtr& parent), gst_caps_save_thyself)
-  _WRAP_METHOD(static Glib::RefPtr<Caps> load_thyself(xmlNodePtr parent), gst_caps_load_thyself)
+  _WRAP_METHOD(bool simplify(), gst_caps_do_simplify)
+  _WRAP_METHOD(xmlNodePtr save(const xmlNodePtr& parent), gst_caps_save_thyself)
+  _WRAP_METHOD(static Glib::RefPtr<Caps> load(xmlNodePtr parent), gst_caps_load_thyself)
 
   _WRAP_METHOD(Glib::ustring to_string() const, gst_caps_to_string)
 

Modified: gstreamermm/trunk/tests/Makefile.am
==============================================================================
--- gstreamermm/trunk/tests/Makefile.am	(original)
+++ gstreamermm/trunk/tests/Makefile.am	Thu Feb  7 03:39:45 2008
@@ -2,11 +2,14 @@
 
 LDADD=$(top_builddir)/gstreamer/gstreamermm/libgstreamermm-0.10.la
 
-noinst_PROGRAMS = test-create-element test-pipeline-add-element \
+noinst_PROGRAMS = test-caps test-create-element test-pipeline-add-element \
                   test-link-elements test-create-bin test-miniobject-wrap \
                   test-message-wrap test-event-wrap test-query-wrap \
 		  test-structure
 
+test_caps_SOURCES=test-caps.cc
+test_caps_LDFLAGS= GSTREAMERMM_LIBS@
+
 test_create_element_SOURCES=test-create-element.cc
 test_create_element_LDFLAGS= GSTREAMERMM_LIBS@
 

Added: gstreamermm/trunk/tests/test-caps.cc
==============================================================================
--- (empty file)
+++ gstreamermm/trunk/tests/test-caps.cc	Thu Feb  7 03:39:45 2008
@@ -0,0 +1,24 @@
+#include <gstreamermm.h>
+#include <iostream>
+
+int main (int argc, char* argv[])
+{
+  Gst::init(argc, argv);
+
+  Glib::RefPtr<Gst::Caps> caps = Gst::Caps::create_simple("video/x-raw-yuv");
+ 
+  //caps->set_simple("width", Glib::Value<int>(384));
+  //caps->set_simple("height", Glib::Value<int>(288));
+
+  Glib::Value<int> width, height;
+  width.init(G_TYPE_INT);
+  width.set(384);
+
+  height.init(G_TYPE_INT);
+  height.set(288);
+
+  caps->set_simple("width", width);
+  caps->set_simple("height", height);
+
+  return 0;
+}

Modified: gstreamermm/trunk/tests/test-structure.cc
==============================================================================
--- gstreamermm/trunk/tests/test-structure.cc	(original)
+++ gstreamermm/trunk/tests/test-structure.cc	Thu Feb  7 03:39:45 2008
@@ -12,7 +12,7 @@
   stringValue.init(Glib::Value<Glib::ustring>::value_type());
   stringValue.set("Hello; This is a ustring.");
 
-  structure.set_field("string", stringValue);
+  structure.set_field(Glib::Quark("string"), stringValue);
 
   Glib::Value<Glib::ustring> value;
   structure.get_field("string", value);



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