17 #if !defined(_opusfile_h)
18 # define _opusfile_h (1)
102 # if defined(__cplusplus)
108 # include <ogg/ogg.h>
109 # include <opus_multistream.h>
112 # if !defined(OP_GNUC_PREREQ)
113 # if defined(__GNUC__)&&defined(__GNUC_MINOR__)
114 # define OP_GNUC_PREREQ(_maj,_min) \
115 ((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min))
117 # define OP_GNUC_PREREQ(_maj,_min) 0
121 # if OP_GNUC_PREREQ(4,0)
122 # pragma GCC visibility push(default)
128 typedef struct OggOpusFile OggOpusFile;
131 # if OP_GNUC_PREREQ(3,4)
132 # define OP_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
134 # define OP_WARN_UNUSED_RESULT
136 # if OP_GNUC_PREREQ(3,4)
137 # define OP_ARG_NONNULL(_x) __attribute__((__nonnull__(_x)))
139 # define OP_ARG_NONNULL(_x)
153 #define OP_FALSE (-1)
161 #define OP_EREAD (-128)
165 #define OP_EFAULT (-129)
168 #define OP_EIMPL (-130)
170 #define OP_EINVAL (-131)
175 #define OP_ENOTFORMAT (-132)
178 #define OP_EBADHEADER (-133)
180 #define OP_EVERSION (-134)
182 #define OP_ENOTAUDIO (-135)
186 #define OP_EBADPACKET (-136)
190 #define OP_EBADLINK (-137)
192 #define OP_ENOSEEK (-138)
194 #define OP_EBADTIMESTAMP (-139)
203 #define OPUS_CHANNEL_COUNT_MAX (255)
310 #define OP_PIC_FORMAT_UNKNOWN (-1)
312 #define OP_PIC_FORMAT_URL (0)
314 #define OP_PIC_FORMAT_JPEG (1)
316 #define OP_PIC_FORMAT_PNG (2)
318 #define OP_PIC_FORMAT_GIF (3)
421 const unsigned char *_data,
size_t _len) OP_ARG_NONNULL(2);
455 const unsigned char *_data,
size_t _len) OP_ARG_NONNULL(2);
475 OP_ARG_NONNULL(1) OP_ARG_NONNULL(2) OP_ARG_NONNULL(3);
488 OP_ARG_NONNULL(1) OP_ARG_NONNULL(2);
506 OP_ARG_NONNULL(1) OP_ARG_NONNULL(2);
516 OP_ARG_NONNULL(1) OP_ARG_NONNULL(2);
534 OP_ARG_NONNULL(1) OP_ARG_NONNULL(2);
573 OP_ARG_NONNULL(1) OP_ARG_NONNULL(2);
606 #define OP_SSL_SKIP_CERTIFICATE_CHECK_REQUEST (6464)
607 #define OP_HTTP_PROXY_HOST_REQUEST (6528)
608 #define OP_HTTP_PROXY_PORT_REQUEST (6592)
609 #define OP_HTTP_PROXY_USER_REQUEST (6656)
610 #define OP_HTTP_PROXY_PASS_REQUEST (6720)
612 #define OP_URL_OPT(_request) ((_request)+(char *)0)
616 #define OP_CHECK_INT(_x) ((void)((_x)==(opus_int32)0),(opus_int32)(_x))
617 #define OP_CHECK_CONST_CHAR_PTR(_x) ((_x)+((_x)-(const char *)(_x)))
625 #define OP_SSL_SKIP_CERTIFICATE_CHECK(_b) \
626 OP_URL_OPT(OP_SSL_SKIP_CERTIFICATE_CHECK_REQUEST),OP_CHECK_INT(_b)
636 #define OP_HTTP_PROXY_HOST(_host) \
637 OP_URL_OPT(OP_HTTP_PROXY_HOST_REQUEST),OP_CHECK_CONST_CHAR_PTR(_host)
649 #define OP_HTTP_PROXY_PORT(_port) \
650 OP_URL_OPT(OP_HTTP_PROXY_PORT_REQUEST),OP_CHECK_INT(_port)
662 #define OP_HTTP_PROXY_USER(_user) \
663 OP_URL_OPT(OP_HTTP_PROXY_USER_REQUEST),OP_CHECK_CONST_CHAR_PTR(_host)
675 #define OP_HTTP_PROXY_PASS(_pass) \
676 OP_URL_OPT(OP_HTTP_PROXY_PASS_REQUEST),OP_CHECK_CONST_CHAR_PTR(_host)
703 typedef int (*
op_read_func)(
void *_stream,
unsigned char *_ptr,
int _nbytes);
714 typedef int (*
op_seek_func)(
void *_stream,opus_int64 _offset,
int _whence);
768 const char *_path,
const char *_mode) OP_ARG_NONNULL(1) OP_ARG_NONNULL(2)
785 int _fd,const
char *_mode) OP_ARG_NONNULL(1) OP_ARG_NONNULL(3);
807 const
char *_path,const
char *_mode,
void *_stream) OP_ARG_NONNULL(1)
808 OP_ARG_NONNULL(2) OP_ARG_NONNULL(3) OP_ARG_NONNULL(4);
821 const
unsigned char *_data,
size_t _size) OP_ARG_NONNULL(1);
842 const
char *_url,va_list _ap) OP_ARG_NONNULL(1) OP_ARG_NONNULL(2);
859 const
char *_url,...) OP_ARG_NONNULL(1) OP_ARG_NONNULL(2);
905 const
unsigned char *_initial_data,
size_t _initial_bytes);
916 OP_WARN_UNUSED_RESULT OggOpusFile *
op_open_file(const
char *_path,
int *_error)
927 OP_WARN_UNUSED_RESULT OggOpusFile *
op_open_memory(const
unsigned char *_data,
928 size_t _size,
int *_error);
951 OP_WARN_UNUSED_RESULT OggOpusFile *
op_vopen_url(const
char *_url,
952 int *_error,va_list _ap) OP_ARG_NONNULL(1);
970 OP_WARN_UNUSED_RESULT OggOpusFile *
op_open_url(const
char *_url,
971 int *_error,...) OP_ARG_NONNULL(1);
1052 size_t _initial_bytes,
int *_error) OP_ARG_NONNULL(2);
1064 OP_WARN_UNUSED_RESULT OggOpusFile *
op_test_file(const
char *_path,
int *_error)
1076 OP_WARN_UNUSED_RESULT OggOpusFile *
op_test_memory(const
unsigned char *_data,
1077 size_t _size,
int *_error);
1102 OP_WARN_UNUSED_RESULT OggOpusFile *
op_vtest_url(const
char *_url,
1103 int *_error,va_list _ap) OP_ARG_NONNULL(1);
1121 OP_WARN_UNUSED_RESULT OggOpusFile *
op_test_url(const
char *_url,
1122 int *_error,...) OP_ARG_NONNULL(1);
1189 size_t _initial_bytes,
int *_error) OP_ARG_NONNULL(2);
1221 void op_free(OggOpusFile *_of);
1258 int op_seekable(OggOpusFile *_of) OP_ARG_NONNULL(1);
1283 opus_uint32
op_serialno(OggOpusFile *_of,
int _li) OP_ARG_NONNULL(1);
1318 opus_int64
op_raw_total(OggOpusFile *_of,
int _li) OP_ARG_NONNULL(1);
1336 ogg_int64_t
op_pcm_total(OggOpusFile *_of,
int _li) OP_ARG_NONNULL(1);
1400 opus_int32
op_bitrate(OggOpusFile *_of,
int _li) OP_ARG_NONNULL(1);
1419 opus_int64
op_raw_tell(OggOpusFile *_of) OP_ARG_NONNULL(1);
1428 ogg_int64_t
op_pcm_tell(OggOpusFile *_of) OP_ARG_NONNULL(1);
1474 int op_raw_seek(OggOpusFile *_of,opus_int64 _byte_offset) OP_ARG_NONNULL(1);
1490 int op_pcm_seek(OggOpusFile *_of,ogg_int64_t _pcm_offset) OP_ARG_NONNULL(1);
1539 #define OP_HEADER_GAIN (0)
1543 #define OP_TRACK_GAIN (3008)
1547 #define OP_ABSOLUTE_GAIN (3009)
1567 int _gain_type,opus_int32 _gain_offset_q8);
1649 OP_WARN_UNUSED_RESULT
int op_read(OggOpusFile *_of,
1650 opus_int16 *_pcm,
int _buf_size,
int *_li) OP_ARG_NONNULL(1);
1731 float *_pcm,
int _buf_size,
int *_li) OP_ARG_NONNULL(1);
1792 opus_int16 *_pcm,
int _buf_size) OP_ARG_NONNULL(1);
1853 float *_pcm,
int _buf_size) OP_ARG_NONNULL(1);
1858 # if OP_GNUC_PREREQ(4,0)
1859 # pragma GCC visibility pop
1862 # if defined(__cplusplus)
int(* op_close_func)(void *_stream)
Closes the underlying stream.
Definition: opusfile.h:724
int op_test(OpusHead *_head, const unsigned char *_initial_data, size_t _initial_bytes)
Test to see if this is an Opus stream.
int op_set_gain_offset(OggOpusFile *_of, int _gain_type, opus_int32 _gain_offset_q8)
Sets the gain to be used for decoded output.
ogg_int64_t op_pcm_total(OggOpusFile *_of, int _li) OP_ARG_NONNULL(1)
Get the total PCM length (number of samples at 48 kHz) of the stream, or of an individual link in a (...
int coupled_count
The number of coupled Opus streams in each Ogg packet, in the range 0...127.
Definition: opusfile.h:252
op_tell_func tell
Used to return the current read position in the stream.
Definition: opusfile.h:744
opus_int32 type
The picture type according to the ID3v2 APIC frame:
Definition: opusfile.h:350
OP_WARN_UNUSED_RESULT OggOpusFile * op_open_callbacks(void *_source, const OpusFileCallbacks *_cb, const unsigned char *_initial_data, size_t _initial_bytes, int *_error) OP_ARG_NONNULL(2)
Open a stream using the given set of callbacks to access it.
OP_WARN_UNUSED_RESULT int op_read_stereo(OggOpusFile *_of, opus_int16 *_pcm, int _buf_size) OP_ARG_NONNULL(1)
Reads more samples from the stream and downmixes to stereo, if necessary.
OP_WARN_UNUSED_RESULT OggOpusFile * op_vopen_url(const char *_url, int *_error, va_list _ap) OP_ARG_NONNULL(1)
Open a stream from a URL.
void op_free(OggOpusFile *_of)
Release all memory used by an OggOpusFile.
OP_WARN_UNUSED_RESULT OggOpusFile * op_test_memory(const unsigned char *_data, size_t _size, int *_error)
Partially open a stream from a memory buffer.
const OpusHead * op_head(OggOpusFile *_of, int _li) OP_ARG_NONNULL(1)
Get the ID header information for the given link in a (possibly chained) Ogg Opus stream...
int version
The Ogg Opus format version, in the range 0...255.
Definition: opusfile.h:218
int mapping_family
The channel mapping family, in the range 0...255.
Definition: opusfile.h:243
int op_test_open(OggOpusFile *_of) OP_ARG_NONNULL(1)
Finish opening a stream partially opened with op_test_callbacks() or one of the associated convenienc...
unsigned char mapping[OPUS_CHANNEL_COUNT_MAX]
The mapping from coded stream channels to output channels.
Definition: opusfile.h:260
OP_WARN_UNUSED_RESULT int op_read_float_stereo(OggOpusFile *_of, float *_pcm, int _buf_size) OP_ARG_NONNULL(1)
Reads more samples from the stream and downmixes to stereo, if necessary.
OP_WARN_UNUSED_RESULT OggOpusFile * op_open_memory(const unsigned char *_data, size_t _size, int *_error)
Open a stream from a memory buffer.
const OpusTags * op_tags(OggOpusFile *_of, int _li) OP_ARG_NONNULL(1)
Get the comment header information for the given link in a (possibly chained) Ogg Opus stream...
opus_uint32 op_serialno(OggOpusFile *_of, int _li) OP_ARG_NONNULL(1)
Get the serial number of the given link in a (possibly-chained) Ogg Opus stream.
opus_uint32 depth
The color depth of the picture in bits-per-pixel (not bits-per-channel).
Definition: opusfile.h:366
int op_link_count(OggOpusFile *_of) OP_ARG_NONNULL(1)
Returns the number of links in this chained stream.
Ogg Opus bitstream information.
Definition: opusfile.h:208
int op_seekable(OggOpusFile *_of) OP_ARG_NONNULL(1)
Returns whether or not the data source being read is seekable.
int output_gain
The gain to apply to the decoded output, in dB, as a Q8 value in the range -32768...32767.
Definition: opusfile.h:236
opus_int32 op_bitrate_instant(OggOpusFile *_of) OP_ARG_NONNULL(1)
Compute the instantaneous bitrate, measured as the ratio of bits to playable samples decoded since a)...
int format
The format of the picture data, if known.
Definition: opusfile.h:383
opus_int64(* op_tell_func)(void *_stream)
Obtains the current value of the position indicator for _stream.
Definition: opusfile.h:718
opus_uint32 input_sample_rate
The sampling rate of the original input.
Definition: opusfile.h:230
int(* op_seek_func)(void *_stream, opus_int64 _offset, int _whence)
Sets the position indicator for _stream.
Definition: opusfile.h:714
opus_uint32 height
The height of the picture in pixels.
Definition: opusfile.h:363
opus_uint32 data_length
The length of the picture data in bytes.
Definition: opusfile.h:371
opus_uint32 colors
For indexed-color pictures (e.g., GIF), the number of colors used, or 0 for non-indexed pictures...
Definition: opusfile.h:369
int op_current_link(OggOpusFile *_of) OP_ARG_NONNULL(1)
Retrieve the index of the current link.
OP_WARN_UNUSED_RESULT void * op_url_stream_create(OpusFileCallbacks *_cb, const char *_url,...) OP_ARG_NONNULL(1) OP_ARG_NONNULL(2)
Creates a stream that reads from the given URL using the specified proxy.
opus_uint32 width
The width of the picture in pixels.
Definition: opusfile.h:361
OP_WARN_UNUSED_RESULT void * op_fdopen(OpusFileCallbacks *_cb, int _fd, const char *_mode) OP_ARG_NONNULL(1) OP_ARG_NONNULL(3)
Opens a stream with fdopen() and fills in a set of callbacks that can be used to access it...
The contents of a METADATA_BLOCK_PICTURE tag.
Definition: opusfile.h:323
OP_WARN_UNUSED_RESULT void * op_fopen(OpusFileCallbacks *_cb, const char *_path, const char *_mode) OP_ARG_NONNULL(1) OP_ARG_NONNULL(2) OP_ARG_NONNULL(3)
Opens a stream with fopen() and fills in a set of callbacks that can be used to access it...
The callbacks used to access non-FILE stream resources.
Definition: opusfile.h:735
opus_int64 op_raw_tell(OggOpusFile *_of) OP_ARG_NONNULL(1)
Obtain the current value of the position indicator for _of.
char * mime_type
The MIME type of the picture, in printable ASCII characters 0x20-0x7E.
Definition: opusfile.h:357
OP_WARN_UNUSED_RESULT OggOpusFile * op_test_url(const char *_url, int *_error,...) OP_ARG_NONNULL(1)
Partially open a stream from a URL.
char * description
The description of the picture, in UTF-8.
Definition: opusfile.h:359
OP_WARN_UNUSED_RESULT OggOpusFile * op_open_file(const char *_path, int *_error) OP_ARG_NONNULL(1)
Open a stream from the given file path.
OP_WARN_UNUSED_RESULT void * op_freopen(OpusFileCallbacks *_cb, const char *_path, const char *_mode, void *_stream) OP_ARG_NONNULL(1) OP_ARG_NONNULL(2) OP_ARG_NONNULL(3) OP_ARG_NONNULL(4)
Opens a stream with freopen() and fills in a set of callbacks that can be used to access it...
int op_raw_seek(OggOpusFile *_of, opus_int64 _byte_offset) OP_ARG_NONNULL(1)
Seek to a byte offset relative to the compressed data.
OP_WARN_UNUSED_RESULT void * op_url_stream_vcreate(OpusFileCallbacks *_cb, const char *_url, va_list _ap) OP_ARG_NONNULL(1) OP_ARG_NONNULL(2)
Creates a stream that reads from the given URL.
int op_channel_count(OggOpusFile *_of, int _li) OP_ARG_NONNULL(1)
Get the channel count of the given link in a (possibly-chained) Ogg Opus stream.
opus_int64 op_raw_total(OggOpusFile *_of, int _li) OP_ARG_NONNULL(1)
Get the total (compressed) size of the stream, or of an individual link in a (possibly-chained) Ogg O...
op_read_func read
Used to read data from the stream.
Definition: opusfile.h:738
OP_WARN_UNUSED_RESULT OggOpusFile * op_test_file(const char *_path, int *_error) OP_ARG_NONNULL(1)
Partially open a stream from the given file path.
int op_pcm_seek(OggOpusFile *_of, ogg_int64_t _pcm_offset) OP_ARG_NONNULL(1)
Seek to the specified PCM offset, such that decoding will begin at exactly the requested position...
ogg_int64_t op_pcm_tell(OggOpusFile *_of) OP_ARG_NONNULL(1)
Obtain the PCM offset of the next sample to be read.
op_close_func close
Used to close the stream when the decoder is freed.
Definition: opusfile.h:747
op_seek_func seek
Used to seek in the stream.
Definition: opusfile.h:741
OP_WARN_UNUSED_RESULT void * op_mem_stream_create(OpusFileCallbacks *_cb, const unsigned char *_data, size_t _size) OP_ARG_NONNULL(1)
Creates a stream that reads from the given block of memory.
unsigned char * data
The binary picture data.
Definition: opusfile.h:373
opus_int32 op_bitrate(OggOpusFile *_of, int _li) OP_ARG_NONNULL(1)
Computes the bitrate for a given link in a (possibly chained) Ogg Opus stream.
int stream_count
The number of Opus streams in each Ogg packet, in the range 1...255.
Definition: opusfile.h:245
OP_WARN_UNUSED_RESULT int op_read_float(OggOpusFile *_of, float *_pcm, int _buf_size, int *_li) OP_ARG_NONNULL(1)
Reads more samples from the stream.
int(* op_read_func)(void *_stream, unsigned char *_ptr, int _nbytes)
Reads up to _nbytes bytes of data from _stream.
Definition: opusfile.h:703
OP_WARN_UNUSED_RESULT int op_read(OggOpusFile *_of, opus_int16 *_pcm, int _buf_size, int *_li) OP_ARG_NONNULL(1)
Reads more samples from the stream.
int channel_count
The number of channels, in the range 1...255.
Definition: opusfile.h:220
OP_WARN_UNUSED_RESULT OggOpusFile * op_test_callbacks(void *_source, const OpusFileCallbacks *_cb, const unsigned char *_initial_data, size_t _initial_bytes, int *_error) OP_ARG_NONNULL(2)
Partially open a stream using the given set of callbacks to access it.
OP_WARN_UNUSED_RESULT OggOpusFile * op_vtest_url(const char *_url, int *_error, va_list _ap) OP_ARG_NONNULL(1)
Partially open a stream from a URL.
OP_WARN_UNUSED_RESULT OggOpusFile * op_open_url(const char *_url, int *_error,...) OP_ARG_NONNULL(1)
Open a stream from a URL.
unsigned pre_skip
The number of samples that should be discarded from the beginning of the stream.
Definition: opusfile.h:223