| 1 |
/* gstreamermm - a C++ wrapper for gstreamer |
| 2 |
* |
| 3 |
* Copyright 2008 The gstreamermm Development Team |
| 4 |
* |
| 5 |
* This library is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU Lesser General Public |
| 7 |
* License as published by the Free Software Foundation; either |
| 8 |
* version 2.1 of the License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This library is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* Lesser General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU Lesser General Public |
| 16 |
* License along with this library; if not, write to the Free |
| 17 |
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 18 |
*/ |
| 19 |
|
| 20 |
#include <gst/gst.h> |
| 21 |
#include <glibmm/interface.h> |
| 22 |
#include <gstreamermm/enums.h> |
| 23 |
#include <gstreamermm/taglist.h> |
| 24 |
|
| 25 |
_DEFS(gstreamermm,gst) |
| 26 |
|
| 27 |
namespace Gst |
| 28 |
{ |
| 29 |
|
| 30 |
/** An interface that allows setting and retrieval of media metadata. |
| 31 |
* Elements that support changing a stream's metadata will implement this |
| 32 |
* interface. Examples of such elements are 'vorbisenc', 'theoraenc' and |
| 33 |
* 'id3v2mux'. |
| 34 |
* |
| 35 |
* If you just want to retrieve metadata in your application then all you need |
| 36 |
* to do is watch for tag messages on your pipeline's bus. This interface is |
| 37 |
* only for setting metadata, not for extracting it. To set tags from the |
| 38 |
* application, find tagsetter elements and set tags using e.g. merge_tags() or |
| 39 |
* add_tags(). The application should do that before the element goes to |
| 40 |
* Gst::STATE_PAUSED. |
| 41 |
* @ingroup GstInterfaces |
| 42 |
*/ |
| 43 |
class TagSetter : public Glib::Interface |
| 44 |
{ |
| 45 |
_CLASS_INTERFACE(TagSetter, GstTagSetter, GST_TAG_SETTER, GstTagSetterInterface) |
| 46 |
|
| 47 |
public: |
| 48 |
_WRAP_METHOD(void reset_tags(), gst_tag_setter_reset_tags) |
| 49 |
_WRAP_METHOD(void merge_tags(const Gst::TagList& list, TagMergeMode mode = TAG_MERGE_PREPEND), gst_tag_setter_merge_tags) |
| 50 |
|
| 51 |
/** Adds the given Glib::ValueBase on the setter using the given merge mode. |
| 52 |
* |
| 53 |
* @param tag The tag to set. |
| 54 |
* @param value The value to set the tag to. |
| 55 |
* @param mode The mode to use. |
| 56 |
*/ |
| 57 |
void add_tag(Tag tag, const Glib::ValueBase& value, TagMergeMode mode = TAG_MERGE_PREPEND); |
| 58 |
_IGNORE(gst_tag_setter_add_tag_valist, |
| 59 |
gst_tag_setter_add_tag_value, |
| 60 |
gst_tag_setter_add_tag_valist_values) |
| 61 |
|
| 62 |
/** Adds the given Glib::ValueBase on the setter using the given merge mode. |
| 63 |
* |
| 64 |
* @param tag The tag to set. |
| 65 |
* @param value The value to set the tag to. |
| 66 |
* @param mode The mode to use. |
| 67 |
*/ |
| 68 |
void add_tag(const Glib::ustring& tag, const Glib::ValueBase& value, |
| 69 |
TagMergeMode mode = TAG_MERGE_PREPEND); |
| 70 |
|
| 71 |
/** Adds the given value on the setter using the given merge mode. |
| 72 |
* |
| 73 |
* @param tag The tag to set. |
| 74 |
* @param data The value to set the tag to (this may be any supported C++ |
| 75 |
* type). |
| 76 |
* @param mode The mode to use. |
| 77 |
*/ |
| 78 |
template <class DataType> |
| 79 |
void add_tag(Tag tag, const DataType& data, TagMergeMode mode = TAG_MERGE_PREPEND); |
| 80 |
|
| 81 |
/** Adds the given value on the setter using the given merge mode. |
| 82 |
* |
| 83 |
* @param tag The tag to set. |
| 84 |
* @param data The value to set the tag to (this may be any supported C++ |
| 85 |
* type). |
| 86 |
* @param mode The mode to use. |
| 87 |
*/ |
| 88 |
template <class DataType> |
| 89 |
void add_tag(const Glib::ustring& tag, const DataType& data, |
| 90 |
TagMergeMode mode = TAG_MERGE_PREPEND); |
| 91 |
|
| 92 |
/** Adds the given value on the setter using the given merge mode. |
| 93 |
* |
| 94 |
* @param tag The tag to set. |
| 95 |
* @param data The value to set the tag to. |
| 96 |
* @param mode The mode to use. |
| 97 |
*/ |
| 98 |
void add_tag(Tag tag, const char* data, TagMergeMode mode = TAG_MERGE_PREPEND); |
| 99 |
|
| 100 |
/** Adds the given value on the setter using the given merge mode. |
| 101 |
* |
| 102 |
* @param tag The tag to set. |
| 103 |
* @param data The value to set the tag to. |
| 104 |
* @param mode The mode to use. |
| 105 |
*/ |
| 106 |
void add_tag(const Glib::ustring& tag, const char* data, |
| 107 |
TagMergeMode mode = TAG_MERGE_PREPEND); |
| 108 |
|
| 109 |
// A copy is taken so that the original is not freed by the wrapper. |
| 110 |
#m4 _CONVERSION(`const GstTagList*',`const Gst::TagList',`Glib::wrap_taglist(const_cast<GstTagList*>($3), true)') |
| 111 |
_WRAP_METHOD(const Gst::TagList get_tag_list() const, gst_tag_setter_get_tag_list) |
| 112 |
|
| 113 |
_WRAP_METHOD(void set_tag_merge_mode(TagMergeMode mode), gst_tag_setter_set_tag_merge_mode) |
| 114 |
_WRAP_METHOD(TagMergeMode get_tag_merge_mode() const, gst_tag_setter_get_tag_merge_mode) |
| 115 |
|
| 116 |
//Variable argument functions are ignored. |
| 117 |
_IGNORE(gst_tag_setter_add_tags, gst_tag_setter_add_tag_values) |
| 118 |
}; |
| 119 |
|
| 120 |
#ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 121 |
|
| 122 |
/************************** Gst::TagSetter ***************************/ |
| 123 |
|
| 124 |
template <class DataType> |
| 125 |
void TagSetter::add_tag(Tag tag, const DataType& data, TagMergeMode mode) |
| 126 |
{ |
| 127 |
typedef Glib::Value<DataType> ValueType; |
| 128 |
|
| 129 |
ValueType value; |
| 130 |
value.init(ValueType::value_type()); |
| 131 |
value.set(data); |
| 132 |
this->add_tag(tag, (Glib::ValueBase)(value), mode); |
| 133 |
} |
| 134 |
|
| 135 |
template <class DataType> |
| 136 |
void TagSetter::add_tag(const Glib::ustring& tag, const DataType& data, |
| 137 |
TagMergeMode mode) |
| 138 |
{ |
| 139 |
typedef Glib::Value<DataType> ValueType; |
| 140 |
|
| 141 |
ValueType value; |
| 142 |
value.init(ValueType::value_type()); |
| 143 |
value.set(data); |
| 144 |
this->add_tag(tag, (Glib::ValueBase)(value), mode); |
| 145 |
} |
| 146 |
|
| 147 |
#endif /* DOXYGEN_SHOULD_SKIP_THIS */ |
| 148 |
|
| 149 |
} // namespace Gst |