| 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 |
#include <gst/audio/gstaudiosrc.h> |
| 21 |
_PINCLUDE(gstreamermm/private/audiobasesrc_p.h) |
| 22 |
|
| 23 |
namespace Gst |
| 24 |
{ |
| 25 |
|
| 26 |
gboolean AudioSrc_Class::prepare_vfunc_callback(GstAudioSrc* self, GstAudioRingBufferSpec* spec) |
| 27 |
{ |
| 28 |
Glib::ObjectBase *const 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 |
CppObjectType *const 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 |
Gst::AudioRingBufferSpec cpp_spec(*spec); |
| 44 |
|
| 45 |
// Call the virtual member method, which derived classes might override. |
| 46 |
return static_cast<int>(obj->prepare_vfunc(cpp_spec)); |
| 47 |
} |
| 48 |
catch(...) |
| 49 |
{ |
| 50 |
Glib::exception_handlers_invoke(); |
| 51 |
} |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
BaseClassType *const base = static_cast<BaseClassType*>( |
| 56 |
g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class). |
| 57 |
); |
| 58 |
|
| 59 |
// Call the original underlying C function: |
| 60 |
if(base && base->prepare) |
| 61 |
return (*base->prepare)(self, spec); |
| 62 |
|
| 63 |
|
| 64 |
typedef gboolean RType; |
| 65 |
return RType(); |
| 66 |
} |
| 67 |
bool Gst::AudioSrc::prepare_vfunc(Gst::AudioRingBufferSpec& spec) |
| 68 |
{ |
| 69 |
BaseClassType *const base = static_cast<BaseClassType*>( |
| 70 |
g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class). |
| 71 |
); |
| 72 |
|
| 73 |
if(base && base->prepare) |
| 74 |
return static_cast<bool>((*base->prepare)(gobj(), spec.gobj())); |
| 75 |
|
| 76 |
typedef bool RType; |
| 77 |
return RType(); |
| 78 |
} |
| 79 |
guint AudioSrc_Class::read_vfunc_callback(GstAudioSrc* self, gpointer data, guint length, ClockTime* timestamp) |
| 80 |
{ |
| 81 |
Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>( |
| 82 |
Glib::ObjectBase::_get_current_wrapper((GObject*)self)); |
| 83 |
|
| 84 |
// Non-gtkmmproc-generated custom classes implicitly call the default |
| 85 |
// Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc- |
| 86 |
// generated classes can use this optimisation, which avoids the unnecessary |
| 87 |
// parameter conversions if there is no possibility of the virtual function |
| 88 |
// being overridden: |
| 89 |
if(obj_base && obj_base->is_derived_()) |
| 90 |
{ |
| 91 |
CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base); |
| 92 |
if(obj) // This can be NULL during destruction. |
| 93 |
{ |
| 94 |
try // Trap C++ exceptions which would normally be lost because this is a C callback. |
| 95 |
{ |
| 96 |
// Call the virtual member method, which derived classes might override. |
| 97 |
return obj->read_vfunc(data, length, *timestamp); |
| 98 |
} |
| 99 |
catch(...) |
| 100 |
{ |
| 101 |
Glib::exception_handlers_invoke(); |
| 102 |
} |
| 103 |
} |
| 104 |
} |
| 105 |
|
| 106 |
BaseClassType *const base = static_cast<BaseClassType*>( |
| 107 |
g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class). |
| 108 |
); |
| 109 |
|
| 110 |
// Call the original underlying C function: |
| 111 |
if(base && base->read) |
| 112 |
return (*base->read)(self, data, length, timestamp); |
| 113 |
|
| 114 |
|
| 115 |
typedef guint RType; |
| 116 |
return RType(); |
| 117 |
} |
| 118 |
guint Gst::AudioSrc::read_vfunc(const void* data, guint length, Gst::ClockTime& timestamp) |
| 119 |
{ |
| 120 |
BaseClassType *const base = static_cast<BaseClassType*>( |
| 121 |
g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class). |
| 122 |
); |
| 123 |
|
| 124 |
if(base && base->read) |
| 125 |
return (*base->read)(gobj(),const_cast<void*>(data),length, ×tamp); |
| 126 |
|
| 127 |
typedef guint RType; |
| 128 |
return RType(); |
| 129 |
} |
| 130 |
|
| 131 |
} // namespace Gst |