| 1 | // Generated by gmmproc 2.50.1 -- DO NOT MODIFY! |
| 2 | #ifndef _GSTREAMERMM_VALUE_H |
| 3 | #define _GSTREAMERMM_VALUE_H |
| 4 | |
| 5 | |
| 6 | #include <glibmm/ustring.h> |
| 7 | #include <sigc++/sigc++.h> |
| 8 | |
| 9 | /* gstreamermm - a C++ wrapper for gstreamer |
| 10 | * |
| 11 | * Copyright 2008-2016 The gstreamermm Development Team |
| 12 | * |
| 13 | * This library is free software; you can redistribute it and/or |
| 14 | * modify it under the terms of the GNU Lesser General Public |
| 15 | * License as published by the Free Software Foundation; either |
| 16 | * version 2.1 of the License, or (at your option) any later version. |
| 17 | * |
| 18 | * This library is distributed in the hope that it will be useful, |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 21 | * Lesser General Public License for more details. |
| 22 | * |
| 23 | * You should have received a copy of the GNU Lesser General Public |
| 24 | * License along with this library; if not, write to the Free |
| 25 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 26 | */ |
| 27 | |
| 28 | #include <gst/gst.h> |
| 29 | #include <gst/gstvalue.h> |
| 30 | #include <glibmm/value_custom.h> |
| 31 | |
| 32 | |
| 33 | namespace Gst |
| 34 | { |
| 35 | |
| 36 | /** @defgroup GstHelperClasses gstreamermm Helper Classes |
| 37 | * Classes used to represent GStreamer internal GValue types such as |
| 38 | * GST_TYPE_FRACTION, etc. |
| 39 | */ |
| 40 | |
| 41 | /** A class that represents a 4 byte identifier (used in codecs). |
| 42 | * Gst::Fourcc is used to store a four byte identifier in Gst::Structure of |
| 43 | * Gst::Caps as a value representing a property (see GStreamer Application |
| 44 | * Development Manual section 8.2.2 and GstValue docs). When the value is set, |
| 45 | * it is transformed to a GStreamer GType so retrieving the value is a bit |
| 46 | * different. The class can be used in setting and getting a Gst::Structure |
| 47 | * field like so: |
| 48 | * |
| 49 | * @code |
| 50 | * Glib::Value<Gst::Fourcc> value; |
| 51 | * value.init(Glib::Value<Gst::Fourcc>::value_type()); |
| 52 | * value.set(Gst::Fourcc('M', 'J', 'P', 'G')); |
| 53 | * |
| 54 | * Gst::Structure structure("my-structure"); |
| 55 | * structure.set_field("id", value); |
| 56 | * ... |
| 57 | * Glib::ValueBase gst_value; |
| 58 | * structure.get_field("id", gst_value); |
| 59 | * Gst::Fourcc fourcc(gst_value); |
| 60 | * char first_char = fourcc.first; |
| 61 | * ... |
| 62 | * @endcode |
| 63 | * |
| 64 | * Last reviewed on 2016-08-27 (1.8.0) |
| 65 | * |
| 66 | * @ingroup GstHelperClasses |
| 67 | */ |
| 68 | class Fourcc |
| 69 | { |
| 70 | public: |
| 71 | /** Construct an undefined Gst::Fourcc. |
| 72 | */ |
| 73 | Fourcc(); |
| 74 | |
| 75 | /** Construct a Gst::Fourcc from another. |
| 76 | */ |
| 77 | Fourcc(const Fourcc& src); |
| 78 | |
| 79 | /** Construct a Gst::Fourcc from 4 characters. |
| 80 | */ |
| 81 | Fourcc(char first, char second, char third, char fourth); |
| 82 | |
| 83 | /** Construct a Gst::Fourcc from an input string. Caller is responsible for |
| 84 | * ensuring the input string consists of at least four characters. |
| 85 | */ |
| 86 | explicit Fourcc(const Glib::ustring& s); |
| 87 | |
| 88 | /** Construct a Gst::Fourcc from a 32 bit unsigned integer. |
| 89 | */ |
| 90 | explicit Fourcc(guint32 fourcc); |
| 91 | |
| 92 | Fourcc& operator=(const Fourcc& src); |
| 93 | |
| 94 | |
| 95 | public: |
| 96 | |
| 97 | public: |
| 98 | char first; |
| 99 | char second; |
| 100 | char third; |
| 101 | char fourth; |
| 102 | |
| 103 | private: |
| 104 | void set_ccs(guint32 fourcc); |
| 105 | }; |
| 106 | |
| 107 | |
| 108 | /** A class that represents a fraction. |
| 109 | * Gst::Fraction is used to store a fraction in Gst::Structures of Gst::Caps as |
| 110 | * a value representing a property (see GStreamer Application Development |
| 111 | * Manual section 8.2.2 and GstValue docs). When the value is set, it is |
| 112 | * transformed to a GStreamer GType so retrieving the value is a bit different. |
| 113 | * The class can be used in setting and getting a Gst::Structure field like so: |
| 114 | * |
| 115 | * @code |
| 116 | * Glib::Value<Gst::Fraction> value; |
| 117 | * value.init(Glib::Value<Gst::Fraction>::value_type()); |
| 118 | * value.set(Gst::Fraction(25,1)); |
| 119 | * |
| 120 | * Gst::Structure structure("my-structure"); |
| 121 | * structure.set_field("framerate", value); |
| 122 | * ... |
| 123 | * Glib::ValueBase gst_value; |
| 124 | * structure.get_field("framerate", gst_value); |
| 125 | * Gst::Fraction fract(gst_value); |
| 126 | * int numerator = fract.num; |
| 127 | * ... |
| 128 | * @endcode |
| 129 | * |
| 130 | * Last reviewed on 2016-08-27 (1.8.0) |
| 131 | * |
| 132 | * @ingroup GstHelperClasses |
| 133 | */ |
| 134 | class Fraction |
| 135 | { |
| 136 | public: |
| 137 | /** Constructs a zero Gst::Fraction (0/1). |
| 138 | */ |
| 139 | Fraction(); |
| 140 | |
| 141 | /** Constructs a Gst::Fraction from another. |
| 142 | */ |
| 143 | Fraction(const Fraction& src); |
| 144 | |
| 145 | /** Constructs a Gst::Fraction (num/denom). |
| 146 | */ |
| 147 | Fraction(int num, int denom); |
| 148 | |
| 149 | /** Constructs a Gst::Fraction from a GST_TYPE_FRACTION. |
| 150 | */ |
| 151 | explicit Fraction(const Glib::ValueBase& gst_fraction_value); |
| 152 | |
| 153 | /** Constructs a Gst::Fraction from a GST_TYPE_FRACTION. |
| 154 | */ |
| 155 | explicit Fraction(const GValue& gst_fraction_value); |
| 156 | |
| 157 | Fraction& operator=(const Fraction& src); |
| 158 | |
| 159 | |
| 160 | public: |
| 161 | int num; |
| 162 | int denom; |
| 163 | }; |
| 164 | |
| 165 | /** A class that represents a range (min - max). |
| 166 | * Gst::Range is used to store a range in Gst::Structures of |
| 167 | * Gst::Caps as a value representing a property (see GStreamer Application |
| 168 | * Development Manual section 8.2.2 and GstValue docs). When the value is set, |
| 169 | * it is transformed to a GStreamer GType so retrieving the value is a bit |
| 170 | * different. The class can be used in setting and getting a Gst::Structure |
| 171 | * field like so: |
| 172 | * |
| 173 | * @code |
| 174 | * Glib::Value<Gst::Range<int>> value; |
| 175 | * value.init(Glib::Value<Gst::Range<int>>::value_type()); |
| 176 | * value.set(Gst::Range<int>(8000, 50000)); |
| 177 | * |
| 178 | * Gst::Structure structure("my-structure"); |
| 179 | * structure.set_field("rate", value); |
| 180 | * ... |
| 181 | * Glib::ValueBase gst_value; |
| 182 | * structure.get_field("rate", gst_value); |
| 183 | * Gst::Range<int> range(gst_value); |
| 184 | * int max = range.max; |
| 185 | * ... |
| 186 | * @endcode |
| 187 | * |
| 188 | * Gst::Range should be used with following types: int, double, Gst::Fraction. |
| 189 | * |
| 190 | * Last reviewed on 2016-08-27 (1.8.0) |
| 191 | * |
| 192 | * @ingroup GstHelperClasses |
| 193 | */ |
| 194 | template<typename T> |
| 195 | class Range |
| 196 | { |
| 197 | public: |
| 198 | /** Constructs a zero Gst::Range. |
| 199 | */ |
| 200 | Range() : min(T()), max(T()) {} |
| 201 | |
| 202 | /** Constructs a Gst::Range (min - max). |
| 203 | */ |
| 204 | Range(T min, T max) : min(min), max(max) {} |
| 205 | |
| 206 | /** Constructs an Gst::Range from another range. |
| 207 | */ |
| 208 | Range(const Range& src) : min(src.min), max(src.max) {} |
| 209 | |
| 210 | /** Constructs an Gst::Range from a Glib::ValueBase. |
| 211 | */ |
| 212 | explicit Range(const Glib::Value<Range<T>>& range_value) |
| 213 | { |
| 214 | min = range_value.get().min; |
| 215 | max = range_value.get().max; |
| 216 | } |
| 217 | |
| 218 | /** Constructs an Gst::Range from a GValue. |
| 219 | */ |
| 220 | explicit Range(const GValue& range_value) |
| 221 | { |
| 222 | init_range(range_value); |
| 223 | } |
| 224 | |
| 225 | Range& operator=(const Range& src) |
| 226 | { |
| 227 | min = src.min; |
| 228 | max = src.max; |
| 229 | return *this; |
| 230 | } |
| 231 | |
| 232 | public: |
| 233 | T min; |
| 234 | T max; |
| 235 | |
| 236 | private: |
| 237 | void init_range(const GValue& range_value); |
| 238 | }; |
| 239 | |
| 240 | } //namespace Gst |
| 241 | |
| 242 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 243 | namespace Glib |
| 244 | { |
| 245 | |
| 246 | template<> |
| 247 | class Value<Gst::Fourcc> : public Value<unsigned int> |
| 248 | { |
| 249 | public: |
| 250 | typedef Gst::Fourcc CppType; |
| 251 | typedef guint32 CType; |
| 252 | |
| 253 | static GType value_type() G_GNUC_CONST; |
| 254 | |
| 255 | void set(const Gst::Fourcc& data); |
| 256 | Gst::Fourcc get() const; |
| 257 | }; |
| 258 | |
| 259 | template<> |
| 260 | class Value<Gst::Range<int>> : public ValueBase_Boxed |
| 261 | { |
| 262 | public: |
| 263 | typedef Gst::Range<int> CppType; |
| 264 | |
| 265 | static GType value_type() G_GNUC_CONST; |
| 266 | |
| 267 | void set(const Gst::Range<int>& data); |
| 268 | Gst::Range<int> get() const; |
| 269 | }; |
| 270 | |
| 271 | template<> |
| 272 | class Value<Gst::Range<double>> : public ValueBase_Boxed |
| 273 | { |
| 274 | public: |
| 275 | typedef Gst::Range<double> CppType; |
| 276 | |
| 277 | static GType value_type() G_GNUC_CONST; |
| 278 | |
| 279 | void set(const Gst::Range<double>& data); |
| 280 | Gst::Range<double> get() const; |
| 281 | }; |
| 282 | |
| 283 | template<> |
| 284 | class Value<Gst::Fraction> : public ValueBase_Boxed |
| 285 | { |
| 286 | public: |
| 287 | typedef Gst::Fraction CppType; |
| 288 | |
| 289 | static GType value_type() G_GNUC_CONST; |
| 290 | |
| 291 | void set(const Gst::Fraction& data); |
| 292 | Gst::Fraction get() const; |
| 293 | }; |
| 294 | |
| 295 | template<> |
| 296 | class Value<Gst::Range<Gst::Fraction>> : public ValueBase_Boxed |
| 297 | { |
| 298 | public: |
| 299 | typedef Gst::Range<Gst::Fraction> CppType; |
| 300 | |
| 301 | static GType value_type() G_GNUC_CONST; |
| 302 | |
| 303 | void set(const Gst::Range<Gst::Fraction>& data); |
| 304 | Gst::Range<Gst::Fraction> get() const; |
| 305 | }; |
| 306 | |
| 307 | } // namespace Glib |
| 308 | #endif /* DOXYGEN_SHOULD_SKIP_THIS */ |
| 309 | |
| 310 | |
| 311 | #endif /* _GSTREAMERMM_VALUE_H */ |
| 312 |