summaryrefslogtreecommitdiff
path: root/transcode.cpp
blob: 394f60487825bd6ee2d9c7ec6c8c6788dc1a47df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "transcode.h"

#include <boost/iostreams/device/file.hpp>
#include <boost/iostreams/filtering_stream.hpp>

Transcoder::Transcoder(std::string p, HTTP::Connection::p r, DecoderFilter::p d, EncoderFilter::p e) : path(p), res(r), decoder(d), encoder(e) {
}

void Transcoder::run() {
	const std::streamsize buffer_size = 0x1000;
	boost::iostreams::file_source is(path, std::ios::in | std::ios::binary);
	boost::iostreams::filtering_istream s;
	s.push(*encoder.get(), buffer_size);
	s.push(*decoder.get(), buffer_size);
	s.push(is, buffer_size);
	
	res->send_data(s);
}