|
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 (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 (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 #define GST_AUDIO_INT_PAD_TEMPLATE_CAPS \ |
|
81 "audio/x-raw-int, " \ |
|
82 "rate = (int) [ 1, MAX ], " \ |
|
83 "channels = (int) [ 1, MAX ], " \ |
|
84 "endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \ |
|
85 "width = (int) { 8, 16, 24, 32 }, " \ |
|
86 "depth = (int) [ 1, 32 ], " \ |
|
87 "signed = (boolean) { true, false }" |
|
88 |
|
89 /* "standard" int audio is native order, 16 bit stereo. */ |
|
90 #define GST_AUDIO_INT_STANDARD_PAD_TEMPLATE_CAPS \ |
|
91 "audio/x-raw-int, " \ |
|
92 "rate = (int) [ 1, MAX ], " \ |
|
93 "channels = (int) 2, " \ |
|
94 "endianness = (int) BYTE_ORDER, " \ |
|
95 "width = (int) 16, " \ |
|
96 "depth = (int) 16, " \ |
|
97 "signed = (boolean) true" |
|
98 |
|
99 #define GST_AUDIO_FLOAT_PAD_TEMPLATE_CAPS \ |
|
100 "audio/x-raw-float, " \ |
|
101 "rate = (int) [ 1, MAX ], " \ |
|
102 "channels = (int) [ 1, MAX ], " \ |
|
103 "endianness = (int) { LITTLE_ENDIAN , BIG_ENDIAN }, " \ |
|
104 "width = (int) { 32, 64 }" |
|
105 |
|
106 /* "standard" float audio is native order, 32 bit mono. */ |
|
107 #define GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS \ |
|
108 "audio/x-raw-float, " \ |
|
109 "width = (int) 32, " \ |
|
110 "rate = (int) [ 1, MAX ], " \ |
|
111 "channels = (int) 1, " \ |
|
112 "endianness = (int) BYTE_ORDER" |
|
113 |
|
114 /* |
|
115 * this library defines and implements some helper functions for audio |
|
116 * handling |
|
117 */ |
|
118 |
|
119 /* get byte size of audio frame (based on caps of pad */ |
|
120 #ifdef __SYMBIAN32__ |
|
121 IMPORT_C |
|
122 #endif |
|
123 |
|
124 int gst_audio_frame_byte_size (GstPad* pad); |
|
125 |
|
126 /* get length in frames of buffer */ |
|
127 #ifdef __SYMBIAN32__ |
|
128 IMPORT_C |
|
129 #endif |
|
130 |
|
131 long gst_audio_frame_length (GstPad* pad, GstBuffer* buf); |
|
132 #ifdef __SYMBIAN32__ |
|
133 IMPORT_C |
|
134 #endif |
|
135 |
|
136 |
|
137 GstClockTime gst_audio_duration_from_pad_buffer (GstPad * pad, GstBuffer * buf); |
|
138 |
|
139 /* check if the buffer size is a whole multiple of the frame size */ |
|
140 #ifdef __SYMBIAN32__ |
|
141 IMPORT_C |
|
142 #endif |
|
143 |
|
144 gboolean gst_audio_is_buffer_framed (GstPad* pad, GstBuffer* buf); |
|
145 |
|
146 /* functions useful for _getcaps functions */ |
|
147 /** |
|
148 * GstAudioFieldFlag: |
|
149 * |
|
150 * Do not use anymore. |
|
151 * |
|
152 * Deprecated: use gst_structure_set() directly |
|
153 */ |
|
154 #ifndef GST_DISABLE_DEPRECATED |
|
155 typedef enum { |
|
156 GST_AUDIO_FIELD_RATE = (1 << 0), |
|
157 GST_AUDIO_FIELD_CHANNELS = (1 << 1), |
|
158 GST_AUDIO_FIELD_ENDIANNESS = (1 << 2), |
|
159 GST_AUDIO_FIELD_WIDTH = (1 << 3), |
|
160 GST_AUDIO_FIELD_DEPTH = (1 << 4), |
|
161 GST_AUDIO_FIELD_SIGNED = (1 << 5), |
|
162 } GstAudioFieldFlag; |
|
163 #endif |
|
164 |
|
165 #ifndef GST_DISABLE_DEPRECATED |
|
166 void gst_audio_structure_set_int (GstStructure *structure, GstAudioFieldFlag flag); |
|
167 #endif /* GST_DISABLE_DEPRECATED */ |
|
168 #ifdef __SYMBIAN32__ |
|
169 IMPORT_C |
|
170 #endif |
|
171 |
|
172 |
|
173 GstBuffer *gst_audio_buffer_clip (GstBuffer *buffer, GstSegment *segment, gint rate, gint frame_size); |
|
174 |
|
175 G_END_DECLS |
|
176 |
|
177 #endif /* __GST_AUDIO_AUDIO_H__ */ |