Opus  0.9.14
IETFlow-delayaudiocodec
opus.h
Go to the documentation of this file.
00001 /* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited
00002    Written by Jean-Marc Valin and Koen Vos */
00003 /*
00004    Redistribution and use in source and binary forms, with or without
00005    modification, are permitted provided that the following conditions
00006    are met:
00007 
00008    - Redistributions of source code must retain the above copyright
00009    notice, this list of conditions and the following disclaimer.
00010 
00011    - Redistributions in binary form must reproduce the above copyright
00012    notice, this list of conditions and the following disclaimer in the
00013    documentation and/or other materials provided with the distribution.
00014 
00015    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00016    ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00017    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00018    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
00019    OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00020    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00021    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00022    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00023    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00024    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00025    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 */
00027 
00033 #ifndef OPUS_H
00034 #define OPUS_H
00035 
00036 #include "opus_types.h"
00037 #include "opus_defines.h"
00038 
00039 #ifdef __cplusplus
00040 extern "C" {
00041 #endif
00042 
00158 typedef struct OpusEncoder OpusEncoder;
00159 
00160 OPUS_EXPORT int opus_encoder_get_size(int channels);
00161 
00195 OPUS_EXPORT OpusEncoder *opus_encoder_create(
00196     opus_int32 Fs,
00197     int channels,
00198     int application,
00199     int *error
00200 );
00201 
00213 OPUS_EXPORT int opus_encoder_init(
00214     OpusEncoder *st,
00215     opus_int32 Fs,
00216     int channels,
00217     int application
00218 );
00219 
00232 OPUS_EXPORT opus_int32 opus_encode(
00233     OpusEncoder *st,
00234     const opus_int16 *pcm,
00235     int frame_size,
00236     unsigned char *data,
00237     opus_int32 max_data_bytes
00238 );
00239 
00252 OPUS_EXPORT opus_int32 opus_encode_float(
00253     OpusEncoder *st,
00254     const float *pcm,
00255     int frame_size,
00256     unsigned char *data,
00257     opus_int32 max_data_bytes
00258 );
00259 
00263 OPUS_EXPORT void opus_encoder_destroy(OpusEncoder *st);
00264 
00271 OPUS_EXPORT int opus_encoder_ctl(OpusEncoder *st, int request, ...);
00329 typedef struct OpusDecoder OpusDecoder;
00330 
00335 OPUS_EXPORT int opus_decoder_get_size(int channels);
00336 
00350 OPUS_EXPORT OpusDecoder *opus_decoder_create(
00351     opus_int32 Fs,
00352     int channels,
00353     int *error
00354 );
00355 
00365 OPUS_EXPORT int opus_decoder_init(
00366     OpusDecoder *st,
00367     opus_int32 Fs,
00368     int channels
00369 );
00370 
00383 OPUS_EXPORT int opus_decode(
00384     OpusDecoder *st,
00385     const unsigned char *data,
00386     opus_int32 len,
00387     opus_int16 *pcm,
00388     int frame_size,
00389     int decode_fec
00390 );
00391 
00404 OPUS_EXPORT int opus_decode_float(
00405     OpusDecoder *st,
00406     const unsigned char *data,
00407     opus_int32 len,
00408     float *pcm,
00409     int frame_size,
00410     int decode_fec
00411 );
00412 
00419 OPUS_EXPORT int opus_decoder_ctl(OpusDecoder *st, int request, ...);
00420 
00424 OPUS_EXPORT void opus_decoder_destroy(OpusDecoder *st);
00425 
00439 OPUS_EXPORT int opus_packet_parse(
00440    const unsigned char *data,
00441    opus_int32 len,
00442    unsigned char *out_toc,
00443    const unsigned char *frames[48],
00444    short size[48],
00445    int *payload_offset
00446 );
00447 
00457 OPUS_EXPORT int opus_packet_get_bandwidth(const unsigned char *data);
00458 
00465 OPUS_EXPORT int opus_packet_get_samples_per_frame(const unsigned char *data, opus_int32 Fs);
00466 
00472 OPUS_EXPORT int opus_packet_get_nb_channels(const unsigned char *data);
00473 
00480 OPUS_EXPORT int opus_packet_get_nb_frames(const unsigned char packet[], opus_int32 len);
00481 
00489 OPUS_EXPORT int opus_decoder_get_nb_samples(const OpusDecoder *dec, const unsigned char packet[], opus_int32 len);
00500 typedef struct OpusRepacketizer OpusRepacketizer;
00501 
00502 OPUS_EXPORT int opus_repacketizer_get_size(void);
00503 
00504 OPUS_EXPORT OpusRepacketizer *opus_repacketizer_init(OpusRepacketizer *rp);
00505 
00506 OPUS_EXPORT OpusRepacketizer *opus_repacketizer_create(void);
00507 
00508 OPUS_EXPORT void opus_repacketizer_destroy(OpusRepacketizer *rp);
00509 
00510 OPUS_EXPORT int opus_repacketizer_cat(OpusRepacketizer *rp, const unsigned char *data, opus_int32 len);
00511 
00512 OPUS_EXPORT opus_int32 opus_repacketizer_out_range(OpusRepacketizer *rp, int begin, int end, unsigned char *data, opus_int32 maxlen);
00513 
00514 OPUS_EXPORT int opus_repacketizer_get_nb_frames(OpusRepacketizer *rp);
00515 
00516 OPUS_EXPORT opus_int32 opus_repacketizer_out(OpusRepacketizer *rp, unsigned char *data, opus_int32 maxlen);
00517 
00520 #ifdef __cplusplus
00521 }
00522 #endif
00523 
00524 #endif /* OPUS_H */
 All Files Functions Typedefs Defines