| 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 <gstreamermm/systemclock.h> |
| 21 |
#include <memory> |
| 22 |
|
| 23 |
_DEFS(gstreamermm,gst) |
| 24 |
|
| 25 |
namespace Gst |
| 26 |
{ |
| 27 |
|
| 28 |
/** A Helper object for implementing audio clocks. |
| 29 |
* Gst::AudioClock makes it easy for elements to implement a Gst::Clock, |
| 30 |
* they simply need to provide a slot that returns the current clock time. |
| 31 |
* |
| 32 |
* This object is internally used to implement the clock in |
| 33 |
* Gst::AudioBaseSink. |
| 34 |
* |
| 35 |
* Last reviewed on 2016-04-23 (1.8.0). |
| 36 |
*/ |
| 37 |
class AudioClock : public Gst::SystemClock |
| 38 |
{ |
| 39 |
_CLASS_GOBJECT(AudioClock, GstAudioClock, GST_AUDIO_CLOCK, Gst::SystemClock, GstSystemClock) |
| 40 |
|
| 41 |
public: |
| 42 |
/** For example, |
| 43 |
* Gst::ClockTime on_get_time(const Glib::RefPtr<Gst::Clock>& clock);. |
| 44 |
* This function will be called whenever the current clock time needs to be |
| 45 |
* calculated. If this function returns Gst::CLOCK_TIME_NONE, the last |
| 46 |
* reported time will be returned by the clock. |
| 47 |
* |
| 48 |
* @param clock The Gst::AudioClock. |
| 49 |
*/ |
| 50 |
typedef sigc::slot< Gst::ClockTime, const Glib::RefPtr<Gst::Clock>& > SlotGetTime; |
| 51 |
|
| 52 |
protected: |
| 53 |
AudioClock(const Glib::ustring& name, const SlotGetTime& time_slot); |
| 54 |
|
| 55 |
public: |
| 56 |
/** Create a new Gst::AudioClock instance. Whenever the clock time should |
| 57 |
* be calculated it will call @a time_slot. When @a time_slot returns |
| 58 |
* Gst::CLOCK_TIME_NONE, the clock will return the last reported time. |
| 59 |
* |
| 60 |
* @param name The name of the clock. |
| 61 |
* @param time_slot A slot that returns the time. |
| 62 |
* |
| 63 |
* @return a new Gst::AudioClock. |
| 64 |
*/ |
| 65 |
_WRAP_CREATE(const Glib::ustring& name, const SlotGetTime& time_slot) |
| 66 |
|
| 67 |
_WRAP_METHOD(void reset(Gst::ClockTime time), gst_audio_clock_reset) |
| 68 |
|
| 69 |
// TODO methods below get GstClock as a first argument, |
| 70 |
// so have to be wrapped manually. It has been fixed in |
| 71 |
// GStreamer (https://bugzilla.gnome.org/show_bug.cgi?id=756628) |
| 72 |
// but patch is not available in 1.8.0 version. |
| 73 |
_WRAP_METHOD_DOCS_ONLY(gst_audio_clock_adjust) |
| 74 |
Gst::ClockTime adjust(Gst::ClockTime time); |
| 75 |
|
| 76 |
_WRAP_METHOD_DOCS_ONLY(gst_audio_clock_get_time) |
| 77 |
Gst::ClockTime get_time() const; |
| 78 |
|
| 79 |
_WRAP_METHOD_DOCS_ONLY(gst_audio_clock_invalidate) |
| 80 |
void invalidate(); |
| 81 |
|
| 82 |
#ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 83 |
private: |
| 84 |
// TODO this slot should be moved in move constructor, but for now it's |
| 85 |
// impossible to provide custom move constructor |
| 86 |
// (see https://bugzilla.gnome.org/show_bug.cgi?id=756593). |
| 87 |
// However, task should be managed by RefPtr class, so move constructor |
| 88 |
// and move assignment operator will never be called. |
| 89 |
std::unique_ptr<SlotGetTime> m_slot; |
| 90 |
#endif |
| 91 |
}; |
| 92 |
|
| 93 |
} // namespace Gst |