Sirikata
|
Represents a single audio stream within a media file. More...
#include <FFmpegAudioStream.hpp>
Public Member Functions | |
~FFmpegAudioStream () | |
bool | finished () const |
void | samples (int16 *samples_out, bool loop) |
Get the next samples from the stream, or fill them with silence if the stream has ended. | |
Private Member Functions | |
FFmpegAudioStream (FFmpegStreamPtr parent, uint32 stream_idx, uint8 target_nchannels) | |
bool | openCodec () |
void | closeCodec () |
AVPacket * | getNextPacket (bool loop) |
void | decodeSome (bool loop) |
void | convertFormat (int decoded_size) |
Private Attributes | |
FFmpegStreamPtr | mParent |
AVCodecContext * | mCodecCtx |
AVCodec * | mCodec |
uint32 | mStreamIndex |
bool | mFinished |
AVPacket * | mCurrentPacket |
int | mCurrentPacketOffset |
uint8 * | mDecodedData |
SDL_AudioCVT * | mConverter |
uint8 | mTargetChannels |
uint16 * | mConvertedData |
int | mConvertedOffset |
int | mConvertedSize |
Friends | |
class | FFmpegStream |
Represents a single audio stream within a media file.
Sirikata::SDL::FFmpegAudioStream::~FFmpegAudioStream | ( | ) |
References closeCodec(), mConvertedData, mConverter, and mDecodedData.
Sirikata::SDL::FFmpegAudioStream::FFmpegAudioStream | ( | FFmpegStreamPtr | parent, |
uint32 | stream_idx, | ||
uint8 | target_nchannels | ||
) | [private] |
References openCodec().
void Sirikata::SDL::FFmpegAudioStream::closeCodec | ( | ) | [private] |
References mCodecCtx.
Referenced by getNextPacket(), and ~FFmpegAudioStream().
void Sirikata::SDL::FFmpegAudioStream::convertFormat | ( | int | decoded_size | ) | [private] |
References AUDIO_LOG, DECODE_BUFFER_SIZE, Sirikata::Logging::error, mCodecCtx, mConvertedData, mConvertedOffset, mConvertedSize, mConverter, mDecodedData, and mTargetChannels.
Referenced by decodeSome().
void Sirikata::SDL::FFmpegAudioStream::decodeSome | ( | bool | loop | ) | [private] |
References AUDIO_LOG, convertFormat(), DECODE_BUFFER_SIZE, getNextPacket(), Sirikata::Logging::insane, mCodecCtx, mConvertedOffset, mConvertedSize, mCurrentPacket, mCurrentPacketOffset, and mDecodedData.
Referenced by samples().
bool Sirikata::SDL::FFmpegAudioStream::finished | ( | ) | const |
AVPacket * Sirikata::SDL::FFmpegAudioStream::getNextPacket | ( | bool | loop | ) | [private] |
References AUDIO_LOG, closeCodec(), Sirikata::Logging::insane, mFinished, mParent, mStreamIndex, and openCodec().
Referenced by decodeSome().
bool Sirikata::SDL::FFmpegAudioStream::openCodec | ( | ) | [private] |
References AUDIO_LOG, Sirikata::Logging::error, mCodec, mCodecCtx, mParent, and mStreamIndex.
Referenced by FFmpegAudioStream(), and getNextPacket().
void Sirikata::SDL::FFmpegAudioStream::samples | ( | int16 * | samples_out, |
bool | loop | ||
) |
Get the next samples from the stream, or fill them with silence if the stream has ended.
If the requested number of channels doesn't match, the conversion will be performed automatically.
samples_out | output buffer for decoded samples. Always uses 16-bit signed values |
loop | if true, loops the track if the end is reached while decoding the requested samples |
References decodeSome(), finished(), mConvertedData, mConvertedOffset, mConvertedSize, and mTargetChannels.
friend class FFmpegStream [friend] |
AVCodec* Sirikata::SDL::FFmpegAudioStream::mCodec [private] |
Referenced by openCodec().
AVCodecContext* Sirikata::SDL::FFmpegAudioStream::mCodecCtx [private] |
Referenced by closeCodec(), convertFormat(), decodeSome(), and openCodec().
uint16* Sirikata::SDL::FFmpegAudioStream::mConvertedData [private] |
Referenced by convertFormat(), samples(), and ~FFmpegAudioStream().
int Sirikata::SDL::FFmpegAudioStream::mConvertedOffset [private] |
Referenced by convertFormat(), decodeSome(), and samples().
int Sirikata::SDL::FFmpegAudioStream::mConvertedSize [private] |
Referenced by convertFormat(), decodeSome(), and samples().
SDL_AudioCVT* Sirikata::SDL::FFmpegAudioStream::mConverter [private] |
Referenced by convertFormat(), and ~FFmpegAudioStream().
AVPacket* Sirikata::SDL::FFmpegAudioStream::mCurrentPacket [private] |
Referenced by decodeSome().
int Sirikata::SDL::FFmpegAudioStream::mCurrentPacketOffset [private] |
Referenced by decodeSome().
uint8* Sirikata::SDL::FFmpegAudioStream::mDecodedData [private] |
Referenced by convertFormat(), decodeSome(), and ~FFmpegAudioStream().
bool Sirikata::SDL::FFmpegAudioStream::mFinished [private] |
Referenced by finished(), and getNextPacket().
Referenced by getNextPacket(), and openCodec().
uint32 Sirikata::SDL::FFmpegAudioStream::mStreamIndex [private] |
Referenced by getNextPacket(), and openCodec().
uint8 Sirikata::SDL::FFmpegAudioStream::mTargetChannels [private] |
Referenced by convertFormat(), and samples().