Debian Codegraph @

gstreamer/src/format.ccg

raw
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 <gstreamermm/iterator.h>
22
23 namespace Gst
24 {
25
26 FormatDefinition::FormatDefinition()
27 : value(Gst::FORMAT_UNDEFINED),
28 quark(static_cast<GQuark>(0))
29 {}
30
31 FormatDefinition::FormatDefinition(const GstFormatDefinition* castitem)
32 : value(Gst::FORMAT_UNDEFINED),
33 quark((castitem) ? castitem->quark : static_cast<GQuark>(0))
34 {
35 if(castitem)
36 {
37 value = static_cast<Format>(castitem->value);
38 nick = castitem->nick;
39 description = castitem->description;
40 }
41 }
42
43 namespace Enums
44 {
45
46 Glib::ustring get_name(Format f)
47 {
48 return gst_format_get_name(static_cast<GstFormat>(f));
49 }
50
51 Glib::QueryQuark get_quark(Format f)
52 {
53 return Glib::QueryQuark(gst_format_to_quark(static_cast<GstFormat>(f)));
54 }
55
56 } //namespace Enums
57
58 Format get_format(const Glib::ustring& nick)
59 {
60 return static_cast<Format>(gst_format_get_by_nick(nick.c_str()));
61 }
62
63 Format register_format(const Glib::ustring& nick, const Glib::ustring&
64 description)
65 {
66 return static_cast<Format>(gst_format_register(nick.c_str(), description.c_str()));
67 }
68
69 bool formats_contain(const Glib::ArrayHandle<Format>& formats, Format format)
70 {
71 return gst_formats_contains(reinterpret_cast<const GstFormat*>((formats).data()), static_cast<GstFormat>(format));
72 }
73
74 bool get_format_details(Format format, FormatDefinition& def)
75 {
76 const GstFormatDefinition* gstdef = gst_format_get_details(static_cast<GstFormat>(format));
77
78 if(!gstdef)
79 return false;
80
81 def.value = Format(gstdef->value);
82 def.nick = gstdef->nick;
83 def.description = gstdef->description;
84 def.quark = gstdef->quark;
85
86 return true;
87 }
88
89 IteratorBasic<const FormatDefinition> iterate_format_definitions()
90 {
91 return IteratorBasic<const FormatDefinition>(gst_format_iterate_definitions());
92 }
93
94 } //namespace Gst