diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2010-12-28 16:57:41 +0100 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2010-12-28 16:57:41 +0100 |
commit | f33934505764d66ae56fdfea9dbcc5c6eb08b39b (patch) | |
tree | 0ec75a872d87a2ce22890d108387318556565774 | |
parent | 398114468e86df5cacf2ad3ff09e9822e074e4b4 (diff) |
Added Transcoder.
-rw-r--r-- | transcode.cpp | 20 | ||||
-rw-r--r-- | transcode.h | 22 |
2 files changed, 42 insertions, 0 deletions
diff --git a/transcode.cpp b/transcode.cpp new file mode 100644 index 0000000..249ffb3 --- /dev/null +++ b/transcode.cpp @@ -0,0 +1,20 @@ +#include "transcode.h" + +Transcoder::Transcoder(std::istream& i, HTTPResponse& r, DecoderBase& d, EncoderBase& e) : is(i), res(r), decoder(d), encoder(e) { +} + +void Transcoder::run() { + char data[0x1000]; + bool encoding_fone = false; + while(!encoding_fone) { + size_t decoded_size = 0; + char decoded_data[0x1000]; + if(is.good()) { + is.read(data, 0x1000); + decoded_size = decoder.decode((uint8_t*)data, is.gcount(), (uint8_t*)decoded_data, 0x1000); + } + char encoded_data[0x1000]; + size_t encoded_size = encoder.encode((uint8_t*)decoded_data, decoded_size, (uint8_t*)encoded_data, 0x1000); + res.write(encoded_data, encoded_size); + } +} diff --git a/transcode.h b/transcode.h new file mode 100644 index 0000000..2a63b17 --- /dev/null +++ b/transcode.h @@ -0,0 +1,22 @@ +#ifndef TRANSCODE_H +#define TRANSCODE_H + +#include "decoder.h" +#include "encoder.h" +#include "http.h" + +#include <iostream> + +class Transcoder { + private: + std::istream& is; + HTTPResponse& res; + DecoderBase& decoder; + EncoderBase& encoder; + + public: + Transcoder(std::istream& i, HTTPResponse& r, DecoderBase& d, EncoderBase& e); + void run(); +}; + +#endif |