1 | /* GStreamer |
2 | * Copyright (C) 2004 Ronald Bultje <rbultje@ronald.bitfreak.net> |
3 | * (C) 2015 Wim Taymans <wim.taymans@gmail.com> |
4 | * |
5 | * audioconverter.h: audio format conversion library |
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., 51 Franklin St, Fifth Floor, |
20 | * Boston, MA 02110-1301, USA. |
21 | */ |
22 | |
23 | #ifndef __GST_AUDIO_CONVERTER_H__ |
24 | #define __GST_AUDIO_CONVERTER_H__ |
25 | |
26 | #include <gst/gst.h> |
27 | #include <gst/audio/audio.h> |
28 | |
29 | G_BEGIN_DECLS |
30 | |
31 | /** |
32 | * GstAudioConverter: |
33 | * |
34 | * Opaque #GstAudioConverter struct. |
35 | * |
36 | * Since: 1.8 |
37 | */ |
38 | typedef struct _GstAudioConverter GstAudioConverter; |
39 | |
40 | /** |
41 | * GST_AUDIO_CONVERTER_OPT_RESAMPLER_METHOD: |
42 | * |
43 | * #GstAudioResamplerMethod, The resampler method to use when |
44 | * changing sample rates. |
45 | * Default is #GST_AUDIO_RESAMPLER_METHOD_BLACKMAN_NUTTALL. |
46 | */ |
47 | #define GST_AUDIO_CONVERTER_OPT_RESAMPLER_METHOD "GstAudioConverter.resampler-method" |
48 | |
49 | /** |
50 | * GST_AUDIO_CONVERTER_OPT_DITHER_METHOD: |
51 | * |
52 | * #GstAudioDitherMethod, The dither method to use when |
53 | * changing bit depth. |
54 | * Default is #GST_AUDIO_DITHER_NONE. |
55 | */ |
56 | #define GST_AUDIO_CONVERTER_OPT_DITHER_METHOD "GstAudioConverter.dither-method" |
57 | |
58 | /** |
59 | * GST_AUDIO_CONVERTER_OPT_NOISE_SHAPING_METHOD: |
60 | * |
61 | * #GstAudioNoiseShapingMethod, The noise shaping method to use |
62 | * to mask noise from quantization errors. |
63 | * Default is #GST_AUDIO_NOISE_SHAPING_NONE. |
64 | */ |
65 | #define GST_AUDIO_CONVERTER_OPT_NOISE_SHAPING_METHOD "GstAudioConverter.noise-shaping-method" |
66 | |
67 | /** |
68 | * GST_AUDIO_CONVERTER_OPT_QUANTIZATION: |
69 | * |
70 | * #G_TYPE_UINT, The quantization amount. Components will be |
71 | * quantized to multiples of this value. |
72 | * Default is 1 |
73 | */ |
74 | #define GST_AUDIO_CONVERTER_OPT_QUANTIZATION "GstAudioConverter.quantization" |
75 | |
76 | /** |
77 | * GST_AUDIO_CONVERTER_OPT_MIX_MATRIX: |
78 | * |
79 | * #GST_TYPE_LIST, The channel mapping matrix. |
80 | * |
81 | * The matrix coefficients must be between -1 and 1: the number of rows is equal |
82 | * to the number of output channels and the number of columns is equal to the |
83 | * number of input channels. |
84 | * |
85 | * ## Example matrix generation code |
86 | * To generate the matrix using code: |
87 | * |
88 | * |[ |
89 | * GValue v = G_VALUE_INIT; |
90 | * GValue v2 = G_VALUE_INIT; |
91 | * GValue v3 = G_VALUE_INIT; |
92 | * |
93 | * g_value_init (&v2, GST_TYPE_ARRAY); |
94 | * g_value_init (&v3, G_TYPE_DOUBLE); |
95 | * g_value_set_double (&v3, 1); |
96 | * gst_value_array_append_value (&v2, &v3); |
97 | * g_value_unset (&v3); |
98 | * [ Repeat for as many double as your input channels - unset and reinit v3 ] |
99 | * g_value_init (&v, GST_TYPE_ARRAY); |
100 | * gst_value_array_append_value (&v, &v2); |
101 | * g_value_unset (&v2); |
102 | * [ Repeat for as many v2's as your output channels - unset and reinit v2] |
103 | * g_object_set_property (G_OBJECT (audiomixmatrix), "matrix", &v); |
104 | * g_value_unset (&v); |
105 | * ]| |
106 | */ |
107 | #define GST_AUDIO_CONVERTER_OPT_MIX_MATRIX "GstAudioConverter.mix-matrix" |
108 | |
109 | /** |
110 | * GstAudioConverterFlags: |
111 | * @GST_AUDIO_CONVERTER_FLAG_NONE: no flag |
112 | * @GST_AUDIO_CONVERTER_FLAG_IN_WRITABLE: the input sample arrays are writable and can be |
113 | * used as temporary storage during conversion. |
114 | * @GST_AUDIO_CONVERTER_FLAG_VARIABLE_RATE: allow arbitrary rate updates with |
115 | * gst_audio_converter_update_config(). |
116 | * |
117 | * Extra flags passed to gst_audio_converter_new() and gst_audio_converter_samples(). |
118 | */ |
119 | typedef enum { |
120 | GST_AUDIO_CONVERTER_FLAG_NONE = 0, |
121 | GST_AUDIO_CONVERTER_FLAG_IN_WRITABLE = (1 << 0), |
122 | GST_AUDIO_CONVERTER_FLAG_VARIABLE_RATE = (1 << 1) |
123 | } GstAudioConverterFlags; |
124 | |
125 | GST_AUDIO_API |
126 | GstAudioConverter * gst_audio_converter_new (GstAudioConverterFlags flags, |
127 | GstAudioInfo *in_info, |
128 | GstAudioInfo *out_info, |
129 | GstStructure *config); |
130 | |
131 | GST_AUDIO_API |
132 | GType gst_audio_converter_get_type (void); |
133 | |
134 | GST_AUDIO_API |
135 | void gst_audio_converter_free (GstAudioConverter * convert); |
136 | |
137 | GST_AUDIO_API |
138 | void gst_audio_converter_reset (GstAudioConverter * convert); |
139 | |
140 | GST_AUDIO_API |
141 | gboolean gst_audio_converter_update_config (GstAudioConverter * convert, |
142 | gint in_rate, gint out_rate, |
143 | GstStructure *config); |
144 | |
145 | GST_AUDIO_API |
146 | const GstStructure * gst_audio_converter_get_config (GstAudioConverter * convert, |
147 | gint *in_rate, gint *out_rate); |
148 | |
149 | GST_AUDIO_API |
150 | gsize gst_audio_converter_get_out_frames (GstAudioConverter *convert, |
151 | gsize in_frames); |
152 | |
153 | GST_AUDIO_API |
154 | gsize gst_audio_converter_get_in_frames (GstAudioConverter *convert, |
155 | gsize out_frames); |
156 | |
157 | GST_AUDIO_API |
158 | gsize gst_audio_converter_get_max_latency (GstAudioConverter *convert); |
159 | |
160 | GST_AUDIO_API |
161 | gboolean gst_audio_converter_samples (GstAudioConverter * convert, |
162 | GstAudioConverterFlags flags, |
163 | gpointer in[], gsize in_frames, |
164 | gpointer out[], gsize out_frames); |
165 | |
166 | GST_AUDIO_API |
167 | gboolean gst_audio_converter_supports_inplace (GstAudioConverter *convert); |
168 | |
169 | GST_AUDIO_API |
170 | gboolean gst_audio_converter_is_passthrough (GstAudioConverter *convert); |
171 | |
172 | GST_AUDIO_API |
173 | gboolean gst_audio_converter_convert (GstAudioConverter * convert, |
174 | GstAudioConverterFlags flags, |
175 | gpointer in, gsize in_size, |
176 | gpointer *out, gsize *out_size); |
177 | |
178 | G_END_DECLS |
179 | |
180 | #endif /* __GST_AUDIO_CONVERTER_H__ */ |
181 | |