gnomemm r1557 - in gstreamermm/trunk: . gstreamer/gstreamermm gstreamer/src tests tools/m4
- From: jaalburqu svn gnome org
- To: svn-commits-list gnome org
- Subject: gnomemm r1557 - in gstreamermm/trunk: . gstreamer/gstreamermm gstreamer/src tests tools/m4
- Date: Thu, 12 Jun 2008 02:54:11 +0000 (UTC)
Author: jaalburqu
Date: Thu Jun 12 02:54:11 2008
New Revision: 1557
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1557&view=rev
Log:
2008-06-11 Josà Alburquerque <jaalburqu svn gnome org>
* gstreamer/src/taglist.ccg:
* gstreamer/src/taglist.hg:
* gstreamer/gstreamermm/taglist.cc:
* gstreamer/gstreamermm/taglist.h: Used Gst::TAG_MERGE_PREPEND as
default TagMergeMode in add/insert/merge methods.
* gstreamer/src/structure.ccg: Used Glib::Date GDate constructor in
get_field(..., Glib::Date&) method.
* gstreamer/src/tagsetter.ccg:
* gstreamer/src/tagsetter.hg:
* tools/m4/convert_gst.m4: Added add_tag(), get_tag_list(),
set_tag_merge_mode(), and get_tag_merge_mode() methods (Wrapped
GstTagSetter).
* tests/Makefile.am:
* tests/test-tagsetter.cc: Added a Gst::TagSetter test.
* gstreamer/src/element.hg: Whitespace.
Added:
gstreamermm/trunk/tests/test-tagsetter.cc
Modified:
gstreamermm/trunk/ChangeLog
gstreamermm/trunk/gstreamer/gstreamermm/taglist.cc
gstreamermm/trunk/gstreamer/gstreamermm/taglist.h
gstreamermm/trunk/gstreamer/src/element.hg
gstreamermm/trunk/gstreamer/src/structure.ccg
gstreamermm/trunk/gstreamer/src/taglist.ccg
gstreamermm/trunk/gstreamer/src/taglist.hg
gstreamermm/trunk/gstreamer/src/tagsetter.ccg
gstreamermm/trunk/gstreamer/src/tagsetter.hg
gstreamermm/trunk/tests/Makefile.am
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 12 02:54:11 2008
@@ -195,9 +195,8 @@
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));
+ value.set_julian(Glib::Date(*gst_value).get_julian());
return result;
}
Modified: gstreamermm/trunk/gstreamer/gstreamermm/taglist.h
==============================================================================
--- gstreamermm/trunk/gstreamer/gstreamermm/taglist.h (original)
+++ gstreamermm/trunk/gstreamer/gstreamermm/taglist.h Thu Jun 12 02:54:11 2008
@@ -374,8 +374,6 @@
public:
- //TODO: Add operator bool() to handle when C functions return NULL TagList*?
-
/** Checks if the given type is already registered.
* @param tag Name of the tag.
@@ -425,7 +423,7 @@
* @param from List to merge from.
* @param mode The mode to use.
*/
- void insert(const TagList& other, TagMergeMode mode=TAG_MERGE_APPEND);
+ void insert(const TagList& other, TagMergeMode mode=TAG_MERGE_PREPEND);
/** 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.
@@ -447,7 +445,7 @@
* @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);
+ void add(const Glib::ustring& tag, const Glib::ValueBase& value, TagMergeMode mode=TAG_MERGE_PREPEND);
/** Sets the value for the given tag to string @a data using the specified
* mode.
@@ -456,7 +454,7 @@
* @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);
+ void add(const Glib::ustring& tag, const char* data, TagMergeMode mode=TAG_MERGE_PREPEND);
/** Sets the value for the given tag using the specified mode.
*
@@ -466,7 +464,7 @@
* @param mode The merge mode to use.
*/
template <class DataType>
- void add(const Glib::ustring& tag, const DataType& data, TagMergeMode mode=TAG_MERGE_APPEND);
+ void add(const Glib::ustring& tag, const DataType& data, TagMergeMode mode=TAG_MERGE_PREPEND);
/** Removes the given tag from the taglist.
Modified: gstreamermm/trunk/gstreamer/src/element.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/element.hg (original)
+++ gstreamermm/trunk/gstreamer/src/element.hg Thu Jun 12 02:54:11 2008
@@ -347,7 +347,7 @@
* "source");
*
* Glib::RefPtr< Gst::ElementInterfaced<Gst::URIHandler> > handler =
- * Gst::Interface::cast <Gst::URIHandler>(element);
+ * Gst::Interface::cast<Gst::URIHandler>(element);
*
* if(handler)
* {
Modified: gstreamermm/trunk/gstreamer/src/structure.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/structure.ccg (original)
+++ gstreamermm/trunk/gstreamer/src/structure.ccg Thu Jun 12 02:54:11 2008
@@ -298,10 +298,10 @@
bool Structure::get_field(const Glib::ustring& name, Glib::Date& date) const
{
- GDate *gdate = 0;
+ GDate* gdate = 0;
const bool has = gst_structure_get_date(gobj(), name.c_str(), &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.
+ date.set_julian(Glib::Date(*gdate).get_julian());
return has;
}
@@ -402,4 +402,4 @@
return Structure(gst_structure_from_string(the_string.c_str(), NULL));
}
-} //namespace GstG
+} //namespace Gst
Modified: gstreamermm/trunk/gstreamer/src/taglist.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/taglist.ccg (original)
+++ gstreamermm/trunk/gstreamer/src/taglist.ccg Thu Jun 12 02:54:11 2008
@@ -189,9 +189,8 @@
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));
+ value.set_julian(Glib::Date(*gst_value).get_julian());
return result;
}
Modified: gstreamermm/trunk/gstreamer/src/taglist.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/taglist.hg (original)
+++ gstreamermm/trunk/gstreamer/src/taglist.hg Thu Jun 12 02:54:11 2008
@@ -267,8 +267,6 @@
_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)
_WRAP_METHOD(static GType get_type(const Glib::ustring& tag), gst_tag_get_type)
_WRAP_METHOD(static Glib::ustring get_nick(const Glib::ustring& tag), gst_tag_get_nick)
@@ -276,7 +274,7 @@
_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 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(void insert(const TagList& other, TagMergeMode mode=TAG_MERGE_PREPEND), 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)
@@ -286,7 +284,7 @@
* @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);
+ void add(const Glib::ustring& tag, const Glib::ValueBase& value, TagMergeMode mode=TAG_MERGE_PREPEND);
/** Sets the value for the given tag to string @a data using the specified
* mode.
@@ -295,7 +293,7 @@
* @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);
+ void add(const Glib::ustring& tag, const char* data, TagMergeMode mode=TAG_MERGE_PREPEND);
/** Sets the value for the given tag using the specified mode.
*
@@ -305,7 +303,7 @@
* @param mode The merge mode to use.
*/
template <class DataType>
- void add(const Glib::ustring& tag, const DataType& data, TagMergeMode mode=TAG_MERGE_APPEND);
+ void add(const Glib::ustring& tag, const DataType& data, TagMergeMode mode=TAG_MERGE_PREPEND);
_WRAP_METHOD(void remove_tag(const Glib::ustring& tag), gst_tag_list_remove_tag)
Modified: gstreamermm/trunk/gstreamer/src/tagsetter.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/tagsetter.ccg (original)
+++ gstreamermm/trunk/gstreamer/src/tagsetter.ccg Thu Jun 12 02:54:11 2008
@@ -19,3 +19,12 @@
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+namespace Gst
+{
+
+void TagSetter::add_tag(const Glib::ustring& tag, const Glib::ValueBase& value, TagMergeMode mode)
+{
+ gst_tag_setter_add_tag_values(gobj(), (GstTagMergeMode) mode, tag.c_str(), value.gobj(), NULL);
+}
+
+} //namespace Gst
Modified: gstreamermm/trunk/gstreamer/src/tagsetter.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/tagsetter.hg (original)
+++ gstreamermm/trunk/gstreamer/src/tagsetter.hg Thu Jun 12 02:54:11 2008
@@ -23,6 +23,7 @@
#include <glibmm/interface.h>
#include <gstreamermm/enums.h>
#include <gstreamermm/taglist.h>
+#include <gstreamermm/structurevalue.h>
_DEFS(gstreamermm,gst)
@@ -42,22 +43,53 @@
* application, find tagsetter elements and set tags using e.g. merge_tags() or
* add_tags(). The application should do that before the element goes to
* Gst::STATE_PAUSED.
- *
- * Elements implementing the Gst::TagSetter interface often have to merge any
- * tags received from upstream and the tags set by the application via the
- * interface. This can be done like this:
- *
- * TODO: Add code example from C API docs
*/
class TagSetter : public Glib::Interface
{
_CLASS_INTERFACE(TagSetter, GstTagSetter, GST_TAG_SETTER, GstTagSetterIFace)
public:
- //TODO: Add suitable default value for mode?
- _WRAP_METHOD(void merge_tags(const TagList& list, TagMergeMode mode=TAG_MERGE_APPEND), gst_tag_setter_merge_tags)
- //TODO: Wrap rest of GstTagStetter methods
+ _WRAP_METHOD(void merge_tags(const TagList& list, TagMergeMode mode=TAG_MERGE_PREPEND), gst_tag_setter_merge_tags)
+
+ /** Adds the given Glib::ValueBase on the setter using the given merge mode.
+ *
+ * @param tag The tag to set.
+ * @param value The value to set the tag to.
+ * @param mode The mode to use.
+ */
+ void add_tag(const Glib::ustring& tag, const Glib::ValueBase& value, TagMergeMode mode=TAG_MERGE_PREPEND);
+
+ /** Adds the given value on the setter using the given merge mode.
+ *
+ * @param tag The tag to set.
+ * @param data The value to set the tag to.
+ * @param mode The mode to use.
+ */
+ template <class DataType>
+ void add_tag(const Glib::ustring& tag, const DataType& data, TagMergeMode mode=TAG_MERGE_PREPEND);
+
+ _WRAP_METHOD(TagList get_tag_list(), gst_tag_setter_get_tag_list)
+ _WRAP_METHOD(void set_tag_merge_mode(TagMergeMode mode), gst_tag_setter_set_tag_merge_mode)
+ _WRAP_METHOD(TagMergeMode qet_tag_merge_mode(), gst_tag_setter_get_tag_merge_mode)
};
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+/************************** Gst::TagSetter ***************************/
+
+template <class DataType>
+void TagSetter::add_tag(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(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 12 02:54:11 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-taglist
+ test-create-bus test-taglist test-tagsetter
test_caps_SOURCES=test-caps.cc
test_caps_LDFLAGS= GSTREAMERMM_LIBS@
@@ -51,6 +51,9 @@
test_taglist_SOURCES=test-taglist.cc
test_taglist_LDFLAGS= GSTREAMERMM_LIBS@
+test_tagsetter_SOURCES=test-tagsetter.cc
+test_tagsetter_LDFLAGS= GSTREAMERMM_LIBS@
+
#runtestbasic runtestlangs \
#runtestsearch runtestmimetypes \
#runtestgetbuffer
Added: gstreamermm/trunk/tests/test-tagsetter.cc
==============================================================================
--- (empty file)
+++ gstreamermm/trunk/tests/test-tagsetter.cc Thu Jun 12 02:54:11 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);
+
+ Glib::RefPtr<Gst::Element> vorbisenc = Gst::ElementFactory::create_element("vorbisenc");
+
+ if (!vorbisenc)
+ {
+ std::cout << "Failed to create vorbisenc element." << std::endl;
+ exit(1);
+ }
+
+ Glib::RefPtr< Gst::ElementInterfaced<Gst::TagSetter> > setter =
+ Gst::Interface::cast<Gst::TagSetter>(vorbisenc);
+
+ if (!setter)
+ {
+ std::cout << "Failed to cast vorbisenc element to Gst::TagSetter." <<
+ std::endl;
+ exit(1);
+ }
+
+ setter->add_tag("bitrate", 192);
+
+ int bitrate = 0;
+ setter->get_tag_list().get("bitrate", bitrate);
+ std::cout << "bitrate = " << bitrate << "." << std::endl;
+
+ return 0;
+}
Modified: gstreamermm/trunk/tools/m4/convert_gst.m4
==============================================================================
--- gstreamermm/trunk/tools/m4/convert_gst.m4 (original)
+++ gstreamermm/trunk/tools/m4/convert_gst.m4 Thu Jun 12 02:54:11 2008
@@ -117,6 +117,7 @@
_CONVERSION(`GstTagList*',`TagList',`Glib::wrap($3, false, false)')
_CONVERSION(`TagList&',`GstTagList*',`(($3).gobj())')
_CONVERSION(`const TagList&',`GstTagList*',`const_cast<GstTagList*>(($3).gobj())')
+_CONVERSION(`const GstTagList*',`TagList',`Glib::wrap(const_cast<GstTagList*>($3), true, false)')
#URIHandler
_CONVERSION(`const Glib::RefPtr<URIHandler>&',`GstURIHandler*',`Glib::unwrap($3)')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]