libopusenc  0.2.1-13-gdc6ab59
Stand-alone encoder library for .opus files.
Encoding

Functions for encoding Ogg Opus files

These functions make it possible to encode Ogg Opus files.

OPE_EXPORT OggOpusEnc * ope_encoder_create_file (const char *path, OggOpusComments *comments, opus_int32 rate, int channels, int family, int *error)
 Create a new OggOpus file. More...
 
OPE_EXPORT OggOpusEnc * ope_encoder_create_callbacks (const OpusEncCallbacks *callbacks, void *user_data, OggOpusComments *comments, opus_int32 rate, int channels, int family, int *error)
 Create a new OggOpus stream to be handled using callbacks. More...
 
OPE_EXPORT OggOpusEnc * ope_encoder_create_pull (OggOpusComments *comments, opus_int32 rate, int channels, int family, int *error)
 Create a new OggOpus stream to be used along with.ope_encoder_get_page(). More...
 
OPE_EXPORT int ope_encoder_deferred_init_with_mapping (OggOpusEnc *enc, int family, int streams, int coupled_streams, const unsigned char *mapping)
 Deferred initialization of the encoder to force an explicit channel mapping. More...
 
OPE_EXPORT int ope_encoder_write_float (OggOpusEnc *enc, const float *pcm, int samples_per_channel)
 Add/encode any number of float samples to the stream. More...
 
OPE_EXPORT int ope_encoder_write (OggOpusEnc *enc, const opus_int16 *pcm, int samples_per_channel)
 Add/encode any number of 16-bit linear samples to the stream. More...
 
OPE_EXPORT int ope_encoder_get_page (OggOpusEnc *enc, unsigned char **page, opus_int32 *len, int flush)
 Get the next page from the stream (only if using ope_encoder_create_pull()). More...
 
OPE_EXPORT int ope_encoder_drain (OggOpusEnc *enc)
 Finalizes the stream, but does not deallocate the object. More...
 
OPE_EXPORT void ope_encoder_destroy (OggOpusEnc *enc)
 Deallocates the obect. More...
 
OPE_EXPORT int ope_encoder_chain_current (OggOpusEnc *enc, OggOpusComments *comments)
 Ends the stream and create a new stream within the same file. More...
 
OPE_EXPORT int ope_encoder_continue_new_file (OggOpusEnc *enc, const char *path, OggOpusComments *comments)
 Ends the stream and create a new file. More...
 
OPE_EXPORT int ope_encoder_continue_new_callbacks (OggOpusEnc *enc, void *user_data, OggOpusComments *comments)
 Ends the stream and create a new file (callback-based). More...
 
OPE_EXPORT int ope_encoder_flush_header (OggOpusEnc *enc)
 Write out the header now rather than wait for audio to begin. More...
 
OPE_EXPORT int ope_encoder_ctl (OggOpusEnc *enc, int request,...)
 Sets encoder options. More...
 
OPE_EXPORT const char * ope_strerror (int error)
 Converts a libopusenc error code into a human readable string. More...
 
OPE_EXPORT const char * ope_get_version_string (void)
 Returns a string representing the version of libopusenc being used at run time. More...
 
OPE_EXPORT int ope_get_abi_version (void)
 ABI version for this header. More...
 

Detailed Description

Function Documentation

◆ ope_encoder_create_file()

OPE_EXPORT OggOpusEnc* ope_encoder_create_file ( const char *  path,
OggOpusComments *  comments,
opus_int32  rate,
int  channels,
int  family,
int *  error 
)

Create a new OggOpus file.

Parameters
pathPath where to create the file
commentsComments associated with the stream
rateInput sampling rate (48 kHz is faster)
channelsNumber of channels
familyMapping family (0 for mono/stereo, 1 for surround)
[out]errorError code (NULL if no error is to be returned)
Returns
Newly-created encoder.

◆ ope_encoder_create_callbacks()

OPE_EXPORT OggOpusEnc* ope_encoder_create_callbacks ( const OpusEncCallbacks callbacks,
void *  user_data,
OggOpusComments *  comments,
opus_int32  rate,
int  channels,
int  family,
int *  error 
)

Create a new OggOpus stream to be handled using callbacks.

Parameters
callbacksCallback functions
user_dataPointer to be associated with the stream and passed to the callbacks
commentsComments associated with the stream
rateInput sampling rate (48 kHz is faster)
channelsNumber of channels
familyMapping family (0 for mono/stereo, 1 for surround)
[out]errorError code (NULL if no error is to be returned)
Returns
Newly-created encoder.

◆ ope_encoder_create_pull()

OPE_EXPORT OggOpusEnc* ope_encoder_create_pull ( OggOpusComments *  comments,
opus_int32  rate,
int  channels,
int  family,
int *  error 
)

Create a new OggOpus stream to be used along with.ope_encoder_get_page().

This is mostly useful for muxing with other streams.

Parameters
commentsComments associated with the stream
rateInput sampling rate (48 kHz is faster)
channelsNumber of channels
familyMapping family (0 for mono/stereo, 1 for surround)
[out]errorError code (NULL if no error is to be returned)
Returns
Newly-created encoder.

◆ ope_encoder_deferred_init_with_mapping()

OPE_EXPORT int ope_encoder_deferred_init_with_mapping ( OggOpusEnc *  enc,
int  family,
int  streams,
int  coupled_streams,
const unsigned char *  mapping 
)

Deferred initialization of the encoder to force an explicit channel mapping.

This can be used to override the default channel coupling, but using it for regular surround will almost certainly lead to worse quality.

Parameters
[in,out]encEncoder
familyMapping family (0 for mono/stereo, 1 for surround)
streamsTotal number of streams
coupled_streamsNumber of coupled streams
mappingChannel mapping
Returns
Error code

◆ ope_encoder_write_float()

OPE_EXPORT int ope_encoder_write_float ( OggOpusEnc *  enc,
const float *  pcm,
int  samples_per_channel 
)

Add/encode any number of float samples to the stream.

Parameters
[in,out]encEncoder
pcmFloating-point PCM values in the +/-1 range (interleaved if multiple channels)
samples_per_channelNumber of samples for each channel
Returns
Error code

◆ ope_encoder_write()

OPE_EXPORT int ope_encoder_write ( OggOpusEnc *  enc,
const opus_int16 *  pcm,
int  samples_per_channel 
)

Add/encode any number of 16-bit linear samples to the stream.

Parameters
[in,out]encEncoder
pcmLinear 16-bit PCM values in the [-32768,32767] range (interleaved if multiple channels)
samples_per_channelNumber of samples for each channel
Returns
Error code

◆ ope_encoder_get_page()

OPE_EXPORT int ope_encoder_get_page ( OggOpusEnc *  enc,
unsigned char **  page,
opus_int32 *  len,
int  flush 
)

Get the next page from the stream (only if using ope_encoder_create_pull()).

Parameters
[in,out]encEncoder
[out]pageNext available encoded page
[out]lenSize (in bytes) of the page returned
flushIf non-zero, forces a flush of the page (if any data avaiable)
Returns
1 if there is a page available, 0 if not.

◆ ope_encoder_drain()

OPE_EXPORT int ope_encoder_drain ( OggOpusEnc *  enc)

Finalizes the stream, but does not deallocate the object.

Parameters
[in,out]encEncoder
Returns
Error code

◆ ope_encoder_destroy()

OPE_EXPORT void ope_encoder_destroy ( OggOpusEnc *  enc)

Deallocates the obect.

Make sure to ope_drain() first.

Parameters
[in,out]encEncoder

◆ ope_encoder_chain_current()

OPE_EXPORT int ope_encoder_chain_current ( OggOpusEnc *  enc,
OggOpusComments *  comments 
)

Ends the stream and create a new stream within the same file.

Parameters
[in,out]encEncoder
commentsComments associated with the stream
Returns
Error code

◆ ope_encoder_continue_new_file()

OPE_EXPORT int ope_encoder_continue_new_file ( OggOpusEnc *  enc,
const char *  path,
OggOpusComments *  comments 
)

Ends the stream and create a new file.

Parameters
[in,out]encEncoder
pathPath where to write the new file
commentsComments associated with the stream
Returns
Error code

◆ ope_encoder_continue_new_callbacks()

OPE_EXPORT int ope_encoder_continue_new_callbacks ( OggOpusEnc *  enc,
void *  user_data,
OggOpusComments *  comments 
)

Ends the stream and create a new file (callback-based).

Parameters
[in,out]encEncoder
user_dataPointer to be associated with the new stream and passed to the callbacks
commentsComments associated with the stream
Returns
Error code

◆ ope_encoder_flush_header()

OPE_EXPORT int ope_encoder_flush_header ( OggOpusEnc *  enc)

Write out the header now rather than wait for audio to begin.

Parameters
[in,out]encEncoder
Returns
Error code

◆ ope_encoder_ctl()

OPE_EXPORT int ope_encoder_ctl ( OggOpusEnc *  enc,
int  request,
  ... 
)

Sets encoder options.

Parameters
[in,out]encEncoder
requestUse a request macro
Returns
Error code

◆ ope_strerror()

OPE_EXPORT const char* ope_strerror ( int  error)

Converts a libopusenc error code into a human readable string.

Parameters
errorError number
Returns
Error string

◆ ope_get_version_string()

OPE_EXPORT const char* ope_get_version_string ( void  )

Returns a string representing the version of libopusenc being used at run time.

Returns
A string describing the version of this library

◆ ope_get_abi_version()

OPE_EXPORT int ope_get_abi_version ( void  )

ABI version for this header.

Can be used to check for features at run time.

Returns
An integer representing the ABI version