17 #if !defined(_opusfile_h)
18 # define _opusfile_h (1)
103 # if defined(__cplusplus)
109 # include <ogg/ogg.h>
110 # include <opus_multistream.h>
115 # if !defined(OP_GNUC_PREREQ)
116 # if defined(__GNUC__)&&defined(__GNUC_MINOR__)
117 # define OP_GNUC_PREREQ(_maj,_min) \
118 ((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min))
120 # define OP_GNUC_PREREQ(_maj,_min) 0
124 # if OP_GNUC_PREREQ(4,0)
125 # pragma GCC visibility push(default)
133 typedef struct OggOpusFile OggOpusFile;
136 # if OP_GNUC_PREREQ(3,4)
137 # define OP_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
139 # define OP_WARN_UNUSED_RESULT
141 # if OP_GNUC_PREREQ(3,4)
142 # define OP_ARG_NONNULL(_x) __attribute__((__nonnull__(_x)))
144 # define OP_ARG_NONNULL(_x)
160 #define OP_FALSE (-1)
168 #define OP_EREAD (-128)
172 #define OP_EFAULT (-129)
175 #define OP_EIMPL (-130)
177 #define OP_EINVAL (-131)
182 #define OP_ENOTFORMAT (-132)
185 #define OP_EBADHEADER (-133)
187 #define OP_EVERSION (-134)
189 #define OP_ENOTAUDIO (-135)
193 #define OP_EBADPACKET (-136)
197 #define OP_EBADLINK (-137)
199 #define OP_ENOSEEK (-138)
201 #define OP_EBADTIMESTAMP (-139)
210 #define OPUS_CHANNEL_COUNT_MAX (255)
317 #define OP_PIC_FORMAT_UNKNOWN (-1)
319 #define OP_PIC_FORMAT_URL (0)
321 #define OP_PIC_FORMAT_JPEG (1)
323 #define OP_PIC_FORMAT_PNG (2)
325 #define OP_PIC_FORMAT_GIF (3)
428 const unsigned char *_data,
size_t _len) OP_ARG_NONNULL(2);
462 const unsigned char *_data,
size_t _len) OP_ARG_NONNULL(2);
491 OP_ARG_NONNULL(1) OP_ARG_NONNULL(2) OP_ARG_NONNULL(3);
504 OP_ARG_NONNULL(1) OP_ARG_NONNULL(2);
520 const
unsigned char *_data,
int _len) OP_ARG_NONNULL(1);
538 OP_ARG_NONNULL(1) OP_ARG_NONNULL(2);
548 OP_ARG_NONNULL(1) OP_ARG_NONNULL(2);
556 int *_len) OP_ARG_NONNULL(1) OP_ARG_NONNULL(2);
574 OP_ARG_NONNULL(1) OP_ARG_NONNULL(2);
592 OP_ARG_NONNULL(1) OP_ARG_NONNULL(2);
625 int opus_tagncompare(const
char *_tag_name,
int _tag_len,const
char *_comment);
658 const
char *_tag) OP_ARG_NONNULL(1) OP_ARG_NONNULL(2);
693 #define OP_SSL_SKIP_CERTIFICATE_CHECK_REQUEST (6464)
694 #define OP_HTTP_PROXY_HOST_REQUEST (6528)
695 #define OP_HTTP_PROXY_PORT_REQUEST (6592)
696 #define OP_HTTP_PROXY_USER_REQUEST (6656)
697 #define OP_HTTP_PROXY_PASS_REQUEST (6720)
698 #define OP_GET_SERVER_INFO_REQUEST (6784)
700 #define OP_URL_OPT(_request) ((_request)+(char *)0)
704 #define OP_CHECK_INT(_x) ((void)((_x)==(opus_int32)0),(opus_int32)(_x))
705 #define OP_CHECK_CONST_CHAR_PTR(_x) ((_x)+((_x)-(const char *)(_x)))
706 #define OP_CHECK_SERVER_INFO_PTR(_x) ((_x)+((_x)-(OpusServerInfo *)(_x)))
771 #define OP_SSL_SKIP_CERTIFICATE_CHECK(_b) \
772 OP_URL_OPT(OP_SSL_SKIP_CERTIFICATE_CHECK_REQUEST),OP_CHECK_INT(_b)
782 #define OP_HTTP_PROXY_HOST(_host) \
783 OP_URL_OPT(OP_HTTP_PROXY_HOST_REQUEST),OP_CHECK_CONST_CHAR_PTR(_host)
795 #define OP_HTTP_PROXY_PORT(_port) \
796 OP_URL_OPT(OP_HTTP_PROXY_PORT_REQUEST),OP_CHECK_INT(_port)
808 #define OP_HTTP_PROXY_USER(_user) \
809 OP_URL_OPT(OP_HTTP_PROXY_USER_REQUEST),OP_CHECK_CONST_CHAR_PTR(_user)
821 #define OP_HTTP_PROXY_PASS(_pass) \
822 OP_URL_OPT(OP_HTTP_PROXY_PASS_REQUEST),OP_CHECK_CONST_CHAR_PTR(_pass)
842 #define OP_GET_SERVER_INFO(_info) \
843 OP_URL_OPT(OP_GET_SERVER_INFO_REQUEST),OP_CHECK_SERVER_INFO_PTR(_info)
868 typedef int (*
op_read_func)(
void *_stream,
unsigned char *_ptr,
int _nbytes);
879 typedef int (*
op_seek_func)(
void *_stream,opus_int64 _offset,
int _whence);
933 const char *_path,
const char *_mode) OP_ARG_NONNULL(1) OP_ARG_NONNULL(2)
950 int _fd,const
char *_mode) OP_ARG_NONNULL(1) OP_ARG_NONNULL(3);
972 const
char *_path,const
char *_mode,
void *_stream) OP_ARG_NONNULL(1)
973 OP_ARG_NONNULL(2) OP_ARG_NONNULL(3) OP_ARG_NONNULL(4);
986 const
unsigned char *_data,
size_t _size) OP_ARG_NONNULL(1);
1012 const
char *_url,va_list _ap) OP_ARG_NONNULL(1) OP_ARG_NONNULL(2);
1034 const
char *_url,...) OP_ARG_NONNULL(1) OP_ARG_NONNULL(2);
1080 const
unsigned char *_initial_data,
size_t _initial_bytes);
1091 OP_WARN_UNUSED_RESULT OggOpusFile *
op_open_file(const
char *_path,
int *_error)
1102 OP_WARN_UNUSED_RESULT OggOpusFile *
op_open_memory(const
unsigned char *_data,
1103 size_t _size,
int *_error);
1131 OP_WARN_UNUSED_RESULT OggOpusFile *
op_vopen_url(const
char *_url,
1132 int *_error,va_list _ap) OP_ARG_NONNULL(1);
1153 OP_WARN_UNUSED_RESULT OggOpusFile *
op_open_url(const
char *_url,
1154 int *_error,...) OP_ARG_NONNULL(1);
1235 size_t _initial_bytes,
int *_error) OP_ARG_NONNULL(2);
1247 OP_WARN_UNUSED_RESULT OggOpusFile *
op_test_file(const
char *_path,
int *_error)
1259 OP_WARN_UNUSED_RESULT OggOpusFile *
op_test_memory(const
unsigned char *_data,
1260 size_t _size,
int *_error);
1290 OP_WARN_UNUSED_RESULT OggOpusFile *
op_vtest_url(const
char *_url,
1291 int *_error,va_list _ap) OP_ARG_NONNULL(1);
1314 OP_WARN_UNUSED_RESULT OggOpusFile *
op_test_url(const
char *_url,
1315 int *_error,...) OP_ARG_NONNULL(1);
1382 size_t _initial_bytes,
int *_error) OP_ARG_NONNULL(2);
1414 void op_free(OggOpusFile *_of);
1451 int op_seekable(const OggOpusFile *_of) OP_ARG_NONNULL(1);
1461 int op_link_count(const OggOpusFile *_of) OP_ARG_NONNULL(1);
1476 opus_uint32
op_serialno(const OggOpusFile *_of,
int _li) OP_ARG_NONNULL(1);
1515 opus_int64
op_raw_total(const OggOpusFile *_of,
int _li) OP_ARG_NONNULL(1);
1533 ogg_int64_t
op_pcm_total(const OggOpusFile *_of,
int _li) OP_ARG_NONNULL(1);
1549 const
OpusHead *
op_head(const OggOpusFile *_of,
int _li) OP_ARG_NONNULL(1);
1567 const
OpusTags *
op_tags(const OggOpusFile *_of,
int _li) OP_ARG_NONNULL(1);
1606 opus_int32
op_bitrate(const OggOpusFile *_of,
int _li) OP_ARG_NONNULL(1);
1625 opus_int64
op_raw_tell(const OggOpusFile *_of) OP_ARG_NONNULL(1);
1634 ogg_int64_t
op_pcm_tell(const OggOpusFile *_of) OP_ARG_NONNULL(1);
1680 int op_raw_seek(OggOpusFile *_of,opus_int64 _byte_offset) OP_ARG_NONNULL(1);
1696 int op_pcm_seek(OggOpusFile *_of,ogg_int64_t _pcm_offset) OP_ARG_NONNULL(1);
1744 #define OP_DEC_FORMAT_SHORT (7008)
1747 #define OP_DEC_FORMAT_FLOAT (7040)
1751 #define OP_DEC_USE_DEFAULT (6720)
1784 const ogg_packet *_op,
int _nsamples,
int _nchannels,
int _format,
int _li);
1805 #define OP_HEADER_GAIN (0)
1809 #define OP_ALBUM_GAIN (3007)
1813 #define OP_TRACK_GAIN (3008)
1817 #define OP_ABSOLUTE_GAIN (3009)
1837 int _gain_type,opus_int32 _gain_offset_q8) OP_ARG_NONNULL(1);
1931 OP_WARN_UNUSED_RESULT
int op_read(OggOpusFile *_of,
1932 opus_int16 *_pcm,
int _buf_size,
int *_li) OP_ARG_NONNULL(1);
2013 float *_pcm,
int _buf_size,
int *_li) OP_ARG_NONNULL(1);
2074 opus_int16 *_pcm,
int _buf_size) OP_ARG_NONNULL(1);
2135 float *_pcm,
int _buf_size) OP_ARG_NONNULL(1);
2140 # if OP_GNUC_PREREQ(4,0)
2141 # pragma GCC visibility pop
2144 # if defined(__cplusplus)
int op_test(OpusHead *_head, const unsigned char *_initial_data, size_t _initial_bytes)
Test to see if this is an Opus stream.
int coupled_count
The number of coupled Opus streams in each Ogg packet, in the range 0...127.
Definition: opusfile.h:259
op_tell_func tell
Used to return the current read position in the stream.
Definition: opusfile.h:909
ogg_int64_t op_pcm_tell(const OggOpusFile *_of) OP_ARG_NONNULL(1)
Obtain the PCM offset of the next sample to be read.
opus_int32 bitrate_kbps
The nominal stream bitrate in kbps (icy-br/ice-bitrate).
Definition: opusfile.h:738
char * genre
The genre the server falls under (icy-genre/ice-genre).
Definition: opusfile.h:723
int(* op_seek_func)(void *_stream, opus_int64 _offset, int _whence)
Sets the position indicator for _stream.
Definition: opusfile.h:879
opus_int32 type
The picture type according to the ID3v2 APIC frame:
Definition: opusfile.h:357
int op_channel_count(const OggOpusFile *_of, int _li) OP_ARG_NONNULL(1)
Get the channel count of the given link in a (possibly-chained) Ogg Opus stream.
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.
int(* op_decode_cb_func)(void *_ctx, OpusMSDecoder *_decoder, void *_pcm, const ogg_packet *_op, int _nsamples, int _nchannels, int _format, int _li)
Called to decode an Opus packet.
Definition: opusfile.h:1783
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.
HTTP/Shoutcast/Icecast server information associated with a URL.
Definition: opusfile.h:711
int version
The Ogg Opus format version, in the range 0...255.
Definition: opusfile.h:225
int mapping_family
The channel mapping family, in the range 0...255.
Definition: opusfile.h:250
const OpusHead * op_head(const 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 op_current_link(const OggOpusFile *_of) OP_ARG_NONNULL(1)
Retrieve the index of the current link.
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:267
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.
opus_uint32 depth
The color depth of the picture in bits-per-pixel (not bits-per-channel).
Definition: opusfile.h:373
char * url
The homepage for the server (icy-url/ice-url).
Definition: opusfile.h:727
opus_int64 op_raw_total(const 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...
opus_uint32 op_serialno(const OggOpusFile *_of, int _li) OP_ARG_NONNULL(1)
Get the serial number of the given link in a (possibly-chained) Ogg Opus stream.
Ogg Opus bitstream information.
Definition: opusfile.h:215
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:243
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:390
const OpusTags * op_tags(const OggOpusFile *_of, int _li) OP_ARG_NONNULL(1)
Get the comment header information for the given link in a (possibly chained) Ogg Opus stream...
int is_public
Flag indicating whether the server is public (1) or not (0) (icy-pub/ice-public). ...
Definition: opusfile.h:743
opus_uint32 input_sample_rate
The sampling rate of the original input.
Definition: opusfile.h:237
ogg_int64_t op_pcm_total(const 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 (...
opus_uint32 height
The height of the picture in pixels.
Definition: opusfile.h:370
char * server
The software used by the origin server (Server).
Definition: opusfile.h:730
opus_uint32 data_length
The length of the picture data in bytes.
Definition: opusfile.h:378
opus_uint32 colors
For indexed-color pictures (e.g., GIF), the number of colors used, or 0 for non-indexed pictures...
Definition: opusfile.h:376
void opus_server_info_clear(OpusServerInfo *_info) OP_ARG_NONNULL(1)
Clears the OpusServerInfo structure.
opus_int64 op_raw_tell(const OggOpusFile *_of) OP_ARG_NONNULL(1)
Obtain the current value of the position indicator for _of.
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.
opus_uint32 width
The width of the picture in pixels.
Definition: opusfile.h:368
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...
void opus_server_info_init(OpusServerInfo *_info) OP_ARG_NONNULL(1)
Initializes an OpusServerInfo structure.
The contents of a METADATA_BLOCK_PICTURE tag.
Definition: opusfile.h:330
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...
int op_set_gain_offset(OggOpusFile *_of, int _gain_type, opus_int32 _gain_offset_q8) OP_ARG_NONNULL(1)
Sets the gain to be used for decoded output.
The callbacks used to access non-FILE stream resources.
Definition: opusfile.h:900
char * mime_type
The MIME type of the picture, in printable ASCII characters 0x20-0x7E.
Definition: opusfile.h:364
OP_WARN_UNUSED_RESULT OggOpusFile * op_test_url(const char *_url, int *_error,...) OP_ARG_NONNULL(1)
Partially open a stream from a URL.
int op_seekable(const OggOpusFile *_of) OP_ARG_NONNULL(1)
Returns whether or not the data source being read is seekable.
char * description
The description of the picture, in UTF-8.
Definition: opusfile.h:366
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_read_func)(void *_stream, unsigned char *_ptr, int _nbytes)
Reads up to _nbytes bytes of data from _stream.
Definition: opusfile.h:868
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.
void op_set_decode_callback(OggOpusFile *_of, op_decode_cb_func _decode_cb, void *_ctx) OP_ARG_NONNULL(1)
Sets the packet decode callback function.
op_read_func read
Used to read data from the stream.
Definition: opusfile.h:903
void op_set_dither_enabled(OggOpusFile *_of, int _enabled) OP_ARG_NONNULL(1)
Sets whether or not dithering is enabled for 16-bit decoding.
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...
op_close_func close
Used to close the stream when the decoder is freed.
Definition: opusfile.h:912
op_seek_func seek
Used to seek in the stream.
Definition: opusfile.h:906
char * content_type
The media type of the entity sent to the recepient (Content-Type).
Definition: opusfile.h:734
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:380
opus_int32 op_bitrate(const OggOpusFile *_of, int _li) OP_ARG_NONNULL(1)
Computes the bitrate of the stream, or of an individual 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:252
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_close_func)(void *_stream)
Closes the underlying stream.
Definition: opusfile.h:889
opus_int64(* op_tell_func)(void *_stream)
Obtains the current value of the position indicator for _stream.
Definition: opusfile.h:883
int is_ssl
Flag indicating whether the server is using HTTPS instead of HTTP.
Definition: opusfile.h:748
char * name
The name of the server (icy-name/ice-name).
Definition: opusfile.h:715
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:227
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.
char * description
A short description of the server (icy-description/ice-description).
Definition: opusfile.h:719
int op_link_count(const OggOpusFile *_of) OP_ARG_NONNULL(1)
Returns the number of links in this chained stream.
unsigned pre_skip
The number of samples that should be discarded from the beginning of the stream.
Definition: opusfile.h:230