| 1 | // Generated by gmmproc 2.50.1 -- DO NOT MODIFY! |
| 2 | #ifndef _GSTREAMERMM_AUDIOCLOCK_H |
| 3 | #define _GSTREAMERMM_AUDIOCLOCK_H |
| 4 | |
| 5 | |
| 6 | #include <glibmm/ustring.h> |
| 7 | #include <sigc++/sigc++.h> |
| 8 | |
| 9 | /* gstreamermm - a C++ wrapper for gstreamer |
| 10 | * |
| 11 | * Copyright 2008-2016 The gstreamermm Development Team |
| 12 | * |
| 13 | * This library is free software; you can redistribute it and/or |
| 14 | * modify it under the terms of the GNU Lesser General Public |
| 15 | * License as published by the Free Software Foundation; either |
| 16 | * version 2.1 of the License, or (at your option) any later version. |
| 17 | * |
| 18 | * This library is distributed in the hope that it will be useful, |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 21 | * Lesser General Public License for more details. |
| 22 | * |
| 23 | * You should have received a copy of the GNU Lesser General Public |
| 24 | * License along with this library; if not, write to the Free |
| 25 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 26 | */ |
| 27 | |
| 28 | #include <gstreamermm/systemclock.h> |
| 29 | #include <memory> |
| 30 | |
| 31 | |
| 32 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 33 | using GstAudioClock = struct _GstAudioClock; |
| 34 | using GstAudioClockClass = struct _GstAudioClockClass; |
| 35 | #endif /* DOXYGEN_SHOULD_SKIP_THIS */ |
| 36 | |
| 37 | |
| 38 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 39 | namespace Gst |
| 40 | { class AudioClock_Class; } // namespace Gst |
| 41 | #endif //DOXYGEN_SHOULD_SKIP_THIS |
| 42 | |
| 43 | namespace Gst |
| 44 | { |
| 45 | |
| 46 | /** A Helper object for implementing audio clocks. |
| 47 | * Gst::AudioClock makes it easy for elements to implement a Gst::Clock, |
| 48 | * they simply need to provide a slot that returns the current clock time. |
| 49 | * |
| 50 | * This object is internally used to implement the clock in |
| 51 | * Gst::AudioBaseSink. |
| 52 | * |
| 53 | * Last reviewed on 2016-04-23 (1.8.0). |
| 54 | */ |
| 55 | |
| 56 | class AudioClock : public Gst::SystemClock |
| 57 | { |
| 58 | |
| 59 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 60 | |
| 61 | public: |
| 62 | using CppObjectType = AudioClock; |
| 63 | using CppClassType = AudioClock_Class; |
| 64 | using BaseObjectType = GstAudioClock; |
| 65 | using BaseClassType = GstAudioClockClass; |
| 66 | |
| 67 | // noncopyable |
| 68 | AudioClock(const AudioClock&) = delete; |
| 69 | AudioClock& operator=(const AudioClock&) = delete; |
| 70 | |
| 71 | private: friend class AudioClock_Class; |
| 72 | static CppClassType audioclock_class_; |
| 73 | |
| 74 | protected: |
| 75 | explicit AudioClock(const Glib::ConstructParams& construct_params); |
| 76 | explicit AudioClock(GstAudioClock* castitem); |
| 77 | |
| 78 | #endif /* DOXYGEN_SHOULD_SKIP_THIS */ |
| 79 | |
| 80 | public: |
| 81 | |
| 82 | AudioClock(AudioClock&& src) noexcept; |
| 83 | AudioClock& operator=(AudioClock&& src) noexcept; |
| 84 | |
| 85 | ~AudioClock() noexcept override; |
| 86 | |
| 87 | /** Get the GType for this class, for use with the underlying GObject type system. |
| 88 | */ |
| 89 | static GType get_type() G_GNUC_CONST; |
| 90 | |
| 91 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 92 | |
| 93 | |
| 94 | static GType get_base_type() G_GNUC_CONST; |
| 95 | #endif |
| 96 | |
| 97 | ///Provides access to the underlying C GObject. |
| 98 | GstAudioClock* gobj() { return reinterpret_cast<GstAudioClock*>(gobject_); } |
| 99 | |
| 100 | ///Provides access to the underlying C GObject. |
| 101 | const GstAudioClock* gobj() const { return reinterpret_cast<GstAudioClock*>(gobject_); } |
| 102 | |
| 103 | ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. |
| 104 | GstAudioClock* gobj_copy(); |
| 105 | |
| 106 | private: |
| 107 | |
| 108 | |
| 109 | public: |
| 110 | /** For example, |
| 111 | * Gst::ClockTime on_get_time(const Glib::RefPtr<Gst::Clock>& clock);. |
| 112 | * This function will be called whenever the current clock time needs to be |
| 113 | * calculated. If this function returns Gst::CLOCK_TIME_NONE, the last |
| 114 | * reported time will be returned by the clock. |
| 115 | * |
| 116 | * @param clock The Gst::AudioClock. |
| 117 | */ |
| 118 | typedef sigc::slot< Gst::ClockTime, const Glib::RefPtr<Gst::Clock>& > SlotGetTime; |
| 119 | |
| 120 | protected: |
| 121 | AudioClock(const Glib::ustring& name, const SlotGetTime& time_slot); |
| 122 | |
| 123 | public: |
| 124 | /** Create a new Gst::AudioClock instance. Whenever the clock time should |
| 125 | * be calculated it will call @a time_slot. When @a time_slot returns |
| 126 | * Gst::CLOCK_TIME_NONE, the clock will return the last reported time. |
| 127 | * |
| 128 | * @param name The name of the clock. |
| 129 | * @param time_slot A slot that returns the time. |
| 130 | * |
| 131 | * @return a new Gst::AudioClock. |
| 132 | */ |
| 133 | |
| 134 | static Glib::RefPtr<AudioClock> create(const Glib::ustring& name, const SlotGetTime& time_slot); |
| 135 | |
| 136 | |
| 137 | /** Inform @a clock that future calls to Gst::AudioClockGetTimeFunc will return values |
| 138 | * starting from @a time. The clock will update an internal offset to make sure that |
| 139 | * future calls to internal_time will return an increasing result as required by |
| 140 | * the Gst::Clock object. |
| 141 | * |
| 142 | * @param time A Gst::ClockTime. |
| 143 | */ |
| 144 | void reset(Gst::ClockTime time); |
| 145 | |
| 146 | // TODO methods below get GstClock as a first argument, |
| 147 | // so have to be wrapped manually. It has been fixed in |
| 148 | // GStreamer (https://bugzilla.gnome.org/show_bug.cgi?id=756628) |
| 149 | // but patch is not available in 1.8.0 version. |
| 150 | |
| 151 | /** Adjust @a time with the internal offset of the audio clock. |
| 152 | * |
| 153 | * @param clock A Gst::AudioClock. |
| 154 | * @param time A Gst::ClockTime. |
| 155 | * @return @a time adjusted with the internal offset. |
| 156 | */ |
| 157 | |
| 158 | Gst::ClockTime adjust(Gst::ClockTime time); |
| 159 | |
| 160 | |
| 161 | /** Report the time as returned by the Gst::AudioClockGetTimeFunc without applying |
| 162 | * any offsets. |
| 163 | * |
| 164 | * @param clock A Gst::AudioClock. |
| 165 | * @return The time as reported by the time function of the audio clock. |
| 166 | */ |
| 167 | |
| 168 | Gst::ClockTime get_time() const; |
| 169 | |
| 170 | |
| 171 | /** Invalidate the clock function. Call this function when the provided |
| 172 | * Gst::AudioClockGetTimeFunc cannot be called anymore, for example, when the |
| 173 | * user_data becomes invalid. |
| 174 | * |
| 175 | * After calling this function, @a clock will return the last returned time for |
| 176 | * the rest of its lifetime. |
| 177 | * |
| 178 | * @param clock A Gst::AudioClock. |
| 179 | */ |
| 180 | |
| 181 | void invalidate(); |
| 182 | |
| 183 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 184 | private: |
| 185 | // TODO this slot should be moved in move constructor, but for now it's |
| 186 | // impossible to provide custom move constructor |
| 187 | // (see https://bugzilla.gnome.org/show_bug.cgi?id=756593). |
| 188 | // However, task should be managed by RefPtr class, so move constructor |
| 189 | // and move assignment operator will never be called. |
| 190 | std::unique_ptr<SlotGetTime> m_slot; |
| 191 | #endif |
| 192 | |
| 193 | |
| 194 | public: |
| 195 | |
| 196 | public: |
| 197 | //C++ methods used to invoke GTK+ virtual functions: |
| 198 | |
| 199 | protected: |
| 200 | //GTK+ Virtual Functions (override these to change behaviour): |
| 201 | |
| 202 | //Default Signal Handlers:: |
| 203 | |
| 204 | |
| 205 | }; |
| 206 | |
| 207 | } // namespace Gst |
| 208 | |
| 209 | |
| 210 | namespace Glib |
| 211 | { |
| 212 | /** A Glib::wrap() method for this object. |
| 213 | * |
| 214 | * @param object The C instance. |
| 215 | * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref. |
| 216 | * @result A C++ instance that wraps this C instance. |
| 217 | * |
| 218 | * @relates Gst::AudioClock |
| 219 | */ |
| 220 | Glib::RefPtr<Gst::AudioClock> wrap(GstAudioClock* object, bool take_copy = false); |
| 221 | } |
| 222 | |
| 223 | |
| 224 | #endif /* _GSTREAMERMM_AUDIOCLOCK_H */ |
| 225 |