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



Author: murrayc
Date: Wed May 21 12:42:48 2008
New Revision: 1517
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1517&view=rev

Log:
2008-05-21  Murray Cumming  <murrayc murrayc com>

* gstreamer/src/structure.ccg:
* gstreamer/src/structure.hg: Added several set_field() method 
overloads, so people don't have to use Glib::Value for common types.
Renamed get_*() to get_field(), and made them take actual types instead 
of Glib::ValueBase. Some TODOs show parts of this still left to do.
Do not return *this from set_field(). It did reduce the code, but it 
is not a natural syntax for simply setting data.
* gstreamer/src/value.ccg:
* gstreamer/src/value.hg: Fourcc, Fraction, IntRange, DoubleRange, 
FractionRange: Made single-parameter constructors explicit (apart from 
copy constructors) and added operator= (because we should always have 
one where we have a copy constructor).
* tests/test-caps.cc:
* tests/test-structure.cc: Adapted to the changed API.

Modified:
   gstreamermm/trunk/ChangeLog
   gstreamermm/trunk/gstreamer/src/pad.hg
   gstreamermm/trunk/gstreamer/src/structure.ccg
   gstreamermm/trunk/gstreamer/src/structure.hg
   gstreamermm/trunk/gstreamer/src/value.ccg
   gstreamermm/trunk/gstreamer/src/value.hg
   gstreamermm/trunk/tests/test-caps.cc
   gstreamermm/trunk/tests/test-structure.cc

Modified: gstreamermm/trunk/gstreamer/src/pad.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/pad.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/pad.hg	Wed May 21 12:42:48 2008
@@ -113,6 +113,7 @@
   _WRAP_METHOD(Glib::RefPtr<Caps> get_negotiated_caps(), gst_pad_get_negotiated_caps)
   _WRAP_METHOD(Glib::RefPtr<const Caps> get_negotiated_caps() const, gst_pad_get_negotiated_caps, constversion)
 
+  //The documentation gst_pad_get_pad_template_caps() suggests that there shouldn't be a non-const return:
   /** Gets the capabilities for pad's template.
    *
    * @return The Gst::Caps of this pad template.

Modified: gstreamermm/trunk/gstreamer/src/structure.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/structure.ccg	(original)
+++ gstreamermm/trunk/gstreamer/src/structure.ccg	Wed May 21 12:42:48 2008
@@ -63,20 +63,120 @@
   return gobject_ != 0;
 }
 
-void
-Structure::get_field(const Glib::ustring& name, Glib::ValueBase& value) const
+void Structure::get_field(const Glib::ustring& name, Glib::ValueBase& value) const
 {
   value.init(gst_structure_get_value(gobj(), name.c_str()));
 }
 
-Structure&
-Structure::set_field(const Glib::ustring& fieldname, const Glib::ValueBase& value)
+void Structure::set_field(const Glib::ustring& fieldname, const Glib::ValueBase& value)
 {
   _set_gstructure_field(gobj(), fieldname, value);
+}
 
-  return *this;
+void Structure::set_field(const Glib::ustring& fieldname, bool value)
+{
+   Glib::Value<bool> val;
+   val.init( Glib::Value<bool>::value_type() );
+   val.set(value);
+
+   set_field(fieldname, val);
+}
+
+void Structure::set_field(const Glib::ustring& fieldname, int value)
+{
+  Glib::Value<int> val;
+  val.init( Glib::Value<int>::value_type() );
+  val.set(value);
+
+  set_field(fieldname, val);
 }
 
+void Structure::set_field(const Glib::ustring& fieldname, guint value)
+{
+  Glib::Value<guint> val;
+  val.init( Glib::Value<guint>::value_type() );
+  val.set(value);
+
+  set_field(fieldname, val);
+}
+
+void Structure::set_field(const Glib::ustring& fieldname, const Fourcc& value)
+{
+  //TODO: Or should this be a uint32?
+  Glib::Value<Fourcc> val;
+  val.init( Glib::Value<Fourcc>::value_type() );
+  val.set(value);
+
+  set_field(fieldname, val);
+}
+
+void Structure::set_field(const Glib::ustring& fieldname, double value)
+{
+  Glib::Value<double> val;
+  val.init( Glib::Value<double>::value_type() );
+  val.set(value);
+
+  set_field(fieldname, val);
+};
+
+//We use std::string, because the encoding is unknown. murrayc
+void Structure::set_field(const Glib::ustring& fieldname, const std::string& value)
+{
+  Glib::Value<std::string> val;
+  val.init( Glib::Value<std::string>::value_type() );
+  val.set(value);
+
+  set_field(fieldname, val);
+}
+ 
+void Structure::set_field(const Glib::ustring& fieldname, const Glib::Date& value)
+{
+  //TODO: Or should this be a GDate?
+  Glib::Value<Glib::Date> val;
+  val.init( Glib::Value<Glib::Date>::value_type() );
+  val.set(value);
+
+  set_field(fieldname, val);
+}
+
+void Structure::set_field(const Glib::ustring& fieldname, const ClockTime& value)
+{
+  //TODO: Or should this be a GstClockTime?
+  Glib::Value<ClockTime> val;
+  val.init( Glib::Value<ClockTime>::value_type() );
+  val.set(value);
+
+  set_field(fieldname, val);
+}
+
+void Structure::set_field(const Glib::ustring& fieldname, GType enumtype, const Glib::ValueBase& value)
+{
+  //TODO: We must need to do something more. murrayc
+  set_field(fieldname, value);
+}
+
+void Structure::set_field(const Glib::ustring& fieldname, const Gst::Fraction& value)
+{
+  //TODO: Or should we use two ints somehow?
+  Glib::Value<Gst::Fraction> val;
+  val.init( Glib::Value<Gst::Fraction>::value_type() );
+  val.set(value);
+
+   set_field(fieldname, val);
+}
+
+void Structure::set_field(const Glib::ustring& fieldname, const Gst::FractionRange& value)
+{
+  //TODO: Or should we use two Fractions somehow?
+  Glib::Value<Gst::FractionRange> val;
+  val.init( Glib::Value<Gst::FractionRange>::value_type() );
+  val.set(value);
+
+  set_field(fieldname, val);
+}
+
+
+
 void Structure::_set_gstructure_field(GstStructure* cstructure, const Glib::ustring& fieldname, const Glib::ValueBase& value)
 {
   const GType type = G_VALUE_TYPE(value.gobj());
@@ -161,96 +261,94 @@
 }
 
 bool
-Structure::get_boolean(const Glib::ustring& name, Glib::ValueBase& value) const
+Structure::get_field(const Glib::ustring& name, bool& value) const
 {
-  bool result = gst_structure_has_field_typed(gobj(), name.c_str(), G_TYPE_BOOLEAN);
-
-  if (result)
-    value.init(gst_structure_get_value(gobj(), name.c_str()));
-
+  gboolean cvalue = FALSE;
+  const bool result = gst_structure_get_boolean(gobj(), name.c_str(), &cvalue);
+  value = cvalue;
   return result;
 }
 
 bool
-Structure::get_int(const Glib::ustring& name, Glib::ValueBase& value) const
+Structure::get_field(const Glib::ustring& name, int& value) const
 {
-  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;
+  return gst_structure_get_int(gobj(), name.c_str(), &value);
 }
 
 bool
-Structure::get_uint(const Glib::ustring& name, Glib::ValueBase& value) const
+Structure::get_field(const Glib::ustring& name, guint& value) const
 {
-  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;
+  return gst_structure_get_uint(gobj(), name.c_str(), &value);
 }
 
 bool
-Structure::get_fourcc(const Glib::ustring& name, Glib::ValueBase& value) const
+Structure::get_field(const Glib::ustring& name, Fourcc& value) const
 {
-  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()));
+  guint32 cvalue = 0;
+  const bool result = gst_structure_get_fourcc(gobj(), name.c_str(), &cvalue);
+  if(result)
+    value = Fourcc(cvalue);
 
   return result;
 }
 
 
 bool
-Structure::get_double(const Glib::ustring& name, Glib::ValueBase& value) const
+Structure::get_field(const Glib::ustring& name, double& value) const
 {
-  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;
+  return gst_structure_get_double(gobj(), name.c_str(), &value);
 }
 
 bool
-Structure::get_string(const Glib::ustring& name, Glib::ValueBase& value) const
+Structure::get_field(const Glib::ustring& name, Glib::ustring& value) const
 {
-  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()));
+  const gchar* cvalue = gst_structure_get_string(gobj(), name.c_str());
+  if(cvalue)
+  {
+    value = Glib::convert_const_gchar_ptr_to_stdstring(cvalue);
+    return true;
+  }
+  else
+    return false;
+}
 
-  return result;
+bool
+Structure::get_field(const Glib::ustring& name, std::string& value) const
+{
+  const gchar* cvalue = gst_structure_get_string(gobj(), name.c_str());
+  if(cvalue)
+  {
+    value = Glib::convert_const_gchar_ptr_to_stdstring(cvalue);
+    return true;
+  }
+  else
+    return false;
 }
 
 bool
-Structure::get_date (const Glib::ustring& name, Glib::Date& date) const
+Structure::get_field(const Glib::ustring& name, Glib::Date& date) const
 {
   GDate *gdate = 0;
   const bool has = gst_structure_get_date(gobj(), name.c_str(), &gdate);
-  date.set_julian(g_date_get_julian(gdate));
+  if(has)
+    date.set_julian(g_date_get_julian(gdate)); //TODO: Don't we have a wrap()/constructor for this? If not, we should.
+
   return has;
 }
 
 
 bool
-Structure::get_clock_time(const Glib::ustring& name, Glib::ValueBase& value) const
+Structure::get_field(const Glib::ustring& name, ClockTime& value) const
 {
-  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()));
-
+  GstClockTime cvalue = 0;
+  const bool result = gst_structure_get_clock_time(gobj(), name.c_str(), &cvalue);
+  value = cvalue;
   return result;
 }
 
 
 bool
-Structure::get_enum(const Glib::ustring& name, GType enum_type, Glib::ValueBase& value) const
+Structure::get_field(const Glib::ustring& name, GType enum_type, Glib::ValueBase& value) const
 {
   bool result = gst_structure_has_field_typed(gobj(), name.c_str(), enum_type);
 
@@ -262,9 +360,23 @@
 
 
 bool
-Structure::get_fraction(const Glib::ustring& name, Gst::Fraction& f) const
+Structure::get_field(const Glib::ustring& name, Gst::Fraction& f) const
+{
+  int value_numerator = 0;
+  int value_denominator = 0;
+  const bool result = gst_structure_get_fraction(gobj(), name.c_str(), &value_numerator, &value_denominator);
+  if(result)
+    f = Gst::Fraction(value_numerator, value_denominator);
+  
+  return result;
+}
+
+bool
+Structure::get_field(const Glib::ustring& name, Gst::FractionRange& range) const
 {
-  return gst_structure_get_fraction(gobj(), name.c_str(), &f.num, &f.denom);
+  //TODO
+  
+  return false;
 }
 
 bool
@@ -287,4 +399,4 @@
   return Structure(gst_structure_from_string(the_string.c_str(), NULL)); 
 }
 
-} //namespace Gst
+} //namespace GstG

Modified: gstreamermm/trunk/gstreamer/src/structure.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/structure.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/structure.hg	Wed May 21 12:42:48 2008
@@ -48,8 +48,19 @@
  _CLASS_BOXEDTYPE(Structure, GstStructure, NONE, gst_structure_copy, gst_structure_free)
 public:
 
+  /** Creates a Structure with the given @a name.
+   * You should then use set_field() to set field values.
+   */
   explicit Structure(const Glib::ustring& name);
 
+  /** Creates a Gst::Structure from a string representation.
+   *
+   * @param the_string A string representation of a Gst::Structure. See to_string().
+   * @returns A Structure. This will be invalid (see operator=) when the string 
+   * could not be parsed.
+   */
+  static Structure create_from_string(const Glib::ustring& the_string);
+
   /** Use this to discover if the Structure is a valid object.
    */
   operator bool() const;
@@ -75,11 +86,34 @@
    * attempting to get these fields back, they can no longer be stored in the
    * same Glib::Value<...>.
    *
-   * @param fieldname the name of the field to set
-   * @param value the new value of the field 
-   * @return this Gst::Structure
+   * @param fieldname the name of the field to set.
+   * @param value the new value of the field.
    */
-  Structure& set_field(const Glib::ustring& fieldname, const Glib::ValueBase& value);
+  void set_field(const Glib::ustring& fieldname, const Glib::ValueBase& value);
+
+  void set_field(const Glib::ustring& fieldname, bool value);
+
+  void set_field(const Glib::ustring& fieldname, int value);
+
+  void set_field(const Glib::ustring& fieldname, guint value);
+
+  void set_field(const Glib::ustring& fieldname, const Fourcc& value);
+
+  void set_field(const Glib::ustring& fieldname, double value);
+
+  //We use std::string, because the encoding is unknown. murrayc
+  void set_field(const Glib::ustring& fieldname, const std::string& value);
+ 
+  void set_field(const Glib::ustring& fieldname, const Glib::Date& value);
+
+  void set_field(const Glib::ustring& fieldname, const ClockTime& value);
+
+  void set_field(const Glib::ustring& fieldname, GType enumtype, const Glib::ValueBase& value);
+
+  void set_field(const Glib::ustring& fieldname, const Gst::Fraction& value);
+
+  void set_field(const Glib::ustring& fieldname, const Gst::FractionRange& value);
+
 
   //Only for use inside gstreamermm:
   static void _set_gstructure_field(GstStructure* cstructure, const Glib::ustring& fieldname, const Glib::ValueBase& value);
@@ -96,6 +130,8 @@
   _WRAP_METHOD(void remove_all_fields(), gst_structure_remove_all_fields)
   _WRAP_METHOD(GType get_field_type(const Glib::ustring& fieldname) const, gst_structure_get_field_type)
 
+  //TODO: Remove any use of Quarks from the API, using plain strings instead? They seem like implementation detail. murrayc.
+
   /** For example,
    * bool on_foreach(const Glib::QueryQuark& id, const Glib::ValueBase& value);
    * The foreach function should return true if foreach operation should
@@ -116,117 +152,161 @@
   _WRAP_METHOD(bool has_field(const Glib::ustring& fieldname) const, gst_structure_has_field)
   _WRAP_METHOD(bool has_field(const Glib::ustring& fieldname, GType type) const, gst_structure_has_field_typed)
 
-  /** Sets the GValue of value to the boolean value of the given field. Caller
-   * is responsible for making sure the field exists and has the correct type.
+  /** Gets the value of the given boolean field.
+   * The caller is responsible for making sure the field exists and has the correct
+   * type.
    *
    * @param fieldname the name of a field
-   * @param value the Value class to set
+   * @param value An output parameter that will be set with the value
    * @return true if the value could be set correctly. If there was no field
-   * with fieldname or the existing field did not contain a boolean, this
+   * with @a fieldname or the existing field did not contain a boolean, this
    * function returns false.
    */
-  bool get_boolean(const Glib::ustring& fieldname, Glib::ValueBase& value) const;
+  bool get_field(const Glib::ustring& fieldname, bool& value) const;
+  _IGNORE(gst_structure_get_boolean)
 
-  /** Sets the GValue of value to the int value of the given field. Caller
-   * is responsible for making sure the field exists and has the correct type.
+  /** Gets the value of the given integer field.
+   * The caller is responsible for making sure the field exists and has the correct
+   * type.
    *
    * @param fieldname the name of a field
-   * @param value the Value class to set
+   * @param value An output parameter that will be set with the value
    * @return true if the value could be set correctly. If there was no field
-   * with fieldname or the existing field did not contain an int, this function
-   * returns false returns false
+   * with @a fieldname or the existing field did not contain an int, this function
+   * returns false.
    */
-  bool get_int(const Glib::ustring& fieldname, Glib::ValueBase& value) const;
+  bool get_field(const Glib::ustring& fieldname, int& value) const;
+  _IGNORE(gst_structure_get_int)
 
-  /** Sets the GValue of value to the uint value of the given field. Caller
-   * is responsible for making sure the field exists and has the correct type.
+  /** Gets the value of the given unsigned integer field.
+   * The caller is responsible for making sure the field exists and has the correct
+   * type.
    *
    * @param fieldname the name of a field
-   * @param value the Value class to set
+   * @param value An output parameter that will be set with the value
    * @return true if the value could be set correctly. If there was no field
-   * with fieldname or the existing field did not contain an uint, this
-   * function returns false returns false
+   * with @a fieldname or the existing field did not contain an uint, this
+   * function returns false.
    */
-  bool get_uint(const Glib::ustring& fieldname, Glib::ValueBase& value) const;
+  bool get_field(const Glib::ustring& fieldname, guint& value) const;
+  _IGNORE(gst_structure_get_uint)
 
-  /** Sets the GValue of value to the fourc value of the given field. Caller
-   * is responsible for making sure the field exists and has the correct type.
+  /** Gets the value of the given Fourcc field.
+   * The caller is responsible for making sure the field exists and has the correct
+   * type.
    *
    * @param fieldname the name of a field
-   * @param value the Value class to set
+   * @param value An output parameter that will be set with the value
    * @return true if the value could be set correctly. If there was no field
-   * with fieldname or the existing field did not contain a fourc, this
-   * function returns false returns false
+   * with @a fieldname or the existing field did not contain a fourc, this
+   * function returns false.
    */
-  bool get_fourcc(const Glib::ustring& fieldname, Glib::ValueBase& value) const;
+  bool get_field(const Glib::ustring& fieldname, Fourcc& value) const;
+  _IGNORE(gst_structure_get_fourcc)
 
-  /** Sets the GValue of value to the double value of the given field. Caller
-   * is responsible for making sure the field exists and has the correct type.
+  /** Gets the value of the given double field.
+   * The caller is responsible for making sure the field exists and has the correct
+   * type.
    *
    * @param fieldname the name of a field
-   * @param value the Value class to set
+   * @param value An output parameter that will be set with the value
    * @return true if the value could be set correctly. If there was no field
-   * with fieldname or the existing field did not contain a double, this
-   * function returns false returns false
+   * with @a fieldname or the existing field did not contain a double, this
+   * function returns false.
    */
-  bool get_double(const Glib::ustring& fieldname, Glib::ValueBase& value) const;
+  bool get_field(const Glib::ustring& fieldname, double& value) const;
+  _IGNORE(gst_structure_get_double)
 
-  /** Sets the GValue of value to the string value of the given field. Caller
-   * is responsible for making sure the field exists and has the correct type.
+  /** Gets the value of the given string field.
+   * The caller is responsible for making sure the field exists and has the correct
+   * type.
    *
    * @param fieldname the name of a field
-   * @param value the Value class to set
+   * @param value An output parameter that will be set with the value
    * @return true if the value could be set correctly. If there was no field
-   * with fieldname or the existing field did not contain a string, this
-   * function returns false returns false
+   * with @a fieldname or the existing field did not contain a string, this
+   * function returns false.
    */
-  bool get_string(const Glib::ustring& fieldname, Glib::ValueBase& value) const;
+  bool get_field(const Glib::ustring& fieldname, Glib::ustring& value) const;
 
-  /** Sets the GValue of value to the GDate value of the given field. Caller
-   * is responsible for making sure the field exists and has the correct type.
+  /** Gets the value of the given string field.
+   * The caller is responsible for making sure the field exists and has the correct
+   * type.
    *
    * @param fieldname the name of a field
-   * @param date the Glib::Date class to set
+   * @param value An output parameter that will be set with the value
    * @return true if the value could be set correctly. If there was no field
-   * with fieldname or the existing field did not contain a GDate, this
-   * function returns false returns false
+   * with @a fieldname or the existing field did not contain a string, this
+   * function returns false.
    */
-  bool get_date(const Glib::ustring& fieldname, Glib::Date& value) const;
+  bool get_field(const Glib::ustring& fieldname, std::string& value) const;
+  _IGNORE(gst_structure_get_string)
 
-  /** Sets the GValue of value to the Gst::ClockTime value of the given field.
-   * Caller is responsible for making sure the field exists and has the correct
+  /** Gets the value of the given date field.
+   * The caller is responsible for making sure the field exists and has the correct
    * type.
    *
-   * @param fieldname the name of a field
-   * @param value the Value class to set
+   * @param fieldname the name of a field.
+   * @param date the Glib::Date to set
    * @return true if the value could be set correctly. If there was no field
-   * with fieldname or the existing field did not contain a Gst::ClockTime,
-   * this function returns false returns false
+   * with @a fieldname or the existing field did not contain a GDate, this
+   * function returns false.
    */
-  bool get_clock_time(const Glib::ustring& fieldname, Glib::ValueBase& value) const;
+  bool get_field(const Glib::ustring& fieldname, Glib::Date& value) const;
+  _IGNORE(gst_structure_get_date)
 
+  /** Gets the value of the given clock time field.
+   * The caller is responsible for making sure the field exists and has the correct
+   * type.
+   *
+   * @param fieldname the name of a field.
+   * @param value An output parameter that will be set with the value
+   * @return true if the value could be set correctly. If there was no field
+   * with @a fieldname or the existing field did not contain a Gst::ClockTime,
+   * this function returns false.
+   */
+  bool get_field(const Glib::ustring& fieldname, ClockTime& value) const;
+  _IGNORE(gst_structure_get_clocktime)
+
+  //TODO: Don't use ValueBase.
   /** Sets the GValue of value to the enum value of the given field. Caller
    * is responsible for making sure the field exists and has the correct type.
    *
    * @param fieldname the name of a field
-   * @param value the Value class to set
+   * @param value An output parameter that will be set with the value
    * @return true if the value could be set correctly. If there was no field
-   * with fieldname or the existing field did not contain a enum, this
-   * function returns false returns false
+   * with @a fieldname or the existing field did not contain a enum, this
+   * function returns false.
    */
-  bool get_enum(const Glib::ustring& fieldname, GType enumtype, Glib::ValueBase& value) const;
+  bool get_field(const Glib::ustring& fieldname, GType enumtype, Glib::ValueBase& value) const;
+  _IGNORE(gst_structure_get_enum)
 
-  /** Sets the GValue of value to the Gst::Fraction value of the given field.
-   * Caller is responsible for making sure the field exists and has the correct
+  /** Gets the value of the given fraction field.
+   * The caller is responsible for making sure the field exists and has the correct
    * type.
    *
    * @param fieldname the name of a field
-   * @param fraction the Gst::Fraction class to set
+   * @param fraction the Gst::Fraction to set
    * @return true if the value could be set correctly. If there was no field
-   * with fieldname or the existing field did not contain a Gst::Fraction, this
-   * function returns false returns false
+   * with @a fieldname or the existing field did not contain a Gst::FractionRange, this
+   * function returns false.
    */
-  bool get_fraction(const Glib::ustring& fieldname, Gst::Fraction& fraction) const;
+  bool get_field(const Glib::ustring& fieldname, Gst::Fraction& fraction) const;
+  _IGNORE(gst_structure_get_fraction)
+
+  /** Gets the value of the given fraction-range field.
+   * The caller is responsible for making sure the field exists and has the correct
+   * type.
+   *
+   * @param fieldname the name of a field
+   * @param fraction the Gst::FractionRange to set
+   * @return true if the value could be set correctly. If there was no field
+   * with @a fieldname or the existing field did not contain a Gst::Fraction, this
+   * function returns false.
+   */
+  bool get_field(const Glib::ustring& fieldname, Gst::FractionRange& fraction) const;
+
+  //TODO: Add Set/Get for the other *Range classes?
 
   /** For example,
    * bool on_map(const Glib::QueryQuark& id, Glib::ValueBase& value);
@@ -248,7 +328,6 @@
   _WRAP_METHOD(Glib::ustring get_nth_field_name(guint index) const, gst_structure_nth_field_name)
   _WRAP_METHOD(Glib::ustring to_string() const, gst_structure_to_string)
 
-  static Structure create_from_string(const Glib::ustring& the_string);
 
   _IGNORE(
       gst_structure_get_date,
@@ -257,13 +336,9 @@
       gst_structure_remove_fields_valist,
       gst_structure_fixate_field_boolean,
       gst_structure_id_set_value,
-      gst_structure_get_enum,
-      gst_structure_get_clock_time,
       gst_structure_remove_all_fields,
-      gst_structure_get_fraction,
       gst_structure_remove_field,
       gst_structure_has_field_typed,
-      gst_structure_get_string,
       gst_structure_fixate_field_nearest_int,
       gst_structure_fixate_field_nearest_double,
       gst_structure_remove_fields,
@@ -274,18 +349,13 @@
       gst_structure_get_value,
       gst_structure_free,
       gst_structure_n_fields,
-      gst_structure_get_double,
-      gst_structure_get_boolean,
       gst_structure_has_field,
       gst_structure_set,
-      gst_structure_get_fourcc,
       gst_structure_set_value,
       gst_structure_foreach,
       gst_structure_fixate_field_nearest_fraction,
       gst_structure_set_valist,
-      gst_structure_set_parent_refcount,
-      gst_structure_get_int,
-      gst_structure_get_uint)
+      gst_structure_set_parent_refcount)
 
 };
 

Modified: gstreamermm/trunk/gstreamer/src/value.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/value.ccg	(original)
+++ gstreamermm/trunk/gstreamer/src/value.ccg	Wed May 21 12:42:48 2008
@@ -22,9 +22,20 @@
 namespace Gst
 {
 
-Fourcc::Fourcc() : first(0), second(0), third(0), fourth(0)
+Fourcc::Fourcc()
+: first(0), second(0), third(0), fourth(0)
 {}
 
+Fourcc& Fourcc::operator=(const Fourcc& src)
+{
+  first = src.first;
+  second = src.second;
+  third = src.third;
+  fourth = src.fourth;
+
+  return *this;
+}
+
 Fourcc::Fourcc(char first, char second, char third, char fourth)
 : first(first), second(second), third(third), fourth(fourth)
 {}
@@ -70,16 +81,21 @@
   fourth = (fourcc >> 24) & 0xff;
 }
 
-Fraction::Fraction() : num(0), denom(1)
+
+Fraction::Fraction()
+: num(0), denom(1)
 {}
 
-Fraction::Fraction(int num, int denom) : num(num), denom(denom)
+Fraction::Fraction(int num, int denom)
+: num(num), denom(denom)
 {}
 
-Fraction::Fraction(const Fraction& f) : num(f.num), denom(f.denom)
+Fraction::Fraction(const Fraction& src)
+: num(src.num), denom(src.denom)
 {}
 
-Fraction::Fraction(const Glib::ValueBase& value) : num(0), denom(1)
+Fraction::Fraction(const Glib::ValueBase& value)
+: num(0), denom(1)
 {
   if(G_VALUE_TYPE(value.gobj()) == GST_TYPE_FRACTION)
   {
@@ -88,16 +104,29 @@
   }
 }
 
-IntRange::IntRange() : min(0), max(0)
+Fraction& Fraction::operator=(const Fraction& src)
+{
+  num = src.num;
+  denom = src.denom;
+
+  return *this;
+}
+
+
+IntRange::IntRange()
+: min(0), max(0)
 {}
 
-IntRange::IntRange(int min, int max) : min(min), max(max)
+IntRange::IntRange(int min, int max)
+: min(min), max(max)
 {}
 
-IntRange::IntRange(const IntRange& r) : min(r.min), max(r.max)
+IntRange::IntRange(const IntRange& src)
+: min(src.min), max(src.max)
 {}
 
-IntRange::IntRange(const Glib::ValueBase& value) : min(0), max(0)
+IntRange::IntRange(const Glib::ValueBase& value)
+: min(0), max(0)
 {
   if(G_VALUE_TYPE(value.gobj()) == GST_TYPE_INT_RANGE)
   {
@@ -106,16 +135,29 @@
   }
 }
 
-DoubleRange::DoubleRange() : min(0), max(0)
+IntRange& IntRange::operator=(const IntRange& src)
+{
+  min = src.min;
+  max = src.max;
+
+  return *this;
+}
+
+
+DoubleRange::DoubleRange()
+: min(0), max(0)
 {}
 
-DoubleRange::DoubleRange(double min, double max) : min(min), max(max)
+DoubleRange::DoubleRange(double min, double max)
+: min(min), max(max)
 {}
 
-DoubleRange::DoubleRange(const DoubleRange& r) : min(r.min), max(r.max)
+DoubleRange::DoubleRange(const DoubleRange& r)
+: min(r.min), max(r.max)
 {}
 
-DoubleRange::DoubleRange(const Glib::ValueBase& value) : min(0), max(0)
+DoubleRange::DoubleRange(const Glib::ValueBase& value)
+: min(0), max(0)
 {
   if(G_VALUE_TYPE(value.gobj()) == GST_TYPE_DOUBLE_RANGE)
   {
@@ -124,16 +166,36 @@
   }
 }
 
-FractionRange::FractionRange() : min(), max()
+DoubleRange& DoubleRange::operator=(const DoubleRange& src)
+{
+  min = src.min;
+  max = src.max;
+
+  return *this;
+}
+
+FractionRange::FractionRange()
+: min(), max()
 {}
 
-FractionRange::FractionRange(const Fraction& min, const Fraction& max) : min(min), max(max)
+FractionRange::FractionRange(const Fraction& min, const Fraction& max)
+: min(min), max(max)
 {}
 
-FractionRange::FractionRange(const FractionRange& r) : min(r.min), max(r.max)
+FractionRange::FractionRange(const FractionRange& src)
+: min(src.min), max(src.max)
 {}
 
-FractionRange::FractionRange(const Glib::ValueBase& value) : min(), max()
+FractionRange& FractionRange::operator=(const FractionRange& src)
+{
+  min = src.min;
+  max = src.max;
+
+  return *this;
+}
+
+FractionRange::FractionRange(const Glib::ValueBase& value)
+: min(), max()
 {
   if(G_VALUE_TYPE(value.gobj()) == GST_TYPE_FRACTION_RANGE)
   {

Modified: gstreamermm/trunk/gstreamer/src/value.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/value.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/value.hg	Wed May 21 12:42:48 2008
@@ -57,6 +57,10 @@
    */
   Fourcc();
 
+  /** Construct a Gst::Fourcc from another
+   */
+  Fourcc(const Fourcc& src);
+
   /** Construct a Gst::Fourcc from 4 characters
    */
   Fourcc(char first, char second, char third, char fourth);
@@ -64,19 +68,18 @@
   /** Construct a Gst::Fourcc from an input string. Caller is responsible for
    * ensuring the input string consists of at least four characters.
    */
-  Fourcc(const Glib::ustring& s);
+  explicit Fourcc(const Glib::ustring& s);
 
   /** Construct a Gst::Fourcc from a 32 bit unsigned integer
    */
-  Fourcc(guint32 fourcc);
+  explicit Fourcc(guint32 fourcc);
 
-  /** Construct a Gst::Fourcc from another
+  /** Construct a Gst::Fourcc from a GST_TYPE_FOURCC
    */
-  Fourcc(const Fourcc& f);
+  explicit Fourcc(const Glib::ValueBase& gst_fraction_value);
+
+  Fourcc& operator=(const Fourcc& src);
 
-  /** Cosntruct a Gst::Fourcc from a GST_TYPE_FOURCC
-   */
-  Fourcc(const Glib::ValueBase& gst_fraction_value);
 
 public:
   /** Gets the four characters converted into a guint32 fourcc value with host
@@ -94,6 +97,7 @@
   void get_ccs(guint32 fourcc);
 };
 
+
 /** Represents a fraction.
  * Gst::Fraction is used to store a fraction in Gst::Structures of Gst::Caps as
  * a value representing a property (see GStreamer Application Development
@@ -123,23 +127,28 @@
    */
   Fraction();
 
-  /** Constructs a Gst::Fraction (num/denom)
+  /** Constructs a Gst::Fraction from another
    */
-  Fraction(int num, int denom);
+  Fraction(const Fraction& src);
 
-  /** Constructs a Gst::Fraction from another
+  /** Constructs a Gst::Fraction (num/denom)
    */
-  Fraction(const Fraction& f);
+  explicit Fraction(int num, int denom);
 
   /** Constructs a Gst::Fraction from a GST_TYPE_FRACTION
    */
-  Fraction(const Glib::ValueBase& gst_fraction_value);
+  explicit Fraction(const Glib::ValueBase& gst_fraction_value);
+
+  Fraction& operator=(const Fraction& src);
+
 
 public:
   int num;
   int denom;
 };
 
+//TODO: Use a template for IntRange, DoubleRange, FractionRange? murrayc
+
 /** Represents an integer range (min - max).
  * Gst::IntRange is used to store an integer range in Gst::Structures of
  * Gst::Caps as a value representing a property (see GStreamer Application
@@ -176,11 +185,13 @@
 
   /** Constructs an Gst::IntRange from another
    */
-  IntRange(const IntRange& r);
+  IntRange(const IntRange& src);
 
   /** Constructs an Gst::IntRange from a GST_TYPE_INT_RANGE
    */
-  IntRange(const Glib::ValueBase& gst_int_range_value);
+  explicit IntRange(const Glib::ValueBase& gst_int_range_value);
+
+  IntRange& operator=(const IntRange& src);
 
 public:
   int min;
@@ -223,11 +234,13 @@
 
   /** Constructs a Gst::DoubleRange from another
    */
-  DoubleRange(const DoubleRange& r);
+  DoubleRange(const DoubleRange& src);
 
   /** Constructs a Gst::DoubleRange from a GST_TYPE_DOUBLE_RANGE
    */
-  DoubleRange(const Glib::ValueBase& gst_double_range_value);
+  explicit DoubleRange(const Glib::ValueBase& gst_double_range_value);
+
+  DoubleRange& operator=(const DoubleRange& src);
 
 public:
   double min;
@@ -270,11 +283,13 @@
 
   /** Constructs a Gst::FractionRange from another
    */
-  FractionRange(const FractionRange& r);
+  FractionRange(const FractionRange& src);
 
   /** Constructs a Gst::FractionRange from a GST_TYPE_FRACTION_RANGE
    */
-  FractionRange(const Glib::ValueBase& gst_fraction_range_value);
+  explicit FractionRange(const Glib::ValueBase& gst_fraction_range_value);
+
+  FractionRange& operator=(const FractionRange& src);
 
 public:
   Fraction min;

Modified: gstreamermm/trunk/tests/test-caps.cc
==============================================================================
--- gstreamermm/trunk/tests/test-caps.cc	(original)
+++ gstreamermm/trunk/tests/test-caps.cc	Wed May 21 12:42:48 2008
@@ -28,24 +28,17 @@
 int link_elements_with_filter (const Glib::RefPtr<Gst::Element> e1,
   const Glib::RefPtr<Gst::Element> e2)
 {
-  Glib::Value<int> widthValue;
-  widthValue.init(Glib::Value<int>::value_type());
-  widthValue.set(384);
-
-  Glib::Value<int> heightValue;
-  heightValue.init(Glib::Value<int>::value_type());
-  heightValue.set(288);
-
-  Glib::Value<Gst::Fraction> rateValue;
-  rateValue.init(Glib::Value<Gst::Fraction>::value_type());
-  rateValue.set(Gst::Fraction(25, 1));
-
-  Glib::RefPtr<Gst::Caps> caps = Gst::Caps::create(
-    Gst::Structure("video/x-raw-yuv").set_field("width", widthValue).set_field("height", heightValue).set_field("framerate", rateValue));
-
-  caps->append_structure(
-    Gst::Structure("video/x-raw-rgb").set_field("width", widthValue)
-      .set_field("height", heightValue).set_field("framerate", rateValue));
+  Gst::Structure structure("video/x-raw-yuv") ;
+  structure.set_field("width", 384);
+  structure.set_field("height", 288);
+  structure.set_field("framerate", Gst::Fraction(25, 1));
+  Glib::RefPtr<Gst::Caps> caps = Gst::Caps::create(structure);
+    
+  Gst::Structure structure2("video/x-raw-rgb");
+  structure2.set_field("width", 384);
+  structure2.set_field("height", 288);
+  structure2.set_field("framerate", Gst::Fraction(25, 1));
+  caps->append_structure(structure2);
 
   return e1->link_filtered(e2, caps);
 }

Modified: gstreamermm/trunk/tests/test-structure.cc
==============================================================================
--- gstreamermm/trunk/tests/test-structure.cc	(original)
+++ gstreamermm/trunk/tests/test-structure.cc	Wed May 21 12:42:48 2008
@@ -29,56 +29,36 @@
 
   Gst::Structure structure("my_structure");
 
-  Glib::Value<Glib::ustring> stringValue;
-  stringValue.init(Glib::Value<Glib::ustring>::value_type());
-  stringValue.set("Hello; This is a ustring.");
-
-  Glib::Value<int> intValue;
-  intValue.init(Glib::Value<int>::value_type());
-  intValue.set(100);
-
-  Glib::Value<Gst::Fraction> fractValue;
-  fractValue.init(Glib::Value<Gst::Fraction>::value_type());
-  fractValue.set(Gst::Fraction(1,2));
-
-  Glib::Value<Gst::FractionRange> rangeValue;
-  rangeValue.init(Glib::Value<Gst::FractionRange>::value_type());
-  rangeValue.set(Gst::FractionRange(Gst::Fraction(1,2), Gst::Fraction(3,4)));
-
+  structure.set_field(Glib::Quark("string"), "Hello; This is a ustring.");
+  structure.set_field("integer", 100);
+  structure.set_field("fraction", Gst::Fraction(1,2));
+  structure.set_field("range", Gst::FractionRange(Gst::Fraction(1,2), Gst::Fraction(3,4)));
   Glib::Date date;
   date.set_time_current();
-  Glib::Value<Glib::Date> dateValue;
-  dateValue.init(Glib::Value<Glib::Date>::value_type());
-  dateValue.set(date);
-
-  structure.set_field(Glib::Quark("string"), stringValue).set_field("integer", intValue).set_field("fraction", fractValue).set_field("range", rangeValue).set_field("date", dateValue);
+  structure.set_field("date", date);
 
-  Glib::Value<Glib::ustring> value1;
+  Glib::ustring value1;
   structure.get_field("string", value1);
-  std::cout << "string value = '" << value1.get() << "'" << std::endl;
+  std::cout << "string value = '" << value1 << "'" << std::endl;
 
-  Glib::Value<int> value2;
+  int value2;
   structure.get_field("integer", value2);
-  std::cout << "integer value = '" << value2.get() << "'" << std::endl;
+  std::cout << "integer value = '" << value2 << "'" << std::endl;
 
-  Glib::ValueBase value3;
+  Gst::Fraction value3;
   structure.get_field("fraction", value3);
-  Gst::Fraction fract(value3);
-  std::cout << "fraction value = '" << fract.num << "/" <<
-      fract.denom << "'" << std::endl;
+  std::cout << "fraction value = '" << value3.num << "/" <<
+    value3.denom << "'" << std::endl;
 
-  Glib::ValueBase value4;
+  Gst::FractionRange value4;
   structure.get_field("range", value4);
-  Gst::FractionRange range(value4);
-  std::cout << "fractional range value = '[(" << range.min.num << "/" <<
-      range.min.denom << "), (" << range.max.num << "/" << range.max.denom <<
-          ")]'" << std::endl;
+  std::cout << "fractional range value = '[(" << value4.min.num << "/" <<
+    value4.min.denom << "), (" << value4.max.num << "/" << value4.max.denom << ")]'" << std::endl;
 
-  Glib::ValueBase value5;
+  Glib::Date value5;
   structure.get_field("date", value5);
-  Glib::Date date_copy(*gst_value_get_date(value5.gobj()));
-  std::cout << "date value = " <<  date_copy.get_month() << "/" <<
-      (int) date_copy.get_day() << "/" << date_copy.get_year() << std::endl;
+  std::cout << "date value = " <<  value5.get_month() << "/" <<
+    (int) value5.get_day() << "/" << value5.get_year() << std::endl;
 
   return 0;
 }



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