Debian Codegraph @

gstreamer/src/registry.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/pluginfeature.h>
22 #include <gstreamermm/plugin.h>
23 _PINCLUDE(gstreamermm/private/object_p.h)
24
25 namespace
26 {
27
28 extern "C"
29 {
30
31 static gboolean Registry_Plugin_Filter_gstreamermm_callback(GstPlugin* plugin, void* data)
32 {
33 Gst::Plugin::SlotFilter* the_slot = static_cast<Gst::Plugin::SlotFilter*>(data);
34
35 try
36 {
37 bool result = (*the_slot)(Glib::wrap(plugin, true));
38 return result;
39 }
40 catch(...)
41 {
42 Glib::exception_handlers_invoke();
43 }
44
45 return false;
46 }
47
48 static gboolean Registry_PluginFeature_Filter_gstreamermm_callback(GstPluginFeature* feature, void* data)
49 {
50 Gst::PluginFeature::SlotFilter* the_slot = static_cast<Gst::PluginFeature::SlotFilter*>(data);
51
52 try
53 {
54 bool result = (*the_slot)(Glib::wrap(feature, true));
55 return result;
56 }
57 catch(...)
58 {
59 Glib::exception_handlers_invoke();
60 }
61
62 return false;
63 }
64
65 } // extern "C"
66
67 } // anonymous namespace
68
69 namespace Gst
70 {
71
72 Glib::ListHandle< Glib::RefPtr<Gst::Plugin> >
73 Registry::get_plugin_list(const Plugin::SlotFilter& filter, bool first)
74 {
75 GList* list = gst_registry_plugin_filter(gobj(),
76 &Registry_Plugin_Filter_gstreamermm_callback, first,
77 const_cast<Plugin::SlotFilter*>(&filter));
78
79 return Glib::ListHandle< Glib::RefPtr<Gst::Plugin> >(list,
80 Glib::OWNERSHIP_DEEP);
81 }
82
83 Glib::ListHandle< Glib::RefPtr<const Gst::Plugin> >
84 Registry::get_plugin_list(const Plugin::SlotFilter& filter, bool first) const
85 {
86 GList* list = gst_registry_plugin_filter(const_cast<GstRegistry*>(gobj()),
87 &Registry_Plugin_Filter_gstreamermm_callback, first,
88 const_cast<Plugin::SlotFilter*>(&filter));
89
90 return Glib::ListHandle< Glib::RefPtr<const Gst::Plugin> >(list,
91 Glib::OWNERSHIP_DEEP);
92 }
93
94 Glib::ListHandle< Glib::RefPtr<Gst::PluginFeature> >
95 Registry::get_feature_list(const PluginFeature::SlotFilter& filter, bool first)
96 {
97 GList* list = gst_registry_feature_filter(gobj(),
98 &Registry_PluginFeature_Filter_gstreamermm_callback, first,
99 const_cast<PluginFeature::SlotFilter*>(&filter));
100
101 return Glib::ListHandle< Glib::RefPtr<Gst::PluginFeature> >(list,
102 Glib::OWNERSHIP_DEEP);
103 }
104
105 Glib::ListHandle< Glib::RefPtr<const Gst::PluginFeature> >
106 Registry::get_feature_list(const PluginFeature::SlotFilter& filter,
107 bool first) const
108 {
109 GList* list = gst_registry_feature_filter(const_cast<GstRegistry*>(gobj()),
110 &Registry_PluginFeature_Filter_gstreamermm_callback, first,
111 const_cast<PluginFeature::SlotFilter*>(&filter));
112
113 return Glib::ListHandle< Glib::RefPtr<const Gst::PluginFeature> >(list,
114 Glib::OWNERSHIP_DEEP);
115 }
116
117 Glib::RefPtr<Gst::Registry>
118 Registry::get()
119 {
120 return Glib::wrap(gst_registry_get(), true);
121 }
122
123 void Registry::add_feature(const Glib::RefPtr<Gst::PluginFeature>& feature)
124 {
125 feature->reference();
126 gst_registry_add_feature(gobj(), feature->gobj());
127 }
128
129 void Registry::add_plugin(const Glib::RefPtr<Gst::Plugin>& plugin)
130 {
131 plugin->reference();
132 gst_registry_add_plugin(gobj(), plugin->gobj());
133 }
134
135
136 } //namespace Gst