gnomemm r1315 - in gstreamermm/trunk: . gstreamer/src tests tools/m4



Author: jaalburqu
Date: Wed Jan 30 20:27:36 2008
New Revision: 1315
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1315&view=rev

Log:
2008-01-30  Josà Alburquerque  <jaalburqu svn gnome org>

	* AUTHORS: minor change in Jose's e-mail (added first letter)
	* gstreamer/src/event.ccg:
	* gstreamer/src/message.ccg:
	* gstreamer/src/query.ccg: modified get_structure() methods to
	reference GstStructure
	* gstreamer/src/structure.ccg:
	* gstreamer/src/structure.hg: wrapped size() and clear() methods; used
	Glib::QueryQuark instead GQuark for method parameters; change
	StructureValueProxy to use Glib::ValueBase
	* tests/Makefile.am: added test-structure
	* tests/test-structure.cc: new test for Gst::Structure
	* tools/m4/convert_gst.m4: added conversion from Glib::QueryQuark to
	GQuark


Added:
   gstreamermm/trunk/tests/test-structure.cc
Modified:
   gstreamermm/trunk/AUTHORS
   gstreamermm/trunk/ChangeLog
   gstreamermm/trunk/gstreamer/src/event.ccg
   gstreamermm/trunk/gstreamer/src/message.ccg
   gstreamermm/trunk/gstreamer/src/query.ccg
   gstreamermm/trunk/gstreamer/src/structure.ccg
   gstreamermm/trunk/gstreamer/src/structure.hg
   gstreamermm/trunk/tests/Makefile.am
   gstreamermm/trunk/tools/m4/convert_gst.m4

Modified: gstreamermm/trunk/AUTHORS
==============================================================================
--- gstreamermm/trunk/AUTHORS	(original)
+++ gstreamermm/trunk/AUTHORS	Wed Jan 30 20:27:36 2008
@@ -1,7 +1,7 @@
 Please use the mailing list (gtkmm-list gnome org) instead of emailing
 developers directly.  See the ChangeLog for up-to-date information.
 
-Josà Alburquerque <aalburquerque cox net>
+Josà Alburquerque <jaalburquerque cox net>
 Murray Cumming <murrayc murrayc com>
 Milosz Derezynski <internalerror gmail com>
 Siavash Safi <siavash safi gmail com>

Modified: gstreamermm/trunk/gstreamer/src/event.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/event.ccg	(original)
+++ gstreamermm/trunk/gstreamer/src/event.ccg	Wed Jan 30 20:27:36 2008
@@ -5,7 +5,7 @@
 
 const Structure& Event::get_structure()
 {
-  structure_ = Structure(const_cast<GstStructure*>(gst_event_get_structure(gobj())), false);
+  structure_ = Structure(const_cast<GstStructure*>(gst_event_get_structure(gobj())), true);
   return structure_;
 }
 

Modified: gstreamermm/trunk/gstreamer/src/message.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/message.ccg	(original)
+++ gstreamermm/trunk/gstreamer/src/message.ccg	Wed Jan 30 20:27:36 2008
@@ -4,7 +4,7 @@
 const Structure&
 Message::get_structure()
 {
-  structure_ = Structure(const_cast<GstStructure*>(gst_message_get_structure(gobj())), false);
+  structure_ = Structure(const_cast<GstStructure*>(gst_message_get_structure(gobj())), true);
   return structure_;
 }
 

Modified: gstreamermm/trunk/gstreamer/src/query.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/query.ccg	(original)
+++ gstreamermm/trunk/gstreamer/src/query.ccg	Wed Jan 30 20:27:36 2008
@@ -5,7 +5,7 @@
 
 const Structure& Query::get_structure()
 {
-  structure_ = Structure(const_cast<GstStructure*>(gst_query_get_structure(gobj())), false);
+  structure_ = Structure(const_cast<GstStructure*>(gst_query_get_structure(gobj())), true);
   return structure_;
 }
 

Modified: gstreamermm/trunk/gstreamer/src/structure.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/structure.ccg	(original)
+++ gstreamermm/trunk/gstreamer/src/structure.ccg	Wed Jan 30 20:27:36 2008
@@ -11,31 +11,19 @@
 {
 }
 
-void
-StructureValueProxy::operator=(const Glib::ustring& value)
+void StructureValueProxy::set(const Glib::ValueBase& value)
 {
-  gst_structure_set(m_Structure.gobj(), m_Name.c_str(), G_TYPE_STRING, value.c_str(), NULL);
+  gst_structure_set_value(m_Structure.gobj(), m_Name.c_str(), value.gobj());
 }
 
-void
-StructureValueProxy::operator=(bool value)
+StructureValueProxy&
+StructureValueProxy::operator=(const Glib::ValueBase& value)
 {
-  gst_structure_set(m_Structure.gobj(), m_Name.c_str(), G_TYPE_BOOLEAN, value, NULL);
+  set(value);
+  return *this;
 }
 
-void
-StructureValueProxy::operator=(gdouble value)
-{
-  gst_structure_set(m_Structure.gobj(), m_Name.c_str(), G_TYPE_DOUBLE, value, NULL);
-}
-
-void
-StructureValueProxy::operator=(int value)
-{
-  gst_structure_set(m_Structure.gobj(), m_Name.c_str(), G_TYPE_INT, value, NULL);
-}
-
-void
+StructureValueProxy&
 StructureValueProxy::operator=(const Fraction& value)
 {
   GValue v = {0,};
@@ -43,6 +31,19 @@
   gst_value_set_fraction(&v, value.numerator, value.denominator);
   gst_structure_set_value(m_Structure.gobj(), m_Name.c_str(), &v);
   g_value_unset(&v);
+  return *this;
+}
+
+void StructureValueProxy::get(Glib::ValueBase& value) const
+{
+  const GValue* gval = gst_structure_get_value(m_Structure.gobj(), m_Name.c_str());
+  value.init(gval);
+}
+
+StructureValueProxy::operator bool() {
+  Glib::ValueBase val;
+  get(val);
+  return (G_VALUE_TYPE(val.gobj()) == 0) ? false : true;
 }
 
 // Structure
@@ -66,7 +67,7 @@
   gobject_ = gst_structure_empty_new(name.c_str());
 }
 
-Structure::Structure(GQuark quark)
+Structure::Structure(Glib::QueryQuark quark)
 {
   gobject_ = gst_structure_id_empty_new(quark);
 }
@@ -77,19 +78,6 @@
   return StructureValueProxy(*this, name);
 }
 
-void
-Structure::clear()
-{
-  gst_structure_remove_all_fields(gobject_);
-}
-
-int
-Structure::size() const
-{
-  return gst_structure_n_fields(gobject_);
-}
-
-
 //TODO: ValueBase should be used as an output paramter in getters because it is a base type.
 /*
 Glib::ValueBase

Modified: gstreamermm/trunk/gstreamer/src/structure.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/structure.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/structure.hg	Wed Jan 30 20:27:36 2008
@@ -33,11 +33,11 @@
 public:
   StructureValueProxy(Structure& structure, const Glib::ustring& name);
 
-  void operator=(const Glib::ustring& src);
-  void operator=(bool src);
-  void operator=(double src);
-  void operator=(int src);
-  void operator=(const Fraction& src);
+  void set(const Glib::ValueBase& value);
+  StructureValueProxy& operator=(const Glib::ValueBase& value);
+  StructureValueProxy& operator=(const Fraction& src);
+  void get(Glib::ValueBase& value) const;
+  operator bool();
 
 private:
   Structure& m_Structure;
@@ -54,19 +54,19 @@
 
 public:
   Structure(const Glib::ustring& name);
-  Structure(GQuark quark);
+  Structure(Glib::QueryQuark quark);
   Structure(const GstStructure* castitem); // for Message::get_structure()
 
   StructureValueProxy operator[](const Glib::ustring& fieldname);
 
-  void clear(); // remove_all_fields in C API
-  int size() const;
+  _WRAP_METHOD(int size() const, gst_structure_n_fields)
+  _WRAP_METHOD(void clear(), gst_structure_remove_all_fields)
 
   //TODO: ValueBase should be used as an output paramter in getters because it is a base type.
   //See Gtk::TreeModel, for instance. murrayc.
-  //Glib::ValueBase id_get_value(GQuark field);
+  //Glib::ValueBase id_get_value(Glib::QueryQuark field);
 
-  _WRAP_METHOD(void id_set_value(GQuark field, const Glib::ValueBase& value), gst_structure_id_set_value)
+  _WRAP_METHOD(void id_set_value(Glib::QueryQuark field, const Glib::ValueBase& value), gst_structure_id_set_value)
 
   //TODO: ValueBase should be used as an output paramter in getters because it is a base type.
   //Glib::ValueBase get_value(const Glib::ustring& fieldname) const;
@@ -104,7 +104,7 @@
 
   static Structure create_from_string(const Glib::ustring& the_string);
 
-  _WRAP_METHOD(GQuark get_name_id() const, gst_structure_get_name_id)
+  _WRAP_METHOD(Glib::QueryQuark get_name_id() const, gst_structure_get_name_id)
   _WRAP_METHOD(Glib::ustring get_name() const, gst_structure_get_name)
   _WRAP_METHOD(bool has_name(const Glib::ustring& name) const, gst_structure_has_name)
   _WRAP_METHOD(void set_name(const Glib::ustring& name), gst_structure_set_name)

Modified: gstreamermm/trunk/tests/Makefile.am
==============================================================================
--- gstreamermm/trunk/tests/Makefile.am	(original)
+++ gstreamermm/trunk/tests/Makefile.am	Wed Jan 30 20:27:36 2008
@@ -4,7 +4,8 @@
 
 noinst_PROGRAMS = 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-message-wrap test-event-wrap test-query-wrap \
+		  test-structure
 
 test_create_element_SOURCES=test-create-element.cc
 test_create_element_LDFLAGS= GSTMM_LIBS@
@@ -30,6 +31,9 @@
 test_query_wrap_SOURCES=test-query-wrap.cc
 test_query_wrap_LDFLAGS= GSTMM_LIBS@
 
+test_structure_SOURCES=test-structure.cc
+test_structure_LDFLAGS= GSTMM_LIBS@
+
 #runtestbasic runtestlangs \
 #runtestsearch runtestmimetypes \
 #runtestgetbuffer

Added: gstreamermm/trunk/tests/test-structure.cc
==============================================================================
--- (empty file)
+++ gstreamermm/trunk/tests/test-structure.cc	Wed Jan 30 20:27:36 2008
@@ -0,0 +1,33 @@
+#include <gstreamermm.h>
+#include <iostream>
+
+int main (int argc, char* argv[])
+{
+  Gst::init(argc, argv);
+
+  Glib::ustring fieldName = "field";
+  Glib::RefPtr<Gst::Query> latencyQuery = Gst::QueryLatency::create();
+  Gst::Structure structure = latencyQuery->get_structure();
+
+
+  Glib::Value<Glib::ustring> stringValue;
+  stringValue.init(Glib::Value<Glib::ustring>::value_type());
+  stringValue.set("Hello; This is a ustring.");
+
+  structure[fieldName] = stringValue;
+
+  Gst::StructureValueProxy testProxy = structure[fieldName];
+
+  if (!testProxy) {
+    std::cout << "No field named '" << fieldName << "' found." << std::endl;
+  };
+
+  if (testProxy) {
+    Glib::ValueBase value;
+    testProxy.get(value);
+    std::cout << "Value type id = '" << typeid(value).name() <<
+      "'" << std::endl;
+  };
+
+  return 0;
+}

Modified: gstreamermm/trunk/tools/m4/convert_gst.m4
==============================================================================
--- gstreamermm/trunk/tools/m4/convert_gst.m4	(original)
+++ gstreamermm/trunk/tools/m4/convert_gst.m4	Wed Jan 30 20:27:36 2008
@@ -65,6 +65,7 @@
 _CONVERSION(`QueryType',`GstQueryType',`GstQueryType($3)')
 
 _CONVERSION(`GQuark',`Glib::QueryQuark',`Glib::QueryQuark($3)')
+_CONVERSION(`Glib::QueryQuark',`GQuark',`$3')
 
 _CONV_ENUM(Gst,State)
 _CONV_ENUM(Gst,StateChangeReturn)



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