2012-03-16 23:59:21 -07:00
|
|
|
#ifndef GAME_SOUND_FFMPEG_DECODER_H
|
|
|
|
#define GAME_SOUND_FFMPEG_DECODER_H
|
|
|
|
|
2012-03-20 14:13:58 -07:00
|
|
|
// FIXME: This can't be right? The headers refuse to build without UINT64_C,
|
|
|
|
// which only gets defined in stdint.h in either C99 mode or with this macro
|
|
|
|
// defined...
|
|
|
|
#define __STDC_CONSTANT_MACROS
|
|
|
|
#include <stdint.h>
|
2012-03-16 23:59:21 -07:00
|
|
|
extern "C"
|
|
|
|
{
|
2012-12-01 20:53:28 +01:00
|
|
|
#include <libavcodec/avcodec.h>
|
|
|
|
#include <libavformat/avformat.h>
|
2013-06-24 21:08:29 +02:00
|
|
|
|
2013-06-26 07:17:29 +02:00
|
|
|
// From libavutil version 52.2.0 and onward the declaration of
|
2013-06-24 21:08:29 +02:00
|
|
|
// AV_CH_LAYOUT_* is removed from libavcodec/avcodec.h and moved to
|
|
|
|
// libavutil/channel_layout.h
|
2013-06-26 07:17:29 +02:00
|
|
|
#if AV_VERSION_INT(52, 2, 0) <= AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
|
|
|
|
LIBAVUTIL_VERSION_MINOR, LIBAVUTIL_VERSION_MICRO)
|
2013-06-24 21:08:29 +02:00
|
|
|
#include <libavutil/channel_layout.h>
|
|
|
|
#endif
|
2012-03-16 23:59:21 -07:00
|
|
|
}
|
|
|
|
|
2013-05-26 10:36:17 +02:00
|
|
|
#include <string>
|
|
|
|
|
2012-03-16 23:59:21 -07:00
|
|
|
#include "sound_decoder.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
namespace MWSound
|
|
|
|
{
|
|
|
|
class FFmpeg_Decoder : public Sound_Decoder
|
|
|
|
{
|
2012-03-20 16:45:01 -07:00
|
|
|
AVFormatContext *mFormatCtx;
|
2012-12-15 23:46:32 -08:00
|
|
|
AVStream **mStream;
|
|
|
|
|
|
|
|
AVPacket mPacket;
|
|
|
|
AVFrame *mFrame;
|
|
|
|
|
|
|
|
int mFrameSize;
|
|
|
|
int mFramePos;
|
2012-03-20 16:45:01 -07:00
|
|
|
|
2012-12-16 01:56:52 -08:00
|
|
|
double mNextPts;
|
2012-03-20 16:45:01 -07:00
|
|
|
|
2012-12-15 22:13:19 -08:00
|
|
|
bool getNextPacket();
|
2012-03-20 16:45:01 -07:00
|
|
|
|
|
|
|
Ogre::DataStreamPtr mDataStream;
|
|
|
|
static int readPacket(void *user_data, uint8_t *buf, int buf_size);
|
|
|
|
static int writePacket(void *user_data, uint8_t *buf, int buf_size);
|
|
|
|
static int64_t seek(void *user_data, int64_t offset, int whence);
|
|
|
|
|
2012-12-15 23:46:32 -08:00
|
|
|
bool getAVAudioData();
|
|
|
|
size_t readAVAudioData(void *data, size_t length);
|
|
|
|
|
2012-03-18 11:47:15 -07:00
|
|
|
virtual void open(const std::string &fname);
|
|
|
|
virtual void close();
|
2012-03-16 23:59:21 -07:00
|
|
|
|
2012-12-12 22:19:44 -08:00
|
|
|
virtual std::string getName();
|
2012-03-18 11:47:15 -07:00
|
|
|
virtual void getInfo(int *samplerate, ChannelConfig *chans, SampleType *type);
|
2012-03-19 08:48:25 -07:00
|
|
|
|
2012-03-18 11:47:15 -07:00
|
|
|
virtual size_t read(char *buffer, size_t bytes);
|
2012-03-20 17:57:28 -07:00
|
|
|
virtual void readAll(std::vector<char> &output);
|
2012-03-19 08:48:25 -07:00
|
|
|
virtual void rewind();
|
2012-12-13 05:04:53 -08:00
|
|
|
virtual size_t getSampleOffset();
|
2012-03-17 02:51:46 -07:00
|
|
|
|
2012-03-24 03:49:03 -07:00
|
|
|
FFmpeg_Decoder& operator=(const FFmpeg_Decoder &rhs);
|
|
|
|
FFmpeg_Decoder(const FFmpeg_Decoder &rhs);
|
|
|
|
|
2012-03-16 23:59:21 -07:00
|
|
|
FFmpeg_Decoder();
|
2012-03-20 14:13:58 -07:00
|
|
|
public:
|
2012-03-16 23:59:21 -07:00
|
|
|
virtual ~FFmpeg_Decoder();
|
|
|
|
|
|
|
|
friend class SoundManager;
|
|
|
|
};
|
|
|
|
#ifndef DEFAULT_DECODER
|
|
|
|
#define DEFAULT_DECODER (::MWSound::FFmpeg_Decoder)
|
|
|
|
#endif
|
2012-10-17 18:03:02 +02:00
|
|
|
}
|
2012-03-16 23:59:21 -07:00
|
|
|
|
|
|
|
#endif
|