2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3 * Library <2001> Thomas Vander Stichele <thomas@apestaart.org>
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.
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.
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.
23 #ifndef __GST_AUDIO_AUDIO_H__
24 #define __GST_AUDIO_AUDIO_H__
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.
36 * For example, to make a source pad that can output streams of either mono
37 * float or any channel int:
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)),
47 * sinkpad = gst_pad_new_from_template(template, "sink");
49 * Andy Wingo, 18 August 2001
50 * Thomas, 6 September 2002 */
52 /* conversion macros */
54 * GST_FRAMES_TO_CLOCK_TIME:
55 * @frames: sample frames
56 * @rate: sampling rate
58 * Calculate clocktime from sample @frames and @rate.
60 #define GST_FRAMES_TO_CLOCK_TIME(frames, rate) \
61 ((GstClockTime) gst_util_uint64_scale_round (frames, GST_SECOND, rate))
64 * GST_CLOCK_TIME_TO_FRAMES:
65 * @clocktime: clock time
66 * @rate: sampling rate
68 * Calculate frames from @clocktime and sample @rate.
70 #define GST_CLOCK_TIME_TO_FRAMES(clocktime, rate) \
71 gst_util_uint64_scale_round (clocktime, rate, GST_SECOND)
76 * Standard sampling rate used in consumer audio.
78 #define GST_AUDIO_DEF_RATE 44100
81 * GST_AUDIO_INT_PAD_TEMPLATE_CAPS:
83 * Template caps for integer audio. Can be used when defining a
84 * #GstStaticPadTemplate
86 #define GST_AUDIO_INT_PAD_TEMPLATE_CAPS \
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 }"
96 * GST_AUDIO_INT_STANDARD_PAD_TEMPLATE_CAPS:
98 * Template caps for 16bit integer stereo audio in native byte-order.
99 * Can be used when defining a #GstStaticPadTemplate
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"
111 * GST_AUDIO_FLOAT_PAD_TEMPLATE_CAPS:
113 * Template caps for float audio. Can be used when defining a
114 * #GstStaticPadTemplate
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 }"
124 * GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS:
126 * Template caps for 32bit float mono audio in native byte-order.
127 * Can be used when defining a #GstStaticPadTemplate
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"
137 * this library defines and implements some helper functions for audio
141 /* get byte size of audio frame (based on caps of pad */
142 int gst_audio_frame_byte_size (GstPad* pad);
144 /* get length in frames of buffer */
145 long gst_audio_frame_length (GstPad* pad, GstBuffer* buf);
147 GstClockTime gst_audio_duration_from_pad_buffer (GstPad * pad, GstBuffer * buf);
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);
152 /* functions useful for _getcaps functions */
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
162 * Do not use anymore.
164 * Deprecated: use gst_structure_set() directly
166 #ifndef GST_DISABLE_DEPRECATED
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)
177 #ifndef GST_DISABLE_DEPRECATED
178 void gst_audio_structure_set_int (GstStructure *structure, GstAudioFieldFlag flag);
179 #endif /* GST_DISABLE_DEPRECATED */
181 GstBuffer *gst_audio_buffer_clip (GstBuffer *buffer, GstSegment *segment, gint rate, gint frame_size);
185 #endif /* __GST_AUDIO_AUDIO_H__ */