Debian Codegraph @

gstreamer/src/basesink.ccg

raw
1 /* gstreamermm - a C++ wrapper for gstreamer
2 *
3 * Copyright 2008-2016 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 _PINCLUDE(gstreamermm/private/element_p.h)
21
22 #define IGNORE_RESULT(x) { auto release_value = x; (void)release_value; }
23
24 namespace Gst {
25
26 gboolean BaseSink_Class::query_vfunc_callback(GstBaseSink* self, GstQuery* query)
27 {
28 const auto obj_base = static_cast<Glib::ObjectBase*>(
29 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
30
31 // Non-gtkmmproc-generated custom classes implicitly call the default
32 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
33 // generated classes can use this optimisation, which avoids the unnecessary
34 // parameter conversions if there is no possibility of the virtual function
35 // being overridden:
36 if(obj_base && obj_base->is_derived_())
37 {
38 const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
39 if(obj) // This can be NULL during destruction.
40 {
41 try // Trap C++ exceptions which would normally be lost because this is a C callback.
42 {
43 // Call the virtual member method, which derived classes might override.
44 auto qurery_wrapper = Glib::wrap(query, false);
45 int retval = static_cast<int>(obj->base_sink_query_vfunc(qurery_wrapper));
46 IGNORE_RESULT(qurery_wrapper.release());
47 return retval;
48 }
49 catch(...)
50 {
51 Glib::exception_handlers_invoke();
52 }
53 }
54 }
55
56 BaseClassType *const base = static_cast<BaseClassType*>(
57 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
58 );
59
60 // Call the original underlying C function:
61 if(base && base->query)
62 {
63 gboolean retval = (*base->query)(self, query);
64 return retval;
65 }
66
67 typedef gboolean RType;
68 return RType();
69 }
70
71 bool Gst::BaseSink::base_sink_query_vfunc(const Glib::RefPtr<Gst::Query>& query)
72 {
73 const auto base = static_cast<BaseClassType*>(
74 g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
75 );
76
77 if(base && base->query)
78 {
79 bool retval((*base->query)(gobj(),Glib::unwrap(query)));
80 return retval;
81 }
82
83 typedef bool RType;
84 return RType();
85 }
86
87
88 }