summaryrefslogtreecommitdiff
path: root/decoder.cpp
blob: 9330c6e1bfedbe2caae7a734c384138aecb3e5f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "decoder.h"
#include "decoders/mpg123_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::p Decoder::get(const std::string& name, const std::string& filename) {
	return decoder_factories[name](filename);
}