Opus
IETF low-delay audio codec: API and operations manual
1.0.1-rc2
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 
00162 typedef struct OpusEncoder OpusEncoder;
00163 
00164 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_encoder_get_size(int channels);
00165 
00199 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusEncoder *opus_encoder_create(
00200     opus_int32 Fs,
00201     int channels,
00202     int application,
00203     int *error
00204 );
00205 
00217 OPUS_EXPORT int opus_encoder_init(
00218     OpusEncoder *st,
00219     opus_int32 Fs,
00220     int channels,
00221     int application
00222 ) OPUS_ARG_NONNULL(1);
00223 
00236 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_encode(
00237     OpusEncoder *st,
00238     const opus_int16 *pcm,
00239     int frame_size,
00240     unsigned char *data,
00241     opus_int32 max_data_bytes
00242 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
00243 
00261 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_encode_float(
00262     OpusEncoder *st,
00263     const float *pcm,
00264     int frame_size,
00265     unsigned char *data,
00266     opus_int32 max_data_bytes
00267 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
00268 
00272 OPUS_EXPORT void opus_encoder_destroy(OpusEncoder *st);
00273 
00280 OPUS_EXPORT int opus_encoder_ctl(OpusEncoder *st, int request, ...) OPUS_ARG_NONNULL(1);
00351 typedef struct OpusDecoder OpusDecoder;
00352 
00357 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decoder_get_size(int channels);
00358 
00372 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusDecoder *opus_decoder_create(
00373     opus_int32 Fs,
00374     int channels,
00375     int *error
00376 );
00377 
00387 OPUS_EXPORT int opus_decoder_init(
00388     OpusDecoder *st,
00389     opus_int32 Fs,
00390     int channels
00391 ) OPUS_ARG_NONNULL(1);
00392 
00405 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decode(
00406     OpusDecoder *st,
00407     const unsigned char *data,
00408     opus_int32 len,
00409     opus_int16 *pcm,
00410     int frame_size,
00411     int decode_fec
00412 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
00413 
00426 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decode_float(
00427     OpusDecoder *st,
00428     const unsigned char *data,
00429     opus_int32 len,
00430     float *pcm,
00431     int frame_size,
00432     int decode_fec
00433 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
00434 
00441 OPUS_EXPORT int opus_decoder_ctl(OpusDecoder *st, int request, ...) OPUS_ARG_NONNULL(1);
00442 
00446 OPUS_EXPORT void opus_decoder_destroy(OpusDecoder *st);
00447 
00461 OPUS_EXPORT int opus_packet_parse(
00462    const unsigned char *data,
00463    opus_int32 len,
00464    unsigned char *out_toc,
00465    const unsigned char *frames[48],
00466    short size[48],
00467    int *payload_offset
00468 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
00469 
00479 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_bandwidth(const unsigned char *data) OPUS_ARG_NONNULL(1);
00480 
00487 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_samples_per_frame(const unsigned char *data, opus_int32 Fs) OPUS_ARG_NONNULL(1);
00488 
00494 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_channels(const unsigned char *data) OPUS_ARG_NONNULL(1);
00495 
00502 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_frames(const unsigned char packet[], opus_int32 len) OPUS_ARG_NONNULL(1);
00503 
00511 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decoder_get_nb_samples(const OpusDecoder *dec, const unsigned char packet[], opus_int32 len) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2);
00522 typedef struct OpusRepacketizer OpusRepacketizer;
00523 
00524 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_repacketizer_get_size(void);
00525 
00526 OPUS_EXPORT OpusRepacketizer *opus_repacketizer_init(OpusRepacketizer *rp) OPUS_ARG_NONNULL(1);
00527 
00528 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusRepacketizer *opus_repacketizer_create(void);
00529 
00530 OPUS_EXPORT void opus_repacketizer_destroy(OpusRepacketizer *rp);
00531 
00532 OPUS_EXPORT int opus_repacketizer_cat(OpusRepacketizer *rp, const unsigned char *data, opus_int32 len) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2);
00533 
00534 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_repacketizer_out_range(OpusRepacketizer *rp, int begin, int end, unsigned char *data, opus_int32 maxlen) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
00535 
00536 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_repacketizer_get_nb_frames(OpusRepacketizer *rp) OPUS_ARG_NONNULL(1);
00537 
00538 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_repacketizer_out(OpusRepacketizer *rp, unsigned char *data, opus_int32 maxlen) OPUS_ARG_NONNULL(1);
00539 
00542 #ifdef __cplusplus
00543 }
00544 #endif
00545 
00546 #endif /* OPUS_H */
 All Files Functions Typedefs Defines
For more information visit the Opus Website.