00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef OPUSENC_H
00028 # define OPUSENC_H
00029
00053 # if defined(__cplusplus)
00054 extern "C" {
00055 # endif
00056
00057 #include <stddef.h>
00058 #include <opus.h>
00059
00060 #ifndef OPE_EXPORT
00061 # if defined(WIN32)
00062 # if defined(OPE_BUILD) && defined(DLL_EXPORT)
00063 # define OPE_EXPORT __declspec(dllexport)
00064 # else
00065 # define OPE_EXPORT
00066 # endif
00067 # elif defined(__GNUC__) && defined(OPE_BUILD)
00068 # define OPE_EXPORT __attribute__ ((visibility ("default")))
00069 # else
00070 # define OPE_EXPORT
00071 # endif
00072 #endif
00073
00083
00084
00085
00087 #define OPE_API_VERSION 0
00088
00089 #define OPE_OK 0
00090
00091 #define OPE_BAD_ARG -11
00092 #define OPE_INTERNAL_ERROR -13
00093 #define OPE_UNIMPLEMENTED -15
00094 #define OPE_ALLOC_FAIL -17
00095
00096
00097 #define OPE_CANNOT_OPEN -30
00098 #define OPE_TOO_LATE -31
00099 #define OPE_INVALID_PICTURE -32
00100 #define OPE_INVALID_ICON -33
00101 #define OPE_WRITE_FAIL -34
00102 #define OPE_CLOSE_FAIL -35
00103
00106
00107
00108
00109 #define OPE_SET_DECISION_DELAY_REQUEST 14000
00110 #define OPE_GET_DECISION_DELAY_REQUEST 14001
00111 #define OPE_SET_MUXING_DELAY_REQUEST 14002
00112 #define OPE_GET_MUXING_DELAY_REQUEST 14003
00113 #define OPE_SET_COMMENT_PADDING_REQUEST 14004
00114 #define OPE_GET_COMMENT_PADDING_REQUEST 14005
00115 #define OPE_SET_SERIALNO_REQUEST 14006
00116 #define OPE_GET_SERIALNO_REQUEST 14007
00117 #define OPE_SET_PACKET_CALLBACK_REQUEST 14008
00118
00119 #define OPE_SET_HEADER_GAIN_REQUEST 14010
00120 #define OPE_GET_HEADER_GAIN_REQUEST 14011
00121 #define OPE_GET_NB_STREAMS_REQUEST 14013
00122 #define OPE_GET_NB_COUPLED_STREAMS_REQUEST 14015
00123
00126
00131
00132 #define OPE_SET_DECISION_DELAY(x) OPE_SET_DECISION_DELAY_REQUEST, __opus_check_int(x)
00133 #define OPE_GET_DECISION_DELAY(x) OPE_GET_DECISION_DELAY_REQUEST, __opus_check_int_ptr(x)
00134 #define OPE_SET_MUXING_DELAY(x) OPE_SET_MUXING_DELAY_REQUEST, __opus_check_int(x)
00135 #define OPE_GET_MUXING_DELAY(x) OPE_GET_MUXING_DELAY_REQUEST, __opus_check_int_ptr(x)
00136 #define OPE_SET_COMMENT_PADDING(x) OPE_SET_COMMENT_PADDING_REQUEST, __opus_check_int(x)
00137 #define OPE_GET_COMMENT_PADDING(x) OPE_GET_COMMENT_PADDING_REQUEST, __opus_check_int_ptr(x)
00138 #define OPE_SET_SERIALNO(x) OPE_SET_SERIALNO_REQUEST, __opus_check_int(x)
00139 #define OPE_GET_SERIALNO(x) OPE_GET_SERIALNO_REQUEST, __opus_check_int_ptr(x)
00140
00141 #define OPE_SET_PACKET_CALLBACK(x,u) OPE_SET_PACKET_CALLBACK_REQUEST, (x), (u)
00142
00143 #define OPE_SET_HEADER_GAIN(x) OPE_SET_HEADER_GAIN_REQUEST, __opus_check_int(x)
00144 #define OPE_GET_HEADER_GAIN(x) OPE_GET_HEADER_GAIN_REQUEST, __opus_check_int_ptr(x)
00145 #define OPE_GET_NB_STREAMS(x) OPE_GET_NB_STREAMS_REQUEST, __opus_check_int_ptr(x)
00146 #define OPE_GET_NB_COUPLED_STREAMS(x) OPE_GET_NB_COUPLED_STREAMS_REQUEST, __opus_check_int_ptr(x)
00147
00149
00152
00157
00166 typedef int (*ope_write_func)(void *user_data, const unsigned char *ptr, opus_int32 len);
00167
00174 typedef int (*ope_close_func)(void *user_data);
00175
00182 typedef void (*ope_packet_func)(void *user_data, const unsigned char *packet_ptr, opus_int32 packet_len, opus_uint32 flags);
00183
00185 typedef struct {
00187 ope_write_func write;
00189 ope_close_func close;
00190 } OpusEncCallbacks;
00193
00195 typedef struct OggOpusComments OggOpusComments;
00196
00198 typedef struct OggOpusEnc OggOpusEnc;
00199
00202
00207
00210 OPE_EXPORT OggOpusComments *ope_comments_create(void);
00211
00215 OPE_EXPORT OggOpusComments *ope_comments_copy(OggOpusComments *comments);
00216
00219 OPE_EXPORT void ope_comments_destroy(OggOpusComments *comments);
00220
00227 OPE_EXPORT int ope_comments_add(OggOpusComments *comments, const char *tag, const char *val);
00228
00234 OPE_EXPORT int ope_comments_add_string(OggOpusComments *comments, const char *tag_and_val);
00235
00243 OPE_EXPORT int ope_comments_add_picture(OggOpusComments *comments, const char *filename, int picture_type, const char *description);
00244
00253 OPE_EXPORT int ope_comments_add_picture_from_memory(OggOpusComments *comments, const char *ptr, size_t size, int picture_type, const char *description);
00254
00257
00260
00265
00275 OPE_EXPORT OggOpusEnc *ope_encoder_create_file(const char *path, OggOpusComments *comments, opus_int32 rate, int channels, int family, int *error);
00276
00287 OPE_EXPORT OggOpusEnc *ope_encoder_create_callbacks(const OpusEncCallbacks *callbacks, void *user_data,
00288 OggOpusComments *comments, opus_int32 rate, int channels, int family, int *error);
00289
00299 OPE_EXPORT OggOpusEnc *ope_encoder_create_pull(OggOpusComments *comments, opus_int32 rate, int channels, int family, int *error);
00300
00310 OPE_EXPORT int ope_encoder_deferred_init_with_mapping(OggOpusEnc *enc, int family, int streams,
00311 int coupled_streams, const unsigned char *mapping);
00312
00318 OPE_EXPORT int ope_encoder_write_float(OggOpusEnc *enc, const float *pcm, int samples_per_channel);
00319
00325 OPE_EXPORT int ope_encoder_write(OggOpusEnc *enc, const opus_int16 *pcm, int samples_per_channel);
00326
00333 OPE_EXPORT int ope_encoder_get_page(OggOpusEnc *enc, unsigned char **page, opus_int32 *len, int flush);
00334
00339 OPE_EXPORT int ope_encoder_drain(OggOpusEnc *enc);
00340
00344 OPE_EXPORT void ope_encoder_destroy(OggOpusEnc *enc);
00345
00351 OPE_EXPORT int ope_encoder_chain_current(OggOpusEnc *enc, OggOpusComments *comments);
00352
00359 OPE_EXPORT int ope_encoder_continue_new_file(OggOpusEnc *enc, const char *path, OggOpusComments *comments);
00360
00367 OPE_EXPORT int ope_encoder_continue_new_callbacks(OggOpusEnc *enc, void *user_data, OggOpusComments *comments);
00368
00373 OPE_EXPORT int ope_encoder_flush_header(OggOpusEnc *enc);
00374
00380 OPE_EXPORT int ope_encoder_ctl(OggOpusEnc *enc, int request, ...);
00381
00387 OPE_EXPORT const char *ope_strerror(int error);
00388
00391 OPE_EXPORT const char *ope_get_version_string(void);
00392
00395 OPE_EXPORT int ope_get_abi_version(void);
00396
00399
00400 # if defined(__cplusplus)
00401 }
00402 # endif
00403
00404 #endif