Added gst-plugins-base-subtitles0.10-0.10.34 for Meego Harmattan 1.2
[mafwsubrenderer] / gst-plugins-base-subtitles0.10 / gst-libs / gst / audio / audio.h
1 /* GStreamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  * Library       <2001> Thomas Vander Stichele <thomas@apestaart.org>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 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  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 #include <gst/gst.h>
22
23 #ifndef __GST_AUDIO_AUDIO_H__
24 #define __GST_AUDIO_AUDIO_H__
25
26 G_BEGIN_DECLS
27
28 /* For people that are looking at this source: the purpose of these defines is
29  * to make GstCaps a bit easier, in that you don't have to know all of the
30  * properties that need to be defined. you can just use these macros. currently
31  * (8/01) the only plugins that use these are the passthrough, speed, volume,
32  * adder, and [de]interleave plugins. These are for convenience only, and do not
33  * specify the 'limits' of GStreamer. you might also use these definitions as a
34  * base for making your own caps, if need be.
35  *
36  * For example, to make a source pad that can output streams of either mono
37  * float or any channel int:
38  *
39  *  template = gst_pad_template_new
40  *    ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
41  *    gst_caps_append(gst_caps_new ("sink_int",  "audio/x-raw-int",
42  *                                  GST_AUDIO_INT_PAD_TEMPLATE_PROPS),
43  *                    gst_caps_new ("sink_float", "audio/x-raw-float",
44  *                                  GST_AUDIO_FLOAT_PAD_TEMPLATE_PROPS)),
45  *    NULL);
46  *
47  *  sinkpad = gst_pad_new_from_template(template, "sink");
48  *
49  * Andy Wingo, 18 August 2001
50  * Thomas, 6 September 2002 */
51
52 /* conversion macros */
53 /**
54  * GST_FRAMES_TO_CLOCK_TIME:
55  * @frames: sample frames
56  * @rate: sampling rate
57  * 
58  * Calculate clocktime from sample @frames and @rate.
59  */
60 #define GST_FRAMES_TO_CLOCK_TIME(frames, rate) \
61   ((GstClockTime) gst_util_uint64_scale_round (frames, GST_SECOND, rate))
62
63 /**
64  * GST_CLOCK_TIME_TO_FRAMES:
65  * @clocktime: clock time
66  * @rate: sampling rate
67  * 
68  * Calculate frames from @clocktime and sample @rate.
69  */
70 #define GST_CLOCK_TIME_TO_FRAMES(clocktime, rate) \
71   gst_util_uint64_scale_round (clocktime, rate, GST_SECOND)
72
73 /**
74  * GST_AUDIO_DEF_RATE:
75  * 
76  * Standard sampling rate used in consumer audio.
77  */
78 #define GST_AUDIO_DEF_RATE 44100
79
80 /**
81  * GST_AUDIO_INT_PAD_TEMPLATE_CAPS:
82  * 
83  * Template caps for integer audio. Can be used when defining a 
84  * #GstStaticPadTemplate
85  */
86 #define GST_AUDIO_INT_PAD_TEMPLATE_CAPS \
87   "audio/x-raw-int, " \
88   "rate = (int) [ 1, MAX ], " \
89   "channels = (int) [ 1, MAX ], " \
90   "endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \
91   "width = (int) { 8, 16, 24, 32 }, " \
92   "depth = (int) [ 1, 32 ], " \
93   "signed = (boolean) { true, false }"
94
95 /**
96  * GST_AUDIO_INT_STANDARD_PAD_TEMPLATE_CAPS:
97  * 
98  * Template caps for 16bit integer stereo audio in native byte-order.
99  * Can be used when defining a #GstStaticPadTemplate
100  */
101 #define GST_AUDIO_INT_STANDARD_PAD_TEMPLATE_CAPS \
102   "audio/x-raw-int, " \
103   "rate = (int) [ 1, MAX ], " \
104   "channels = (int) 2, " \
105   "endianness = (int) BYTE_ORDER, " \
106   "width = (int) 16, " \
107   "depth = (int) 16, " \
108   "signed = (boolean) true"
109
110 /**
111  * GST_AUDIO_FLOAT_PAD_TEMPLATE_CAPS:
112  * 
113  * Template caps for float audio. Can be used when defining a 
114  * #GstStaticPadTemplate
115  */
116 #define GST_AUDIO_FLOAT_PAD_TEMPLATE_CAPS \
117   "audio/x-raw-float, " \
118   "rate = (int) [ 1, MAX ], " \
119   "channels = (int) [ 1, MAX ], " \
120   "endianness = (int) { LITTLE_ENDIAN , BIG_ENDIAN }, " \
121   "width = (int) { 32, 64 }"
122
123 /**
124  * GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS:
125  * 
126  * Template caps for 32bit float mono audio in native byte-order.
127  * Can be used when defining a #GstStaticPadTemplate
128  */
129 #define GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS \
130   "audio/x-raw-float, " \
131   "width = (int) 32, " \
132   "rate = (int) [ 1, MAX ], " \
133   "channels = (int) 1, " \
134   "endianness = (int) BYTE_ORDER"
135
136 /*
137  * this library defines and implements some helper functions for audio
138  * handling
139  */
140
141 /* get byte size of audio frame (based on caps of pad */
142 int      gst_audio_frame_byte_size      (GstPad* pad);
143
144 /* get length in frames of buffer */
145 long     gst_audio_frame_length         (GstPad* pad, GstBuffer* buf);
146
147 GstClockTime gst_audio_duration_from_pad_buffer (GstPad * pad, GstBuffer * buf);
148
149 /* check if the buffer size is a whole multiple of the frame size */
150 gboolean gst_audio_is_buffer_framed     (GstPad* pad, GstBuffer* buf);
151
152 /* functions useful for _getcaps functions */
153 /**
154  * GstAudioFieldFlag:
155  * @GST_AUDIO_FIELD_RATE: add rate field to caps
156  * @GST_AUDIO_FIELD_CHANNELS: add channels field to caps
157  * @GST_AUDIO_FIELD_ENDIANNESS: add endianness field to caps
158  * @GST_AUDIO_FIELD_WIDTH: add width field to caps
159  * @GST_AUDIO_FIELD_DEPTH: add depth field to caps
160  * @GST_AUDIO_FIELD_SIGNED: add signed field to caps
161  *
162  * Do not use anymore.
163  *
164  * Deprecated: use gst_structure_set() directly
165  */
166 #ifndef GST_DISABLE_DEPRECATED
167 typedef enum {
168   GST_AUDIO_FIELD_RATE          = (1 << 0),
169   GST_AUDIO_FIELD_CHANNELS      = (1 << 1),
170   GST_AUDIO_FIELD_ENDIANNESS    = (1 << 2),
171   GST_AUDIO_FIELD_WIDTH         = (1 << 3),
172   GST_AUDIO_FIELD_DEPTH         = (1 << 4),
173   GST_AUDIO_FIELD_SIGNED        = (1 << 5)
174 } GstAudioFieldFlag;
175 #endif
176
177 #ifndef GST_DISABLE_DEPRECATED
178 void gst_audio_structure_set_int (GstStructure *structure, GstAudioFieldFlag flag);
179 #endif /* GST_DISABLE_DEPRECATED */
180
181 GstBuffer *gst_audio_buffer_clip (GstBuffer *buffer, GstSegment *segment, gint rate, gint frame_size);
182
183 G_END_DECLS
184
185 #endif /* __GST_AUDIO_AUDIO_H__ */