#include "transcode.h" #include #include Transcoder::Transcoder(std::string p, HTTP::Connection::p r, DecoderBase& d, EncoderBase& 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(EncoderFilter(encoder), buffer_size); s.push(DecoderFilter(decoder), buffer_size); s.push(is, buffer_size); char data[0x1000]; std::streamsize size = 1; while(size) { s.read(data, 0x1000); size = s.gcount(); if(size > 0) res->send_data(data, size); } }