gnomemm r1551 - in gstreamermm/trunk: . gstreamer/gstreamermm gstreamer/src tests tools/m4
- From: jaalburqu svn gnome org
- To: svn-commits-list gnome org
- Subject: gnomemm r1551 - in gstreamermm/trunk: . gstreamer/gstreamermm gstreamer/src tests tools/m4
- Date: Thu, 5 Jun 2008 02:57:27 +0000 (UTC)
Author: jaalburqu
Date: Thu Jun 5 02:57:27 2008
New Revision: 1551
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1551&view=rev
Log:
008-06-04 Josà Alburquerque <jaalburqu svn gnome org>
* gstreamer/src/taglist.ccg:
* gstreamer/src/taglist.hg: Wrapped various GST_TAG_* names; Expounded
the class docs; Added add/get methods to insert and get tag values
into TagLists; Wrapped remove_tag() and get_tag_size().
* tools/m4/Makefile_list_of_sources.am_fragment:
* tools/m4/class_boxedtype_extra.m4:
* tools/m4/convert.m4:
* tools/m4/convert_gst.m4: Had to add CLASS_BOXEDTYPE_EXTRA because
Gst::TagList::wrap(GstTagList*,bool) ambiguates Gst::Structure::wrap()
since a GstTagList is a GstStructure.
* gstreamer/gstreamermm/taglist.cc:
* gstreamer/gstreamermm/taglist.h: Regenerated these files by
temporarily adding taglist.hg to
gstreamer/src/Makefile_list_of_hg.am_fragment, removing the extern "C"
section in taglist.h and proceeding with build process; taglist.hg
cannot be left in Makefile_list_of_hg.am_fragment because a compile
error results when gmmproc generates taglist.h from taglist.hg (see
report #518934).
Added:
gstreamermm/trunk/tests/test-taglist.cc
gstreamermm/trunk/tools/m4/class_boxedtype_extra.m4
Modified:
gstreamermm/trunk/ChangeLog
gstreamermm/trunk/gstreamer/gstreamermm/taglist.cc
gstreamermm/trunk/gstreamer/gstreamermm/taglist.h
gstreamermm/trunk/gstreamer/src/caps.ccg
gstreamermm/trunk/gstreamer/src/caps.hg
gstreamermm/trunk/gstreamer/src/structure.ccg
gstreamermm/trunk/gstreamer/src/structure.hg
gstreamermm/trunk/gstreamer/src/taglist.ccg
gstreamermm/trunk/gstreamer/src/taglist.hg
gstreamermm/trunk/tests/Makefile.am
gstreamermm/trunk/tools/m4/Makefile_list_of_sources.am_fragment
gstreamermm/trunk/tools/m4/convert.m4
gstreamermm/trunk/tools/m4/convert_gst.m4
Modified: gstreamermm/trunk/gstreamer/gstreamermm/taglist.cc
==============================================================================
--- gstreamermm/trunk/gstreamer/gstreamermm/taglist.cc (original)
+++ gstreamermm/trunk/gstreamer/gstreamermm/taglist.cc Thu Jun 5 02:57:27 2008
@@ -27,28 +27,191 @@
#include <gst/gstenumtypes.h>
-/*
-static gboolean
-TagList_Foreach_gstreamermm_callback(const GstTagList* list, const gchar *tag, void* data)
+static void TagList_foreach_gstreamermm_callback(const GstTagList* list, const gchar *tag, void* data)
{
Gst::TagList::SlotForeach* slot = static_cast<Gst::TagList::SlotForeach*>(data);
- bool result = (*slot)(Glib::wrap(list), Glib::ustring(value));
- delete slot;
- return result;
+
+ const Glib::ustring tag_str = Glib::convert_const_gchar_ptr_to_ustring(tag);
+ (*slot)(tag_str);
}
-*/
namespace Gst
{
-/*
-void
-TagList::foreach(const SlotForeach& slot)
+void TagList::add(const Glib::ustring& tag, const Glib::ValueBase& value, TagMergeMode mode)
+{
+ gst_tag_list_add_values(gobj(), (GstTagMergeMode) mode, tag.c_str(), value.gobj(), NULL);
+}
+
+void TagList::add(const Glib::ustring& tag, const char* data, TagMergeMode mode)
+{
+ gst_tag_list_add(gobj(), (GstTagMergeMode) mode, tag.c_str(), data, NULL);
+}
+
+void TagList::foreach(const SlotForeach& slot)
{
SlotForeach* slot_copy = new SlotForeach(slot);
- gst_taglist_foreach(gobj(), &TagList_Foreach_gstreamermm_callback, slot_copy);
+ gst_tag_list_foreach(gobj(), &TagList_foreach_gstreamermm_callback, slot_copy);
+ delete slot_copy;
+}
+
+bool TagList::get(const Glib::ustring& tag, guint index, Glib::ValueBase& value)
+{
+ const GValue* gst_value = gst_tag_list_get_value_index(gobj(), tag.c_str(), index);
+ if (gst_value)
+ {
+ value.init(gst_value);
+ return true;
+ }
+ return false;
+}
+
+bool TagList::get(const Glib::ustring& tag, char& value)
+{
+ return gst_tag_list_get_char(gobj(), tag.c_str(), &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, guint index, char& value)
+{
+ return gst_tag_list_get_char_index(gobj(), tag.c_str(), index, &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, guchar& value)
+{
+ return gst_tag_list_get_uchar(gobj(), tag.c_str(), &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, guint index, guchar& value)
+{
+ return gst_tag_list_get_uchar_index(gobj(), tag.c_str(), index, &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, bool& value)
+{
+ gboolean gst_value = false;
+ bool result = gst_tag_list_get_boolean(gobj(), tag.c_str(), &gst_value);
+ value = gst_value;
+ return result;
+}
+
+bool TagList::get(const Glib::ustring& tag, guint index, bool& value)
+{
+ gboolean gst_value = false;
+ bool result = gst_tag_list_get_boolean_index(gobj(), tag.c_str(), index, &gst_value);
+ value = gst_value;
+ return result;
+}
+
+bool TagList::get(const Glib::ustring& tag, int& value)
+{
+ return gst_tag_list_get_int(gobj(), tag.c_str(), &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, guint index, int& value)
+{
+ return gst_tag_list_get_int_index(gobj(), tag.c_str(), index, &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, guint& value)
+{
+ return gst_tag_list_get_uint(gobj(), tag.c_str(), &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, guint index, guint& value)
+{
+ return gst_tag_list_get_uint_index(gobj(), tag.c_str(), index, &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, long& value)
+{
+ return gst_tag_list_get_long(gobj(), tag.c_str(), &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, guint index, long& value)
+{
+ return gst_tag_list_get_long_index(gobj(), tag.c_str(), index, &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, gulong& value)
+{
+ return gst_tag_list_get_ulong(gobj(), tag.c_str(), &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, guint index, gulong& value)
+{
+ return gst_tag_list_get_ulong_index(gobj(), tag.c_str(), index, &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, float& value)
+{
+ return gst_tag_list_get_float(gobj(), tag.c_str(), &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, guint index, float& value)
+{
+ return gst_tag_list_get_float_index(gobj(), tag.c_str(), index, &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, double& value)
+{
+ return gst_tag_list_get_double(gobj(), tag.c_str(), &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, guint index, double& value)
+{
+ return gst_tag_list_get_double_index(gobj(), tag.c_str(), index, &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, Glib::ustring& value)
+{
+ gchar *gst_value = 0;
+ bool result = gst_tag_list_get_string(gobj(), tag.c_str(), &gst_value);
+
+ if (result)
+ {
+ value = gst_value;
+ g_free(gst_value);
+ }
+
+ return result;
+}
+
+bool TagList::get(const Glib::ustring& tag, guint index, Glib::ustring& value)
+{
+ gchar *gst_value = 0;
+ bool result = gst_tag_list_get_string_index(gobj(), tag.c_str(), index, &gst_value);
+
+ if (result)
+ {
+ value = gst_value;
+ g_free(gst_value);
+ }
+
+ return result;
+}
+
+bool TagList::get(const Glib::ustring& tag, Glib::Date& value)
+{
+ GDate* gst_value = 0;
+ bool result = gst_tag_list_get_date(gobj(), tag.c_str(), &gst_value);
+
+ //TODO: Use Glib::Date constructor if possible.
+ if (result)
+ value.set_julian(g_date_julian(gst_value));
+
+ return result;
+}
+
+bool TagList::get(const Glib::ustring& tag, guint index, Glib::Date& value)
+{
+ GDate* gst_value = 0;
+ bool result = gst_tag_list_get_date_index(gobj(), tag.c_str(), index, &gst_value);
+
+ if (result)
+ value.set_julian(g_date_julian(gst_value));
+
+ return result;
}
-*/
} //namespace Gst
@@ -72,9 +235,9 @@
namespace Glib
{
-Gst::TagList wrap(GstTagList* object, bool take_copy, bool destroy, bool dummy)
+Gst::TagList wrap(GstTagList* object, bool take_copy, bool dummy)
{
- return Gst::TagList(object, take_copy, destroy);
+ return Gst::TagList(object, take_copy);
}
} // namespace Glib
@@ -97,30 +260,27 @@
TagList::TagList(const TagList& other)
:
- gobject_ (other.gobject_), // Always use original object
- destroy(false) // Do not delete gobject when wrapper is destroyed (let
- // original wrapper do that)
+ gobject_ ((other.gobject_) ? gst_tag_list_copy(other.gobject_) : 0)
{}
-TagList::TagList(GstTagList* gobject, bool make_a_copy, bool destroy)
+TagList::TagList(GstTagList* gobject, bool make_a_copy)
:
- // For this ncopy extra BoxedType wrapper, make_a_copy is false by default
- // and destroy is true.
- gobject_ ((make_a_copy && gobject) ? gst_tag_list_copy(gobject) : gobject),
- destroy(destroy) // Should wrapper destroy gobject when deleted?
+ // For BoxedType wrappers, make_a_copy is true by default. The static
+ // BoxedType wrappers must always take a copy, thus make_a_copy = true
+ // ensures identical behaviour if the default argument is used.
+ gobject_ ((make_a_copy && gobject) ? gst_tag_list_copy(gobject) : gobject)
{}
-// operator=() DOES make copies of gobject.
TagList& TagList::operator=(const TagList& other)
{
- TagList temp (gobject_, true);
+ TagList temp (other);
swap(temp);
return *this;
}
TagList::~TagList()
{
- if(destroy && gobject_)
+ if(gobject_)
gst_tag_list_free(gobject_);
}
@@ -129,10 +289,6 @@
GstTagList *const temp = gobject_;
gobject_ = other.gobject_;
other.gobject_ = temp;
-
- bool const destroy_temp = destroy;
- destroy = other.destroy;
- other.destroy = destroy_temp;
}
GstTagList* TagList::gobj_copy() const
@@ -140,12 +296,6 @@
return gst_tag_list_copy(gobject_);
}
-//
-void TagList::set_destroy(bool destroy)
-{
- this->destroy = destroy;
-}
-
bool TagList::exists(const Glib::ustring& tag)
{
@@ -183,9 +333,9 @@
}
-bool TagList::empty()
+bool TagList::is_empty() const
{
- return gst_tag_list_is_empty(gobj());
+ return gst_tag_list_is_empty(const_cast<GstTagList*>(gobj()));
}
void TagList::insert(const TagList& other, TagMergeMode mode)
@@ -195,7 +345,17 @@
TagList TagList::merge(const TagList& other, TagMergeMode mode)
{
- return Glib::wrap(gst_tag_list_merge(gobj(), ((other).gobj()), ((GstTagMergeMode)(mode))));
+ return Glib::wrap(gst_tag_list_merge(gobj(), ((other).gobj()), ((GstTagMergeMode)(mode))), false, false);
+}
+
+guint TagList::get_tag_size(const Glib::ustring& tag) const
+{
+ return gst_tag_list_get_tag_size(const_cast<GstTagList*>(gobj()), tag.c_str());
+}
+
+void TagList::remove_tag(const Glib::ustring& tag)
+{
+gst_tag_list_remove_tag(gobj(), tag.c_str());
}
Modified: gstreamermm/trunk/gstreamer/gstreamermm/taglist.h
==============================================================================
--- gstreamermm/trunk/gstreamer/gstreamermm/taglist.h (original)
+++ gstreamermm/trunk/gstreamer/gstreamermm/taglist.h Thu Jun 5 02:57:27 2008
@@ -28,7 +28,8 @@
*/
#include <gst/gsttaglist.h>
-
+#include <gstreamermm/structure.h>
+#include <gstreamermm/structurevalue.h>
namespace Gst
{
@@ -105,9 +106,238 @@
{
-/** Gst::TagList â List of tags and values used to describe media metadata.
+/** Commonly used title (string).
+ * The title as it should be displayed, e.g. 'The Doll House'.
+ */
+const Glib::ustring TAG_TITLE = GST_TAG_TITLE;
+
+/** Commonly used title, as used for sorting (string).
+ * The title as it should be sorted, e.g. 'Doll House, The'.
+ *
+ * Since 0.10.15.
+ */
+const Glib::ustring TAG_TITLE_SORTNAME = GST_TAG_TITLE_SORTNAME;
+
+/** Person(s) responsible for the recording (string).
+ * The artist name as it should be displayed, e.g. 'Jimi Hendrix' or 'The
+ * Guitar Heroes'.
+ */
+const Glib::ustring TAG_ARTIST = GST_TAG_ARTIST;
+
+/** Person(s) responsible for the recording, as used for sorting (string).
+ * The artist name as it should be sorted, e.g. 'Hendrix, Jimi' or 'Guitar
+ * Heroes, The'.
+ *
+ * Since 0.10.15.
+ */
+const Glib::ustring TAG_ARTIST_SORTNAME = GST_TAG_ARTIST_SORTNAME;
+
+/** Album containing this data (string).
+ * The album name as it should be displayed, e.g. 'The Jazz Guitar'.
+ */
+const Glib::ustring TAG_ALBUM = GST_TAG_ALBUM;
+
+/** Album containing this data, as used for sorting (string).
+ * The album name as it should be sorted, e.g. 'Jazz Guitar, The'.
+ *
+ * Since 0.10.15.
+ */
+const Glib::ustring TAG_ALBUM_SORTNAME = GST_TAG_ALBUM_SORTNAME;
+
+/** Date the data was created (GDate structure).
+ */
+const Glib::ustring TAG_DATE = GST_TAG_DATE;
+
+/** Genre this data belongs to (string).
+ */
+const Glib::ustring TAG_GENRE = GST_TAG_GENRE;
+
+/** Free text commenting the data (string).
+ */
+const Glib::ustring TAG_COMMENT = GST_TAG_COMMENT;
+
+/** Key/value text commenting the data (string).
+ * Must be in the form of 'key=comment' or 'key[lc]=comment' where 'lc' is an
+ * ISO-639 language code.
+ *
+ * This tag is used for unknown Vorbis comment tags, unknown APE tags and
+ * certain ID3v2 comment fields.
+ *
+ * Since 0.10.10.
+ */
+const Glib::ustring TAG_EXTENDED_COMMENT = GST_TAG_EXTENDED_COMMENT;
+
+/** Track number inside a collection (unsigned integer).
+ */
+const Glib::ustring TAG_TRACK_NUMBER = GST_TAG_TRACK_NUMBER;
+
+/** Count of tracks inside collection this track belongs to (unsigned integer).
+ */
+const Glib::ustring TAG_TRACK_COUNT = GST_TAG_TRACK_COUNT;
+
+/** Disc number inside a collection (unsigned integer).
+ */
+const Glib::ustring TAG_ALBUM_VOLUME_NUMBER = GST_TAG_ALBUM_VOLUME_NUMBER;
+
+/** Count of discs inside collection this disc belongs to (unsigned integer).
+ */
+const Glib::ustring TAG_ALBUM_VOLUME_COUNT = GST_TAG_ALBUM_VOLUME_COUNT;
+
+/** Original location of file as a URI (string).
+ */
+const Glib::ustring TAG_LOCATION = GST_TAG_LOCATION;
+
+/** Short text describing the content of the data (string).
+ */
+const Glib::ustring TAG_DESCRIPTION = GST_TAG_DESCRIPTION;
+
+/** Version of this data (string).
+ */
+const Glib::ustring TAG_VERSION = GST_TAG_VERSION;
+
+/** International Standard Recording Code - see http://www.ifpi.org/isrc/
+ * (string).
+ */
+const Glib::ustring TAG_ISRC = GST_TAG_ISRC;
+
+/** Organization (string).
+ */
+const Glib::ustring TAG_ORGANIZATION = GST_TAG_ORGANIZATION;
+
+/** Copyright notice of the data (string).
+ */
+const Glib::ustring TAG_COPYRIGHT = GST_TAG_COPYRIGHT;
+
+/** URI to location where copyright details can be found (string).
+ * Since 0.10.14.
+ */
+const Glib::ustring TAG_COPYRIGHT_URI = GST_TAG_COPYRIGHT_URI;
+
+/** Person(s) who composed the recording (string).
+ * Since 0.10.15.
+ */
+const Glib::ustring TAG_COMPOSER = GST_TAG_COMPOSER;
+
+/** Contact information (string).
+ */
+const Glib::ustring TAG_CONTACT = GST_TAG_CONTACT;
+
+/** License of data (string).
+ */
+const Glib::ustring TAG_LICENSE = GST_TAG_LICENSE;
+
+/** URI to location where license details can be found (string).
+ * Since 0.10.14.
+ */
+const Glib::ustring TAG_LICENSE_URI = GST_TAG_LICENSE_URI;
+
+/** Person(s) performing (string).
+ */
+const Glib::ustring TAG_PERFORMER = GST_TAG_PERFORMER;
+
+/** Length in GStreamer time units (nanoseconds) (unsigned 64-bit integer).
+ */
+const Glib::ustring TAG_DURATION = GST_TAG_DURATION;
+
+/** Codec the data is stored in (string).
+ */
+const Glib::ustring TAG_CODEC = GST_TAG_CODEC;
+
+/** Codec the video data is stored in (string).
+ */
+const Glib::ustring TAG_VIDEO_CODEC = GST_TAG_VIDEO_CODEC;
+
+/** Codec the audio data is stored in (string).
+ */
+const Glib::ustring TAG_AUDIO_CODEC = GST_TAG_AUDIO_CODEC;
+
+/** Exact or average bitrate in bits/s (unsigned integer).
+ */
+const Glib::ustring TAG_BITRATE = GST_TAG_BITRATE;
+
+/** Nominal bitrate in bits/s (unsigned integer).
+ */
+const Glib::ustring TAG_NOMINAL_BITRATE = GST_TAG_NOMINAL_BITRATE;
+
+/** Minimum bitrate in bits/s (unsigned integer).
+ */
+const Glib::ustring TAG_MINIMUM_BITRATE = GST_TAG_MINIMUM_BITRATE;
+
+/** Maximum bitrate in bits/s (unsigned integer).
+ */
+const Glib::ustring TAG_MAXIMUM_BITRATE = GST_TAG_MAXIMUM_BITRATE;
+
+/** Serial number of track (unsigned integer).
+ */
+const Glib::ustring TAG_SERIAL = GST_TAG_SERIAL;
+
+/** Encoder used to encode this stream (string).
+ */
+const Glib::ustring TAG_ENCODER = GST_TAG_ENCODER;
+
+/** Version of the encoder used to encode this stream (unsigned integer).
+ */
+const Glib::ustring TAG_ENCODER_VERSION = GST_TAG_ENCODER_VERSION;
+
+/** Track gain in db (double).
+ */
+const Glib::ustring TAG_TRACK_GAIN = GST_TAG_TRACK_GAIN;
+
+/** Peak of the track (double).
+ */
+const Glib::ustring TAG_TRACK_PEAK = GST_TAG_TRACK_PEAK;
+
+/** Album gain in db (double).
+ */
+const Glib::ustring TAG_ALBUM_GAIN = GST_TAG_ALBUM_GAIN;
+
+/** Peak of the album (double).
+ */
+const Glib::ustring TAG_ALBUM_PEAK = GST_TAG_ALBUM_PEAK;
+
+/** Reference level of track and album gain values (double).
+ * Since 0.10.12.
+ */
+const Glib::ustring TAG_REFERENCE_LEVEL = GST_TAG_REFERENCE_LEVEL;
+
+/** Language code (ISO-639-1) (string) of the content.
+ */
+const Glib::ustring TAG_LANGUAGE_CODE = GST_TAG_LANGUAGE_CODE;
+
+/** Image (buffer) (buffer caps should specify the content type and preferably
+ * also set "image-type" field as GstTagImageType).
+ * Since 0.10.6
+ */
+const Glib::ustring TAG_IMAGE = GST_TAG_IMAGE;
+
+/** Image that is meant for preview purposes, e.g. small icon-sized version
+ * (buffer) (buffer caps should specify the content type).
+ * Since 0.10.7.
+ */
+const Glib::ustring TAG_PREVIEW_IMAGE = GST_TAG_PREVIEW_IMAGE;
+
+/** Number of beats per minute in audio (double).
+ * Since 0.10.12.
+ */
+const Glib::ustring TAG_BEATS_PER_MINUTE = GST_TAG_BEATS_PER_MINUTE;
+
+/** A List of tags and values used to describe media metadata.
+ * Taglists form part of media streams and describe the content of a stream in
+ * a non-technical way. Examples include the author of a song, the title of
+ * that very same song or the album it is a part of. Tag reading is done
+ * through a Gst::Bus. You can listen for Gst::MESSAGE_TAG messages and handle
+ * them as you wish.
+ *
+ * Note, however, that the Gst::MESSAGE_TAG message may be fired multiple
+ * times in the pipeline. It is the application's responsibility to put all
+ * those tags together and display them to the user in a nice, coherent way.
+ * Usually, using merge() is a good enough way of doing this; make sure to
+ * empty the cache when loading a new song, or after every few minutes when
+ * listening to internet radio. Also, make sure you use Gst::TAG_MERGE_PREPEND
+ * as merging mode, so that a new title (which came in later) has a preference
+ * over the old one for display.
*/
-class TagList
+class TagList : public Structure
{
public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
@@ -119,7 +349,7 @@
TagList();
- explicit TagList(GstTagList* gobject, bool make_a_copy = false, bool destroy = true);
+ explicit TagList(GstTagList* gobject, bool make_a_copy = true);
TagList(const TagList& other);
TagList& operator=(const TagList& other);
@@ -137,27 +367,14 @@
///Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.
GstTagList* gobj_copy() const;
- /** Change whether the wrapper should destroy the underlying gobject or not
- * when the wrapper is deleted.
- * @param destroy whether or not the wrapper should destroy the underlying
- * gobject when it is destroyed
- */
- void set_destroy(bool destroy);
-
protected:
GstTagList* gobject_;
private:
- bool destroy;
-
-private:
public:
- /** For example,
- * void on_foreach(const Gst::TagList& taglist, const Glib::Ustring& tag);
- */
- typedef sigc::slot<void, const TagList&, const Glib::ustring&> SlotForeach;
+ //TODO: Add operator bool() to handle when C functions return NULL TagList*?
/** Checks if the given type is already registered.
@@ -202,13 +419,13 @@
*
* Since: 0.10.11.
*/
- bool empty();
+ bool is_empty() const;
/** Inserts the tags of the second list into the first list using the given mode.
* @param from List to merge from.
* @param mode The mode to use.
*/
- void insert(const TagList& other, TagMergeMode mode);
+ void insert(const TagList& other, TagMergeMode mode=TAG_MERGE_APPEND);
/** Merges the two given lists into a new list. If one of the lists is <tt>0</tt>, a
* copy of the other is returned. If both lists are <tt>0</tt>, <tt>0</tt> is returned.
@@ -216,18 +433,299 @@
* @param mode The mode to use.
* @return The new list.
*/
- TagList merge(const TagList& other, TagMergeMode mode);
+ TagList merge(const TagList& other, TagMergeMode mode=TAG_MERGE_PREPEND);
+
+ /** Checks how many value are stored in this tag list for the given tag.
+ * @param tag The tag to query.
+ * @return The number of tags stored.
+ */
+ guint get_tag_size(const Glib::ustring& tag) const;
+
+ /** Sets a GValue for the given @a tag using the specified mode.
+ *
+ * @param tag The tag name.
+ * @param mode The mode to use.
+ * @param value The GValue to set.
+ */
+ void add(const Glib::ustring& tag, const Glib::ValueBase& value, TagMergeMode mode=TAG_MERGE_APPEND);
+
+ /** Sets the value for the given tag to string @a data using the specified
+ * mode.
+ *
+ * @param tag The tag name.
+ * @param data A string to which the tag should be set to.
+ * @param mode The merge mode to use.
+ */
+ void add(const Glib::ustring& tag, const char* data, TagMergeMode mode=TAG_MERGE_APPEND);
+
+ /** Sets the value for the given tag using the specified mode.
+ *
+ * @param tag The tag name.
+ * @param data A value which the tag should be set to (this can be any C++
+ * class).
+ * @param mode The merge mode to use.
+ */
+ template <class DataType>
+ void add(const Glib::ustring& tag, const DataType& data, TagMergeMode mode=TAG_MERGE_APPEND);
+
+
+ /** Removes the given tag from the taglist.
+ * @param tag Tag to remove.
+ */
+ void remove_tag(const Glib::ustring& tag);
+
+ /** For example,
+ * void on_foreach(const Glib::ustring& tag);
+ */
+ typedef sigc::slot<void, const Glib::ustring&> SlotForeach;
/** Calls the given slot for each tag inside the tag list. Note that if there
* is no tag, the slot won't be called at all.
*
- * @param slot slot to be called for each tag
+ * @param slot Slot to be called for each tag.
*/
void foreach(const SlotForeach& slot);
+ /** Gets the value that is at the given index for the given tag.
+
+ * @param tag The tag to read out.
+ * @param index Number of entry to read out.
+ * @@param The Glib::ValueBase to store the value in.
+ * @return true if tag was available and had right number of entries, false
+ * otherwise.
+ */
+ bool get(const Glib::ustring& tag, guint index, Glib::ValueBase& value);
+
+ /** Copies the contents for the given tag into the value, merging multiple
+ * values into one if multiple values are associated with the tag.
+ * @param tag The tag to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, char& value);
+
+ /** Gets the value that is at the given index for the given tag.
+ * @param tag The tag to read out.
+ * @param index Number of entry to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, guint index, char& value);
+
+ /** Copies the contents for the given tag into the value, merging multiple
+ * values into one if multiple values are associated with the tag.
+ * @param tag The tag to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, guchar& value);
+
+ /** Gets the value that is at the given index for the given tag.
+ * @param tag The tag to read out.
+ * @param index Number of entry to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, guint index, guchar& value);
+
+ /** Copies the contents for the given tag into the value, merging multiple
+ * values into one if multiple values are associated with the tag.
+ * @param tag The tag to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, bool& value);
+
+ /** Gets the value that is at the given index for the given tag.
+ * @param tag The tag to read out.
+ * @param index Number of entry to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, guint index, bool& value);
+
+ /** Copies the contents for the given tag into the value, merging multiple
+ * values into one if multiple values are associated with the tag.
+ * @param tag The tag to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, int& value);
+
+ /** Gets the value that is at the given index for the given tag.
+ * @param tag The tag to read out.
+ * @param index Number of entry to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, guint index, int& value);
+
+ /** Copies the contents for the given tag into the value, merging multiple
+ * values into one if multiple values are associated with the tag.
+ * @param tag The tag to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, guint& value);
+
+ /** Gets the value that is at the given index for the given tag.
+ * @param tag The tag to read out.
+ * @param index Number of entry to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, guint index, guint& value);
+
+ /** Copies the contents for the given tag into the value, merging multiple
+ * values into one if multiple values are associated with the tag.
+ * @param tag The tag to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, long& value);
+
+ /** Gets the value that is at the given index for the given tag.
+ * @param tag The tag to read out.
+ * @param index Number of entry to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, guint index, long& value);
+
+ /** Copies the contents for the given tag into the value, merging multiple
+ * values into one if multiple values are associated with the tag.
+ * @param tag The tag to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, gulong& value);
+
+ /** Gets the value that is at the given index for the given tag.
+ * @param tag The tag to read out.
+ * @param index Number of entry to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, guint index, gulong& value);
+
+ /** Copies the contents for the given tag into the value, merging multiple
+ * values into one if multiple values are associated with the tag.
+ * @param tag The tag to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, float& value);
+
+ /** Gets the value that is at the given index for the given tag.
+ * @param tag The tag to read out.
+ * @param index Number of entry to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, guint index, float& value);
+
+ /** Copies the contents for the given tag into the value, merging multiple
+ * values into one if multiple values are associated with the tag.
+ * @param tag The tag to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, double& value);
+
+ /** Gets the value that is at the given index for the given tag.
+ * @param tag The tag to read out.
+ * @param index Number of entry to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, guint index, double& value);
+
+ /** Copies the contents for the given tag into the value, possibly merging
+ * multiple values into one if multiple values are associated with the tag.
+ *
+ * Use the index version of this method if you want to retrieve the first
+ * string associated with this tag unmodified.
+ *
+ * The resulting string in value will be in UTF-8 encoding.
+ *
+ * @param tag The tag to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, Glib::ustring& value);
+
+ /** Gets the value that is at the given index for the given tag in the given
+ * list.
+ *
+ * The resulting string in value will be in UTF-8 encoding.
+ *
+ * @param tag The tag to read out.
+ * @param index Number of entry to read out.
+ * @param value location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, guint index, Glib::ustring& value);
+
+ /** Copies the contents for the given tag into the value, merging multiple
+ * values into one if multiple values are associated with the tag.
+ * @param tag The tag to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, Glib::Date& value);
+
+ /** Gets the value that is at the given index for the given tag.
+ * @param tag The tag to read out.
+ * @param index Number of entry to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, guint index, Glib::Date& value);
+
};
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+/******************************* Gst::Caps *******************************/
+
+template <class DataType>
+void TagList::add(const Glib::ustring& tag, const DataType& data, TagMergeMode mode)
+{
+ typedef typename Gst::StructureValue<DataType> type_cppdata;
+ typedef typename type_cppdata::ValueType ValueType;
+
+ ValueType value;
+ value.init(ValueType::value_type());
+ value.set(data);
+ this->add(tag, (Glib::ValueBase) value, mode);
+}
+
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+
+
} //namespace Gst
@@ -246,21 +744,16 @@
namespace Glib
{
-/** A Glib::wrap() method for this object.
+/** A Glib::wrap() method for this object. The dummy boolean parameter is added to disambiguate Gst::TagList::wrap() from Gst::Structure::wrap() (GstTagList is in fact a GstStructure so wrap method becomes ambiguous).
*
* @param object The C instance.
- * @param take_copy False if the result should take ownership of the C
- * instance. True if it should take a new copy or ref.
- * @param destroy False if the result should not delete the C instance when
- * wrapper is destroyed. True if it should.
- * @param dummy Unused; simply an extra param to disambiguate wrap in weird
- * case such as GStreamer types GstStructure and GstTagList which are both
- * really same C type
+ * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
+ * @param dummy An unused parameter to disambiguate Gst::TagList::wrap() from Gst::Structure::wrap().
* @result A C++ instance that wraps this C instance.
*
* @relates Gst::TagList
*/
-Gst::TagList wrap(GstTagList* object, bool take_copy = false, bool destroy = true, bool dummy = false);
+Gst::TagList wrap(GstTagList* object, bool take_copy = false, bool dummy = false);
#ifndef DOXYGEN_SHOULD_SKIP_THIS
template <>
Modified: gstreamermm/trunk/gstreamer/src/caps.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/caps.ccg (original)
+++ gstreamermm/trunk/gstreamer/src/caps.ccg Thu Jun 5 02:57:27 2008
@@ -77,8 +77,8 @@
//TODO: Want to return RefPtr to Caps but using RefPtr in expressions such
// as 'caps->set_simple(name1, value1)->set_simple(name2, value2)' a
-// causes gstreamer Structure immutability warnings because the Caps is referenced
-// more than once in the expression
+// causes gstreamer Structure immutability warnings because the Caps is
+// referenced more than once in the expression
/*
This method is implemented in place of gst_caps_set_simple which is a
variable argument function and cannot be wrapped. We don't call
Modified: gstreamermm/trunk/gstreamer/src/caps.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/caps.hg (original)
+++ gstreamermm/trunk/gstreamer/src/caps.hg Thu Jun 5 02:57:27 2008
@@ -132,7 +132,7 @@
*
* @param name Field to set.
* @param data A value which the field should be set to (this can be any C++
- * type).
+ * class).
*/
template <class DataType>
void set_simple(const Glib::ustring& name, const DataType& data);
Modified: gstreamermm/trunk/gstreamer/src/structure.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/structure.ccg (original)
+++ gstreamermm/trunk/gstreamer/src/structure.ccg Thu Jun 5 02:57:27 2008
@@ -233,15 +233,12 @@
}
}
-Structure&
-Structure::remove_field(const Glib::ustring& fieldname)
+void Structure::remove_field(const Glib::ustring& fieldname)
{
gst_structure_remove_field(gobj(), fieldname.c_str());
- return *this;
}
-bool
-Structure::get_field(const Glib::ustring& name, bool& value) const
+bool Structure::get_field(const Glib::ustring& name, bool& value) const
{
gboolean cvalue = FALSE;
const bool result = gst_structure_get_boolean(gobj(), name.c_str(), &cvalue);
@@ -249,20 +246,17 @@
return result;
}
-bool
-Structure::get_field(const Glib::ustring& name, int& value) const
+bool Structure::get_field(const Glib::ustring& name, int& value) const
{
return gst_structure_get_int(gobj(), name.c_str(), &value);
}
-bool
-Structure::get_field(const Glib::ustring& name, guint& value) const
+bool Structure::get_field(const Glib::ustring& name, guint& value) const
{
return gst_structure_get_uint(gobj(), name.c_str(), &value);
}
-bool
-Structure::get_field(const Glib::ustring& name, Fourcc& value) const
+bool Structure::get_field(const Glib::ustring& name, Fourcc& value) const
{
guint32 cvalue = 0;
const bool result = gst_structure_get_fourcc(gobj(), name.c_str(), &cvalue);
@@ -273,14 +267,12 @@
}
-bool
-Structure::get_field(const Glib::ustring& name, double& value) const
+bool Structure::get_field(const Glib::ustring& name, double& value) const
{
return gst_structure_get_double(gobj(), name.c_str(), &value);
}
-bool
-Structure::get_field(const Glib::ustring& name, Glib::ustring& value) const
+bool Structure::get_field(const Glib::ustring& name, Glib::ustring& value) const
{
const gchar* cvalue = gst_structure_get_string(gobj(), name.c_str());
if(cvalue)
@@ -292,8 +284,7 @@
return false;
}
-bool
-Structure::get_field(const Glib::ustring& name, std::string& value) const
+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)
@@ -305,8 +296,7 @@
return false;
}
-bool
-Structure::get_field(const Glib::ustring& name, Glib::Date& date) const
+bool 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);
@@ -316,9 +306,7 @@
return has;
}
-
-bool
-Structure::get_field(const Glib::ustring& name, ClockTime& value) const
+bool Structure::get_field(const Glib::ustring& name, ClockTime& value) const
{
GstClockTime cvalue = 0;
const bool result = gst_structure_get_clock_time(gobj(), name.c_str(), &cvalue);
@@ -327,15 +315,13 @@
}
-bool
-Structure::get_field(const Glib::ustring& name, GType enum_type, int& value) const
+bool Structure::get_field(const Glib::ustring& name, GType enum_type, int& value) const
{
return gst_structure_get_enum(gobj(), name.c_str(), enum_type, &value);
}
-bool
-Structure::get_field(const Glib::ustring& name, Gst::Fraction& f) const
+bool Structure::get_field(const Glib::ustring& name, Gst::Fraction& f) const
{
int value_numerator = 0;
int value_denominator = 0;
@@ -346,8 +332,7 @@
return result;
}
-bool
-Structure::get_field(const Glib::ustring& name, Gst::IntRange& range) const
+bool Structure::get_field(const Glib::ustring& name, Gst::IntRange& range) const
{
const GValue* gst_range_val = gst_structure_get_value(gobj(), name.c_str());
@@ -362,8 +347,7 @@
return false;
}
-bool
-Structure::get_field(const Glib::ustring& name, Gst::DoubleRange& range) const
+bool Structure::get_field(const Glib::ustring& name, Gst::DoubleRange& range) const
{
const GValue* gst_range_val = gst_structure_get_value(gobj(), name.c_str());
@@ -378,8 +362,7 @@
return false;
}
-bool
-Structure::get_field(const Glib::ustring& name, Gst::FractionRange& range) const
+bool Structure::get_field(const Glib::ustring& name, Gst::FractionRange& range) const
{
const GValue* gst_range_val = gst_structure_get_value(gobj(), name.c_str());
@@ -402,22 +385,19 @@
return false;
}
-bool
-Structure::foreach(const SlotForeach& slot)
+bool Structure::foreach(const SlotForeach& slot)
{
SlotForeach* slot_copy = new SlotForeach(slot);
return gst_structure_foreach(gobj(), &Structure_Foreach_gstreamermm_callback, slot_copy);
}
-bool
-Structure::map_in_place(const SlotMap& slot)
+bool Structure::map_in_place(const SlotMap& slot)
{
SlotMap* slot_copy = new SlotMap(slot);
return gst_structure_map_in_place(gobj(), &Structure_Map_gstreamermm_callback, slot_copy);
}
-Structure
-Structure::create_from_string(const Glib::ustring& the_string)
+Structure Structure::create_from_string(const Glib::ustring& the_string)
{
return Structure(gst_structure_from_string(the_string.c_str(), NULL));
}
Modified: gstreamermm/trunk/gstreamer/src/structure.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/structure.hg (original)
+++ gstreamermm/trunk/gstreamer/src/structure.hg Thu Jun 5 02:57:27 2008
@@ -256,13 +256,11 @@
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
/** Removes the field with name @a fieldname. If the field with the given
- * name does not exist, the structure is unchanged. Returns this
- * Gst::Structure for continued setting convenience.
+ * name does not exist, the structure is unchanged.
*
* @param fieldname The name of the field to remove.
- * @return This Gst::Structure.
*/
- Structure& remove_field(const Glib::ustring& fieldname);
+ void remove_field(const Glib::ustring& fieldname);
_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)
Modified: gstreamermm/trunk/gstreamer/src/taglist.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/taglist.ccg (original)
+++ gstreamermm/trunk/gstreamer/src/taglist.ccg Thu Jun 5 02:57:27 2008
@@ -21,25 +21,190 @@
#include <gst/gstenumtypes.h>
-
-static gboolean
-TagList_foreach_gstreamermm_callback(const GstTagList* list, const gchar *tag, void* data)
+static void TagList_foreach_gstreamermm_callback(const GstTagList* list, const gchar *tag, void* data)
{
Gst::TagList::SlotForeach* slot = static_cast<Gst::TagList::SlotForeach*>(data);
const Glib::ustring tag_str = Glib::convert_const_gchar_ptr_to_ustring(tag);
- return (*slot)(tag_str);
+ (*slot)(tag_str);
}
namespace Gst
{
-void
-TagList::foreach(const SlotForeach& slot)
+void TagList::add(const Glib::ustring& tag, const Glib::ValueBase& value, TagMergeMode mode)
+{
+ gst_tag_list_add_values(gobj(), (GstTagMergeMode) mode, tag.c_str(), value.gobj(), NULL);
+}
+
+void TagList::add(const Glib::ustring& tag, const char* data, TagMergeMode mode)
+{
+ gst_tag_list_add(gobj(), (GstTagMergeMode) mode, tag.c_str(), data, NULL);
+}
+
+void TagList::foreach(const SlotForeach& slot)
{
SlotForeach* slot_copy = new SlotForeach(slot);
- gst_taglist_foreach(gobj(), &TagList_foreach_gstreamermm_callback, slot_copy);
+ gst_tag_list_foreach(gobj(), &TagList_foreach_gstreamermm_callback, slot_copy);
delete slot_copy;
}
+bool TagList::get(const Glib::ustring& tag, guint index, Glib::ValueBase& value)
+{
+ const GValue* gst_value = gst_tag_list_get_value_index(gobj(), tag.c_str(), index);
+ if (gst_value)
+ {
+ value.init(gst_value);
+ return true;
+ }
+ return false;
+}
+
+bool TagList::get(const Glib::ustring& tag, char& value)
+{
+ return gst_tag_list_get_char(gobj(), tag.c_str(), &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, guint index, char& value)
+{
+ return gst_tag_list_get_char_index(gobj(), tag.c_str(), index, &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, guchar& value)
+{
+ return gst_tag_list_get_uchar(gobj(), tag.c_str(), &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, guint index, guchar& value)
+{
+ return gst_tag_list_get_uchar_index(gobj(), tag.c_str(), index, &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, bool& value)
+{
+ gboolean gst_value = false;
+ bool result = gst_tag_list_get_boolean(gobj(), tag.c_str(), &gst_value);
+ value = gst_value;
+ return result;
+}
+
+bool TagList::get(const Glib::ustring& tag, guint index, bool& value)
+{
+ gboolean gst_value = false;
+ bool result = gst_tag_list_get_boolean_index(gobj(), tag.c_str(), index, &gst_value);
+ value = gst_value;
+ return result;
+}
+
+bool TagList::get(const Glib::ustring& tag, int& value)
+{
+ return gst_tag_list_get_int(gobj(), tag.c_str(), &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, guint index, int& value)
+{
+ return gst_tag_list_get_int_index(gobj(), tag.c_str(), index, &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, guint& value)
+{
+ return gst_tag_list_get_uint(gobj(), tag.c_str(), &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, guint index, guint& value)
+{
+ return gst_tag_list_get_uint_index(gobj(), tag.c_str(), index, &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, long& value)
+{
+ return gst_tag_list_get_long(gobj(), tag.c_str(), &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, guint index, long& value)
+{
+ return gst_tag_list_get_long_index(gobj(), tag.c_str(), index, &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, gulong& value)
+{
+ return gst_tag_list_get_ulong(gobj(), tag.c_str(), &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, guint index, gulong& value)
+{
+ return gst_tag_list_get_ulong_index(gobj(), tag.c_str(), index, &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, float& value)
+{
+ return gst_tag_list_get_float(gobj(), tag.c_str(), &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, guint index, float& value)
+{
+ return gst_tag_list_get_float_index(gobj(), tag.c_str(), index, &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, double& value)
+{
+ return gst_tag_list_get_double(gobj(), tag.c_str(), &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, guint index, double& value)
+{
+ return gst_tag_list_get_double_index(gobj(), tag.c_str(), index, &value);
+}
+
+bool TagList::get(const Glib::ustring& tag, Glib::ustring& value)
+{
+ gchar *gst_value = 0;
+ bool result = gst_tag_list_get_string(gobj(), tag.c_str(), &gst_value);
+
+ if (result)
+ {
+ value = gst_value;
+ g_free(gst_value);
+ }
+
+ return result;
+}
+
+bool TagList::get(const Glib::ustring& tag, guint index, Glib::ustring& value)
+{
+ gchar *gst_value = 0;
+ bool result = gst_tag_list_get_string_index(gobj(), tag.c_str(), index, &gst_value);
+
+ if (result)
+ {
+ value = gst_value;
+ g_free(gst_value);
+ }
+
+ return result;
+}
+
+bool TagList::get(const Glib::ustring& tag, Glib::Date& value)
+{
+ GDate* gst_value = 0;
+ bool result = gst_tag_list_get_date(gobj(), tag.c_str(), &gst_value);
+
+ //TODO: Use Glib::Date constructor if possible.
+ if (result)
+ value.set_julian(g_date_julian(gst_value));
+
+ return result;
+}
+
+bool TagList::get(const Glib::ustring& tag, guint index, Glib::Date& value)
+{
+ GDate* gst_value = 0;
+ bool result = gst_tag_list_get_date_index(gobj(), tag.c_str(), index, &gst_value);
+
+ if (result)
+ value.set_julian(g_date_julian(gst_value));
+
+ return result;
+}
+
} //namespace Gst
Modified: gstreamermm/trunk/gstreamer/src/taglist.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/taglist.hg (original)
+++ gstreamermm/trunk/gstreamer/src/taglist.hg Thu Jun 5 02:57:27 2008
@@ -20,6 +20,8 @@
*/
#include <gst/gsttaglist.h>
+#include <gstreamermm/structure.h>
+#include <gstreamermm/structurevalue.h>
_DEFS(gstreamermm,gst)
@@ -29,15 +31,242 @@
_WRAP_ENUM(TagMergeMode, GstTagMergeMode)
_WRAP_ENUM(TagFlag, GstTagFlag)
-//TODO: Suggest how you might get a TagList.
+/** Commonly used title (string).
+ * The title as it should be displayed, e.g. 'The Doll House'.
+ */
+const Glib::ustring TAG_TITLE = GST_TAG_TITLE;
+
+/** Commonly used title, as used for sorting (string).
+ * The title as it should be sorted, e.g. 'Doll House, The'.
+ *
+ * Since 0.10.15.
+ */
+const Glib::ustring TAG_TITLE_SORTNAME = GST_TAG_TITLE_SORTNAME;
+
+/** Person(s) responsible for the recording (string).
+ * The artist name as it should be displayed, e.g. 'Jimi Hendrix' or 'The
+ * Guitar Heroes'.
+ */
+const Glib::ustring TAG_ARTIST = GST_TAG_ARTIST;
+
+/** Person(s) responsible for the recording, as used for sorting (string).
+ * The artist name as it should be sorted, e.g. 'Hendrix, Jimi' or 'Guitar
+ * Heroes, The'.
+ *
+ * Since 0.10.15.
+ */
+const Glib::ustring TAG_ARTIST_SORTNAME = GST_TAG_ARTIST_SORTNAME;
+
+/** Album containing this data (string).
+ * The album name as it should be displayed, e.g. 'The Jazz Guitar'.
+ */
+const Glib::ustring TAG_ALBUM = GST_TAG_ALBUM;
+
+/** Album containing this data, as used for sorting (string).
+ * The album name as it should be sorted, e.g. 'Jazz Guitar, The'.
+ *
+ * Since 0.10.15.
+ */
+const Glib::ustring TAG_ALBUM_SORTNAME = GST_TAG_ALBUM_SORTNAME;
+
+/** Date the data was created (GDate structure).
+ */
+const Glib::ustring TAG_DATE = GST_TAG_DATE;
+
+/** Genre this data belongs to (string).
+ */
+const Glib::ustring TAG_GENRE = GST_TAG_GENRE;
+
+/** Free text commenting the data (string).
+ */
+const Glib::ustring TAG_COMMENT = GST_TAG_COMMENT;
+
+/** Key/value text commenting the data (string).
+ * Must be in the form of 'key=comment' or 'key[lc]=comment' where 'lc' is an
+ * ISO-639 language code.
+ *
+ * This tag is used for unknown Vorbis comment tags, unknown APE tags and
+ * certain ID3v2 comment fields.
+ *
+ * Since 0.10.10.
+ */
+const Glib::ustring TAG_EXTENDED_COMMENT = GST_TAG_EXTENDED_COMMENT;
+
+/** Track number inside a collection (unsigned integer).
+ */
+const Glib::ustring TAG_TRACK_NUMBER = GST_TAG_TRACK_NUMBER;
+
+/** Count of tracks inside collection this track belongs to (unsigned integer).
+ */
+const Glib::ustring TAG_TRACK_COUNT = GST_TAG_TRACK_COUNT;
+
+/** Disc number inside a collection (unsigned integer).
+ */
+const Glib::ustring TAG_ALBUM_VOLUME_NUMBER = GST_TAG_ALBUM_VOLUME_NUMBER;
+
+/** Count of discs inside collection this disc belongs to (unsigned integer).
+ */
+const Glib::ustring TAG_ALBUM_VOLUME_COUNT = GST_TAG_ALBUM_VOLUME_COUNT;
+
+/** Original location of file as a URI (string).
+ */
+const Glib::ustring TAG_LOCATION = GST_TAG_LOCATION;
+
+/** Short text describing the content of the data (string).
+ */
+const Glib::ustring TAG_DESCRIPTION = GST_TAG_DESCRIPTION;
+
+/** Version of this data (string).
+ */
+const Glib::ustring TAG_VERSION = GST_TAG_VERSION;
+
+/** International Standard Recording Code - see http://www.ifpi.org/isrc/
+ * (string).
+ */
+const Glib::ustring TAG_ISRC = GST_TAG_ISRC;
+
+/** Organization (string).
+ */
+const Glib::ustring TAG_ORGANIZATION = GST_TAG_ORGANIZATION;
+
+/** Copyright notice of the data (string).
+ */
+const Glib::ustring TAG_COPYRIGHT = GST_TAG_COPYRIGHT;
+
+/** URI to location where copyright details can be found (string).
+ * Since 0.10.14.
+ */
+const Glib::ustring TAG_COPYRIGHT_URI = GST_TAG_COPYRIGHT_URI;
+
+/** Person(s) who composed the recording (string).
+ * Since 0.10.15.
+ */
+const Glib::ustring TAG_COMPOSER = GST_TAG_COMPOSER;
+
+/** Contact information (string).
+ */
+const Glib::ustring TAG_CONTACT = GST_TAG_CONTACT;
+
+/** License of data (string).
+ */
+const Glib::ustring TAG_LICENSE = GST_TAG_LICENSE;
+
+/** URI to location where license details can be found (string).
+ * Since 0.10.14.
+ */
+const Glib::ustring TAG_LICENSE_URI = GST_TAG_LICENSE_URI;
+
+/** Person(s) performing (string).
+ */
+const Glib::ustring TAG_PERFORMER = GST_TAG_PERFORMER;
+
+/** Length in GStreamer time units (nanoseconds) (unsigned 64-bit integer).
+ */
+const Glib::ustring TAG_DURATION = GST_TAG_DURATION;
+
+/** Codec the data is stored in (string).
+ */
+const Glib::ustring TAG_CODEC = GST_TAG_CODEC;
+
+/** Codec the video data is stored in (string).
+ */
+const Glib::ustring TAG_VIDEO_CODEC = GST_TAG_VIDEO_CODEC;
+
+/** Codec the audio data is stored in (string).
+ */
+const Glib::ustring TAG_AUDIO_CODEC = GST_TAG_AUDIO_CODEC;
+
+/** Exact or average bitrate in bits/s (unsigned integer).
+ */
+const Glib::ustring TAG_BITRATE = GST_TAG_BITRATE;
+
+/** Nominal bitrate in bits/s (unsigned integer).
+ */
+const Glib::ustring TAG_NOMINAL_BITRATE = GST_TAG_NOMINAL_BITRATE;
+
+/** Minimum bitrate in bits/s (unsigned integer).
+ */
+const Glib::ustring TAG_MINIMUM_BITRATE = GST_TAG_MINIMUM_BITRATE;
+
+/** Maximum bitrate in bits/s (unsigned integer).
+ */
+const Glib::ustring TAG_MAXIMUM_BITRATE = GST_TAG_MAXIMUM_BITRATE;
+
+/** Serial number of track (unsigned integer).
+ */
+const Glib::ustring TAG_SERIAL = GST_TAG_SERIAL;
+
+/** Encoder used to encode this stream (string).
+ */
+const Glib::ustring TAG_ENCODER = GST_TAG_ENCODER;
+
+/** Version of the encoder used to encode this stream (unsigned integer).
+ */
+const Glib::ustring TAG_ENCODER_VERSION = GST_TAG_ENCODER_VERSION;
+
+/** Track gain in db (double).
+ */
+const Glib::ustring TAG_TRACK_GAIN = GST_TAG_TRACK_GAIN;
+
+/** Peak of the track (double).
+ */
+const Glib::ustring TAG_TRACK_PEAK = GST_TAG_TRACK_PEAK;
+
+/** Album gain in db (double).
+ */
+const Glib::ustring TAG_ALBUM_GAIN = GST_TAG_ALBUM_GAIN;
+
+/** Peak of the album (double).
+ */
+const Glib::ustring TAG_ALBUM_PEAK = GST_TAG_ALBUM_PEAK;
+
+/** Reference level of track and album gain values (double).
+ * Since 0.10.12.
+ */
+const Glib::ustring TAG_REFERENCE_LEVEL = GST_TAG_REFERENCE_LEVEL;
+
+/** Language code (ISO-639-1) (string) of the content.
+ */
+const Glib::ustring TAG_LANGUAGE_CODE = GST_TAG_LANGUAGE_CODE;
+
+/** Image (buffer) (buffer caps should specify the content type and preferably
+ * also set "image-type" field as GstTagImageType).
+ * Since 0.10.6
+ */
+const Glib::ustring TAG_IMAGE = GST_TAG_IMAGE;
+
+/** Image that is meant for preview purposes, e.g. small icon-sized version
+ * (buffer) (buffer caps should specify the content type).
+ * Since 0.10.7.
+ */
+const Glib::ustring TAG_PREVIEW_IMAGE = GST_TAG_PREVIEW_IMAGE;
+
+/** Number of beats per minute in audio (double).
+ * Since 0.10.12.
+ */
+const Glib::ustring TAG_BEATS_PER_MINUTE = GST_TAG_BEATS_PER_MINUTE;
+
/** A List of tags and values used to describe media metadata.
+ * Taglists form part of media streams and describe the content of a stream in
+ * a non-technical way. Examples include the author of a song, the title of
+ * that very same song or the album it is a part of. Tag reading is done
+ * through a Gst::Bus. You can listen for Gst::MESSAGE_TAG messages and handle
+ * them as you wish.
+ *
+ * Note, however, that the Gst::MESSAGE_TAG message may be fired multiple
+ * times in the pipeline. It is the application's responsibility to put all
+ * those tags together and display them to the user in a nice, coherent way.
+ * Usually, using merge() is a good enough way of doing this; make sure to
+ * empty the cache when loading a new song, or after every few minutes when
+ * listening to internet radio. Also, make sure you use Gst::TAG_MERGE_PREPEND
+ * as merging mode, so that a new title (which came in later) has a preference
+ * over the old one for display.
*/
-class TagList
+class TagList : public Structure
{
- _CLASS_BOXEDTYPE(TagList, GstTagList, gst_tag_list_new, gst_tag_list_copy, gst_tag_list_free)
+ _CLASS_BOXEDTYPE_EXTRA(TagList, GstTagList, gst_tag_list_new, gst_tag_list_copy, gst_tag_list_free)
public:
-
//TODO: Add operator bool() to handle when C functions return NULL TagList*?
_WRAP_METHOD(static bool exists(const Glib::ustring& tag), gst_tag_exists)
@@ -46,16 +275,44 @@
_WRAP_METHOD(static Glib::ustring get_description(const Glib::ustring& tag), gst_tag_get_description)
_WRAP_METHOD(static TagFlag get_flag(const Glib::ustring& tag), gst_tag_get_flag)
_WRAP_METHOD(static bool is_fixed(const Glib::ustring& tag), gst_tag_is_fixed)
- _WRAP_METHOD(bool empty() const, gst_tag_list_is_empty)
+ _WRAP_METHOD(bool is_empty() const, gst_tag_list_is_empty)
+ _WRAP_METHOD(void insert(const TagList& other, TagMergeMode mode=TAG_MERGE_APPEND), gst_tag_list_insert)
+ _WRAP_METHOD(TagList merge(const TagList& other, TagMergeMode mode=TAG_MERGE_PREPEND), gst_tag_list_merge)
+ _WRAP_METHOD(guint get_tag_size(const Glib::ustring& tag) const, gst_tag_list_get_tag_size)
+
+ /** Sets a GValue for the given @a tag using the specified mode.
+ *
+ * @param tag The tag name.
+ * @param mode The mode to use.
+ * @param value The GValue to set.
+ */
+ void add(const Glib::ustring& tag, const Glib::ValueBase& value, TagMergeMode mode=TAG_MERGE_APPEND);
+
+ /** Sets the value for the given tag to string @a data using the specified
+ * mode.
+ *
+ * @param tag The tag name.
+ * @param data A string to which the tag should be set to.
+ * @param mode The merge mode to use.
+ */
+ void add(const Glib::ustring& tag, const char* data, TagMergeMode mode=TAG_MERGE_APPEND);
+
+ /** Sets the value for the given tag using the specified mode.
+ *
+ * @param tag The tag name.
+ * @param data A value which the tag should be set to (this can be any C++
+ * class).
+ * @param mode The merge mode to use.
+ */
+ template <class DataType>
+ void add(const Glib::ustring& tag, const DataType& data, TagMergeMode mode=TAG_MERGE_APPEND);
- //TODO: Add a suitable default value for mode?
- _WRAP_METHOD(void insert(const TagList& other, TagMergeMode mode), gst_tag_list_insert)
- _WRAP_METHOD(TagList merge(const TagList& other, TagMergeMode mode), gst_tag_list_merge)
+ _WRAP_METHOD(void remove_tag(const Glib::ustring& tag), gst_tag_list_remove_tag)
/** For example,
* void on_foreach(const Glib::ustring& tag);
*/
- typedef sigc::slot<void, Glib::ustring&> SlotForeach;
+ typedef sigc::slot<void, const Glib::ustring&> SlotForeach;
/** Calls the given slot for each tag inside the tag list. Note that if there
* is no tag, the slot won't be called at all.
@@ -63,6 +320,243 @@
* @param slot Slot to be called for each tag.
*/
void foreach(const SlotForeach& slot);
+
+ /** Gets the value that is at the given index for the given tag.
+
+ * @param tag The tag to read out.
+ * @param index Number of entry to read out.
+ * @@param The Glib::ValueBase to store the value in.
+ * @return true if tag was available and had right number of entries, false
+ * otherwise.
+ */
+ bool get(const Glib::ustring& tag, guint index, Glib::ValueBase& value);
+
+ /** Copies the contents for the given tag into the value, merging multiple
+ * values into one if multiple values are associated with the tag.
+ * @param tag The tag to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, char& value);
+
+ /** Gets the value that is at the given index for the given tag.
+ * @param tag The tag to read out.
+ * @param index Number of entry to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, guint index, char& value);
+
+ /** Copies the contents for the given tag into the value, merging multiple
+ * values into one if multiple values are associated with the tag.
+ * @param tag The tag to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, guchar& value);
+
+ /** Gets the value that is at the given index for the given tag.
+ * @param tag The tag to read out.
+ * @param index Number of entry to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, guint index, guchar& value);
+
+ /** Copies the contents for the given tag into the value, merging multiple
+ * values into one if multiple values are associated with the tag.
+ * @param tag The tag to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, bool& value);
+
+ /** Gets the value that is at the given index for the given tag.
+ * @param tag The tag to read out.
+ * @param index Number of entry to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, guint index, bool& value);
+
+ /** Copies the contents for the given tag into the value, merging multiple
+ * values into one if multiple values are associated with the tag.
+ * @param tag The tag to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, int& value);
+
+ /** Gets the value that is at the given index for the given tag.
+ * @param tag The tag to read out.
+ * @param index Number of entry to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, guint index, int& value);
+
+ /** Copies the contents for the given tag into the value, merging multiple
+ * values into one if multiple values are associated with the tag.
+ * @param tag The tag to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, guint& value);
+
+ /** Gets the value that is at the given index for the given tag.
+ * @param tag The tag to read out.
+ * @param index Number of entry to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, guint index, guint& value);
+
+ /** Copies the contents for the given tag into the value, merging multiple
+ * values into one if multiple values are associated with the tag.
+ * @param tag The tag to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, long& value);
+
+ /** Gets the value that is at the given index for the given tag.
+ * @param tag The tag to read out.
+ * @param index Number of entry to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, guint index, long& value);
+
+ /** Copies the contents for the given tag into the value, merging multiple
+ * values into one if multiple values are associated with the tag.
+ * @param tag The tag to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, gulong& value);
+
+ /** Gets the value that is at the given index for the given tag.
+ * @param tag The tag to read out.
+ * @param index Number of entry to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, guint index, gulong& value);
+
+ /** Copies the contents for the given tag into the value, merging multiple
+ * values into one if multiple values are associated with the tag.
+ * @param tag The tag to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, float& value);
+
+ /** Gets the value that is at the given index for the given tag.
+ * @param tag The tag to read out.
+ * @param index Number of entry to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, guint index, float& value);
+
+ /** Copies the contents for the given tag into the value, merging multiple
+ * values into one if multiple values are associated with the tag.
+ * @param tag The tag to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, double& value);
+
+ /** Gets the value that is at the given index for the given tag.
+ * @param tag The tag to read out.
+ * @param index Number of entry to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, guint index, double& value);
+
+ /** Copies the contents for the given tag into the value, possibly merging
+ * multiple values into one if multiple values are associated with the tag.
+ *
+ * Use the index version of this method if you want to retrieve the first
+ * string associated with this tag unmodified.
+ *
+ * The resulting string in value will be in UTF-8 encoding.
+ *
+ * @param tag The tag to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, Glib::ustring& value);
+
+ /** Gets the value that is at the given index for the given tag in the given
+ * list.
+ *
+ * The resulting string in value will be in UTF-8 encoding.
+ *
+ * @param tag The tag to read out.
+ * @param index Number of entry to read out.
+ * @param value location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, guint index, Glib::ustring& value);
+
+ /** Copies the contents for the given tag into the value, merging multiple
+ * values into one if multiple values are associated with the tag.
+ * @param tag The tag to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, Glib::Date& value);
+
+ /** Gets the value that is at the given index for the given tag.
+ * @param tag The tag to read out.
+ * @param index Number of entry to read out.
+ * @param value Location for the result.
+ * @return true, if a value was copied, false if the tag didn't exist in the
+ * given list.
+ */
+ bool get(const Glib::ustring& tag, guint index, Glib::Date& value);
};
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+/******************************* Gst::Caps *******************************/
+
+template <class DataType>
+void TagList::add(const Glib::ustring& tag, const DataType& data, TagMergeMode mode)
+{
+ typedef typename Gst::StructureValue<DataType> type_cppdata;
+ typedef typename type_cppdata::ValueType ValueType;
+
+ ValueType value;
+ value.init(ValueType::value_type());
+ value.set(data);
+ this->add(tag, (Glib::ValueBase) value, mode);
+}
+
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+
+
} //namespace Gst
Modified: gstreamermm/trunk/tests/Makefile.am
==============================================================================
--- gstreamermm/trunk/tests/Makefile.am (original)
+++ gstreamermm/trunk/tests/Makefile.am Thu Jun 5 02:57:27 2008
@@ -7,7 +7,7 @@
test-link-elements test-create-bin test-miniobject-wrap \
test-message-wrap test-event-wrap test-query-wrap \
test-structure test-caps-structures test-interface \
- test-create-bus
+ test-create-bus test-taglist
test_caps_SOURCES=test-caps.cc
test_caps_LDFLAGS= GSTREAMERMM_LIBS@
@@ -48,6 +48,9 @@
test_create_bus_SOURCES=test-create-bus.cc
test_create_bus_LDFLAGS= GSTREAMERMM_LIBS@
+test_taglist_SOURCES=test-taglist.cc
+test_taglist_LDFLAGS= GSTREAMERMM_LIBS@
+
#runtestbasic runtestlangs \
#runtestsearch runtestmimetypes \
#runtestgetbuffer
Added: gstreamermm/trunk/tests/test-taglist.cc
==============================================================================
--- (empty file)
+++ gstreamermm/trunk/tests/test-taglist.cc Thu Jun 5 02:57:27 2008
@@ -0,0 +1,54 @@
+// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+
+/* gstreamermm - a C++ wrapper for gstreamer
+ *
+ * Copyright 2008 The gstreamermm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gstreamermm.h>
+#include <iostream>
+
+int main (int argc, char* argv[])
+{
+ Gst::init(argc, argv);
+
+ Gst::TagList taglist;
+
+ if (taglist)
+ {
+ std::cout << "TagList is invalid. Exiting." << std::endl;
+ exit(1);
+ }
+
+ taglist.add(Gst::TAG_TITLE, "My Song");
+ taglist.add(Gst::TAG_ARTIST, "Artist");
+ taglist.add(Gst::TAG_BITRATE, (guint) 192);
+
+ Glib::ustring title;
+ if (taglist.get(Gst::TAG_TITLE, title))
+ std::cout << "Tag title is '" << title << "'." << std::endl;
+
+ Glib::ustring artist;
+ if (taglist.get(Gst::TAG_ARTIST, artist))
+ std::cout << "Tag artist is '" << artist << "'." << std::endl;
+
+ guint rate;
+ if (taglist.get(Gst::TAG_BITRATE, rate))
+ std::cout << "Tag bit-rate is " << rate << "." << std::endl;
+
+ return 0;
+}
Modified: gstreamermm/trunk/tools/m4/Makefile_list_of_sources.am_fragment
==============================================================================
--- gstreamermm/trunk/tools/m4/Makefile_list_of_sources.am_fragment (original)
+++ gstreamermm/trunk/tools/m4/Makefile_list_of_sources.am_fragment Thu Jun 5 02:57:27 2008
@@ -1,2 +1,2 @@
-files_tools_m4 = convert.m4 convert_gst.m4 class_gstminiobject.m4
+files_tools_m4 = convert.m4 convert_gst.m4 class_gstminiobject.m4 class_boxedtype_extra.m4
Added: gstreamermm/trunk/tools/m4/class_boxedtype_extra.m4
==============================================================================
--- (empty file)
+++ gstreamermm/trunk/tools/m4/class_boxedtype_extra.m4 Thu Jun 5 02:57:27 2008
@@ -0,0 +1,219 @@
+dnl $Id: class_boxedtype.m4 413 2007-05-14 19:28:31Z murrayc $
+
+dnl
+dnl _CLASS_BOXEDTYPE_EXTRA(Region, GdkRegion, gdk_region_new, gdk_region_copy, gdk_region_destroy)
+dnl
+
+define(`_CLASS_BOXEDTYPE_EXTRA',`dnl
+_PUSH()
+dnl
+dnl Define the args for later macros
+define(`__CPPNAME__',`$1')
+define(`__CNAME__',`$2')
+define(`__BOXEDTYPE_FUNC_NEW',`$3')
+define(`__BOXEDTYPE_FUNC_COPY',`$4')
+define(`__BOXEDTYPE_FUNC_FREE',`$5')
+
+define(`_CUSTOM_DEFAULT_CTOR',`dnl
+_PUSH()
+dnl Define this macro to be tested for later.
+define(`__BOOL_CUSTOM_DEFAULT_CTOR__',`$1')
+_POP()
+')
+
+
+_POP()
+_SECTION(SECTION_CLASS2)
+') dnl End of _CLASS_BOXEDTYPE_EXTRA.
+
+dnl Some of the Gdk types are unions - e.g. GdkEvent.
+define(`_CUSTOM_STRUCT_PROTOTYPE',`dnl
+_PUSH()
+dnl Define this macro to be tested for later.
+define(`__BOOL_CUSTOM_STRUCT_PROTOTYPE__',`$1')
+_POP()
+')
+
+dnl
+dnl _END_CLASS_BOXEDTYPE_EXTRA()
+dnl denotes the end of a class
+dnl
+define(`_END_CLASS_BOXEDTYPE_EXTRA',`
+_SECTION(SECTION_HEADER1)
+ifdef(`__BOOL_CUSTOM_STRUCT_PROTOTYPE__',`dnl
+',`dnl
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+extern "C" { typedef struct _`'__CNAME__ __CNAME__; }
+#endif
+')dnl
+
+_SECTION(SECTION_HEADER3)
+
+__NAMESPACE_BEGIN__
+
+/** @relates __NAMESPACE__::__CPPNAME__
+ * @param lhs The left-hand side
+ * @param rhs The right-hand side
+ */
+inline void swap(__CPPNAME__& lhs, __CPPNAME__& rhs)
+ { lhs.swap(rhs); }
+
+__NAMESPACE_END__
+
+namespace Glib
+{
+ifdef(`__BOOL_NO_WRAP_FUNCTION__',`dnl
+',`dnl else
+
+/** A Glib::wrap() method for this object. The dummy boolean parameter is added to disambiguate Gst::TagList::wrap() from Gst::Structure::wrap() (GstTagList is in fact a GstStructure so wrap method becomes ambiguous).
+ *
+ * @param object The C instance.
+ * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
+ * @param dummy An unused parameter to disambiguate Gst::TagList::wrap() from Gst::Structure::wrap().
+ * @result A C++ instance that wraps this C instance.
+ *
+ * @relates __NAMESPACE__::__CPPNAME__
+ */
+__NAMESPACE__::__CPPNAME__ wrap(__CNAME__* object, bool take_copy = false, bool dummy = false);
+')dnl endif __BOOL_NO_WRAP_FUNCTION__
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+template <>
+class Value<__NAMESPACE__::__CPPNAME__> : public Glib::Value_Boxed<__NAMESPACE__::__CPPNAME__>
+{};
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+
+} // namespace Glib
+
+_SECTION(SECTION_SRC_GENERATED)
+
+ifdef(`__BOOL_NO_WRAP_FUNCTION__',`dnl
+',`dnl else
+namespace Glib
+{
+
+__NAMESPACE__::__CPPNAME__ wrap(__CNAME__* object, bool take_copy, bool dummy)
+{
+ return __NAMESPACE__::__CPPNAME__`'(object, take_copy);
+}
+
+} // namespace Glib
+')dnl endif
+
+
+__NAMESPACE_BEGIN__
+
+dnl
+dnl The implementation:
+dnl
+
+// static
+GType __CPPNAME__::get_type()
+{
+ return _GET_TYPE_FUNC(__CNAME__);
+}
+
+ifdef(`__BOOL_CUSTOM_DEFAULT_CTOR__',`dnl
+',`dnl else
+__CPPNAME__::__CPPNAME__`'()
+:
+ifelse(__BOXEDTYPE_FUNC_NEW,NONE,`dnl
+ gobject_ (0) // Allows creation of invalid wrapper, e.g. for output arguments to methods.
+',`dnl else
+ gobject_ (__BOXEDTYPE_FUNC_NEW`'())
+')dnl
+{}
+')dnl endif __BOOL_CUSTOM_DEFAULT_CTOR__
+
+__CPPNAME__::__CPPNAME__`'(const __CPPNAME__& other)
+:
+ gobject_ ((other.gobject_) ? __BOXEDTYPE_FUNC_COPY`'(other.gobject_) : 0)
+{}
+
+__CPPNAME__::__CPPNAME__`'(__CNAME__* gobject, bool make_a_copy)
+:
+ // For BoxedType wrappers, make_a_copy is true by default. The static
+ // BoxedType wrappers must always take a copy, thus make_a_copy = true
+ // ensures identical behaviour if the default argument is used.
+ gobject_ ((make_a_copy && gobject) ? __BOXEDTYPE_FUNC_COPY`'(gobject) : gobject)
+{}
+
+__CPPNAME__& __CPPNAME__::operator=(const __CPPNAME__`'& other)
+{
+ __CPPNAME__ temp (other);
+ swap(temp);
+ return *this;
+}
+
+__CPPNAME__::~__CPPNAME__`'()
+{
+dnl This could be a free or an unref, we do not need to know.
+ if(gobject_)
+ __BOXEDTYPE_FUNC_FREE`'(gobject_);
+}
+
+void __CPPNAME__::swap(__CPPNAME__& other)
+{
+ __CNAME__ *const temp = gobject_;
+ gobject_ = other.gobject_;
+ other.gobject_ = temp;
+}
+
+__CNAME__* __CPPNAME__::gobj_copy() const
+{
+ return __BOXEDTYPE_FUNC_COPY`'(gobject_);
+}
+
+_IMPORT(SECTION_CC)
+
+__NAMESPACE_END__
+
+
+dnl
+dnl
+dnl
+dnl
+_POP()
+dnl
+dnl
+dnl The actual class, e.g. Pango::FontDescription, declaration:
+dnl
+_IMPORT(SECTION_CLASS1)
+public:
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+ typedef __CPPNAME__ CppObjectType;
+ typedef __CNAME__ BaseObjectType;
+
+ static GType get_type() G_GNUC_CONST;
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+
+ifdef(`__BOOL_CUSTOM_DEFAULT_CTOR__',`dnl
+',`dnl else
+ __CPPNAME__`'();
+')dnl
+
+ explicit __CPPNAME__`'(__CNAME__* gobject, bool make_a_copy = true);
+
+ __CPPNAME__`'(const __CPPNAME__& other);
+ __CPPNAME__& operator=(const __CPPNAME__& other);
+
+ ~__CPPNAME__`'();
+
+ void swap(__CPPNAME__& other);
+
+ ///Provides access to the underlying C instance.
+ __CNAME__* gobj() { return gobject_; }
+
+ ///Provides access to the underlying C instance.
+ const __CNAME__* gobj() const { return gobject_; }
+
+ ///Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.
+ __CNAME__* gobj_copy() const;
+
+protected:
+ __CNAME__* gobject_;
+
+private:
+_IMPORT(SECTION_CLASS2)
+')
+
Modified: gstreamermm/trunk/tools/m4/convert.m4
==============================================================================
--- gstreamermm/trunk/tools/m4/convert.m4 (original)
+++ gstreamermm/trunk/tools/m4/convert.m4 Thu Jun 5 02:57:27 2008
@@ -2,3 +2,4 @@
include(convert_glib.m4)
include(convert_gst.m4)
include(class_gstminiobject.m4)
+include(class_boxedtype_extra.m4)
Modified: gstreamermm/trunk/tools/m4/convert_gst.m4
==============================================================================
--- gstreamermm/trunk/tools/m4/convert_gst.m4 (original)
+++ gstreamermm/trunk/tools/m4/convert_gst.m4 Thu Jun 5 02:57:27 2008
@@ -114,7 +114,7 @@
#TagList
_CONVERSION(`const TagList&',`const GstTagList*',`(($3).gobj())')
-_CONVERSION(`GstTagList*',`TagList',`Glib::wrap($3)')
+_CONVERSION(`GstTagList*',`TagList',`Glib::wrap($3, false, false)')
_CONVERSION(`TagList&',`GstTagList*',`(($3).gobj())')
_CONVERSION(`const TagList&',`GstTagList*',`const_cast<GstTagList*>(($3).gobj())')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]