2009-12-28 16:15:52 +00:00
|
|
|
#ifndef MANGLE_SOUND_FFMPEG_H
|
|
|
|
#define MANGLE_SOUND_FFMPEG_H
|
|
|
|
|
2010-06-03 18:13:27 +00:00
|
|
|
#include "../source.hpp"
|
2009-12-28 16:15:52 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#include <libavcodec/avcodec.h>
|
|
|
|
#include <libavformat/avformat.h>
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Mangle {
|
|
|
|
namespace Sound {
|
|
|
|
|
|
|
|
class FFMpegSource : public SampleSource
|
|
|
|
{
|
|
|
|
AVFormatContext *FmtCtx;
|
|
|
|
AVCodecContext *CodecCtx;
|
|
|
|
int StreamNum;
|
|
|
|
|
|
|
|
std::vector<uint8_t> storage;
|
|
|
|
|
|
|
|
public:
|
|
|
|
/// Decode the given sound file
|
|
|
|
FFMpegSource(const std::string &file);
|
|
|
|
|
|
|
|
/// Decode the given sound stream (not supported by FFmpeg)
|
2010-01-01 19:18:11 +00:00
|
|
|
FFMpegSource(Mangle::Stream::StreamPtr src) { assert(0); }
|
2009-12-28 16:15:52 +00:00
|
|
|
|
|
|
|
~FFMpegSource();
|
|
|
|
|
|
|
|
// Overrides
|
|
|
|
void getInfo(int32_t *rate, int32_t *channels, int32_t *bits);
|
|
|
|
size_t read(void *data, size_t length);
|
|
|
|
};
|
|
|
|
|
2010-06-03 18:13:27 +00:00
|
|
|
#include "loadertemplate.hpp"
|
2009-12-28 16:15:52 +00:00
|
|
|
|
|
|
|
/// A factory that loads FFMpegSources from file
|
2010-01-01 19:18:11 +00:00
|
|
|
class FFMpegLoader : public SSL_Template<FFMpegSource,false,true>
|
2009-12-29 09:34:40 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
/// Sets up the libavcodec library. If you want to do your own
|
|
|
|
/// setup, send a setup=false parameter.
|
|
|
|
FFMpegLoader(bool setup=true);
|
|
|
|
};
|
2009-12-28 16:15:52 +00:00
|
|
|
|
|
|
|
}} // namespaces
|
|
|
|
#endif
|