Package org.lwjgl.util.opus
Class OpusEnc
- java.lang.Object
-
- org.lwjgl.util.opus.OpusEnc
-
public class OpusEnc extends java.lang.ObjectThis is the documentation for the libopusenc C API.The
libopusencpackage provides a convenient high-level API for encoding Ogg Opus files.Organization
The main API is divided into several sections:
- encoding
- comments
- encoder_ctl
- callbacks
- error_codes
Error Codes
Many of the functions in this library return a negative error code when a function fails.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOpusEnc.FunctionsContains the function pointers loaded fromOpus.getLibrary().
-
Field Summary
Fields Modifier and Type Field Description static intOPE_ALLOC_FAILError codes.static intOPE_API_VERSIONAPI version for this header.static intOPE_BAD_ARG
OPE_CANNOT_OPEN
OPE_CLOSE_FAILError codes.static intOPE_GET_COMMENT_PADDING_REQUEST
OPE_GET_DECISION_DELAY_REQUEST
OPE_GET_HEADER_GAIN_REQUEST
OPE_GET_MUXING_DELAY_REQUEST
OPE_GET_NB_COUPLED_STREAMS_REQUEST
OPE_GET_NB_STREAMS_REQUEST
OPE_GET_SERIALNO_REQUEST"Raw" request values -- they should usually not be used.static intOPE_INTERNAL_ERROR
OPE_INVALID_ICON
OPE_INVALID_PICTURE
OPE_OKError codes.static intOPE_SET_COMMENT_PADDING_REQUEST
OPE_SET_DECISION_DELAY_REQUEST
OPE_SET_HEADER_GAIN_REQUEST
OPE_SET_MUXING_DELAY_REQUEST
OPE_SET_PACKET_CALLBACK_REQUEST
OPE_SET_SERIALNO_REQUEST"Raw" request values -- they should usually not be used.static intOPE_TOO_LATE
OPE_UNIMPLEMENTED
OPE_WRITE_FAILError codes.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intnope_comments_add(long comments, long tag, long val)Unsafe version of:comments_addstatic intnope_comments_add_picture(long comments, long filename, int picture_type, long description)Unsafe version of:comments_add_picturestatic intnope_comments_add_picture_from_memory(long comments, long ptr, long size, int picture_type, long description)Unsafe version of:comments_add_picture_from_memorystatic intnope_comments_add_string(long comments, long tag_and_val)Unsafe version of:comments_add_stringstatic intnope_encoder_continue_new_file(long enc, long path, long comments)Unsafe version of:encoder_continue_new_filestatic longnope_encoder_create_callbacks(long callbacks, long user_data, long comments, int rate, int channels, int family, long error)Unsafe version of:encoder_create_callbacksstatic longnope_encoder_create_file(long path, long comments, int rate, int channels, int family, long error)Unsafe version of:encoder_create_filestatic longnope_encoder_create_pull(long comments, int rate, int channels, int family, long error)Unsafe version of:encoder_create_pullstatic intnope_encoder_deferred_init_with_mapping(long enc, int family, int streams, int coupled_streams, long mapping)Unsafe version of:encoder_deferred_init_with_mappingstatic intnope_encoder_get_page(long enc, long page, long len, int flush)Unsafe version of:encoder_get_pagestatic intnope_encoder_write(long enc, long pcm, int samples_per_channel)Unsafe version of:encoder_writestatic intnope_encoder_write_float(long enc, long pcm, int samples_per_channel)Unsafe version of:encoder_write_floatstatic longnope_get_version_string()Unsafe version of:get_version_stringstatic longnope_strerror(int error)Unsafe version of:strerrorstatic intope_comments_add(long comments, java.lang.CharSequence tag, java.lang.CharSequence val)Add a comment.static intope_comments_add(long comments, java.nio.ByteBuffer tag, java.nio.ByteBuffer val)Add a comment.static intope_comments_add_picture(long comments, java.lang.CharSequence filename, int picture_type, java.lang.CharSequence description)Add a picture from a file.static intope_comments_add_picture(long comments, java.nio.ByteBuffer filename, int picture_type, java.nio.ByteBuffer description)Add a picture from a file.static intope_comments_add_picture_from_memory(long comments, java.nio.ByteBuffer ptr, int picture_type, java.lang.CharSequence description)Add a picture already in memory.static intope_comments_add_picture_from_memory(long comments, java.nio.ByteBuffer ptr, int picture_type, java.nio.ByteBuffer description)Add a picture already in memory.static intope_comments_add_string(long comments, java.lang.CharSequence tag_and_val)Add a comment as a single tag=value string.static intope_comments_add_string(long comments, java.nio.ByteBuffer tag_and_val)Add a comment as a single tag=value string.static longope_comments_copy(long comments)Create a deep copy of a comments object.static longope_comments_create()Create a new comments object.static voidope_comments_destroy(long comments)Destroys a comments object.static intope_encoder_chain_current(long enc, long comments)Ends the stream and create a new stream within the same file.static intope_encoder_continue_new_callbacks(long enc, long user_data, long comments)Ends the stream and create a new file (callback-based).static intope_encoder_continue_new_file(long enc, java.lang.CharSequence path, long comments)Ends the stream and create a new file.static intope_encoder_continue_new_file(long enc, java.nio.ByteBuffer path, long comments)Ends the stream and create a new file.static longope_encoder_create_callbacks(OpusEncCallbacks callbacks, long user_data, long comments, int rate, int channels, int family, java.nio.IntBuffer error)Create a new OggOpus stream to be handled using callbacksstatic longope_encoder_create_file(java.lang.CharSequence path, long comments, int rate, int channels, int family, java.nio.IntBuffer error)Create a new OggOpus file.static longope_encoder_create_file(java.nio.ByteBuffer path, long comments, int rate, int channels, int family, java.nio.IntBuffer error)Create a new OggOpus file.static longope_encoder_create_pull(long comments, int rate, int channels, int family, java.nio.IntBuffer error)Create a new OggOpus stream to be used along withencoder_get_page.static intope_encoder_ctl(long enc, int request)Sets encoder options.static intope_encoder_ctl(long enc, Opus.CTLRequest request)Sets encoder options.static intope_encoder_deferred_init_with_mapping(long enc, int family, int streams, int coupled_streams, java.nio.ByteBuffer mapping)Deferred initialization of the encoder to force an explicit channel mapping.static voidope_encoder_destroy(long enc)Deallocates the obect.static intope_encoder_drain(long enc)Finalizes the stream, but does not deallocate the object.static intope_encoder_flush_header(long enc)Write out the header now rather than wait for audio to begin.static booleanope_encoder_get_page(long enc, org.lwjgl.PointerBuffer page, java.nio.IntBuffer len, boolean flush)Get the next page from the stream (only if usingencoder_create_pull).static intope_encoder_write(long enc, java.nio.ShortBuffer pcm, int samples_per_channel)Add/encode any number of 16-bit linear samples to the stream.static intope_encoder_write_float(long enc, java.nio.FloatBuffer pcm, int samples_per_channel)Add/encode any number of float samples to the stream.static intope_get_abi_version()ABI version for this header.static Opus.CTLRequestOPE_GET_COMMENT_PADDING_REQUEST(java.nio.IntBuffer __result)static Opus.CTLRequestOPE_GET_DECISION_DELAY_REQUEST(java.nio.IntBuffer __result)static Opus.CTLRequestOPE_GET_HEADER_GAIN_REQUEST(java.nio.IntBuffer __result)static Opus.CTLRequestOPE_GET_MUXING_DELAY_REQUEST(java.nio.IntBuffer __result)static Opus.CTLRequestOPE_GET_NB_COUPLED_STREAMS_REQUEST(java.nio.IntBuffer __result)static Opus.CTLRequestOPE_GET_NB_STREAMS_REQUEST(java.nio.IntBuffer __result)static Opus.CTLRequestOPE_GET_SERIALNO_REQUEST(java.nio.IntBuffer __result)static java.lang.Stringope_get_version_string()Returns a string representing the version of libopusenc being used at run time.static Opus.CTLRequestOPE_SET_COMMENT_PADDING_REQUEST(int value)static Opus.CTLRequestOPE_SET_DECISION_DELAY_REQUEST(int value)static Opus.CTLRequestOPE_SET_HEADER_GAIN_REQUEST(int value)static Opus.CTLRequestOPE_SET_MUXING_DELAY_REQUEST(int value)static Opus.CTLRequestOPE_SET_PACKET_CALLBACK_REQUEST(OPEPacketFuncI value)static Opus.CTLRequestOPE_SET_SERIALNO_REQUEST(int value)static java.lang.Stringope_strerror(int error)Converts a libopusenc error code into a human readable string.
-
-
-
Field Detail
-
OPE_API_VERSION
API version for this header. Can be used to check for features at compile time.
-
OPE_OK, OPE_BAD_ARG, OPE_INTERNAL_ERROR, OPE_UNIMPLEMENTED, OPE_ALLOC_FAIL, OPE_CANNOT_OPEN, OPE_TOO_LATE, OPE_INVALID_PICTURE, OPE_INVALID_ICON, OPE_WRITE_FAIL, OPE_CLOSE_FAIL
Error codes.
-
OPE_SET_DECISION_DELAY_REQUEST, OPE_GET_DECISION_DELAY_REQUEST, OPE_SET_MUXING_DELAY_REQUEST, OPE_GET_MUXING_DELAY_REQUEST, OPE_SET_COMMENT_PADDING_REQUEST, OPE_GET_COMMENT_PADDING_REQUEST, OPE_SET_SERIALNO_REQUEST, OPE_GET_SERIALNO_REQUEST, OPE_SET_PACKET_CALLBACK_REQUEST, OPE_SET_HEADER_GAIN_REQUEST, OPE_GET_HEADER_GAIN_REQUEST, OPE_GET_NB_STREAMS_REQUEST, OPE_GET_NB_COUPLED_STREAMS_REQUEST
"Raw" request values -- they should usually not be used.Enum values:
SET_DECISION_DELAY_REQUESTGET_DECISION_DELAY_REQUESTSET_MUXING_DELAY_REQUESTGET_MUXING_DELAY_REQUESTSET_COMMENT_PADDING_REQUESTGET_COMMENT_PADDING_REQUESTSET_SERIALNO_REQUESTGET_SERIALNO_REQUESTSET_PACKET_CALLBACK_REQUESTSET_HEADER_GAIN_REQUESTGET_HEADER_GAIN_REQUESTGET_NB_STREAMS_REQUESTGET_NB_COUPLED_STREAMS_REQUEST
-
-
Method Detail
-
ope_comments_create
public static long ope_comments_create()
Create a new comments object.- Returns:
- newly-created comments object
-
ope_comments_copy
public static long ope_comments_copy(long comments)
Create a deep copy of a comments object.- Parameters:
comments- comments object to copy- Returns:
- deep copy of input
-
ope_comments_destroy
public static void ope_comments_destroy(long comments)
Destroys a comments object.- Parameters:
comments- comments object to destroy
-
nope_comments_add
public static int nope_comments_add(long comments, long tag, long val)Unsafe version of:comments_add
-
ope_comments_add
public static int ope_comments_add(long comments, java.nio.ByteBuffer tag, java.nio.ByteBuffer val) public static int ope_comments_add(long comments, java.lang.CharSequence tag, java.lang.CharSequence val)Add a comment.- Parameters:
comments- where to add the commentstag- tag for the comment (must not contain=char)val- value for the tag- Returns:
- error code
-
nope_comments_add_string
public static int nope_comments_add_string(long comments, long tag_and_val)Unsafe version of:comments_add_string
-
ope_comments_add_string
public static int ope_comments_add_string(long comments, java.nio.ByteBuffer tag_and_val) public static int ope_comments_add_string(long comments, java.lang.CharSequence tag_and_val)Add a comment as a single tag=value string.- Parameters:
comments- where to add the commentstag_and_val- string of the formtag=value(must contain=char)- Returns:
- error code
-
nope_comments_add_picture
public static int nope_comments_add_picture(long comments, long filename, int picture_type, long description)Unsafe version of:comments_add_picture
-
ope_comments_add_picture
public static int ope_comments_add_picture(long comments, java.nio.ByteBuffer filename, int picture_type, @Nullable java.nio.ByteBuffer description) public static int ope_comments_add_picture(long comments, java.lang.CharSequence filename, int picture_type, @Nullable java.lang.CharSequence description)Add a picture from a file.- Parameters:
comments- where to add the commentsfilename- file name for the picturepicture_type- type of picture (-1for default)description- description (NULLmeans no comment)- Returns:
- error code
-
nope_comments_add_picture_from_memory
public static int nope_comments_add_picture_from_memory(long comments, long ptr, long size, int picture_type, long description)Unsafe version of:comments_add_picture_from_memory- Parameters:
size- size of picture pointed to byptr
-
ope_comments_add_picture_from_memory
public static int ope_comments_add_picture_from_memory(long comments, java.nio.ByteBuffer ptr, int picture_type, @Nullable java.nio.ByteBuffer description) public static int ope_comments_add_picture_from_memory(long comments, java.nio.ByteBuffer ptr, int picture_type, @Nullable java.lang.CharSequence description)Add a picture already in memory.- Parameters:
comments- where to add the commentsptr- pointer to picture in memorypicture_type- type of picture (-1for default)description- description (NULLmeans no comment)- Returns:
- error code
-
nope_encoder_create_file
public static long nope_encoder_create_file(long path, long comments, int rate, int channels, int family, long error)Unsafe version of:encoder_create_file
-
ope_encoder_create_file
public static long ope_encoder_create_file(java.nio.ByteBuffer path, long comments, int rate, int channels, int family, @Nullable java.nio.IntBuffer error) public static long ope_encoder_create_file(java.lang.CharSequence path, long comments, int rate, int channels, int family, @Nullable java.nio.IntBuffer error)Create a new OggOpus file.- Parameters:
path- path where to create the filecomments- comments associated with the streamrate- input sampling rate (48 kHz is faster)channels- number of channelsfamily- mapping family (0 for mono/stereo, 1 for surround)error- error code (NULLif no error is to be returned)- Returns:
- newly-created encoder
-
nope_encoder_create_callbacks
public static long nope_encoder_create_callbacks(long callbacks, long user_data, long comments, int rate, int channels, int family, long error)Unsafe version of:encoder_create_callbacks
-
ope_encoder_create_callbacks
public static long ope_encoder_create_callbacks(OpusEncCallbacks callbacks, long user_data, long comments, int rate, int channels, int family, @Nullable java.nio.IntBuffer error)
Create a new OggOpus stream to be handled using callbacks- Parameters:
callbacks- callback functionsuser_data- pointer to be associated with the stream and passed to the callbackscomments- comments associated with the streamrate- input sampling rate (48 kHz is faster)channels- number of channelsfamily- mapping family (0for mono/stereo,1for surround)error- error code (NULLif no error is to be returned)- Returns:
- newly-created encoder
-
nope_encoder_create_pull
public static long nope_encoder_create_pull(long comments, int rate, int channels, int family, long error)Unsafe version of:encoder_create_pull
-
ope_encoder_create_pull
public static long ope_encoder_create_pull(long comments, int rate, int channels, int family, @Nullable java.nio.IntBuffer error)Create a new OggOpus stream to be used along withencoder_get_page. This is mostly useful for muxing with other streams.- Parameters:
comments- comments associated with the streamrate- input sampling rate (48 kHz is faster)channels- number of channelsfamily- mapping family (0 for mono/stereo, 1 for surround)error- error code (NULLif no error is to be returned)- Returns:
- newly-created encoder
-
nope_encoder_deferred_init_with_mapping
public static int nope_encoder_deferred_init_with_mapping(long enc, int family, int streams, int coupled_streams, long mapping)Unsafe version of:encoder_deferred_init_with_mapping
-
ope_encoder_deferred_init_with_mapping
public static int ope_encoder_deferred_init_with_mapping(long enc, int family, int streams, int coupled_streams, java.nio.ByteBuffer 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:
enc- encoderfamily- mapping family (0for mono/stereo,1for surround)streams- total number of streamscoupled_streams- number of coupled streamsmapping- channel mapping- Returns:
- error code
-
nope_encoder_write_float
public static int nope_encoder_write_float(long enc, long pcm, int samples_per_channel)Unsafe version of:encoder_write_float
-
ope_encoder_write_float
public static int ope_encoder_write_float(long enc, java.nio.FloatBuffer pcm, int samples_per_channel)Add/encode any number of float samples to the stream.- Parameters:
enc- encoderpcm- floating-point PCM values in the+/-1range (interleaved if multiple channels)samples_per_channel- number of samples for each channel- Returns:
- error code
-
nope_encoder_write
public static int nope_encoder_write(long enc, long pcm, int samples_per_channel)Unsafe version of:encoder_write
-
ope_encoder_write
public static int ope_encoder_write(long enc, java.nio.ShortBuffer pcm, int samples_per_channel)Add/encode any number of 16-bit linear samples to the stream.- Parameters:
enc- encoderpcm- linear 16-bit PCM values in the[-32768,32767]range (interleaved if multiple channels)samples_per_channel- number of samples for each channel- Returns:
- error code
-
nope_encoder_get_page
public static int nope_encoder_get_page(long enc, long page, long len, int flush)Unsafe version of:encoder_get_page
-
ope_encoder_get_page
public static boolean ope_encoder_get_page(long enc, org.lwjgl.PointerBuffer page, java.nio.IntBuffer len, boolean flush)Get the next page from the stream (only if usingencoder_create_pull).- Parameters:
enc- encoderpage- next available encoded pagelen- size (in bytes) of the page returnedflush- if non-zero, forces a flush of the page (if any data available)- Returns:
- 1 if there is a page available, 0 if not
-
ope_encoder_drain
public static int ope_encoder_drain(long enc)
Finalizes the stream, but does not deallocate the object.- Parameters:
enc- encoder- Returns:
- error code
-
ope_encoder_destroy
public static void ope_encoder_destroy(long enc)
Deallocates the obect. Make sure toencoder_drainfirst.- Parameters:
enc- encoder
-
ope_encoder_chain_current
public static int ope_encoder_chain_current(long enc, long comments)Ends the stream and create a new stream within the same file.- Parameters:
enc- encodercomments- comments associated with the stream- Returns:
- error code
-
nope_encoder_continue_new_file
public static int nope_encoder_continue_new_file(long enc, long path, long comments)Unsafe version of:encoder_continue_new_file
-
ope_encoder_continue_new_file
public static int ope_encoder_continue_new_file(long enc, java.nio.ByteBuffer path, long comments) public static int ope_encoder_continue_new_file(long enc, java.lang.CharSequence path, long comments)Ends the stream and create a new file.- Parameters:
enc- encoderpath- path where to write the new filecomments- comments associated with the stream- Returns:
- error code
-
ope_encoder_continue_new_callbacks
public static int ope_encoder_continue_new_callbacks(long enc, long user_data, long comments)Ends the stream and create a new file (callback-based).- Parameters:
enc- encoderuser_data- pointer to be associated with the new stream and passed to the callbackscomments- comments associated with the stream- Returns:
- error code
-
ope_encoder_flush_header
public static int ope_encoder_flush_header(long enc)
Write out the header now rather than wait for audio to begin.- Parameters:
enc- encoder- Returns:
- error code
-
nope_strerror
public static long nope_strerror(int error)
Unsafe version of:strerror
-
ope_strerror
@Nullable public static java.lang.String ope_strerror(int error)
Converts a libopusenc error code into a human readable string.- Parameters:
error- error number- Returns:
- error string
-
nope_get_version_string
public static long nope_get_version_string()
Unsafe version of:get_version_string
-
ope_get_version_string
@Nullable public static java.lang.String ope_get_version_string()
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
public static int ope_get_abi_version()
ABI version for this header. Can be used to check for features at run time.- Returns:
- an integer representing the ABI version
-
ope_encoder_ctl
public static int ope_encoder_ctl(long enc, int request) public static int ope_encoder_ctl(long enc, Opus.CTLRequest request)Sets encoder options.- Parameters:
enc- encoderrequest- use a request macro- Returns:
- error code
-
OPE_SET_DECISION_DELAY_REQUEST
public static Opus.CTLRequest OPE_SET_DECISION_DELAY_REQUEST(int value)
-
OPE_GET_DECISION_DELAY_REQUEST
public static Opus.CTLRequest OPE_GET_DECISION_DELAY_REQUEST(java.nio.IntBuffer __result)
-
OPE_SET_MUXING_DELAY_REQUEST
public static Opus.CTLRequest OPE_SET_MUXING_DELAY_REQUEST(int value)
-
OPE_GET_MUXING_DELAY_REQUEST
public static Opus.CTLRequest OPE_GET_MUXING_DELAY_REQUEST(java.nio.IntBuffer __result)
-
OPE_SET_COMMENT_PADDING_REQUEST
public static Opus.CTLRequest OPE_SET_COMMENT_PADDING_REQUEST(int value)
-
OPE_GET_COMMENT_PADDING_REQUEST
public static Opus.CTLRequest OPE_GET_COMMENT_PADDING_REQUEST(java.nio.IntBuffer __result)
-
OPE_SET_SERIALNO_REQUEST
public static Opus.CTLRequest OPE_SET_SERIALNO_REQUEST(int value)
-
OPE_GET_SERIALNO_REQUEST
public static Opus.CTLRequest OPE_GET_SERIALNO_REQUEST(java.nio.IntBuffer __result)
-
OPE_SET_PACKET_CALLBACK_REQUEST
public static Opus.CTLRequest OPE_SET_PACKET_CALLBACK_REQUEST(OPEPacketFuncI value)
-
OPE_SET_HEADER_GAIN_REQUEST
public static Opus.CTLRequest OPE_SET_HEADER_GAIN_REQUEST(int value)
-
OPE_GET_HEADER_GAIN_REQUEST
public static Opus.CTLRequest OPE_GET_HEADER_GAIN_REQUEST(java.nio.IntBuffer __result)
-
OPE_GET_NB_STREAMS_REQUEST
public static Opus.CTLRequest OPE_GET_NB_STREAMS_REQUEST(java.nio.IntBuffer __result)
-
OPE_GET_NB_COUPLED_STREAMS_REQUEST
public static Opus.CTLRequest OPE_GET_NB_COUPLED_STREAMS_REQUEST(java.nio.IntBuffer __result)
-
-