1 /+ 2 + Copyright 2023 – 2024 Aya Partridge 3 + Distributed under the Boost Software License, Version 1.0. 4 + (See accompanying file LICENSE_1_0.txt or copy at 5 + http://www.boost.org/LICENSE_1_0.txt) 6 +/ 7 module opusenc; 8 9 import bindbc.opus.config; 10 static if(bindOpusenc): 11 import bindbc.opus.codegen; 12 13 enum opusencVersion = (){ 14 version(Opusenc_0_2) return Version(0,2,0); 15 else static assert(0); 16 }(); 17 18 enum OPE_API_VERSION = 0; 19 20 enum{ 21 OPE_OK = 0, 22 OPE_BAD_ARG = -11, 23 OPE_INTERNAL_ERROR = -13, 24 OPE_UNIMPLEMENTED = -15, 25 OPE_ALLOC_FAIL = -17, 26 27 OPE_CANNOT_OPEN = -30, 28 OPE_TOO_LATE = -31, 29 OPE_INVALID_PICTURE = -32, 30 OPE_INVALID_ICON = -33, 31 OPE_WRITE_FAIL = -34, 32 OPE_CLOSE_FAIL = -35, 33 } 34 35 enum{ 36 OPE_SET_DECISION_DELAY_REQUEST = 14000, 37 OPE_GET_DECISION_DELAY_REQUEST = 14001, 38 OPE_SET_MUXING_DELAY_REQUEST = 14002, 39 OPE_GET_MUXING_DELAY_REQUEST = 14003, 40 OPE_SET_COMMENT_PADDING_REQUEST = 14004, 41 OPE_GET_COMMENT_PADDING_REQUEST = 14005, 42 OPE_SET_SERIALNO_REQUEST = 14006, 43 OPE_GET_SERIALNO_REQUEST = 14007, 44 OPE_SET_PACKET_CALLBACK_REQUEST = 14008, 45 46 OPE_SET_HEADER_GAIN_REQUEST = 14010, 47 OPE_GET_HEADER_GAIN_REQUEST = 14011, 48 OPE_GET_NB_STREAMS_REQUEST = 14013, 49 OPE_GET_NB_COUPLED_STREAMS_REQUEST = 14015, 50 } 51 52 alias ope_write_func = int function(void* userData, const(ubyte)* ptr, int len); 53 54 alias ope_close_func = int function(void* userData); 55 56 alias ope_packet_func = void function(void* userData, const(ubyte)* packetPtr, int packetLen, uint flags); 57 58 struct OpusEncCallbacks{ 59 ope_write_func write; 60 ope_close_func close; 61 } 62 63 struct OggOpusComments; 64 65 struct OggOpusEnc; 66 67 pragma(inline,true) nothrow @nogc{ 68 auto OPE_SET_DECISION_DELAY(OggOpusEnc* enc, int x){ return ope_encoder_ctl(enc, OPE_SET_DECISION_DELAY_REQUEST, x); } 69 auto OPE_GET_DECISION_DELAY(OggOpusEnc* enc, int* x){ return ope_encoder_ctl(enc, OPE_GET_DECISION_DELAY_REQUEST, x); } 70 auto OPE_SET_MUXING_DELAY(OggOpusEnc* enc, int x){ return ope_encoder_ctl(enc, OPE_SET_MUXING_DELAY_REQUEST, x); } 71 auto OPE_GET_MUXING_DELAY(OggOpusEnc* enc, int* x){ return ope_encoder_ctl(enc, OPE_GET_MUXING_DELAY_REQUEST, x); } 72 auto OPE_SET_COMMENT_PADDING(OggOpusEnc* enc, int x){ return ope_encoder_ctl(enc, OPE_SET_COMMENT_PADDING_REQUEST, x); } 73 auto OPE_GET_COMMENT_PADDING(OggOpusEnc* enc, int* x){ return ope_encoder_ctl(enc, OPE_GET_COMMENT_PADDING_REQUEST, x); } 74 auto OPE_SET_SERIALNO(OggOpusEnc* enc, int x){ return ope_encoder_ctl(enc, OPE_SET_SERIALNO_REQUEST, x); } 75 auto OPE_GET_SERIALNO(OggOpusEnc* enc, int* x){ return ope_encoder_ctl(enc, OPE_GET_SERIALNO_REQUEST, x); } 76 auto OPE_SET_PACKET_CALLBACK(OggOpusEnc* enc, ope_packet_func x, void* u){ return ope_encoder_ctl(enc, OPE_SET_PACKET_CALLBACK_REQUEST, x, u); } 77 auto OPE_SET_HEADER_GAIN(OggOpusEnc* enc, int x){ return ope_encoder_ctl(enc, OPE_SET_HEADER_GAIN_REQUEST, x); } 78 auto OPE_GET_HEADER_GAIN(OggOpusEnc* enc, int* x){ return ope_encoder_ctl(enc, OPE_GET_HEADER_GAIN_REQUEST, x); } 79 auto OPE_GET_NB_STREAMS(OggOpusEnc* enc, int* x){ return ope_encoder_ctl(enc, OPE_GET_NB_STREAMS_REQUEST, x); } 80 auto OPE_GET_NB_COUPLED_STREAMS(OggOpusEnc* enc, int* x){ return ope_encoder_ctl(enc, OPE_GET_NB_COUPLED_STREAMS_REQUEST, x); } 81 } 82 83 mixin(joinFnBinds((){ 84 FnBind[] ret = [ 85 {q{OggOpusComments*}, q{ope_comments_create}, q{}}, 86 {q{OggOpusComments*}, q{ope_comments_copy}, q{OggOpusComments* comments}}, 87 {q{void}, q{ope_comments_destroy}, q{OggOpusComments* comments}}, 88 {q{int}, q{ope_comments_add}, q{OggOpusComments* comments, const(char)* tag, const(char)* val}}, 89 {q{int}, q{ope_comments_add_string}, q{OggOpusComments* comments, const(char)* tagAndVal}}, 90 {q{int}, q{ope_comments_add_picture}, q{OggOpusComments* comments, const(char)* filename, int pictureType, const(char)* description}}, 91 {q{int}, q{ope_comments_add_picture_from_memory}, q{OggOpusComments* comments, const(ubyte)* ptr, size_t size, int pictureType, const(char)* description}}, 92 {q{OggOpusEnc*}, q{ope_encoder_create_file}, q{const(char)* path, OggOpusComments* comments, int rate, int channels, int family, int* error}}, 93 {q{OggOpusEnc*}, q{ope_encoder_create_callbacks}, q{const(OpusEncCallbacks)* callbacks, void* userData, OggOpusComments* comments, int rate, int channels, int family, int* error}}, 94 {q{OggOpusEnc*}, q{ope_encoder_create_pull}, q{OggOpusComments* comments, int rate, int channels, int family, int* error}}, 95 {q{int}, q{ope_encoder_deferred_init_with_mapping}, q{OggOpusEnc* enc, int family, int streams, int coupledStreams, const(ubyte)* mapping}}, 96 {q{int}, q{ope_encoder_write_float}, q{OggOpusEnc* enc, const(float)* pcm, int samplesPerChannel}}, 97 {q{int}, q{ope_encoder_write}, q{OggOpusEnc* enc, const(short)* pcm, int samplesPerChannel}}, 98 {q{int}, q{ope_encoder_get_page}, q{OggOpusEnc* enc, ubyte* *page, int* len, int flush}}, 99 {q{int}, q{ope_encoder_drain}, q{OggOpusEnc* enc}}, 100 {q{void}, q{ope_encoder_destroy}, q{OggOpusEnc* enc}}, 101 {q{int}, q{ope_encoder_chain_current}, q{OggOpusEnc* enc, OggOpusComments* comments}}, 102 {q{int}, q{ope_encoder_continue_new_file}, q{OggOpusEnc* enc, const(char)* path, OggOpusComments* comments}}, 103 {q{int}, q{ope_encoder_continue_new_callbacks}, q{OggOpusEnc* enc, void* userData, OggOpusComments* comments}}, 104 {q{int}, q{ope_encoder_flush_header}, q{OggOpusEnc* enc}}, 105 {q{int}, q{ope_encoder_ctl}, q{OggOpusEnc* enc, int request, ...}}, 106 {q{const(char)*}, q{ope_strerror}, q{int error}}, 107 {q{const(char)*}, q{ope_get_version_string}, q{}}, 108 {q{int}, q{ope_get_abi_version}, q{}}, 109 ]; 110 return ret; 111 }())); 112 113 static if(!staticBinding): 114 import bindbc.loader; 115 116 mixin(makeDynloadFns("Opusenc", makeLibPaths(["opusenc"]), [__MODULE__]));