summaryrefslogtreecommitdiff
path: root/decoder.cpp
blob: 3cfbd818613ba3b110189389e8d7b48b87ca5bab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "decoder.h"
#include "decoders/mpg123_decoder.h"
#include "decoders/ffmpeg_decoder.h"

#include <boost/function.hpp>
#include <boost/functional/factory.hpp>

#include <map>

typedef boost::function<Decoder::p (const std::string&)> DecoderFactory;
std::map<std::string, DecoderFactory> decoder_factories;

void Decoder::init() {
	mpg123_init(); // initialize the mpg123 library
	decoder_factories["mpg123"] = boost::factory<boost::shared_ptr<DecoderMpg123> >();
	decoder_factories["ffmpeg"] = boost::factory<boost::shared_ptr<DecoderFFmpeg> >();
}

Decoder::p Decoder::get(const std::string& name, const std::string& filename) {
	return decoder_factories[name](filename);
}