audio-converter.h 6.24 KB
Newer Older
1
2
/* GStreamer
 * 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
8
9
10
11
12
13
14
15
16
17
18
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
Tim-Philipp Müller's avatar
Tim-Philipp Müller committed
19
20
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
21
22
 */

23
24
#ifndef __GST_AUDIO_CONVERTER_H__
#define __GST_AUDIO_CONVERTER_H__
25
26

#include <gst/gst.h>
Wim Taymans's avatar
Wim Taymans committed
27
#include <gst/audio/audio.h>
28

29
30
G_BEGIN_DECLS

31
typedef struct _GstAudioConverter GstAudioConverter;
32

Wim Taymans's avatar
Wim Taymans committed
33
34
35
36
37
38
39
40
41
/**
 * GST_AUDIO_CONVERTER_OPT_RESAMPLER_METHOD:
 *
 * #GST_TYPE_AUDIO_RESAMPLER_METHOD, The resampler method to use when
 * changing sample rates.
 * Default is #GST_AUDIO_RESAMPLER_METHOD_BLACKMAN_NUTTALL.
 */
#define GST_AUDIO_CONVERTER_OPT_RESAMPLER_METHOD   "GstAudioConverter.resampler-method"

42
43
44
45
46
47
48
49
/**
 * GST_AUDIO_CONVERTER_OPT_DITHER_METHOD:
 *
 * #GST_TYPE_AUDIO_DITHER_METHOD, The dither method to use when
 * changing bit depth.
 * Default is #GST_AUDIO_DITHER_NONE.
 */
#define GST_AUDIO_CONVERTER_OPT_DITHER_METHOD   "GstAudioConverter.dither-method"
50

51
52
53
54
55
56
57
58
/**
 * GST_AUDIO_CONVERTER_OPT_NOISE_SHAPING_METHOD:
 *
 * #GST_TYPE_AUDIO_NOISE_SHAPING_METHOD, The noise shaping method to use
 * to mask noise from quantization errors.
 * Default is #GST_AUDIO_NOISE_SHAPING_NONE.
 */
#define GST_AUDIO_CONVERTER_OPT_NOISE_SHAPING_METHOD   "GstAudioConverter.noise-shaping-method"
59

60
61
62
63
64
65
66
67
/**
 * GST_AUDIO_CONVERTER_OPT_QUANTIZATION:
 *
 * #G_TYPE_UINT, The quantization amount. Components will be
 * quantized to multiples of this value.
 * Default is 1
 */
#define GST_AUDIO_CONVERTER_OPT_QUANTIZATION   "GstAudioConverter.quantization"
68

69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/**
 * GST_AUDIO_CONVERTER_OPT_MIX_MATRIX:
 *
 * #GST_TYPE_VALUE_LIST, The channel mapping matrix.
 *
 * The matrix coefficients must be between -1 and 1: the number of rows is equal
 * to the number of output channels and the number of columns is equal to the
 * number of input channels.
 *
 * ## Example matrix generation code
 * To generate the matrix using code:
 *
 * |[
 * GValue v = G_VALUE_INIT;
 * GValue v2 = G_VALUE_INIT;
 * GValue v3 = G_VALUE_INIT;
 *
 * g_value_init (&v2, GST_TYPE_ARRAY);
 * g_value_init (&v3, G_TYPE_DOUBLE);
 * g_value_set_double (&v3, 1);
 * gst_value_array_append_value (&v2, &v3);
 * g_value_unset (&v3);
 * [ Repeat for as many double as your input channels - unset and reinit v3 ]
 * g_value_init (&v, GST_TYPE_ARRAY);
 * gst_value_array_append_value (&v, &v2);
 * g_value_unset (&v2);
 * [ Repeat for as many v2's as your output channels - unset and reinit v2]
 * g_object_set_property (G_OBJECT (audiomixmatrix), "matrix", &v);
 * g_value_unset (&v);
 * ]|
 */
#define GST_AUDIO_CONVERTER_OPT_MIX_MATRIX   "GstAudioConverter.mix-matrix"
101

102
/**
103
 * GstAudioConverterFlags:
104
 * @GST_AUDIO_CONVERTER_FLAG_NONE: no flag
105
 * @GST_AUDIO_CONVERTER_FLAG_IN_WRITABLE: the input sample arrays are writable and can be
106
 *    used as temporary storage during conversion.
107
108
 * @GST_AUDIO_CONVERTER_FLAG_VARIABLE_RATE: allow arbitrary rate updates with
 *    gst_audio_converter_update_config().
109
 *
110
 * Extra flags passed to gst_audio_converter_new() and gst_audio_converter_samples().
111
112
113
 */
typedef enum {
  GST_AUDIO_CONVERTER_FLAG_NONE            = 0,
114
115
  GST_AUDIO_CONVERTER_FLAG_IN_WRITABLE     = (1 << 0),
  GST_AUDIO_CONVERTER_FLAG_VARIABLE_RATE   = (1 << 1)
116
} GstAudioConverterFlags;
117

118
GST_EXPORT
119
120
GstAudioConverter *  gst_audio_converter_new             (GstAudioConverterFlags flags,
                                                          GstAudioInfo *in_info,
121
122
                                                          GstAudioInfo *out_info,
                                                          GstStructure *config);
123

124
125
126
GST_EXPORT
GType                gst_audio_converter_get_type        (void);

127
GST_EXPORT
128
void                 gst_audio_converter_free            (GstAudioConverter * convert);
129

130
GST_EXPORT
131
132
void                 gst_audio_converter_reset           (GstAudioConverter * convert);

133
GST_EXPORT
134
135
136
gboolean             gst_audio_converter_update_config   (GstAudioConverter * convert,
                                                          gint in_rate, gint out_rate,
                                                          GstStructure *config);
137
138

GST_EXPORT
139
140
const GstStructure * gst_audio_converter_get_config      (GstAudioConverter * convert,
                                                          gint *in_rate, gint *out_rate);
141

142
GST_EXPORT
143
144
gsize                gst_audio_converter_get_out_frames  (GstAudioConverter *convert,
                                                          gsize in_frames);
145
146

GST_EXPORT
147
148
gsize                gst_audio_converter_get_in_frames   (GstAudioConverter *convert,
                                                          gsize out_frames);
149

150
GST_EXPORT
151
152
gsize                gst_audio_converter_get_max_latency (GstAudioConverter *convert);

153
GST_EXPORT
154
155
gboolean             gst_audio_converter_samples         (GstAudioConverter * convert,
                                                          GstAudioConverterFlags flags,
156
157
                                                          gpointer in[], gsize in_frames,
                                                          gpointer out[], gsize out_frames);
158

159
GST_EXPORT
160
161
gboolean             gst_audio_converter_supports_inplace (GstAudioConverter *convert);

162
163
164
165
166
167
GST_EXPORT
gboolean             gst_audio_converter_convert          (GstAudioConverter * convert,
                                                           GstAudioConverterFlags flags,
                                                           gpointer in, gsize in_size,
                                                           gpointer *out, gsize *out_size);

168
169
G_END_DECLS

170
#endif /* __GST_AUDIO_CONVERTER_H__ */