1#![no_std]
2#![allow(non_upper_case_globals)]
3#![allow(non_camel_case_types)]
4#![allow(non_snake_case)]
5
6pub const OPE_API_VERSION: u32 = 0;
9pub const OPE_OK: u32 = 0;
10pub const OPE_BAD_ARG: i32 = -11;
11pub const OPE_INTERNAL_ERROR: i32 = -13;
12pub const OPE_UNIMPLEMENTED: i32 = -15;
13pub const OPE_ALLOC_FAIL: i32 = -17;
14pub const OPE_CANNOT_OPEN: i32 = -30;
15pub const OPE_TOO_LATE: i32 = -31;
16pub const OPE_INVALID_PICTURE: i32 = -32;
17pub const OPE_INVALID_ICON: i32 = -33;
18pub const OPE_WRITE_FAIL: i32 = -34;
19pub const OPE_CLOSE_FAIL: i32 = -35;
20pub const OPE_SET_DECISION_DELAY_REQUEST: u32 = 14000;
21pub const OPE_GET_DECISION_DELAY_REQUEST: u32 = 14001;
22pub const OPE_SET_MUXING_DELAY_REQUEST: u32 = 14002;
23pub const OPE_GET_MUXING_DELAY_REQUEST: u32 = 14003;
24pub const OPE_SET_COMMENT_PADDING_REQUEST: u32 = 14004;
25pub const OPE_GET_COMMENT_PADDING_REQUEST: u32 = 14005;
26pub const OPE_SET_SERIALNO_REQUEST: u32 = 14006;
27pub const OPE_GET_SERIALNO_REQUEST: u32 = 14007;
28pub const OPE_SET_PACKET_CALLBACK_REQUEST: u32 = 14008;
29pub const OPE_SET_HEADER_GAIN_REQUEST: u32 = 14010;
30pub const OPE_GET_HEADER_GAIN_REQUEST: u32 = 14011;
31pub const OPE_GET_NB_STREAMS_REQUEST: u32 = 14013;
32pub const OPE_GET_NB_COUPLED_STREAMS_REQUEST: u32 = 14015;
33pub type opus_int16 = i16;
34pub type opus_int32 = i32;
35pub type opus_uint32 = u32;
36#[doc = "Called for writing a page.\n\n# Arguments\n\n* `user_data` - user-defined data passed to the callback\n* `ptr` - buffer to be written\n* `len` - number of bytes to be written\n\n# Returns\n\nerror code\n\\retval 0 success\n\\retval 1 failure"]
37pub type ope_write_func = ::core::option::Option<
38 unsafe extern "C" fn(
39 user_data: *mut ::core::ffi::c_void,
40 ptr: *const ::core::ffi::c_uchar,
41 len: opus_int32,
42 ) -> ::core::ffi::c_int,
43>;
44#[doc = "Called for closing a stream.\n\n# Arguments\n\n* `user_data` - user-defined data passed to the callback\n\n# Returns\n\nerror code\n\\retval 0 success\n\\retval 1 failure"]
45pub type ope_close_func =
46 ::core::option::Option<unsafe extern "C" fn(user_data: *mut ::core::ffi::c_void) -> ::core::ffi::c_int>;
47#[doc = "Called on every packet encoded (including header).\n\n# Arguments\n\n* `user_data` - user-defined data passed to the callback\n* `packet_ptr` - packet data\n* `packet_len` - number of bytes in the packet\n* `flags` - optional flags (none defined for now so zero)"]
48pub type ope_packet_func = ::core::option::Option<
49 unsafe extern "C" fn(
50 user_data: *mut ::core::ffi::c_void,
51 packet_ptr: *const ::core::ffi::c_uchar,
52 packet_len: opus_int32,
53 flags: opus_uint32,
54 ),
55>;
56#[doc = "Callback functions for accessing the stream."]
57#[repr(C)]
58#[derive(Debug, Copy, Clone)]
59pub struct OpusEncCallbacks {
60 #[doc = "Callback for writing to the stream."]
61 pub write: ope_write_func,
62 #[doc = "Callback for closing the stream."]
63 pub close: ope_close_func,
64}
65#[repr(C)]
66#[derive(Debug, Copy, Clone)]
67pub struct OggOpusComments {
68 _unused: [u8; 0],
69}
70#[repr(C)]
71#[derive(Debug, Copy, Clone)]
72pub struct OggOpusEnc {
73 _unused: [u8; 0],
74}
75unsafe extern "C" {
76 #[doc = "Create a new comments object.\n\n# Returns\n\nNewly-created comments object."]
77 pub fn ope_comments_create() -> *mut OggOpusComments;
78 #[doc = "Create a deep copy of a comments object.\n\n# Arguments\n\n* `comments` - Comments object to copy\n\n# Returns\n\nDeep copy of input."]
79 pub fn ope_comments_copy(comments: *mut OggOpusComments) -> *mut OggOpusComments;
80 #[doc = "Destroys a comments object.\n\n# Arguments\n\n* `comments` - Comments object to destroy"]
81 pub fn ope_comments_destroy(comments: *mut OggOpusComments);
82 #[doc = "Add a comment.\n\n# Arguments\n\n* `comments` [in,out] - Where to add the comments\n* `tag` - Tag for the comment (must not contain = char)\n* `val` - Value for the tag\n\n# Returns\n\nError code"]
83 pub fn ope_comments_add(
84 comments: *mut OggOpusComments,
85 tag: *const ::core::ffi::c_char,
86 val: *const ::core::ffi::c_char,
87 ) -> ::core::ffi::c_int;
88 #[doc = "Add a comment as a single tag=value string.\n\n# Arguments\n\n* `comments` [in,out] - Where to add the comments\n* `tag_and_val` - string of the form tag=value (must contain = char)\n\n# Returns\n\nError code"]
89 pub fn ope_comments_add_string(
90 comments: *mut OggOpusComments,
91 tag_and_val: *const ::core::ffi::c_char,
92 ) -> ::core::ffi::c_int;
93 #[doc = "Add a picture from a file.\n\n# Arguments\n\n* `comments` [in,out] - Where to add the comments\n* `filename` - File name for the picture\n* `picture_type` - Type of picture (-1 for default)\n* `description` - Description (NULL means no comment)\n\n# Returns\n\nError code"]
94 pub fn ope_comments_add_picture(
95 comments: *mut OggOpusComments,
96 filename: *const ::core::ffi::c_char,
97 picture_type: ::core::ffi::c_int,
98 description: *const ::core::ffi::c_char,
99 ) -> ::core::ffi::c_int;
100 #[doc = "Add a picture already in memory.\n\n# Arguments\n\n* `comments` [in,out] - Where to add the comments\n* `ptr` - Pointer to picture in memory\n* `size` - Size of picture pointed to by ptr\n* `picture_type` - Type of picture (-1 for default)\n* `description` - Description (NULL means no comment)\n\n# Returns\n\nError code"]
101 pub fn ope_comments_add_picture_from_memory(
102 comments: *mut OggOpusComments,
103 ptr: *const ::core::ffi::c_char,
104 size: usize,
105 picture_type: ::core::ffi::c_int,
106 description: *const ::core::ffi::c_char,
107 ) -> ::core::ffi::c_int;
108 #[doc = "Create a new OggOpus file.\n\n# Arguments\n\n* `path` - Path where to create the file\n* `comments` - Comments associated with the stream\n* `rate` - Input sampling rate (48 kHz is faster)\n* `channels` - Number of channels\n* `family` - Mapping family (0 for mono/stereo, 1 for surround)\n* `error` [out] - Error code (NULL if no error is to be returned)\n\n# Returns\n\nNewly-created encoder."]
109 pub fn ope_encoder_create_file(
110 path: *const ::core::ffi::c_char,
111 comments: *mut OggOpusComments,
112 rate: opus_int32,
113 channels: ::core::ffi::c_int,
114 family: ::core::ffi::c_int,
115 error: *mut ::core::ffi::c_int,
116 ) -> *mut OggOpusEnc;
117 #[doc = "Create a new OggOpus stream to be handled using callbacks\n\n# Arguments\n\n* `callbacks` - Callback functions\n* `user_data` - Pointer to be associated with the stream and passed to the callbacks\n* `comments` - Comments associated with the stream\n* `rate` - Input sampling rate (48 kHz is faster)\n* `channels` - Number of channels\n* `family` - Mapping family (0 for mono/stereo, 1 for surround)\n* `error` [out] - Error code (NULL if no error is to be returned)\n\n# Returns\n\nNewly-created encoder."]
118 pub fn ope_encoder_create_callbacks(
119 callbacks: *const OpusEncCallbacks,
120 user_data: *mut ::core::ffi::c_void,
121 comments: *mut OggOpusComments,
122 rate: opus_int32,
123 channels: ::core::ffi::c_int,
124 family: ::core::ffi::c_int,
125 error: *mut ::core::ffi::c_int,
126 ) -> *mut OggOpusEnc;
127 #[doc = "Create a new OggOpus stream to be used along with.ope_encoder_get_page().\nThis is mostly useful for muxing with other streams.\n\n# Arguments\n\n* `comments` - Comments associated with the stream\n* `rate` - Input sampling rate (48 kHz is faster)\n* `channels` - Number of channels\n* `family` - Mapping family (0 for mono/stereo, 1 for surround)\n* `error` [out] - Error code (NULL if no error is to be returned)\n\n# Returns\n\nNewly-created encoder."]
128 pub fn ope_encoder_create_pull(
129 comments: *mut OggOpusComments,
130 rate: opus_int32,
131 channels: ::core::ffi::c_int,
132 family: ::core::ffi::c_int,
133 error: *mut ::core::ffi::c_int,
134 ) -> *mut OggOpusEnc;
135 #[doc = "Deferred initialization of the encoder to force an explicit channel mapping. This can be used to override the default channel coupling,\nbut using it for regular surround will almost certainly lead to worse quality.\n\n# Arguments\n\n* `enc` [in,out] - Encoder\n* `family` - Mapping family (0 for mono/stereo, 1 for surround)\n* `streams` - Total number of streams\n* `coupled_streams` - Number of coupled streams\n* `mapping` - Channel mapping\n\n# Returns\n\nError code"]
136 pub fn ope_encoder_deferred_init_with_mapping(
137 enc: *mut OggOpusEnc,
138 family: ::core::ffi::c_int,
139 streams: ::core::ffi::c_int,
140 coupled_streams: ::core::ffi::c_int,
141 mapping: *const ::core::ffi::c_uchar,
142 ) -> ::core::ffi::c_int;
143 #[doc = "Add/encode any number of float samples to the stream.\n\n# Arguments\n\n* `enc` [in,out] - Encoder\n* `pcm` - Floating-point PCM values in the +/-1 range (interleaved if multiple channels)\n* `samples_per_channel` - Number of samples for each channel\n\n# Returns\n\nError code"]
144 pub fn ope_encoder_write_float(
145 enc: *mut OggOpusEnc,
146 pcm: *const f32,
147 samples_per_channel: ::core::ffi::c_int,
148 ) -> ::core::ffi::c_int;
149 #[doc = "Add/encode any number of 16-bit linear samples to the stream.\n\n# Arguments\n\n* `enc` [in,out] - Encoder\n* `pcm` - Linear 16-bit PCM values in the [-32768,32767] range (interleaved if multiple channels)\n* `samples_per_channel` - Number of samples for each channel\n\n# Returns\n\nError code"]
150 pub fn ope_encoder_write(
151 enc: *mut OggOpusEnc,
152 pcm: *const opus_int16,
153 samples_per_channel: ::core::ffi::c_int,
154 ) -> ::core::ffi::c_int;
155 #[doc = "Get the next page from the stream (only if using ope_encoder_create_pull()).\n\n# Arguments\n\n* `enc` [in,out] - Encoder\n* `page` [out] - Next available encoded page\n* `len` [out] - Size (in bytes) of the page returned\n* `flush` - If non-zero, forces a flush of the page (if any data avaiable)\n\n# Returns\n\n1 if there is a page available, 0 if not."]
156 pub fn ope_encoder_get_page(
157 enc: *mut OggOpusEnc,
158 page: *mut *mut ::core::ffi::c_uchar,
159 len: *mut opus_int32,
160 flush: ::core::ffi::c_int,
161 ) -> ::core::ffi::c_int;
162 #[doc = "Finalizes the stream, but does not deallocate the object.\n\n# Arguments\n\n* `enc` [in,out] - Encoder\n\n# Returns\n\nError code"]
163 pub fn ope_encoder_drain(enc: *mut OggOpusEnc) -> ::core::ffi::c_int;
164 #[doc = "Deallocates the obect. Make sure to ope_drain() first.\n\n# Arguments\n\n* `enc` [in,out] - Encoder"]
165 pub fn ope_encoder_destroy(enc: *mut OggOpusEnc);
166 #[doc = "Ends the stream and create a new stream within the same file.\n\n# Arguments\n\n* `enc` [in,out] - Encoder\n* `comments` - Comments associated with the stream\n\n# Returns\n\nError code"]
167 pub fn ope_encoder_chain_current(enc: *mut OggOpusEnc, comments: *mut OggOpusComments) -> ::core::ffi::c_int;
168 #[doc = "Ends the stream and create a new file.\n\n# Arguments\n\n* `enc` [in,out] - Encoder\n* `path` - Path where to write the new file\n* `comments` - Comments associated with the stream\n\n# Returns\n\nError code"]
169 pub fn ope_encoder_continue_new_file(
170 enc: *mut OggOpusEnc,
171 path: *const ::core::ffi::c_char,
172 comments: *mut OggOpusComments,
173 ) -> ::core::ffi::c_int;
174 #[doc = "Ends the stream and create a new file (callback-based).\n\n# Arguments\n\n* `enc` [in,out] - Encoder\n* `user_data` - Pointer to be associated with the new stream and passed to the callbacks\n* `comments` - Comments associated with the stream\n\n# Returns\n\nError code"]
175 pub fn ope_encoder_continue_new_callbacks(
176 enc: *mut OggOpusEnc,
177 user_data: *mut ::core::ffi::c_void,
178 comments: *mut OggOpusComments,
179 ) -> ::core::ffi::c_int;
180 #[doc = "Write out the header now rather than wait for audio to begin.\n\n# Arguments\n\n* `enc` [in,out] - Encoder\n\n# Returns\n\nError code"]
181 pub fn ope_encoder_flush_header(enc: *mut OggOpusEnc) -> ::core::ffi::c_int;
182 #[doc = "Sets encoder options.\n\n# Arguments\n\n* `enc` [in,out] - Encoder\n* `request` - Use a request macro\n\n# Returns\n\nError code"]
183 pub fn ope_encoder_ctl(enc: *mut OggOpusEnc, request: ::core::ffi::c_int, ...) -> ::core::ffi::c_int;
184 #[doc = "Converts a libopusenc error code into a human readable string.\n\n# Arguments\n\n* `error` - Error number\n\n# Returns\n\nError string"]
185 pub fn ope_strerror(error: ::core::ffi::c_int) -> *const ::core::ffi::c_char;
186 #[doc = "Returns a string representing the version of libopusenc being used at run time.\n\n# Returns\n\nA string describing the version of this library"]
187 pub fn ope_get_version_string() -> *const ::core::ffi::c_char;
188 #[doc = "ABI version for this header. Can be used to check for features at run time.\n\n# Returns\n\nAn integer representing the ABI version"]
189 pub fn ope_get_abi_version() -> ::core::ffi::c_int;
190}