Debian Codegraph @

gstreamer/src/audiobasesink.hg

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 #include <gst/audio/gstaudiobasesink.h>
21 #include <gstreamermm/basesink.h>
22
23 _PINCLUDE(gstreamermm/private/basesink_p.h)
24
25 _DEFS(gstreamermm,gst)
26
27 namespace Gst
28 {
29
30 class AudioRingBuffer;
31
32 _WRAP_ENUM(AudioBaseSinkSlaveMethod, GstAudioBaseSinkSlaveMethod)
33 _WRAP_ENUM(AudioBaseSinkDiscontReason, GstAudioBaseSinkDiscontReason, NO_GTYPE)
34
35 /** The base class for audio sinks.
36 * This is the base class for audio sinks. Subclasses need to implement the
37 * create_ringbuffer_vfunc vmethod. This base class will then take care of
38 * writing samples to the audioringbuffer, synchronisation, clipping and flushing.
39 *
40 * Last reviewed on 2016-04-23 (1.8.0).
41 *
42 * @ingroup GstBaseClasses
43 */
44 class AudioBaseSink : public Gst::BaseSink
45 {
46 _CLASS_GOBJECT(AudioBaseSink, GstAudioBaseSink, GST_AUDIO_BASE_SINK, Gst::BaseSink, GstBaseSink)
47
48 public:
49 /** This slot is set with set_custom_slaving_callback()
50 * and is called during playback. It receives the current time of external and
51 * internal clocks, which the callback can then use to apply any custom
52 * slaving/synchronization schemes.
53 *
54 * The external clock is the sink's element clock, the internal one is the
55 * internal audio clock. The internal audio clock's calibration is applied to
56 * the timestamps before they are passed to the callback. The difference between
57 * etime and itime is the skew; how much internal and external clock lie apart
58 * from each other. A skew of 0 means both clocks are perfectly in sync.
59 * itime > etime means the external clock is going slower, while itime < etime
60 * means it is going faster than the internal clock. etime and itime are always
61 * valid timestamps, except for when a discontinuity happens.
62 *
63 * requested_skew is an output value the callback can write to. It informs the
64 * sink of whether or not it should move the playout pointer, and if so, by how
65 * much. This pointer is only nullptr if a discontinuity occurs; otherwise, it is
66 * safe to write to *requested_skew. The default skew is 0.
67 *
68 * The sink may experience discontinuities. If one happens, discont is TRUE,
69 * itime, etime are set to CLOCK_TIME_NONE, and requested_skew is nullptr.
70 * This makes it possible to reset custom clock slaving algorithms when a
71 * discontinuity happens.
72 *
73 */
74 typedef sigc::slot<void, const Glib::RefPtr<Gst::AudioBaseSink>&, Gst::ClockTime, Gst::ClockTime, Gst::ClockTimeDiff&, Gst::AudioBaseSinkDiscontReason> SlotCustomSlaving;
75
76 /** Get the Gst::Clock of the Gst::AudioBaseSink.
77 */
78 _MEMBER_GET_GOBJECT(provided_clock, provided_clock, Gst::Clock, GstClock*)
79
80 _WRAP_METHOD(Glib::RefPtr<Gst::AudioRingBuffer> create_ring_buffer(), gst_audio_base_sink_create_ringbuffer)
81 _WRAP_METHOD(void set_provide_clock(bool provide), gst_audio_base_sink_set_provide_clock)
82 _WRAP_METHOD(bool get_provide_clock() const, gst_audio_base_sink_get_provide_clock)
83
84 _WRAP_METHOD(void set_slave_method(Gst::AudioBaseSinkSlaveMethod method), gst_audio_base_sink_set_slave_method)
85 _WRAP_METHOD(Gst::AudioBaseSinkSlaveMethod get_slave_method() const, gst_audio_base_sink_get_slave_method)
86
87 _WRAP_METHOD(gint64 get_drift_tolerance() const, gst_audio_base_sink_get_drift_tolerance)
88 _WRAP_METHOD(void set_drift_tolerance(gint64 drift_tolerance), gst_audio_base_sink_set_drift_tolerance)
89
90 _WRAP_METHOD(void set_discont_wait(Gst::ClockTime discont_wait), gst_audio_base_sink_set_discont_wait)
91 _WRAP_METHOD(Gst::ClockTime get_discont_wait() const, gst_audio_base_sink_get_discont_wait)
92
93 _WRAP_METHOD(void set_alignment_threshold(Gst::ClockTime alignment_threshold), gst_audio_base_sink_set_alignment_threshold)
94 _WRAP_METHOD(Gst::ClockTime get_alignment_threshold() const, gst_audio_base_sink_get_alignment_threshold)
95
96 _WRAP_METHOD(void report_device_failure(), gst_audio_base_sink_report_device_failure)
97
98 _WRAP_METHOD_DOCS_ONLY(gst_audio_base_sink_set_custom_slaving_callback)
99 void set_custom_slaving_callback(const SlotCustomSlaving& slot);
100
101 _WRAP_PROPERTY("alignment-threshold", guint64)
102 _WRAP_PROPERTY("buffer-time", gint64)
103 _WRAP_PROPERTY("can-activate-pull", bool)
104 _WRAP_PROPERTY("discont-wait", guint64)
105 _WRAP_PROPERTY("drift-tolerance", gint64)
106 _WRAP_PROPERTY("latency-time", gint64)
107 _WRAP_PROPERTY("provide-clock", bool)
108 _WRAP_PROPERTY("slave-method", Gst::AudioBaseSinkSlaveMethod)
109
110 /** vfunc to create and return a Gst::AudioRingBuffer to write to.
111 */
112 _WRAP_VFUNC(Glib::RefPtr<Gst::AudioRingBuffer> create_ring_buffer(), "create_ringbuffer")
113
114 /** vfunc to payload data in a format suitable to write to the sink. If no
115 * payloading is required, returns a reffed copy of the original
116 * buffer, else returns the payloaded buffer with all other metadata
117 * copied.
118 */
119 _WRAP_VFUNC(Glib::RefPtr<Gst::Buffer> payload(const Glib::RefPtr<Gst::Buffer>& buffer), "payload")
120 };
121
122 } // namespace Gst