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

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

#include <map>

DecoderFilter::DecoderFilter(DecoderBase::p decoder_) {
	decoder = decoder_;
}

typedef boost::function<DecoderBase::p ()> 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> >();
}

//! Construct a filter with the given decoder.
DecoderFilter::p decoder::get_decoder(const std::string& name) {
	return DecoderFilter::p(new DecoderFilter(decoder_factories[name]()));
}