summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--transcode.cpp20
-rw-r--r--transcode.h22
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