Added gst-plugins-base-subtitles0.10-0.10.34 for Meego Harmattan 1.2
[mafwsubrenderer] / gst-plugins-base-subtitles0.10 / gst-libs / gst / audio / gstbaseaudiosink.h
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2005 Wim Taymans <wim@fluendo.com>
4  *
5  * gstbaseaudiosink.h:
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 /* a base class for audio sinks.
24  *
25  * It uses a ringbuffer to schedule playback of samples. This makes
26  * it very easy to drop or insert samples to align incoming
27  * buffers to the exact playback timestamp.
28  *
29  * Subclasses must provide a ringbuffer pointing to either DMA
30  * memory or regular memory. A subclass should also call a callback
31  * function when it has played N segments in the buffer. The subclass
32  * is free to use a thread to signal this callback, use EIO or any
33  * other mechanism.
34  *
35  * The base class is able to operate in push or pull mode. The chain
36  * mode will queue the samples in the ringbuffer as much as possible.
37  * The available space is calculated in the callback function.
38  *
39  * The pull mode will pull_range() a new buffer of N samples with a
40  * configurable latency. This allows for high-end real time
41  * audio processing pipelines driven by the audiosink. The callback
42  * function will be used to perform a pull_range() on the sinkpad.
43  * The thread scheduling the callback can be a real-time thread.
44  *
45  * Subclasses must implement a GstRingBuffer in addition to overriding
46  * the methods in GstBaseSink and this class.
47  */
48
49 #ifndef __GST_BASE_AUDIO_SINK_H__
50 #define __GST_BASE_AUDIO_SINK_H__
51
52 #include <gst/gst.h>
53 #include <gst/base/gstbasesink.h>
54 #include "gstringbuffer.h"
55 #include "gstaudioclock.h"
56
57 G_BEGIN_DECLS
58
59 #define GST_TYPE_BASE_AUDIO_SINK                (gst_base_audio_sink_get_type())
60 #define GST_BASE_AUDIO_SINK(obj)                (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_AUDIO_SINK,GstBaseAudioSink))
61 #define GST_BASE_AUDIO_SINK_CLASS(klass)        (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_AUDIO_SINK,GstBaseAudioSinkClass))
62 #define GST_BASE_AUDIO_SINK_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_BASE_AUDIO_SINK, GstBaseAudioSinkClass))
63 #define GST_IS_BASE_AUDIO_SINK(obj)             (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_AUDIO_SINK))
64 #define GST_IS_BASE_AUDIO_SINK_CLASS(klass)     (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_AUDIO_SINK))
65
66 /**
67  * GST_BASE_AUDIO_SINK_CLOCK:
68  * @obj: a #GstBaseAudioSink
69  *
70  * Get the #GstClock of @obj.
71  */
72 #define GST_BASE_AUDIO_SINK_CLOCK(obj)   (GST_BASE_AUDIO_SINK (obj)->clock)
73 /**
74  * GST_BASE_AUDIO_SINK_PAD:
75  * @obj: a #GstBaseAudioSink
76  *
77  * Get the sink #GstPad of @obj.
78  */
79 #define GST_BASE_AUDIO_SINK_PAD(obj)     (GST_BASE_SINK (obj)->sinkpad)
80
81 /**
82  * GstBaseAudioSinkSlaveMethod:
83  * @GST_BASE_AUDIO_SINK_SLAVE_RESAMPLE: Resample to match the master clock
84  * @GST_BASE_AUDIO_SINK_SLAVE_SKEW: Adjust playout pointer when master clock
85  * drifts too much.
86  * @GST_BASE_AUDIO_SINK_SLAVE_NONE: No adjustment is done.
87  *
88  * Different possible clock slaving algorithms used when the internal audio
89  * clock is not selected as the pipeline master clock.
90  */
91 typedef enum
92 {
93   GST_BASE_AUDIO_SINK_SLAVE_RESAMPLE,
94   GST_BASE_AUDIO_SINK_SLAVE_SKEW,
95   GST_BASE_AUDIO_SINK_SLAVE_NONE
96 } GstBaseAudioSinkSlaveMethod;
97
98 #define GST_TYPE_BASE_AUDIO_SINK_SLAVE_METHOD (gst_base_audio_sink_slave_method_get_type ())
99
100 typedef struct _GstBaseAudioSink GstBaseAudioSink;
101 typedef struct _GstBaseAudioSinkClass GstBaseAudioSinkClass;
102 typedef struct _GstBaseAudioSinkPrivate GstBaseAudioSinkPrivate;
103
104 /**
105  * GstBaseAudioSink:
106  *
107  * Opaque #GstBaseAudioSink.
108  */
109 struct _GstBaseAudioSink {
110   GstBaseSink    element;
111
112   /*< protected >*/ /* with LOCK */
113   /* our ringbuffer */
114   GstRingBuffer *ringbuffer;
115
116   /* required buffer and latency in microseconds */
117   guint64        buffer_time;
118   guint64        latency_time;
119
120   /* the next sample to write */
121   guint64        next_sample;
122
123   /* clock */
124   gboolean       provide_clock;
125   GstClock      *provided_clock;
126
127   /*< private >*/
128   GstBaseAudioSinkPrivate *priv;
129
130   union {
131     struct {
132       /*< protected >*/
133       /* with g_atomic_; currently rendering eos */
134       gboolean   eos_rendering;
135     } ABI;
136     gpointer _gst_reserved[GST_PADDING - 1];
137   } abidata;
138 };
139
140 /**
141  * GstBaseAudioSinkClass:
142  * @parent_class: the parent class.
143  * @create_ringbuffer: create and return a #GstRingBuffer to write to.
144  *
145  * #GstBaseAudioSink class. Override the vmethod to implement
146  * functionality.
147  */
148 struct _GstBaseAudioSinkClass {
149   GstBaseSinkClass parent_class;
150
151   /* subclass ringbuffer allocation */
152   GstRingBuffer* (*create_ringbuffer)  (GstBaseAudioSink *sink);
153
154   /*< private >*/
155   gpointer _gst_reserved[GST_PADDING];
156 };
157
158 GType gst_base_audio_sink_get_type(void);
159 GType gst_base_audio_sink_slave_method_get_type (void);
160
161 GstRingBuffer *gst_base_audio_sink_create_ringbuffer (GstBaseAudioSink *sink);
162
163 void       gst_base_audio_sink_set_provide_clock      (GstBaseAudioSink *sink, gboolean provide);
164 gboolean   gst_base_audio_sink_get_provide_clock      (GstBaseAudioSink *sink);
165
166 void       gst_base_audio_sink_set_slave_method       (GstBaseAudioSink *sink,
167                                                        GstBaseAudioSinkSlaveMethod method);
168 GstBaseAudioSinkSlaveMethod
169            gst_base_audio_sink_get_slave_method       (GstBaseAudioSink *sink);
170
171 void       gst_base_audio_sink_set_drift_tolerance    (GstBaseAudioSink *sink,
172                                                        gint64 drift_tolerance);
173 gint64     gst_base_audio_sink_get_drift_tolerance    (GstBaseAudioSink *sink);
174
175 G_END_DECLS
176
177 #endif /* __GST_BASE_AUDIO_SINK_H__ */