gnomemm r1316 - in gstreamermm/trunk: . examples/ogg_player gstreamer/src tests tools/m4



Author: jaalburqu
Date: Fri Feb  1 21:46:42 2008
New Revision: 1316
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1316&view=rev

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

	* examples/ogg_player/main.cc: Allow any number of args, but only
	process first one
	* gstreamer/src/Makefile_list_of_hg.am_fragment: Added value.hg
	* gstreamer/src/event.ccg:
	* gstreamer/src/event.hg:
	* gstreamer/src/message.ccg:
	* gstreamer/src/query.ccg:
	* gstreamer/src/query.hg: Removed bool argument for Gst::Structure
	constructor in get_structure() methods; Fixed whitespace
	* gstreamer/src/structure.ccg:
	* gstreamer/src/structure.hg: Removed StructureValueProxy, assignment
	operator and Fraction definition; Changed most getters to use
	Glib::ValueBase as output parameter
	* gstreamer/src/value.ccg:
	* gstreamer/src/value.hg: Added GstValue (place Fraction definition
	here)
	* tests/test-structure.cc: Modified test to not use Gst::Structure
	assignment operator
	* tools/m4/convert_gst.m4: Changed `Glib::QueryQuark' conversion to
	`const Glib::QueryQuark&'


Added:
   gstreamermm/trunk/gstreamer/src/value.ccg
   gstreamermm/trunk/gstreamer/src/value.hg
Modified:
   gstreamermm/trunk/ChangeLog
   gstreamermm/trunk/examples/ogg_player/main.cc
   gstreamermm/trunk/gstreamer/src/Makefile_list_of_hg.am_fragment
   gstreamermm/trunk/gstreamer/src/event.ccg
   gstreamermm/trunk/gstreamer/src/event.hg
   gstreamermm/trunk/gstreamer/src/message.ccg
   gstreamermm/trunk/gstreamer/src/query.ccg
   gstreamermm/trunk/gstreamer/src/query.hg
   gstreamermm/trunk/gstreamer/src/structure.ccg
   gstreamermm/trunk/gstreamer/src/structure.hg
   gstreamermm/trunk/tests/test-structure.cc
   gstreamermm/trunk/tools/m4/convert_gst.m4

Modified: gstreamermm/trunk/examples/ogg_player/main.cc
==============================================================================
--- gstreamermm/trunk/examples/ogg_player/main.cc	(original)
+++ gstreamermm/trunk/examples/ogg_player/main.cc	Fri Feb  1 21:46:42 2008
@@ -85,7 +85,7 @@
 int main(int argc, char* argv[])
 {
   // check input arguments
-  if (argc != 2)
+  if (argc < 2)
   {
     std::cout << "Usage: " << argv[0] << " <Ogg/Vorbis filename>" << std::endl;
     return -1;

Modified: gstreamermm/trunk/gstreamer/src/Makefile_list_of_hg.am_fragment
==============================================================================
--- gstreamermm/trunk/gstreamer/src/Makefile_list_of_hg.am_fragment	(original)
+++ gstreamermm/trunk/gstreamer/src/Makefile_list_of_hg.am_fragment	Fri Feb  1 21:46:42 2008
@@ -7,7 +7,7 @@
 files_general_hg = bin.hg bus.hg caps.hg clock.hg element.hg enums.hg \
         error.hg event.hg format.hg iterator.hg message.hg pad.hg \
         padtemplate.hg pipeline.hg query.hg structure.hg systemclock.hg \
-        xml.hg
+        value.hg xml.hg
 
 files_general_deprecated_hg =
 

Modified: gstreamermm/trunk/gstreamer/src/event.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/event.ccg	(original)
+++ gstreamermm/trunk/gstreamer/src/event.ccg	Fri Feb  1 21:46:42 2008
@@ -5,7 +5,7 @@
 
 const Structure& Event::get_structure()
 {
-  structure_ = Structure(const_cast<GstStructure*>(gst_event_get_structure(gobj())), true);
+  structure_ = Structure(const_cast<GstStructure*>(gst_event_get_structure(gobj())));
   return structure_;
 }
 
@@ -239,9 +239,3 @@
 }
 
 } //namespace Gst
-#include <gst/gstevent.h>
-
-namespace Gst
-{
-
-} //namesapce Gst

Modified: gstreamermm/trunk/gstreamer/src/event.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/event.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/event.hg	Fri Feb  1 21:46:42 2008
@@ -130,4 +130,4 @@
   //TODO: void parse(TagList& taglist);
 };
 
-}//namespace Gst
+} //namespace Gst

Modified: gstreamermm/trunk/gstreamer/src/message.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/message.ccg	(original)
+++ gstreamermm/trunk/gstreamer/src/message.ccg	Fri Feb  1 21:46:42 2008
@@ -4,7 +4,7 @@
 const Structure&
 Message::get_structure()
 {
-  structure_ = Structure(const_cast<GstStructure*>(gst_message_get_structure(gobj())), true);
+  structure_ = Structure(const_cast<GstStructure*>(gst_message_get_structure(gobj())));
   return structure_;
 }
 

Modified: gstreamermm/trunk/gstreamer/src/query.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/query.ccg	(original)
+++ gstreamermm/trunk/gstreamer/src/query.ccg	Fri Feb  1 21:46:42 2008
@@ -5,7 +5,7 @@
 
 const Structure& Query::get_structure()
 {
-  structure_ = Structure(const_cast<GstStructure*>(gst_query_get_structure(gobj())), true);
+  structure_ = Structure(const_cast<GstStructure*>(gst_query_get_structure(gobj())));
   return structure_;
 }
 

Modified: gstreamermm/trunk/gstreamer/src/query.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/query.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/query.hg	Fri Feb  1 21:46:42 2008
@@ -116,4 +116,4 @@
   void parse(double& rate, Format& format, gint64& start_value, gint64& stop_value);
 };
 
-}//namespace Gst
+} //namespace Gst

Modified: gstreamermm/trunk/gstreamer/src/structure.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/structure.ccg	(original)
+++ gstreamermm/trunk/gstreamer/src/structure.ccg	Fri Feb  1 21:46:42 2008
@@ -3,50 +3,6 @@
 
 namespace Gst
 {
-// StructureValueProxy
-
-StructureValueProxy::StructureValueProxy(Structure& structure, const Glib::ustring& name)
-: m_Structure(structure)
-, m_Name(name)
-{
-}
-
-void StructureValueProxy::set(const Glib::ValueBase& value)
-{
-  gst_structure_set_value(m_Structure.gobj(), m_Name.c_str(), value.gobj());
-}
-
-StructureValueProxy&
-StructureValueProxy::operator=(const Glib::ValueBase& value)
-{
-  set(value);
-  return *this;
-}
-
-StructureValueProxy&
-StructureValueProxy::operator=(const Fraction& value)
-{
-  GValue v = {0,};
-  g_value_init(&v, GST_TYPE_FRACTION);
-  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
 
 static gboolean
 Structure_ForEach_gstreamermm_callback(GQuark field_id, const GValue *value, gpointer data)
@@ -67,114 +23,142 @@
   gobject_ = gst_structure_empty_new(name.c_str());
 }
 
-Structure::Structure(Glib::QueryQuark quark)
+Structure::Structure(const Glib::QueryQuark& quark)
 {
   gobject_ = gst_structure_id_empty_new(quark);
 }
 
-StructureValueProxy
-Structure::operator[](const Glib::ustring& name)
+void
+Structure::get_field(const Glib::QueryQuark& quark, Glib::ValueBase& value) const
 {
-  return StructureValueProxy(*this, name);
+  value.init(gst_structure_id_get_value(gobj(), quark));
 }
 
-//TODO: ValueBase should be used as an output paramter in getters because it is a base type.
-/*
-Glib::ValueBase
-Structure::get_value(const Glib::ustring& name) const
+void
+Structure::get_field(const Glib::ustring& name, Glib::ValueBase& value) const
 {
-  Glib::ValueBase v;
-  v.init(gst_structure_get_value(gobject_, name.c_str()));
-  return v;
+  value.init(gst_structure_get_value(gobj(), name.c_str()));
 }
-*/
 
 bool
-Structure::get_boolean(const Glib::ustring& name, bool& value) const
+Structure::get_boolean(const Glib::ustring& name, Glib::ValueBase& value) const
 {
-  gboolean val_ = false;
-  const bool has = gst_structure_get_boolean(gobject_, name.c_str(), &val_);
-  if(has)
-  {
-    value = val_;
-  }
+  bool result = gst_structure_has_field_typed(gobj(), name.c_str(), G_TYPE_BOOLEAN);
 
-  return has;
+  if (result)
+    value.init(gst_structure_get_value(gobj(), name.c_str()));
+
+  return result;
 }
 
 bool
-Structure::get_int(const Glib::ustring& name, int& value) const
+Structure::get_int(const Glib::ustring& name, Glib::ValueBase& value) const
 {
-  return gst_structure_get_int(gobject_, name.c_str(), &value);
+  bool result = gst_structure_has_field_typed(gobj(), name.c_str(), G_TYPE_INT);
+
+  if (result)
+    value.init(gst_structure_get_value(gobj(), name.c_str()));
+
+  return result;
 }
 
 bool
-Structure::get_uint(const Glib::ustring& name, guint& value) const
+Structure::get_uint(const Glib::ustring& name, Glib::ValueBase& value) const
 {
-  return gst_structure_get_uint(gobject_, name.c_str(), &value);
+  bool result = gst_structure_has_field_typed(gobj(), name.c_str(), G_TYPE_UINT);
+
+  if (result)
+    value.init(gst_structure_get_value(gobj(), name.c_str()));
+
+  return result;
 }
 
 bool
-Structure::get_fourcc(const Glib::ustring& name, guint32& value) const
+Structure::get_fourcc(const Glib::ustring& name, Glib::ValueBase& value) const
 {
-  return gst_structure_get_fourcc(gobject_, name.c_str(), &value);
+  bool result = gst_structure_has_field_typed(gobj(), name.c_str(), G_TYPE_UINT);
+
+  if (result)
+    value.init(gst_structure_get_value(gobj(), name.c_str()));
+
+  return result;
 }
 
 
 bool
-Structure::get_double(const Glib::ustring& name, gdouble& value) const
+Structure::get_double(const Glib::ustring& name, Glib::ValueBase& value) const
 {
-  return gst_structure_get_double(gobject_, name.c_str(), &value);
+  bool result = gst_structure_has_field_typed(gobj(), name.c_str(), G_TYPE_DOUBLE);
+
+  if (result)
+    value.init(gst_structure_get_value(gobj(), name.c_str()));
+
+  return result;
 }
 
-Glib::ustring
-Structure::get_string(const Glib::ustring& name) const
+bool
+Structure::get_string(const Glib::ustring& name, Glib::ValueBase& value) const
 {
-  return gst_structure_get_string(gobject_, name.c_str());
+  bool result = gst_structure_has_field_typed(gobj(), name.c_str(), G_TYPE_STRING);
+
+  if (result)
+    value.init(gst_structure_get_value(gobj(), name.c_str()));
+
+  return result;
 }
 
 bool
 Structure::get_date (const Glib::ustring& name, Glib::Date& value) const
 {
   GDate *date = 0;
-  const bool has = gst_structure_get_date(gobject_, name.c_str(), &date);
+  const bool has = gst_structure_get_date(gobj(), name.c_str(), &date);
   value.set_julian(g_date_get_julian(date));
   return has;
 }
 
 
 bool
-Structure::get_clock_time(const Glib::ustring& name, ClockTime& value) const
+Structure::get_clock_time(const Glib::ustring& name, Glib::ValueBase& value) const
 {
-  return gst_structure_get_clock_time(gobject_, name.c_str(), &value);
+  bool result = gst_structure_has_field_typed(gobj(), name.c_str(), G_TYPE_UINT64);
+
+  if (result)
+    value.init(gst_structure_get_value(gobj(), name.c_str()));
+
+  return result;
 }
 
 
 bool
-Structure::get_enum(const Glib::ustring& name, GType enumtype, int& value) const
+Structure::get_enum(const Glib::ustring& name, GType enum_type, Glib::ValueBase& value) const
 {
-  return gst_structure_get_enum(gobject_, name.c_str(), enumtype, &value);
+  bool result = gst_structure_has_field_typed(gobj(), name.c_str(), enum_type);
+
+  if (result)
+    value.init(gst_structure_get_value(gobj(), name.c_str()));
+
+  return result;
 }
 
 
 bool
 Structure::get_fraction(const Glib::ustring& name, int& value_numerator, int& value_denominator) const
 {
-  return gst_structure_get_fraction(gobject_, name.c_str(), &value_numerator, &value_denominator);
+  return gst_structure_get_fraction(gobj(), name.c_str(), &value_numerator, &value_denominator);
 }
 
 bool
 Structure::foreach(const ForeachSlot& slot)
 {
   ForeachSlot slot_copy(slot);
-  gst_structure_foreach(gobject_, &Structure_ForEach_gstreamermm_callback, &slot_copy);
+  gst_structure_foreach(gobj(), &Structure_ForEach_gstreamermm_callback, &slot_copy);
 }
 
 bool
 Structure::map_in_place(const MapSlot& slot)
 {
   MapSlot slot_copy(slot);
-  gst_structure_map_in_place(gobject_, &Structure_Map_gstreamermm_callback, &slot_copy);
+  gst_structure_map_in_place(gobj(), &Structure_Map_gstreamermm_callback, &slot_copy);
 }
 
 Structure

Modified: gstreamermm/trunk/gstreamer/src/structure.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/structure.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/structure.hg	Fri Feb  1 21:46:42 2008
@@ -5,45 +5,6 @@
 namespace Gst
 {
 
-//TODO: Documenation. What is this?
-//TODO: Put implmenetation in the .ccg file.
-//TODO: Probably use the m_ prefix.
-class Fraction
-{
-public:
-  Fraction(int num, int den)
-  : numerator(num),
-    denominator(den)
-  {}
-
-  Fraction()
-  : numerator(0),
-    denominator(0)
-  {}
-
-  int numerator;
-  int denominator;
-};
-
-class Structure;
-
-//TODO: What is this?
-class StructureValueProxy
-{
-public:
-  StructureValueProxy(Structure& structure, const Glib::ustring& name);
-
-  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;
-  Glib::ustring m_Name;
-};
-
 class Structure
 {
   _CLASS_BOXEDTYPE(Structure, GstStructure, NONE, gst_structure_copy, gst_structure_free)
@@ -54,49 +15,44 @@
 
 public:
   Structure(const Glib::ustring& name);
-  Structure(Glib::QueryQuark quark);
-  Structure(const GstStructure* castitem); // for Message::get_structure()
-
-  StructureValueProxy operator[](const Glib::ustring& fieldname);
+  Structure(const Glib::QueryQuark& quark);
 
   _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(Glib::QueryQuark field);
+  void get_field(const Glib::QueryQuark& field, Glib::ValueBase& value) const;
 
-  _WRAP_METHOD(void id_set_value(Glib::QueryQuark field, const Glib::ValueBase& value), gst_structure_id_set_value)
+  _WRAP_METHOD(void set_field(const 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;
+  void get_field(const Glib::ustring& fieldname, Glib::ValueBase& value) const;
 
-  void set_value(const Glib::ustring& fieldname, const Glib::ValueBase& value);
+  _WRAP_METHOD(void set_field(const Glib::ustring& fieldname, const Glib::ValueBase& value), gst_structure_set_value)
 
   _WRAP_METHOD(void remove_field(const Glib::ustring& fieldname), gst_structure_remove_field)
   _WRAP_METHOD(GType get_field_type(const Glib::ustring& fieldname) const, gst_structure_get_field_type)
+
   bool foreach(const ForeachSlot& slot);
 
   _WRAP_METHOD(bool has_field(const Glib::ustring& fieldname) const, gst_structure_has_field)
-  _WRAP_METHOD(bool has_field_typed(const Glib::ustring& fieldname, GType type) const, gst_structure_has_field_typed)
+  _WRAP_METHOD(bool has_field(const Glib::ustring& fieldname, GType type) const, gst_structure_has_field_typed)
 
-  bool get_boolean(const Glib::ustring& fieldname, bool& value) const;
+  bool get_boolean(const Glib::ustring& fieldname, Glib::ValueBase& value) const;
 
-  bool get_int(const Glib::ustring& fieldname, int& value) const;
+  bool get_int(const Glib::ustring& fieldname, Glib::ValueBase& value) const;
 
-  bool get_uint(const Glib::ustring& fieldname, guint& value) const;
+  bool get_uint(const Glib::ustring& fieldname, Glib::ValueBase& value) const;
 
-  bool get_fourcc(const Glib::ustring& fieldname, guint32& value) const;
+  bool get_fourcc(const Glib::ustring& fieldname, Glib::ValueBase& value) const;
 
-  bool get_double(const Glib::ustring& fieldname, double& value) const;
+  bool get_double(const Glib::ustring& fieldname, Glib::ValueBase& value) const;
 
-  Glib::ustring get_string(const Glib::ustring& fieldname) const;
+  bool get_string(const Glib::ustring& fieldname, Glib::ValueBase& value) const;
 
   bool get_date(const Glib::ustring& fieldname, Glib::Date& value) const;
 
-  bool get_clock_time(const Glib::ustring& fieldname, ClockTime& value) const;
+  bool get_clock_time(const Glib::ustring& fieldname, Glib::ValueBase& value) const;
 
-  bool get_enum(const Glib::ustring& fieldname, GType enumtype, int& value) const;
+  bool get_enum(const Glib::ustring& fieldname, GType enumtype, Glib::ValueBase& value) const;
 
   bool get_fraction(const Glib::ustring& fieldname, int& value_numerator, int& value_denominator) const;
 

Added: gstreamermm/trunk/gstreamer/src/value.ccg
==============================================================================
--- (empty file)
+++ gstreamermm/trunk/gstreamer/src/value.ccg	Fri Feb  1 21:46:42 2008
@@ -0,0 +1,35 @@
+#include <iostream>
+
+namespace Gst
+{
+
+Fraction::Fraction() : m_num(0), m_denom(1)
+{
+}
+
+Fraction::Fraction(int num, int denom) : m_num(num), m_denom(denom)
+{
+}
+
+int Fraction::get_num()
+{
+  return m_num;
+}
+
+int Fraction::get_denom()
+{
+  return m_denom;
+}
+
+void Fraction::set_num(int num)
+{
+  m_num = num;
+}
+
+void Fraction::set_denom(int denom)
+{
+  m_denom = denom;
+}
+
+} //namespace Gst
+

Added: gstreamermm/trunk/gstreamer/src/value.hg
==============================================================================
--- (empty file)
+++ gstreamermm/trunk/gstreamer/src/value.hg	Fri Feb  1 21:46:42 2008
@@ -0,0 +1,28 @@
+#include <gst/gstvalue.h>
+#include <glibmm/value_custom.h>
+_DEFS(gstreamermm,gst)
+
+namespace Gst
+{
+
+//TODO: Documenation. What is this?
+//TODO: Put implmenetation in the .ccg file.
+//TODO: Probably use the m_ prefix.
+class Fraction
+{
+public:
+  inline Fraction();
+  inline Fraction(int num, int denom);
+
+  inline int get_num();
+  inline int get_denom();
+  inline void set_num(int num);
+  inline void set_denom(int denom);
+
+private:
+  int m_num;
+  int m_denom;
+};
+
+} //namespace Gst
+

Modified: gstreamermm/trunk/tests/test-structure.cc
==============================================================================
--- gstreamermm/trunk/tests/test-structure.cc	(original)
+++ gstreamermm/trunk/tests/test-structure.cc	Fri Feb  1 21:46:42 2008
@@ -14,20 +14,11 @@
   stringValue.init(Glib::Value<Glib::ustring>::value_type());
   stringValue.set("Hello; This is a ustring.");
 
-  structure[fieldName] = stringValue;
+  structure.set_field(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;
-  };
+  Glib::Value<Glib::ustring> value;
+  structure.get_field(fieldName, value);
+  std::cout << "value = '" << value.get() << "'" << 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	Fri Feb  1 21:46:42 2008
@@ -65,7 +65,7 @@
 _CONVERSION(`QueryType',`GstQueryType',`GstQueryType($3)')
 
 _CONVERSION(`GQuark',`Glib::QueryQuark',`Glib::QueryQuark($3)')
-_CONVERSION(`Glib::QueryQuark',`GQuark',`$3')
+_CONVERSION(`const 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]