| 1 | // Generated by gmmproc 2.50.1 -- DO NOT MODIFY! |
| 2 | #ifndef _GSTREAMERMM_STRUCTURE_H |
| 3 | #define _GSTREAMERMM_STRUCTURE_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 <gstreamermm/clock.h> |
| 29 | #include <gstreamermm/enums.h> |
| 30 | #include <gstreamermm/value.h> |
| 31 | #include <glibmm/date.h> |
| 32 | #include <glibmm/datetime.h> |
| 33 | |
| 34 | |
| 35 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 36 | extern "C" { typedef struct _GstStructure GstStructure; } |
| 37 | #endif |
| 38 | |
| 39 | namespace Gst |
| 40 | { |
| 41 | |
| 42 | /** |
| 43 | * Generic class containing fields of names and values. |
| 44 | * A Gst::Structure is a collection of key/value pairs. The keys are expressed |
| 45 | * as GQuarks and the values can be of any GType. |
| 46 | * |
| 47 | * In addition to the key/value pairs, a Gst::Structure also has a name. The name |
| 48 | * starts with a letter and can be filled by letters, numbers and any of "/-_.:". |
| 49 | * |
| 50 | * Gst::Structure is used by various GStreamer subsystems to store information |
| 51 | * in a flexible and extensible way. A Gst::Structure does not have a refcount |
| 52 | * because it usually is part of a higher level object such as Gst::Caps, |
| 53 | * Gst::Message, Gst::Event, Gst::Query. |
| 54 | * |
| 55 | * A Gst::Structure can be created with constructor, which take a name |
| 56 | * and an optional set of key/value pairs along with the types of the values. |
| 57 | * |
| 58 | * Field values can be changed with set_field() or set_fields(). |
| 59 | * |
| 60 | * Field values can be retrieved with gst_get_field(). |
| 61 | * |
| 62 | * Fields can be removed with remove_field(). |
| 63 | * |
| 64 | * Strings in structures must be ASCII or UTF-8 encoded. |
| 65 | * |
| 66 | * Be aware that the current Gst::Caps / Gst::Structure serialization into string |
| 67 | * has limited support for nested Gst::Caps / Gst::Structure fields. It can only |
| 68 | * support one level of nesting. Using more levels will lead to unexpected |
| 69 | * behavior when using serialization features, such as Gst::Caps::to_string() or |
| 70 | * gst_value_serialize() and their counterparts. |
| 71 | * |
| 72 | * Last reviewed on 2016-07-12 (1.8.0) |
| 73 | */ |
| 74 | class Structure |
| 75 | { |
| 76 | public: |
| 77 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 78 | using CppObjectType = Structure; |
| 79 | using BaseObjectType = GstStructure; |
| 80 | #endif /* DOXYGEN_SHOULD_SKIP_THIS */ |
| 81 | |
| 82 | /** Get the GType for this class, for use with the underlying GObject type system. |
| 83 | */ |
| 84 | static GType get_type() G_GNUC_CONST; |
| 85 | |
| 86 | Structure(); |
| 87 | |
| 88 | explicit Structure(GstStructure* gobject, bool make_a_copy = true); |
| 89 | |
| 90 | Structure(const Structure& other); |
| 91 | Structure& operator=(const Structure& other); |
| 92 | |
| 93 | Structure(Structure&& other) noexcept; |
| 94 | Structure& operator=(Structure&& other) noexcept; |
| 95 | |
| 96 | ~Structure() noexcept; |
| 97 | |
| 98 | void swap(Structure& other) noexcept; |
| 99 | |
| 100 | ///Provides access to the underlying C instance. |
| 101 | GstStructure* gobj() { return gobject_; } |
| 102 | |
| 103 | ///Provides access to the underlying C instance. |
| 104 | const GstStructure* gobj() const { return gobject_; } |
| 105 | |
| 106 | ///Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs. |
| 107 | GstStructure* gobj_copy() const; |
| 108 | |
| 109 | protected: |
| 110 | GstStructure* gobject_; |
| 111 | |
| 112 | private: |
| 113 | |
| 114 | |
| 115 | public: |
| 116 | /** Creates a Structure with the given @a name. Parses the list of variable |
| 117 | * arguments and sets fields to the values listed. Variable arguments |
| 118 | * should be passed as field name and value |
| 119 | */ |
| 120 | template<class ...DataTypes> |
| 121 | explicit Structure(const Glib::ustring &name, DataTypes... data); |
| 122 | |
| 123 | /** Creates a Gst::Structure from a string representation. |
| 124 | * |
| 125 | * @param the_string A string representation of a Gst::Structure. See to_string(). |
| 126 | * @return A Structure. This will be invalid (see operator=) when the string |
| 127 | * could not be parsed. |
| 128 | */ |
| 129 | static Structure create_from_string(const Glib::ustring& the_string); |
| 130 | |
| 131 | |
| 132 | /** Use this to discover if the Structure is a valid object. |
| 133 | */ |
| 134 | operator const void*() const; |
| 135 | |
| 136 | /** Release the ownership of underlying GstStructure instance. |
| 137 | * |
| 138 | * Gst::Structure's underlying instance is set to nullptr, therefore underlying |
| 139 | * object can't be accessed through this Gst::Structure anymore. |
| 140 | * @return an underlying instance of GstStructure object. |
| 141 | * |
| 142 | * Most users should not use release(). It can spoil the automatic destruction |
| 143 | * of the managed object. |
| 144 | */ |
| 145 | GstStructure* release() noexcept; |
| 146 | |
| 147 | |
| 148 | /** Get the name of @a structure as a string. |
| 149 | * |
| 150 | * @return The name of the structure. |
| 151 | */ |
| 152 | Glib::ustring get_name() const; |
| 153 | |
| 154 | /** Checks if the structure has the given name |
| 155 | * |
| 156 | * @param name Structure name to check for. |
| 157 | * @return <tt>true</tt> if @a name matches the name of the structure. |
| 158 | */ |
| 159 | bool has_name(const Glib::ustring& name) const; |
| 160 | |
| 161 | /** Sets the name of the structure to the given @a name. The string |
| 162 | * provided is copied before being used. It must not be empty, start with a |
| 163 | * letter and can be followed by letters, numbers and any of "/-_.:". |
| 164 | * |
| 165 | * @param name The new name of the structure. |
| 166 | */ |
| 167 | void set_name(const Glib::ustring& name); |
| 168 | |
| 169 | /** Get the name of @a structure as a GQuark. |
| 170 | * |
| 171 | * @return The quark representing the name of the structure. |
| 172 | */ |
| 173 | Glib::QueryQuark get_name_id() const; |
| 174 | |
| 175 | /** Removes all fields in a GstStructure. |
| 176 | */ |
| 177 | void remove_all_fields(); |
| 178 | |
| 179 | /** Finds the field with the given name, and returns the type of the |
| 180 | * value it contains. If the field is not found, G_TYPE_INVALID is |
| 181 | * returned. |
| 182 | * |
| 183 | * @param fieldname The name of the field. |
| 184 | * @return The Value of the field. |
| 185 | */ |
| 186 | GType get_field_type(const Glib::ustring& fieldname) const; |
| 187 | |
| 188 | /** Get the number of fields in the structure. |
| 189 | * |
| 190 | * @return The number of fields in the structure. |
| 191 | */ |
| 192 | int size() const; |
| 193 | |
| 194 | /** Get the name of the given field number, counting from 0 onwards. |
| 195 | * |
| 196 | * @param index The index to get the name of. |
| 197 | * @return The name of the given field number. |
| 198 | */ |
| 199 | Glib::ustring get_nth_field_name(guint index) const; |
| 200 | |
| 201 | /** Converts @a structure to a human-readable string representation. |
| 202 | * |
| 203 | * For debugging purposes its easier to do something like this: |
| 204 | * |
| 205 | * [C example ellipted] |
| 206 | * This prints the structure in human readable form. |
| 207 | * |
| 208 | * The current implementation of serialization will lead to unexpected results |
| 209 | * when there are nested Gst::Caps / Gst::Structure deeper than one level. |
| 210 | * |
| 211 | * @return A pointer to string allocated by Glib::malloc(). |
| 212 | */ |
| 213 | Glib::ustring to_string() const; |
| 214 | |
| 215 | /** Fixates a Gst::Structure by changing the given field to the nearest |
| 216 | * integer to @a target that is a subset of the existing field. |
| 217 | * |
| 218 | * @param name A field in @a structure. |
| 219 | * @param target The target value of the fixation. |
| 220 | * @return <tt>true</tt> if the structure could be fixated. |
| 221 | */ |
| 222 | bool fixate_field_nearest_int(const Glib::ustring& name, int target); |
| 223 | |
| 224 | /** Fixates a Gst::Structure by changing the given field to the nearest |
| 225 | * double to @a target that is a subset of the existing field. |
| 226 | * |
| 227 | * @param name A field in @a structure. |
| 228 | * @param target The target value of the fixation. |
| 229 | * @return <tt>true</tt> if the structure could be fixated. |
| 230 | */ |
| 231 | bool fixate_field_nearest_double(const Glib::ustring& name, double target); |
| 232 | |
| 233 | /** Fixates a Gst::Structure by changing the given @a name field to the given |
| 234 | * @a target string if that field is not fixed yet. |
| 235 | * |
| 236 | * @param name A field in @a structure. |
| 237 | * @param target The target value of the fixation. |
| 238 | * @return <tt>true</tt> if the structure could be fixated. |
| 239 | */ |
| 240 | bool fixate_field_string(const Glib::ustring& name, const Glib::ustring& target); |
| 241 | |
| 242 | /** Fixates a Gst::Structure by changing the given field with its fixated value. |
| 243 | * |
| 244 | * @param name A field in @a structure. |
| 245 | * @return <tt>true</tt> if the structure field could be fixated. |
| 246 | */ |
| 247 | bool fixate_field(const Glib::ustring& name); |
| 248 | |
| 249 | /** Fixates a Gst::Structure by changing the given @a name field to the given |
| 250 | * @a target boolean if that field is not fixed yet. |
| 251 | * |
| 252 | * @param name A field in @a structure. |
| 253 | * @param target The target value of the fixation. |
| 254 | * @return <tt>true</tt> if the structure could be fixated. |
| 255 | */ |
| 256 | bool fixate_field_boolean(const Glib::ustring& name, bool target); |
| 257 | |
| 258 | /** Intersects @a struct1 and @a struct2 and returns the intersection. |
| 259 | * |
| 260 | * @param struct2 A Gst::Structure. |
| 261 | * @return Intersection of @a struct1 and @a struct2. |
| 262 | */ |
| 263 | Gst::Structure intersect(const Gst::Structure& struct2) const; |
| 264 | |
| 265 | /** Tests if the two Gst::Structure are equal. |
| 266 | * |
| 267 | * @param struct2 A Gst::Structure. |
| 268 | * @return <tt>true</tt> if the two structures have the same name and field. |
| 269 | */ |
| 270 | bool is_equal(const Gst::Structure& struct2) const; |
| 271 | |
| 272 | /** Checks if @a subset is a subset of @a superset, i.e.\ has the same |
| 273 | * structure name and for all fields that are existing in @a superset, |
| 274 | * @a subset has a value that is a subset of the value in @a superset. |
| 275 | * |
| 276 | * @param superset A potentially greater Gst::Structure. |
| 277 | * @return <tt>true</tt> if @a subset is a subset of @a superset. |
| 278 | */ |
| 279 | bool is_subset(const Gst::Structure& superset) const; |
| 280 | |
| 281 | /** Tries intersecting @a struct1 and @a struct2 and reports whether the result |
| 282 | * would not be empty. |
| 283 | * |
| 284 | * @param struct2 A Gst::Structure. |
| 285 | * @return <tt>true</tt> if intersection would not be empty. |
| 286 | */ |
| 287 | bool can_intersect(const Gst::Structure& struct2) const; |
| 288 | |
| 289 | /** Fixate all values in @a structure using gst_value_fixate(). |
| 290 | * @a structure will be modified in-place and should be writable. |
| 291 | */ |
| 292 | void fixate(); |
| 293 | |
| 294 | /** Read the GstFlagSet flags and mask out of the structure into the |
| 295 | * provided pointers. |
| 296 | * |
| 297 | * @param fieldname The name of a field. |
| 298 | * @param value_flags A pointer to a <tt>unsigned int</tt> for the flags field. |
| 299 | * @param value_mask A pointer to a <tt>unsigned int</tt> for the mask field. |
| 300 | * @return <tt>true</tt> if the values could be set correctly. If there was no field |
| 301 | * with @a fieldname or the existing field did not contain a GstFlagSet, this |
| 302 | * function returns <tt>false</tt>. |
| 303 | */ |
| 304 | bool get_flagset(const Glib::ustring& fieldname, guint& value_flags, guint& value_mask) const; |
| 305 | |
| 306 | |
| 307 | /** Check if @a structure contains a field named @a fieldname. |
| 308 | * |
| 309 | * @param fieldname The name of a field. |
| 310 | * @return <tt>true</tt> if the structure contains a field with the given name. |
| 311 | */ |
| 312 | bool has_field(const Glib::ustring& fieldname) const; |
| 313 | |
| 314 | |
| 315 | /** Check if @a structure contains a field named @a fieldname and with GType @a type. |
| 316 | * |
| 317 | * @param fieldname The name of a field. |
| 318 | * @param type The type of a value. |
| 319 | * @return <tt>true</tt> if the structure contains a field with the given name and type. |
| 320 | */ |
| 321 | bool has_field(const Glib::ustring& fieldname, GType type) const; |
| 322 | |
| 323 | |
| 324 | /** Get the value of the field with name @a fieldname. |
| 325 | * |
| 326 | * @param fieldname The name of the field to get. |
| 327 | * @param value The Value class in which to store the value. |
| 328 | */ |
| 329 | void get_field(const Glib::ustring& fieldname, Glib::ValueBase& value) const; |
| 330 | |
| 331 | /** Get the value of the field with name @a fieldname. |
| 332 | * |
| 333 | * @param fieldname The name of the field to get. |
| 334 | * @param value The Value class in which to store the value. |
| 335 | */ |
| 336 | template<typename DataType> |
| 337 | void get_field(const Glib::ustring& fieldname, Glib::Value<DataType>& value) const; |
| 338 | |
| 339 | /** Gets the value of field @a fieldname with GType enum type @a enumtype |
| 340 | * into integer @a value. Caller is responsible for making sure the |
| 341 | * field exists and has the correct type. A call to this method would look |
| 342 | * like so: |
| 343 | * @code |
| 344 | * ... |
| 345 | * int state; |
| 346 | * structure.get_field("state", Glib::Value<Gst::State>::value_type(), |
| 347 | * state); |
| 348 | * ... |
| 349 | * @endcode |
| 350 | * |
| 351 | * @param fieldname The name of a field. |
| 352 | * @param enumtype The enum GType of the field. |
| 353 | * @param value An output parameter that will be set with the value. |
| 354 | * @return true if @a value could be set correctly. If there was no field |
| 355 | * with @a fieldname or the existing field did not contain an enum, this |
| 356 | * function returns false. |
| 357 | */ |
| 358 | bool get_field(const Glib::ustring& fieldname, GType enumtype, int& value) const; |
| 359 | |
| 360 | |
| 361 | /** Gets the value of field @a fieldname into DataType @a value. |
| 362 | * The caller is responsible for making sure the field exists and has the |
| 363 | * correct type. |
| 364 | * |
| 365 | * @param fieldname The name of a field. |
| 366 | * @param value The DataType to set. |
| 367 | */ |
| 368 | template<typename DataType> |
| 369 | bool get_field(const Glib::ustring& fieldname, DataType& value) const; |
| 370 | |
| 371 | // These are ignored because they are useful in the C API but are either |
| 372 | // variable argument functions or their functionality is already provided. |
| 373 | |
| 374 | |
| 375 | /** Sets the field with name @a fieldname to value. If the field does not |
| 376 | * exist, it is created. If the field exists, the previous value is replaced |
| 377 | * and freed. |
| 378 | * |
| 379 | * @param fieldname The name of the field to set. |
| 380 | * @param value The value to set the field to. |
| 381 | */ |
| 382 | void set_field(const Glib::ustring& fieldname, const Glib::ValueBase& value); |
| 383 | |
| 384 | |
| 385 | /** Sets the field with name @a fieldname to value. If the field does not |
| 386 | * exist, it is created. If the field exists, the previous value is replaced |
| 387 | * and freed. |
| 388 | * |
| 389 | * @param fieldname The name of the field to set. |
| 390 | * @param value The value to set the field to. |
| 391 | */ |
| 392 | template<typename DataType> |
| 393 | void set_field(const Glib::ustring& fieldname, const Glib::Value<DataType>& value); |
| 394 | |
| 395 | /** Sets the field with name @a fieldname to value. If the field does not |
| 396 | * exist, it is created. If the field exists, the previous value is replaced |
| 397 | * and freed. |
| 398 | * |
| 399 | * @param fieldname The name of the field to set. |
| 400 | * @param value The value to set the field to. |
| 401 | */ |
| 402 | void set_field(const Glib::ustring& fieldname, const char* value); |
| 403 | |
| 404 | /** Sets the fields with name @a fieldname to values. If one of the fields does not |
| 405 | * exist, it is created. If the field exists, the previous value is replaced |
| 406 | * and freed. |
| 407 | * |
| 408 | * @param fieldname The name of the field to set. |
| 409 | * @param value The value to set the field to. |
| 410 | * @param further_data List of pairs of the format: fieldname, value. |
| 411 | */ |
| 412 | template<class DataType, class ...DataTypes> |
| 413 | void set_fields(const Glib::ustring & fieldname, const DataType& value, DataTypes ...further_data); |
| 414 | |
| 415 | /** Sets the field with name @a fieldname to the value @a value of the enum |
| 416 | * type @a enum_type. If the field does not exist, it is created. If the |
| 417 | * field exists, the previous value is replaced and freed. Caller is |
| 418 | * responsible for making sure that @a value is a valid @a enumtype. A call |
| 419 | * to this method would look like so: |
| 420 | * @code |
| 421 | * ... |
| 422 | * structure.set_field("state", Glib::Value<Gst::State>::value_type(), |
| 423 | * Gst::STATE_PAUSED); |
| 424 | * ... |
| 425 | * @endcode |
| 426 | * |
| 427 | * @param fieldname The name of the field to set. |
| 428 | * @param enumtype The enum GType that @a value should be treated as. |
| 429 | * @param value The value to set the field to. |
| 430 | */ |
| 431 | void set_field(const Glib::ustring& fieldname, GType enumtype, int value); |
| 432 | |
| 433 | /** Sets the field with name @a fieldname field to the DataType @a value. |
| 434 | * If the field does not exist, it is created. If the field exists, |
| 435 | * the previous value is replaced and freed. Please note that when setting |
| 436 | * fields to special types such as Gst::Fourcc and Gst::Fraction and |
| 437 | * Glib::Date they are converted to the GStreamer GTypes and thus when |
| 438 | * attempting to get these fields back as GValues, they will have the |
| 439 | * GStreamer GType. |
| 440 | * |
| 441 | * @param fieldname The name of the field to set. |
| 442 | * @param value The value to set the field to. |
| 443 | */ |
| 444 | template<typename DataType> |
| 445 | void set_field(const Glib::ustring& fieldname, const DataType& value); |
| 446 | |
| 447 | // These take ownership of the GValue so they are not wrapped. |
| 448 | |
| 449 | |
| 450 | /** Removes the field with name @a fieldname. If the field with the given |
| 451 | * name does not exist, the structure is unchanged. |
| 452 | * |
| 453 | * @param fieldname The name of the field to remove. |
| 454 | */ |
| 455 | void remove_field(const Glib::ustring& fieldname); |
| 456 | |
| 457 | |
| 458 | /** For example, |
| 459 | * bool on_foreach(const Glib::ustring& id, const Glib::ValueBase& value);. |
| 460 | * The on_foreach function should return true if the foreach operation should |
| 461 | * continue, or false if the operation should stop with false. |
| 462 | */ |
| 463 | typedef sigc::slot<bool, const Glib::ustring&, const Glib::ValueBase&> SlotForeach; |
| 464 | |
| 465 | /** Calls the provided slot once for each field in the Gst::Structure. The |
| 466 | * slot must not modify the fields. See also map_in_place(). |
| 467 | * |
| 468 | * @param slot A slot to call for each field. |
| 469 | * @return true if the supplied slot returns true For each of the fields, |
| 470 | * false otherwise. |
| 471 | */ |
| 472 | bool foreach(const SlotForeach& slot); |
| 473 | |
| 474 | |
| 475 | /** For example, |
| 476 | * bool on_map(const Glib::ustring& id, Glib::ValueBase& value);. |
| 477 | * The map function should return true if the map operation should continue, |
| 478 | * or false if the operation should stop with false. |
| 479 | */ |
| 480 | typedef sigc::slot<bool, const Glib::ustring&, Glib::ValueBase&> SlotMap; |
| 481 | |
| 482 | /** Calls the provided slot once for each field in the Gst::Structure. In |
| 483 | * contrast to foreach(), the function may modify but not delete the fields. |
| 484 | * The structure must be mutable. |
| 485 | * |
| 486 | * @param slot A slot to call for each field. |
| 487 | * @return true if the supplied slot returns true For each of the fields, |
| 488 | * false otherwise. |
| 489 | */ |
| 490 | bool map_in_place(const SlotMap& slot); |
| 491 | |
| 492 | |
| 493 | /** Fixates a Gst::Structure by changing the given field to the nearest |
| 494 | * fraction to given Gst::Fraction that is a subset of the existing field. |
| 495 | * |
| 496 | * @param field_name A field in structure. |
| 497 | * @param target The target value of the fixation. |
| 498 | * @return true If the structure could be fixated. |
| 499 | */ |
| 500 | bool fixate_nearest_fraction(const Glib::ustring& field_name, const Gst::Fraction& target); |
| 501 | |
| 502 | |
| 503 | //Variable argument functions are ignored. |
| 504 | |
| 505 | |
| 506 | private: |
| 507 | // This method is used for varadic template recursion |
| 508 | void set_fields() {} |
| 509 | |
| 510 | |
| 511 | }; |
| 512 | |
| 513 | template<class ...DataTypes> |
| 514 | Structure::Structure(const Glib::ustring &name, DataTypes... data) |
| 515 | { |
| 516 | gobject_ = gst_structure_new_empty(name.c_str()); |
| 517 | set_fields(data...); |
| 518 | } |
| 519 | |
| 520 | template<class DataType, class ...DataTypes> |
| 521 | void Structure::set_fields(const Glib::ustring & name, const DataType& data, DataTypes ...further_data) |
| 522 | { |
| 523 | this->set_field(name, data); |
| 524 | this->set_fields(further_data...); |
| 525 | } |
| 526 | |
| 527 | template<typename DataType> |
| 528 | bool Structure::get_field(const Glib::ustring& fieldname, DataType& value) const |
| 529 | { |
| 530 | typedef Glib::Value<DataType> ValueType; |
| 531 | |
| 532 | bool ret = ValueType::value_type() == get_field_type(fieldname); |
| 533 | |
| 534 | if (ret) |
| 535 | { |
| 536 | ValueType v; |
| 537 | this->get_field(fieldname, reinterpret_cast<Glib::ValueBase&>(v)); |
| 538 | value = v.get(); |
| 539 | } |
| 540 | |
| 541 | return ret; |
| 542 | } |
| 543 | |
| 544 | template<typename DataType> |
| 545 | void Structure::set_field(const Glib::ustring& fieldname, const DataType& value) |
| 546 | { |
| 547 | typedef Glib::Value<DataType> ValueType; |
| 548 | ValueType v; |
| 549 | v.init(ValueType::value_type()); |
| 550 | v.set(value); |
| 551 | this->set_field(fieldname, reinterpret_cast<const Glib::ValueBase&>(v)); |
| 552 | } |
| 553 | |
| 554 | template<typename DataType> |
| 555 | void Structure::get_field(const Glib::ustring& fieldname, Glib::Value<DataType>& value) const |
| 556 | { |
| 557 | get_field(fieldname, reinterpret_cast<Glib::ValueBase&>(value)); |
| 558 | } |
| 559 | |
| 560 | template<typename DataType> |
| 561 | void Structure::set_field(const Glib::ustring& fieldname, const Glib::Value<DataType>& value) |
| 562 | { |
| 563 | set_field(fieldname, reinterpret_cast<const Glib::ValueBase&>(value)); |
| 564 | } |
| 565 | |
| 566 | } //namespace Gst |
| 567 | |
| 568 | |
| 569 | namespace Gst |
| 570 | { |
| 571 | |
| 572 | /** @relates Gst::Structure |
| 573 | * @param lhs The left-hand side |
| 574 | * @param rhs The right-hand side |
| 575 | */ |
| 576 | inline void swap(Structure& lhs, Structure& rhs) noexcept |
| 577 | { lhs.swap(rhs); } |
| 578 | |
| 579 | } // namespace Gst |
| 580 | |
| 581 | namespace Glib |
| 582 | { |
| 583 | |
| 584 | /** A Glib::wrap() method for this object. |
| 585 | * |
| 586 | * @param object The C instance. |
| 587 | * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref. |
| 588 | * @result A C++ instance that wraps this C instance. |
| 589 | * |
| 590 | * @relates Gst::Structure |
| 591 | */ |
| 592 | Gst::Structure wrap(GstStructure* object, bool take_copy = false); |
| 593 | |
| 594 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 595 | template <> |
| 596 | class Value<Gst::Structure> : public Glib::Value_Boxed<Gst::Structure> |
| 597 | {}; |
| 598 | #endif /* DOXYGEN_SHOULD_SKIP_THIS */ |
| 599 | |
| 600 | } // namespace Glib |
| 601 | |
| 602 | |
| 603 | #endif /* _GSTREAMERMM_STRUCTURE_H */ |
| 604 |