react-native-audio-api 0.7.1-nightly-5a218c6-20250809 → 0.7.1-nightly-4d86c14-20250811

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/RNAudioAPI.podspec +31 -7
  2. package/android/src/main/cpp/audioapi/CMakeLists.txt +22 -1
  3. package/android/src/main/cpp/audioapi/android/core/AudioDecoder.cpp +81 -63
  4. package/common/cpp/audioapi/core/utils/AudioDecoder.h +54 -29
  5. package/common/cpp/audioapi/external/arm64-v8a/libogg.a +0 -0
  6. package/common/cpp/audioapi/external/arm64-v8a/libopus.a +0 -0
  7. package/common/cpp/audioapi/external/arm64-v8a/libopusfile.a +0 -0
  8. package/common/cpp/audioapi/external/arm64-v8a/libvorbis.a +0 -0
  9. package/common/cpp/audioapi/external/arm64-v8a/libvorbisenc.a +0 -0
  10. package/common/cpp/audioapi/external/arm64-v8a/libvorbisfile.a +0 -0
  11. package/common/cpp/audioapi/external/armeabi-v7a/libogg.a +0 -0
  12. package/common/cpp/audioapi/external/armeabi-v7a/libopus.a +0 -0
  13. package/common/cpp/audioapi/external/armeabi-v7a/libopusfile.a +0 -0
  14. package/common/cpp/audioapi/external/armeabi-v7a/libvorbis.a +0 -0
  15. package/common/cpp/audioapi/external/armeabi-v7a/libvorbisenc.a +0 -0
  16. package/common/cpp/audioapi/external/armeabi-v7a/libvorbisfile.a +0 -0
  17. package/common/cpp/audioapi/external/include/ogg/config_types.h +26 -0
  18. package/common/cpp/audioapi/external/include/ogg/config_types.h.in +26 -0
  19. package/common/cpp/audioapi/external/include/ogg/ogg.h +212 -0
  20. package/common/cpp/audioapi/external/include/ogg/os_types.h +157 -0
  21. package/common/cpp/audioapi/external/include/opus/opus.h +1286 -0
  22. package/common/cpp/audioapi/external/include/opus/opus_custom.h +390 -0
  23. package/common/cpp/audioapi/external/include/opus/opus_defines.h +896 -0
  24. package/common/cpp/audioapi/external/include/opus/opus_multistream.h +728 -0
  25. package/common/cpp/audioapi/external/include/opus/opus_projection.h +621 -0
  26. package/common/cpp/audioapi/external/include/opus/opus_types.h +170 -0
  27. package/common/cpp/audioapi/external/include/opusfile/opusfile.h +2151 -0
  28. package/common/cpp/audioapi/external/include/vorbis/codec.h +241 -0
  29. package/common/cpp/audioapi/external/include/vorbis/vorbisenc.h +446 -0
  30. package/common/cpp/audioapi/external/include/vorbis/vorbisfile.h +226 -0
  31. package/common/cpp/audioapi/external/iphoneos/libogg.a +0 -0
  32. package/common/cpp/audioapi/external/iphoneos/libopus.a +0 -0
  33. package/common/cpp/audioapi/external/iphoneos/libopusfile.a +0 -0
  34. package/common/cpp/audioapi/external/iphoneos/libvorbis.a +0 -0
  35. package/common/cpp/audioapi/external/iphoneos/libvorbisenc.a +0 -0
  36. package/common/cpp/audioapi/external/iphoneos/libvorbisfile.a +0 -0
  37. package/common/cpp/audioapi/external/iphonesimulator/libogg.a +0 -0
  38. package/common/cpp/audioapi/external/iphonesimulator/libopus.a +0 -0
  39. package/common/cpp/audioapi/external/iphonesimulator/libopusfile.a +0 -0
  40. package/common/cpp/audioapi/external/iphonesimulator/libvorbis.a +0 -0
  41. package/common/cpp/audioapi/external/iphonesimulator/libvorbisenc.a +0 -0
  42. package/common/cpp/audioapi/external/iphonesimulator/libvorbisfile.a +0 -0
  43. package/common/cpp/audioapi/external/x86/libogg.a +0 -0
  44. package/common/cpp/audioapi/external/x86/libopus.a +0 -0
  45. package/common/cpp/audioapi/external/x86/libopusfile.a +0 -0
  46. package/common/cpp/audioapi/external/x86/libvorbis.a +0 -0
  47. package/common/cpp/audioapi/external/x86/libvorbisenc.a +0 -0
  48. package/common/cpp/audioapi/external/x86/libvorbisfile.a +0 -0
  49. package/common/cpp/audioapi/external/x86_64/libogg.a +0 -0
  50. package/common/cpp/audioapi/external/x86_64/libopus.a +0 -0
  51. package/common/cpp/audioapi/external/x86_64/libopusfile.a +0 -0
  52. package/common/cpp/audioapi/external/x86_64/libvorbis.a +0 -0
  53. package/common/cpp/audioapi/external/x86_64/libvorbisenc.a +0 -0
  54. package/common/cpp/audioapi/external/x86_64/libvorbisfile.a +0 -0
  55. package/common/cpp/audioapi/libs/miniaudio/decoders/libopus/miniaudio_libopus.c +623 -0
  56. package/common/cpp/audioapi/libs/miniaudio/decoders/libopus/miniaudio_libopus.h +71 -0
  57. package/common/cpp/audioapi/libs/miniaudio/decoders/libvorbis/miniaudio_libvorbis.c +574 -0
  58. package/common/cpp/audioapi/libs/miniaudio/decoders/libvorbis/miniaudio_libvorbis.h +41 -0
  59. package/common/cpp/test/CMakeLists.txt +7 -0
  60. package/common/cpp/test/RunTests.sh +3 -8
  61. package/ios/audioapi/ios/core/AudioDecoder.mm +62 -51
  62. package/package.json +1 -1
@@ -0,0 +1,728 @@
1
+ /* Copyright (c) 2011 Xiph.Org Foundation
2
+ Written by Jean-Marc Valin */
3
+ /*
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions
6
+ are met:
7
+
8
+ - Redistributions of source code must retain the above copyright
9
+ notice, this list of conditions and the following disclaimer.
10
+
11
+ - Redistributions in binary form must reproduce the above copyright
12
+ notice, this list of conditions and the following disclaimer in the
13
+ documentation and/or other materials provided with the distribution.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16
+ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
19
+ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
+ */
27
+
28
+ /**
29
+ * @file opus_multistream.h
30
+ * @brief Opus reference implementation multistream API
31
+ */
32
+
33
+ #ifndef OPUS_MULTISTREAM_H
34
+ #define OPUS_MULTISTREAM_H
35
+
36
+ #include "opus.h"
37
+
38
+ #ifdef __cplusplus
39
+ extern "C" {
40
+ #endif
41
+
42
+ /** @cond OPUS_INTERNAL_DOC */
43
+
44
+ /** Macros to trigger compilation errors when the wrong types are provided to a
45
+ * CTL. */
46
+ /**@{*/
47
+ #define __opus_check_encstate_ptr(ptr) ((ptr) + ((ptr) - (OpusEncoder **)(ptr)))
48
+ #define __opus_check_decstate_ptr(ptr) ((ptr) + ((ptr) - (OpusDecoder **)(ptr)))
49
+ /**@}*/
50
+
51
+ /** These are the actual encoder and decoder CTL ID numbers.
52
+ * They should not be used directly by applications.
53
+ * In general, SETs should be even and GETs should be odd.*/
54
+ /**@{*/
55
+ #define OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST 5120
56
+ #define OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST 5122
57
+ /**@}*/
58
+
59
+ /** @endcond */
60
+
61
+ /** @defgroup opus_multistream_ctls Multistream specific encoder and decoder
62
+ * CTLs
63
+ *
64
+ * These are convenience macros that are specific to the
65
+ * opus_multistream_encoder_ctl() and opus_multistream_decoder_ctl()
66
+ * interface.
67
+ * The CTLs from @ref opus_genericctls, @ref opus_encoderctls, and
68
+ * @ref opus_decoderctls may be applied to a multistream encoder or decoder as
69
+ * well.
70
+ * In addition, you may retrieve the encoder or decoder state for an specific
71
+ * stream via #OPUS_MULTISTREAM_GET_ENCODER_STATE or
72
+ * #OPUS_MULTISTREAM_GET_DECODER_STATE and apply CTLs to it individually.
73
+ */
74
+ /**@{*/
75
+
76
+ /** Gets the encoder state for an individual stream of a multistream encoder.
77
+ * @param[in] x <tt>opus_int32</tt>: The index of the stream whose encoder you
78
+ * wish to retrieve.
79
+ * This must be non-negative and less than
80
+ * the <code>streams</code> parameter used
81
+ * to initialize the encoder.
82
+ * @param[out] y <tt>OpusEncoder**</tt>: Returns a pointer to the given
83
+ * encoder state.
84
+ * @retval OPUS_BAD_ARG The index of the requested stream was out of range.
85
+ * @hideinitializer
86
+ */
87
+ #define OPUS_MULTISTREAM_GET_ENCODER_STATE(x, y) \
88
+ OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST, __opus_check_int(x), \
89
+ __opus_check_encstate_ptr(y)
90
+
91
+ /** Gets the decoder state for an individual stream of a multistream decoder.
92
+ * @param[in] x <tt>opus_int32</tt>: The index of the stream whose decoder you
93
+ * wish to retrieve.
94
+ * This must be non-negative and less than
95
+ * the <code>streams</code> parameter used
96
+ * to initialize the decoder.
97
+ * @param[out] y <tt>OpusDecoder**</tt>: Returns a pointer to the given
98
+ * decoder state.
99
+ * @retval OPUS_BAD_ARG The index of the requested stream was out of range.
100
+ * @hideinitializer
101
+ */
102
+ #define OPUS_MULTISTREAM_GET_DECODER_STATE(x, y) \
103
+ OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST, __opus_check_int(x), \
104
+ __opus_check_decstate_ptr(y)
105
+
106
+ /**@}*/
107
+
108
+ /** @defgroup opus_multistream Opus Multistream API
109
+ * @{
110
+ *
111
+ * The multistream API allows individual Opus streams to be combined into a
112
+ * single packet, enabling support for up to 255 channels. Unlike an
113
+ * elementary Opus stream, the encoder and decoder must negotiate the channel
114
+ * configuration before the decoder can successfully interpret the data in the
115
+ * packets produced by the encoder. Some basic information, such as packet
116
+ * duration, can be computed without any special negotiation.
117
+ *
118
+ * The format for multistream Opus packets is defined in
119
+ * <a href="https://tools.ietf.org/html/rfc7845">RFC 7845</a>
120
+ * and is based on the self-delimited Opus framing described in Appendix B of
121
+ * <a href="https://tools.ietf.org/html/rfc6716">RFC 6716</a>.
122
+ * Normal Opus packets are just a degenerate case of multistream Opus packets,
123
+ * and can be encoded or decoded with the multistream API by setting
124
+ * <code>streams</code> to <code>1</code> when initializing the encoder or
125
+ * decoder.
126
+ *
127
+ * Multistream Opus streams can contain up to 255 elementary Opus streams.
128
+ * These may be either "uncoupled" or "coupled", indicating that the decoder
129
+ * is configured to decode them to either 1 or 2 channels, respectively.
130
+ * The streams are ordered so that all coupled streams appear at the
131
+ * beginning.
132
+ *
133
+ * A <code>mapping</code> table defines which decoded channel <code>i</code>
134
+ * should be used for each input/output (I/O) channel <code>j</code>. This table
135
+ * is typically provided as an unsigned char array. Let <code>i =
136
+ * mapping[j]</code> be the index for I/O channel <code>j</code>. If <code>i <
137
+ * 2*coupled_streams</code>, then I/O channel <code>j</code> is encoded as the
138
+ * left channel of stream <code>(i/2)</code> if <code>i</code> is even, or as
139
+ * the right channel of stream <code>(i/2)</code> if <code>i</code> is odd.
140
+ * Otherwise, I/O channel <code>j</code> is encoded as mono in stream <code>(i -
141
+ * coupled_streams)</code>, unless it has the special value 255, in which case
142
+ * it is omitted from the encoding entirely (the decoder will reproduce it as
143
+ * silence). Each value <code>i</code> must either be the special value 255 or
144
+ * be less than <code>streams + coupled_streams</code>.
145
+ *
146
+ * The output channels specified by the encoder
147
+ * should use the
148
+ * <a
149
+ * href="https://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-810004.3.9">Vorbis
150
+ * channel ordering</a>. A decoder may wish to apply an additional permutation
151
+ * to the mapping the encoder used to achieve a different output channel
152
+ * order (e.g. for outputting in WAV order).
153
+ *
154
+ * Each multistream packet contains an Opus packet for each stream, and all of
155
+ * the Opus packets in a single multistream packet must have the same
156
+ * duration. Therefore the duration of a multistream packet can be extracted
157
+ * from the TOC sequence of the first stream, which is located at the
158
+ * beginning of the packet, just like an elementary Opus stream:
159
+ *
160
+ * @code
161
+ * int nb_samples;
162
+ * int nb_frames;
163
+ * nb_frames = opus_packet_get_nb_frames(data, len);
164
+ * if (nb_frames < 1)
165
+ * return nb_frames;
166
+ * nb_samples = opus_packet_get_samples_per_frame(data, 48000) * nb_frames;
167
+ * @endcode
168
+ *
169
+ * The general encoding and decoding process proceeds exactly the same as in
170
+ * the normal @ref opus_encoder and @ref opus_decoder APIs.
171
+ * See their documentation for an overview of how to use the corresponding
172
+ * multistream functions.
173
+ */
174
+
175
+ /** Opus multistream encoder state.
176
+ * This contains the complete state of a multistream Opus encoder.
177
+ * It is position independent and can be freely copied.
178
+ * @see opus_multistream_encoder_create
179
+ * @see opus_multistream_encoder_init
180
+ */
181
+ typedef struct OpusMSEncoder OpusMSEncoder;
182
+
183
+ /** Opus multistream decoder state.
184
+ * This contains the complete state of a multistream Opus decoder.
185
+ * It is position independent and can be freely copied.
186
+ * @see opus_multistream_decoder_create
187
+ * @see opus_multistream_decoder_init
188
+ */
189
+ typedef struct OpusMSDecoder OpusMSDecoder;
190
+
191
+ /**\name Multistream encoder functions */
192
+ /**@{*/
193
+
194
+ /** Gets the size of an OpusMSEncoder structure.
195
+ * @param streams <tt>int</tt>: The total number of streams to encode from the
196
+ * input.
197
+ * This must be no more than 255.
198
+ * @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams
199
+ * to encode.
200
+ * This must be no larger than the total
201
+ * number of streams.
202
+ * Additionally, The total number of
203
+ * encoded channels (<code>streams +
204
+ * coupled_streams</code>) must be no
205
+ * more than 255.
206
+ * @returns The size in bytes on success, or a negative error code
207
+ * (see @ref opus_errorcodes) on error.
208
+ */
209
+ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32
210
+ opus_multistream_encoder_get_size(int streams, int coupled_streams);
211
+
212
+ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32
213
+ opus_multistream_surround_encoder_get_size(int channels, int mapping_family);
214
+
215
+ /** Allocates and initializes a multistream encoder state.
216
+ * Call opus_multistream_encoder_destroy() to release
217
+ * this object when finished.
218
+ * @param Fs <tt>opus_int32</tt>: Sampling rate of the input signal (in Hz).
219
+ * This must be one of 8000, 12000, 16000,
220
+ * 24000, or 48000.
221
+ * @param channels <tt>int</tt>: Number of channels in the input signal.
222
+ * This must be at most 255.
223
+ * It may be greater than the number of
224
+ * coded channels (<code>streams +
225
+ * coupled_streams</code>).
226
+ * @param streams <tt>int</tt>: The total number of streams to encode from the
227
+ * input.
228
+ * This must be no more than the number of
229
+ * channels.
230
+ * @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams
231
+ * to encode.
232
+ * This must be no larger than the total
233
+ * number of streams.
234
+ * Additionally, The total number of
235
+ * encoded channels (<code>streams +
236
+ * coupled_streams</code>) must be no
237
+ * more than the number of input channels.
238
+ * @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from
239
+ * encoded channels to input channels, as described in
240
+ * @ref opus_multistream. As an extra constraint, the
241
+ * multistream encoder does not allow encoding coupled
242
+ * streams for which one channel is unused since this
243
+ * is never a good idea.
244
+ * @param application <tt>int</tt>: The target encoder application.
245
+ * This must be one of the following:
246
+ * <dl>
247
+ * <dt>#OPUS_APPLICATION_VOIP</dt>
248
+ * <dd>Process signal for improved speech intelligibility.</dd>
249
+ * <dt>#OPUS_APPLICATION_AUDIO</dt>
250
+ * <dd>Favor faithfulness to the original input.</dd>
251
+ * <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt>
252
+ * <dd>Configure the minimum possible coding delay by disabling certain modes
253
+ * of operation.</dd>
254
+ * </dl>
255
+ * @param[out] error <tt>int *</tt>: Returns #OPUS_OK on success, or an error
256
+ * code (see @ref opus_errorcodes) on
257
+ * failure.
258
+ */
259
+ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSEncoder *
260
+ opus_multistream_encoder_create(
261
+ opus_int32 Fs,
262
+ int channels,
263
+ int streams,
264
+ int coupled_streams,
265
+ const unsigned char *mapping,
266
+ int application,
267
+ int *error) OPUS_ARG_NONNULL(5);
268
+
269
+ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSEncoder *
270
+ opus_multistream_surround_encoder_create(
271
+ opus_int32 Fs,
272
+ int channels,
273
+ int mapping_family,
274
+ int *streams,
275
+ int *coupled_streams,
276
+ unsigned char *mapping,
277
+ int application,
278
+ int *error) OPUS_ARG_NONNULL(4) OPUS_ARG_NONNULL(5) OPUS_ARG_NONNULL(6);
279
+
280
+ /** Initialize a previously allocated multistream encoder state.
281
+ * The memory pointed to by \a st must be at least the size returned by
282
+ * opus_multistream_encoder_get_size().
283
+ * This is intended for applications which use their own allocator instead of
284
+ * malloc.
285
+ * To reset a previously initialized state, use the #OPUS_RESET_STATE CTL.
286
+ * @see opus_multistream_encoder_create
287
+ * @see opus_multistream_encoder_get_size
288
+ * @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state to initialize.
289
+ * @param Fs <tt>opus_int32</tt>: Sampling rate of the input signal (in Hz).
290
+ * This must be one of 8000, 12000, 16000,
291
+ * 24000, or 48000.
292
+ * @param channels <tt>int</tt>: Number of channels in the input signal.
293
+ * This must be at most 255.
294
+ * It may be greater than the number of
295
+ * coded channels (<code>streams +
296
+ * coupled_streams</code>).
297
+ * @param streams <tt>int</tt>: The total number of streams to encode from the
298
+ * input.
299
+ * This must be no more than the number of
300
+ * channels.
301
+ * @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams
302
+ * to encode.
303
+ * This must be no larger than the total
304
+ * number of streams.
305
+ * Additionally, The total number of
306
+ * encoded channels (<code>streams +
307
+ * coupled_streams</code>) must be no
308
+ * more than the number of input channels.
309
+ * @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from
310
+ * encoded channels to input channels, as described in
311
+ * @ref opus_multistream. As an extra constraint, the
312
+ * multistream encoder does not allow encoding coupled
313
+ * streams for which one channel is unused since this
314
+ * is never a good idea.
315
+ * @param application <tt>int</tt>: The target encoder application.
316
+ * This must be one of the following:
317
+ * <dl>
318
+ * <dt>#OPUS_APPLICATION_VOIP</dt>
319
+ * <dd>Process signal for improved speech intelligibility.</dd>
320
+ * <dt>#OPUS_APPLICATION_AUDIO</dt>
321
+ * <dd>Favor faithfulness to the original input.</dd>
322
+ * <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt>
323
+ * <dd>Configure the minimum possible coding delay by disabling certain modes
324
+ * of operation.</dd>
325
+ * </dl>
326
+ * @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes)
327
+ * on failure.
328
+ */
329
+ OPUS_EXPORT int opus_multistream_encoder_init(
330
+ OpusMSEncoder *st,
331
+ opus_int32 Fs,
332
+ int channels,
333
+ int streams,
334
+ int coupled_streams,
335
+ const unsigned char *mapping,
336
+ int application) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6);
337
+
338
+ OPUS_EXPORT int opus_multistream_surround_encoder_init(
339
+ OpusMSEncoder *st,
340
+ opus_int32 Fs,
341
+ int channels,
342
+ int mapping_family,
343
+ int *streams,
344
+ int *coupled_streams,
345
+ unsigned char *mapping,
346
+ int application) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(5) OPUS_ARG_NONNULL(6)
347
+ OPUS_ARG_NONNULL(7);
348
+
349
+ /** Encodes a multistream Opus frame.
350
+ * @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state.
351
+ * @param[in] pcm <tt>const opus_int16*</tt>: The input signal as interleaved
352
+ * samples.
353
+ * This must contain
354
+ * <code>frame_size*channels</code>
355
+ * samples.
356
+ * @param frame_size <tt>int</tt>: Number of samples per channel in the input
357
+ * signal.
358
+ * This must be an Opus frame size for the
359
+ * encoder's sampling rate.
360
+ * For example, at 48 kHz the permitted values
361
+ * are 120, 240, 480, 960, 1920, and 2880.
362
+ * Passing in a duration of less than 10 ms
363
+ * (480 samples at 48 kHz) will prevent the
364
+ * encoder from using the LPC or hybrid modes.
365
+ * @param[out] data <tt>unsigned char*</tt>: Output payload.
366
+ * This must contain storage for at
367
+ * least \a max_data_bytes.
368
+ * @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated
369
+ * memory for the output
370
+ * payload. This may be
371
+ * used to impose an upper limit
372
+ * on the instant bitrate, but should not be used as the only bitrate control.
373
+ * Use #OPUS_SET_BITRATE to control the bitrate.
374
+ * @returns The length of the encoded packet (in bytes) on success or a
375
+ * negative error code (see @ref opus_errorcodes) on failure.
376
+ */
377
+ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode(
378
+ OpusMSEncoder *st,
379
+ const opus_int16 *pcm,
380
+ int frame_size,
381
+ unsigned char *data,
382
+ opus_int32 max_data_bytes) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2)
383
+ OPUS_ARG_NONNULL(4);
384
+
385
+ /** Encodes a multistream Opus frame.
386
+ * @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state.
387
+ * @param[in] pcm <tt>const opus_int32*</tt>: The input signal as interleaved
388
+ * samples representing (or slightly
389
+ * exceeding) 24-bit values. This must contain <code>frame_size*channels</code>
390
+ * samples.
391
+ * @param frame_size <tt>int</tt>: Number of samples per channel in the input
392
+ * signal.
393
+ * This must be an Opus frame size for the
394
+ * encoder's sampling rate.
395
+ * For example, at 48 kHz the permitted values
396
+ * are 120, 240, 480, 960, 1920, and 2880.
397
+ * Passing in a duration of less than 10 ms
398
+ * (480 samples at 48 kHz) will prevent the
399
+ * encoder from using the LPC or hybrid modes.
400
+ * @param[out] data <tt>unsigned char*</tt>: Output payload.
401
+ * This must contain storage for at
402
+ * least \a max_data_bytes.
403
+ * @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated
404
+ * memory for the output
405
+ * payload. This may be
406
+ * used to impose an upper limit
407
+ * on the instant bitrate, but should not be used as the only bitrate control.
408
+ * Use #OPUS_SET_BITRATE to control the bitrate.
409
+ * @returns The length of the encoded packet (in bytes) on success or a
410
+ * negative error code (see @ref opus_errorcodes) on failure.
411
+ */
412
+ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode24(
413
+ OpusMSEncoder *st,
414
+ const opus_int32 *pcm,
415
+ int frame_size,
416
+ unsigned char *data,
417
+ opus_int32 max_data_bytes) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2)
418
+ OPUS_ARG_NONNULL(4);
419
+
420
+ /** Encodes a multistream Opus frame from floating point input.
421
+ * @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state.
422
+ * @param[in] pcm <tt>const float*</tt>: The input signal as interleaved
423
+ * samples with a normal range of
424
+ * +/-1.0.
425
+ * Samples with a range beyond +/-1.0
426
+ * are supported but will be clipped by
427
+ * decoders using the integer API and
428
+ * should only be used if it is known
429
+ * that the far end supports extended
430
+ * dynamic range.
431
+ * This must contain
432
+ * <code>frame_size*channels</code>
433
+ * samples.
434
+ * @param frame_size <tt>int</tt>: Number of samples per channel in the input
435
+ * signal.
436
+ * This must be an Opus frame size for the
437
+ * encoder's sampling rate.
438
+ * For example, at 48 kHz the permitted values
439
+ * are 120, 240, 480, 960, 1920, and 2880.
440
+ * Passing in a duration of less than 10 ms
441
+ * (480 samples at 48 kHz) will prevent the
442
+ * encoder from using the LPC or hybrid modes.
443
+ * @param[out] data <tt>unsigned char*</tt>: Output payload.
444
+ * This must contain storage for at
445
+ * least \a max_data_bytes.
446
+ * @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated
447
+ * memory for the output
448
+ * payload. This may be
449
+ * used to impose an upper limit
450
+ * on the instant bitrate, but should not be used as the only bitrate control.
451
+ * Use #OPUS_SET_BITRATE to control the bitrate.
452
+ * @returns The length of the encoded packet (in bytes) on success or a
453
+ * negative error code (see @ref opus_errorcodes) on failure.
454
+ */
455
+ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode_float(
456
+ OpusMSEncoder *st,
457
+ const float *pcm,
458
+ int frame_size,
459
+ unsigned char *data,
460
+ opus_int32 max_data_bytes) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2)
461
+ OPUS_ARG_NONNULL(4);
462
+
463
+ /** Frees an <code>OpusMSEncoder</code> allocated by
464
+ * opus_multistream_encoder_create().
465
+ * @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state to be freed.
466
+ */
467
+ OPUS_EXPORT void opus_multistream_encoder_destroy(OpusMSEncoder *st);
468
+
469
+ /** Perform a CTL function on a multistream Opus encoder.
470
+ *
471
+ * Generally the request and subsequent arguments are generated by a
472
+ * convenience macro.
473
+ * @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state.
474
+ * @param request This and all remaining parameters should be replaced by one
475
+ * of the convenience macros in @ref opus_genericctls,
476
+ * @ref opus_encoderctls, or @ref opus_multistream_ctls.
477
+ * @see opus_genericctls
478
+ * @see opus_encoderctls
479
+ * @see opus_multistream_ctls
480
+ */
481
+ OPUS_EXPORT int opus_multistream_encoder_ctl(
482
+ OpusMSEncoder *st,
483
+ int request,
484
+ ...) OPUS_ARG_NONNULL(1);
485
+
486
+ /**@}*/
487
+
488
+ /**\name Multistream decoder functions */
489
+ /**@{*/
490
+
491
+ /** Gets the size of an <code>OpusMSDecoder</code> structure.
492
+ * @param streams <tt>int</tt>: The total number of streams coded in the
493
+ * input.
494
+ * This must be no more than 255.
495
+ * @param coupled_streams <tt>int</tt>: Number streams to decode as coupled
496
+ * (2 channel) streams.
497
+ * This must be no larger than the total
498
+ * number of streams.
499
+ * Additionally, The total number of
500
+ * coded channels (<code>streams +
501
+ * coupled_streams</code>) must be no
502
+ * more than 255.
503
+ * @returns The size in bytes on success, or a negative error code
504
+ * (see @ref opus_errorcodes) on error.
505
+ */
506
+ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32
507
+ opus_multistream_decoder_get_size(int streams, int coupled_streams);
508
+
509
+ /** Allocates and initializes a multistream decoder state.
510
+ * Call opus_multistream_decoder_destroy() to release
511
+ * this object when finished.
512
+ * @param Fs <tt>opus_int32</tt>: Sampling rate to decode at (in Hz).
513
+ * This must be one of 8000, 12000, 16000,
514
+ * 24000, or 48000.
515
+ * @param channels <tt>int</tt>: Number of channels to output.
516
+ * This must be at most 255.
517
+ * It may be different from the number of coded
518
+ * channels (<code>streams +
519
+ * coupled_streams</code>).
520
+ * @param streams <tt>int</tt>: The total number of streams coded in the
521
+ * input.
522
+ * This must be no more than 255.
523
+ * @param coupled_streams <tt>int</tt>: Number of streams to decode as coupled
524
+ * (2 channel) streams.
525
+ * This must be no larger than the total
526
+ * number of streams.
527
+ * Additionally, The total number of
528
+ * coded channels (<code>streams +
529
+ * coupled_streams</code>) must be no
530
+ * more than 255.
531
+ * @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from
532
+ * coded channels to output channels, as described in
533
+ * @ref opus_multistream.
534
+ * @param[out] error <tt>int *</tt>: Returns #OPUS_OK on success, or an error
535
+ * code (see @ref opus_errorcodes) on
536
+ * failure.
537
+ */
538
+ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSDecoder *
539
+ opus_multistream_decoder_create(
540
+ opus_int32 Fs,
541
+ int channels,
542
+ int streams,
543
+ int coupled_streams,
544
+ const unsigned char *mapping,
545
+ int *error) OPUS_ARG_NONNULL(5);
546
+
547
+ /** Initialize a previously allocated decoder state object.
548
+ * The memory pointed to by \a st must be at least the size returned by
549
+ * opus_multistream_encoder_get_size().
550
+ * This is intended for applications which use their own allocator instead of
551
+ * malloc.
552
+ * To reset a previously initialized state, use the #OPUS_RESET_STATE CTL.
553
+ * @see opus_multistream_decoder_create
554
+ * @see opus_multistream_deocder_get_size
555
+ * @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state to initialize.
556
+ * @param Fs <tt>opus_int32</tt>: Sampling rate to decode at (in Hz).
557
+ * This must be one of 8000, 12000, 16000,
558
+ * 24000, or 48000.
559
+ * @param channels <tt>int</tt>: Number of channels to output.
560
+ * This must be at most 255.
561
+ * It may be different from the number of coded
562
+ * channels (<code>streams +
563
+ * coupled_streams</code>).
564
+ * @param streams <tt>int</tt>: The total number of streams coded in the
565
+ * input.
566
+ * This must be no more than 255.
567
+ * @param coupled_streams <tt>int</tt>: Number of streams to decode as coupled
568
+ * (2 channel) streams.
569
+ * This must be no larger than the total
570
+ * number of streams.
571
+ * Additionally, The total number of
572
+ * coded channels (<code>streams +
573
+ * coupled_streams</code>) must be no
574
+ * more than 255.
575
+ * @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from
576
+ * coded channels to output channels, as described in
577
+ * @ref opus_multistream.
578
+ * @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes)
579
+ * on failure.
580
+ */
581
+ OPUS_EXPORT int opus_multistream_decoder_init(
582
+ OpusMSDecoder *st,
583
+ opus_int32 Fs,
584
+ int channels,
585
+ int streams,
586
+ int coupled_streams,
587
+ const unsigned char *mapping) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6);
588
+
589
+ /** Decode a multistream Opus packet.
590
+ * @param st <tt>OpusMSDecoder*</tt>: Multistream decoder state.
591
+ * @param[in] data <tt>const unsigned char*</tt>: Input payload.
592
+ * Use a <code>NULL</code>
593
+ * pointer to indicate packet
594
+ * loss.
595
+ * @param len <tt>opus_int32</tt>: Number of bytes in payload.
596
+ * @param[out] pcm <tt>opus_int16*</tt>: Output signal, with interleaved
597
+ * samples.
598
+ * This must contain room for
599
+ * <code>frame_size*channels</code>
600
+ * samples.
601
+ * @param frame_size <tt>int</tt>: The number of samples per channel of
602
+ * available space in \a pcm.
603
+ * If this is less than the maximum packet
604
+ * duration (120 ms; 5760 for 48kHz), this function will not be capable of
605
+ * decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=1),
606
+ * then frame_size needs to be exactly the duration of audio that is missing,
607
+ * otherwise the decoder will not be in the optimal state to decode the next
608
+ * incoming packet. For the PLC and FEC cases, frame_size <b>must</b> be a
609
+ * multiple of 2.5 ms.
610
+ * @param decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band
611
+ * forward error correction data be decoded.
612
+ * If no such data is available, the frame is
613
+ * decoded as if it were lost.
614
+ * @returns Number of samples decoded on success or a negative error code
615
+ * (see @ref opus_errorcodes) on failure.
616
+ */
617
+ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode(
618
+ OpusMSDecoder *st,
619
+ const unsigned char *data,
620
+ opus_int32 len,
621
+ opus_int16 *pcm,
622
+ int frame_size,
623
+ int decode_fec) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
624
+
625
+ /** Decode a multistream Opus packet.
626
+ * @param st <tt>OpusMSDecoder*</tt>: Multistream decoder state.
627
+ * @param[in] data <tt>const unsigned char*</tt>: Input payload.
628
+ * Use a <code>NULL</code>
629
+ * pointer to indicate packet
630
+ * loss.
631
+ * @param len <tt>opus_int32</tt>: Number of bytes in payload.
632
+ * @param[out] pcm <tt>opus_int32*</tt>: Output signal, with interleaved
633
+ * samples representing (or slightly
634
+ * exceeding) 24-bit values. This must contain room for
635
+ * <code>frame_size*channels</code>
636
+ * samples.
637
+ * @param frame_size <tt>int</tt>: The number of samples per channel of
638
+ * available space in \a pcm.
639
+ * If this is less than the maximum packet
640
+ * duration (120 ms; 5760 for 48kHz), this function will not be capable of
641
+ * decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=1),
642
+ * then frame_size needs to be exactly the duration of audio that is missing,
643
+ * otherwise the decoder will not be in the optimal state to decode the next
644
+ * incoming packet. For the PLC and FEC cases, frame_size <b>must</b> be a
645
+ * multiple of 2.5 ms.
646
+ * @param decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band
647
+ * forward error correction data be decoded.
648
+ * If no such data is available, the frame is
649
+ * decoded as if it were lost.
650
+ * @returns Number of samples decoded on success or a negative error code
651
+ * (see @ref opus_errorcodes) on failure.
652
+ */
653
+ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode24(
654
+ OpusMSDecoder *st,
655
+ const unsigned char *data,
656
+ opus_int32 len,
657
+ opus_int32 *pcm,
658
+ int frame_size,
659
+ int decode_fec) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
660
+
661
+ /** Decode a multistream Opus packet with floating point output.
662
+ * @param st <tt>OpusMSDecoder*</tt>: Multistream decoder state.
663
+ * @param[in] data <tt>const unsigned char*</tt>: Input payload.
664
+ * Use a <code>NULL</code>
665
+ * pointer to indicate packet
666
+ * loss.
667
+ * @param len <tt>opus_int32</tt>: Number of bytes in payload.
668
+ * @param[out] pcm <tt>opus_int16*</tt>: Output signal, with interleaved
669
+ * samples.
670
+ * This must contain room for
671
+ * <code>frame_size*channels</code>
672
+ * samples.
673
+ * @param frame_size <tt>int</tt>: The number of samples per channel of
674
+ * available space in \a pcm.
675
+ * If this is less than the maximum packet
676
+ * duration (120 ms; 5760 for 48kHz), this function will not be capable of
677
+ * decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=1),
678
+ * then frame_size needs to be exactly the duration of audio that is missing,
679
+ * otherwise the decoder will not be in the optimal state to decode the next
680
+ * incoming packet. For the PLC and FEC cases, frame_size <b>must</b> be a
681
+ * multiple of 2.5 ms.
682
+ * @param decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band
683
+ * forward error correction data be decoded.
684
+ * If no such data is available, the frame is
685
+ * decoded as if it were lost.
686
+ * @returns Number of samples decoded on success or a negative error code
687
+ * (see @ref opus_errorcodes) on failure.
688
+ */
689
+ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode_float(
690
+ OpusMSDecoder *st,
691
+ const unsigned char *data,
692
+ opus_int32 len,
693
+ float *pcm,
694
+ int frame_size,
695
+ int decode_fec) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
696
+
697
+ /** Perform a CTL function on a multistream Opus decoder.
698
+ *
699
+ * Generally the request and subsequent arguments are generated by a
700
+ * convenience macro.
701
+ * @param st <tt>OpusMSDecoder*</tt>: Multistream decoder state.
702
+ * @param request This and all remaining parameters should be replaced by one
703
+ * of the convenience macros in @ref opus_genericctls,
704
+ * @ref opus_decoderctls, or @ref opus_multistream_ctls.
705
+ * @see opus_genericctls
706
+ * @see opus_decoderctls
707
+ * @see opus_multistream_ctls
708
+ */
709
+ OPUS_EXPORT int opus_multistream_decoder_ctl(
710
+ OpusMSDecoder *st,
711
+ int request,
712
+ ...) OPUS_ARG_NONNULL(1);
713
+
714
+ /** Frees an <code>OpusMSDecoder</code> allocated by
715
+ * opus_multistream_decoder_create().
716
+ * @param st <tt>OpusMSDecoder</tt>: Multistream decoder state to be freed.
717
+ */
718
+ OPUS_EXPORT void opus_multistream_decoder_destroy(OpusMSDecoder *st);
719
+
720
+ /**@}*/
721
+
722
+ /**@}*/
723
+
724
+ #ifdef __cplusplus
725
+ }
726
+ #endif
727
+
728
+ #endif /* OPUS_MULTISTREAM_H */