| 1 | // Generated by gmmproc 2.50.1 -- DO NOT MODIFY! |
| 2 | |
| 3 | |
| 4 | #include <glibmm.h> |
| 5 | |
| 6 | #include <gstreamermm/audioclock.h> |
| 7 | #include <gstreamermm/private/audioclock_p.h> |
| 8 | |
| 9 | |
| 10 | /* gstreamermm - a C++ wrapper for gstreamer |
| 11 | * |
| 12 | * Copyright 2008-2016 The gstreamermm Development Team |
| 13 | * |
| 14 | * This library is free software; you can redistribute it and/or |
| 15 | * modify it under the terms of the GNU Lesser General Public |
| 16 | * License as published by the Free Software Foundation; either |
| 17 | * version 2.1 of the License, or (at your option) any later version. |
| 18 | * |
| 19 | * This library is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 22 | * Lesser General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU Lesser General Public |
| 25 | * License along with this library; if not, write to the Free |
| 26 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 27 | */ |
| 28 | |
| 29 | #include <gst/audio/gstaudioclock.h> |
| 30 | |
| 31 | |
| 32 | // TODO: remove this check after we require at least gstreamer 1.12 |
| 33 | #if GST_VERSION_MINOR < 12 |
| 34 | #define GSTMM_AUDIO_CLOCK_CAST(obj) GST_CLOCK(obj) |
| 35 | #else |
| 36 | #define GSTMM_AUDIO_CLOCK_CAST(obj) GST_AUDIO_CLOCK(obj) |
| 37 | #endif |
| 38 | |
| 39 | namespace |
| 40 | { |
| 41 | |
| 42 | extern "C" |
| 43 | { |
| 44 | |
| 45 | static GstClockTime AudioClock_GetTime_gstreamermm_callback(GstClock* clock, void* data) |
| 46 | { |
| 47 | Gst::AudioClock::SlotGetTime* the_slot = static_cast<Gst::AudioClock::SlotGetTime*>(data); |
| 48 | |
| 49 | try |
| 50 | { |
| 51 | return (*the_slot)(Glib::wrap(clock, true)); |
| 52 | } |
| 53 | catch(...) |
| 54 | { |
| 55 | Glib::exception_handlers_invoke(); |
| 56 | } |
| 57 | |
| 58 | return 0; // arbitrary value |
| 59 | } |
| 60 | |
| 61 | } // extern "C" |
| 62 | |
| 63 | } // anonymous namespace |
| 64 | |
| 65 | namespace Gst |
| 66 | { |
| 67 | |
| 68 | AudioClock::AudioClock(const Glib::ustring& name, const SlotGetTime& time_slot) |
| 69 | : // Mark this class as non-derived to allow C++ vfuncs to be skipped. |
| 70 | Glib::ObjectBase(nullptr), |
| 71 | Gst::SystemClock(Glib::ConstructParams(audioclock_class_.init(), "name",(name.empty() ? static_cast<char*>(0) : name.c_str()), nullptr)) |
| 72 | { |
| 73 | // The slot is dynamically allocated because it is called each time the time |
| 74 | // is gotten. |
| 75 | m_slot.reset(new SlotGetTime(time_slot)); |
| 76 | |
| 77 | // The following lines are taken verbatim from gst_audio_clock_new() after |
| 78 | // the call to g_object_new() because it seems that bug #545782 will not be |
| 79 | // accepted. |
| 80 | gobj()->func = &AudioClock_GetTime_gstreamermm_callback; |
| 81 | gobj()->user_data = m_slot.get(); |
| 82 | } |
| 83 | |
| 84 | Gst::ClockTime AudioClock::adjust(Gst::ClockTime time) |
| 85 | { |
| 86 | return static_cast<Gst::ClockTime>(gst_audio_clock_adjust(GSTMM_AUDIO_CLOCK_CAST(gobj()), static_cast<GstClockTime>(time))); |
| 87 | } |
| 88 | |
| 89 | Gst::ClockTime AudioClock::get_time() const |
| 90 | { |
| 91 | return static_cast<Gst::ClockTime>(gst_audio_clock_get_time(GSTMM_AUDIO_CLOCK_CAST(gobj()))); |
| 92 | } |
| 93 | |
| 94 | void AudioClock::invalidate() |
| 95 | { |
| 96 | gst_audio_clock_invalidate(GSTMM_AUDIO_CLOCK_CAST(gobj())); |
| 97 | } |
| 98 | |
| 99 | } //namespace Gst |
| 100 | |
| 101 | namespace |
| 102 | { |
| 103 | } // anonymous namespace |
| 104 | |
| 105 | |
| 106 | namespace Glib |
| 107 | { |
| 108 | |
| 109 | Glib::RefPtr<Gst::AudioClock> wrap(GstAudioClock* object, bool take_copy) |
| 110 | { |
| 111 | return Glib::RefPtr<Gst::AudioClock>( dynamic_cast<Gst::AudioClock*> (Glib::wrap_auto ((GObject*)(object), take_copy)) ); |
| 112 | //We use dynamic_cast<> in case of multiple inheritance. |
| 113 | } |
| 114 | |
| 115 | } /* namespace Glib */ |
| 116 | |
| 117 | |
| 118 | namespace Gst |
| 119 | { |
| 120 | |
| 121 | |
| 122 | /* The *_Class implementation: */ |
| 123 | |
| 124 | const Glib::Class& AudioClock_Class::init() |
| 125 | { |
| 126 | if(!gtype_) // create the GType if necessary |
| 127 | { |
| 128 | // Glib::Class has to know the class init function to clone custom types. |
| 129 | class_init_func_ = &AudioClock_Class::class_init_function; |
| 130 | |
| 131 | // This is actually just optimized away, apparently with no harm. |
| 132 | // Make sure that the parent type has been created. |
| 133 | //CppClassParent::CppObjectType::get_type(); |
| 134 | |
| 135 | // Create the wrapper type, with the same class/instance size as the base type. |
| 136 | register_derived_type(gst_audio_clock_get_type()); |
| 137 | |
| 138 | // Add derived versions of interfaces, if the C type implements any interfaces: |
| 139 | |
| 140 | } |
| 141 | |
| 142 | return *this; |
| 143 | } |
| 144 | |
| 145 | |
| 146 | void AudioClock_Class::class_init_function(void* g_class, void* class_data) |
| 147 | { |
| 148 | const auto klass = static_cast<BaseClassType*>(g_class); |
| 149 | CppClassParent::class_init_function(klass, class_data); |
| 150 | |
| 151 | |
| 152 | } |
| 153 | |
| 154 | |
| 155 | Glib::ObjectBase* AudioClock_Class::wrap_new(GObject* object) |
| 156 | { |
| 157 | return new AudioClock((GstAudioClock*)object); |
| 158 | } |
| 159 | |
| 160 | |
| 161 | /* The implementation: */ |
| 162 | |
| 163 | GstAudioClock* AudioClock::gobj_copy() |
| 164 | { |
| 165 | reference(); |
| 166 | return gobj(); |
| 167 | } |
| 168 | |
| 169 | AudioClock::AudioClock(const Glib::ConstructParams& construct_params) |
| 170 | : |
| 171 | Gst::SystemClock(construct_params) |
| 172 | { |
| 173 | |
| 174 | } |
| 175 | |
| 176 | AudioClock::AudioClock(GstAudioClock* castitem) |
| 177 | : |
| 178 | Gst::SystemClock((GstSystemClock*)(castitem)) |
| 179 | {} |
| 180 | |
| 181 | |
| 182 | AudioClock::AudioClock(AudioClock&& src) noexcept |
| 183 | : Gst::SystemClock(std::move(src)) |
| 184 | {} |
| 185 | |
| 186 | AudioClock& AudioClock::operator=(AudioClock&& src) noexcept |
| 187 | { |
| 188 | Gst::SystemClock::operator=(std::move(src)); |
| 189 | return *this; |
| 190 | } |
| 191 | |
| 192 | |
| 193 | AudioClock::~AudioClock() noexcept |
| 194 | {} |
| 195 | |
| 196 | |
| 197 | AudioClock::CppClassType AudioClock::audioclock_class_; // initialize static member |
| 198 | |
| 199 | GType AudioClock::get_type() |
| 200 | { |
| 201 | return audioclock_class_.init().get_type(); |
| 202 | } |
| 203 | |
| 204 | |
| 205 | GType AudioClock::get_base_type() |
| 206 | { |
| 207 | return gst_audio_clock_get_type(); |
| 208 | } |
| 209 | |
| 210 | |
| 211 | Glib::RefPtr<AudioClock> AudioClock::create(const Glib::ustring& name, const SlotGetTime& time_slot) |
| 212 | { |
| 213 | return Glib::RefPtr<AudioClock>( new AudioClock(name, time_slot) ); |
| 214 | } |
| 215 | |
| 216 | void AudioClock::reset(Gst::ClockTime time) |
| 217 | { |
| 218 | gst_audio_clock_reset(gobj(), ((GstClockTime)(time))); |
| 219 | } |
| 220 | |
| 221 | |
| 222 | } // namespace Gst |
| 223 | |
| 224 |