FFSampledSP
Data Structures | Functions
FFUtils.h File Reference
#include <math.h>
#include <jni.h>
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libswresample/swresample.h>
#include <libavutil/timestamp.h>
#include <libavutil/opt.h>

Go to the source code of this file.

Data Structures

struct  FFAudioIO
 Central context representing the native peer to the Java FFNativePeerInputStream object. More...
 

Functions

void throwUnsupportedAudioFileExceptionIfError (JNIEnv *, int, const char *)
 Throws an UnsupportedAudioFileException. More...
 
void throwIOExceptionIfError (JNIEnv *, int, const char *)
 Throws an IOException. More...
 
void throwIndexOutOfBoundsExceptionIfError (JNIEnv *, int, int)
 Throws an IndexOutOfBoundsException. More...
 
void throwFileNotFoundExceptionIfError (JNIEnv *, int, const char *)
 Throws an IllegalArgumentException. More...
 
void dumpCodecIds ()
 
int ff_open_stream (JNIEnv *, AVStream *, AVCodecContext **)
 Opens the given stream, i.e. More...
 
int ff_open_format_context (JNIEnv *, AVFormatContext **, const char *)
 Opens the input file/url and allocates a AVFormatContext for it, but does not open the audio stream with an appropriate decoder. More...
 
int ff_open_file (JNIEnv *, AVFormatContext **, AVStream **, AVCodecContext **, int *, const char *)
 Opens the input file/url, allocates a AVFormatContext for it and opens the audio stream with an appropriate decoder. More...
 
int ff_init_audioio (JNIEnv *, FFAudioIO *)
 Initialize our main context FFAudioIO, so that SwrContext, decode buffers and the encoder are set to reasonable values. More...
 
void ff_audioio_free (FFAudioIO *)
 Free all resources held by aio and then itself. More...
 
int ff_fill_buffer (FFAudioIO *)
 Reads a frame via av_read_frame(AVFormatContext, AVPacket), decodes it to a AVPacket, and writes the result to the Java-side nativeBuffer. More...
 
AVCodec * ff_find_encoder (enum AVSampleFormat, int, int, int)
 Finds an AVCodec encoder for the given sample format, bits per sample, byte order and signed/unsigned encoding. More...
 
int ff_init_encoder (JNIEnv *, FFAudioIO *, AVCodec *)
 Allocates and initializes the encoder context and frame in FFAudioIO. More...
 
int ff_big_endian (enum AVCodecID)
 Indicates whether the given id belongs to a big endian codec. More...
 

Function Documentation

◆ dumpCodecIds()

void dumpCodecIds ( )

< preferred ID for decoding MPEG audio layer 1, 2 or 3

< as in Berlin toast format

Definition at line 926 of file FFUtils.c.

◆ ff_audioio_free()

void ff_audioio_free ( FFAudioIO )

Free all resources held by aio and then itself.

Definition at line 858 of file FFUtils.c.

◆ ff_big_endian()

int ff_big_endian ( enum AVCodecID  codec_id)

Indicates whether the given id belongs to a big endian codec.

Parameters
codec_idcodec id
Returns
true if the codec id belongs to a big endian codec.

Definition at line 906 of file FFUtils.c.

◆ ff_fill_buffer()

int ff_fill_buffer ( FFAudioIO aio)

Reads a frame via av_read_frame(AVFormatContext, AVPacket), decodes it to a AVPacket, and writes the result to the Java-side nativeBuffer.

Parameters
aiocurrent FFAudioIO
Returns
a negative number, if something went wrong

Definition at line 822 of file FFUtils.c.

◆ ff_find_encoder()

AVCodec* ff_find_encoder ( enum AVSampleFormat  sampleFormat,
int  bits,
int  big_endian,
int  signedSamples 
)

Finds an AVCodec encoder for the given sample format, bits per sample, byte order and signed/unsigned encoding.

This method never returns a planar, but always a packed codec.

Parameters
sampleFormatAVSampleFormat
bitsbits per sample
big_endiantrue or false
signedSamplestrue, if the samples are signed
Returns
an appropriate encoder or NULL, if none can be found

Definition at line 398 of file FFUtils.c.

◆ ff_init_audioio()

int ff_init_audioio ( JNIEnv *  env,
FFAudioIO aio 
)

Initialize our main context FFAudioIO, so that SwrContext, decode buffers and the encoder are set to reasonable values.

Parameters
JNIEnvenv
aioour context, FFAudioIO
Returns
a negative value, if something went wrong

Definition at line 516 of file FFUtils.c.

◆ ff_init_encoder()

int ff_init_encoder ( JNIEnv *  env,
FFAudioIO aio,
AVCodec *  encoder 
)

Allocates and initializes the encoder context and frame in FFAudioIO.

As parameters serve the output parameters of the SwrContext from FFAudioIO. Therefore the SwrContext must be setup first for this to be successful.

Parameters
envJNIEnv
aioFFAudioIO (our context)
encoderAVCodec to use to setup the encoder AVCodecContext
Returns
a negative value, if something goes wrong

Definition at line 451 of file FFUtils.c.

◆ ff_open_file()

int ff_open_file ( JNIEnv *  env,
AVFormatContext **  format_context,
AVStream **  openedStream,
AVCodecContext **  context,
int *  stream_index,
const char *  url 
)

Opens the input file/url, allocates a AVFormatContext for it and opens the audio stream with an appropriate decoder.

Parameters
envJNIEnv
format_contextAVFormatContext
openedStreamopened audio AVStream
stream_index[in]index of the desired audio stream
stream_index[out]index of the selected stream (index of all streams)
urlURL to open
Returns
negative value, if something went wrong

Definition at line 279 of file FFUtils.c.

◆ ff_open_format_context()

int ff_open_format_context ( JNIEnv *  env,
AVFormatContext **  format_context,
const char *  url 
)

Opens the input file/url and allocates a AVFormatContext for it, but does not open the audio stream with an appropriate decoder.

Parameters
envJNIEnv
format_contextAVFormatContext
urlURL to open
Returns
negative value, if something went wrong

Definition at line 223 of file FFUtils.c.

◆ ff_open_stream()

int ff_open_stream ( JNIEnv *  env,
AVStream *  stream,
AVCodecContext **  context 
)

Opens the given stream, i.e.

sets up a decoder.

Parameters
envJNIEnv
streamAVStream

Definition at line 61 of file FFUtils.c.

◆ throwFileNotFoundExceptionIfError()

void throwFileNotFoundExceptionIfError ( JNIEnv *  ,
int  ,
const char *   
)

Throws an IllegalArgumentException.

Definition at line 203 of file FFUtils.c.

◆ throwIndexOutOfBoundsExceptionIfError()

void throwIndexOutOfBoundsExceptionIfError ( JNIEnv *  ,
int  ,
int   
)

Throws an IndexOutOfBoundsException.

Definition at line 173 of file FFUtils.c.

◆ throwIOExceptionIfError()

void throwIOExceptionIfError ( JNIEnv *  ,
int  ,
const char *   
)

Throws an IOException.

Definition at line 188 of file FFUtils.c.

◆ throwUnsupportedAudioFileExceptionIfError()

void throwUnsupportedAudioFileExceptionIfError ( JNIEnv *  ,
int  ,
const char *   
)

Throws an UnsupportedAudioFileException.

Definition at line 158 of file FFUtils.c.