diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2010-08-17 18:19:45 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2010-08-17 18:19:45 +0200 |
commit | ac5e220d0e17f57f2fb3c4dedde186f238fa89ed (patch) | |
tree | dca2c0140bd0ac9438aed657f3e95f8d5f972623 | |
parent | 57acd987aa7a22008f3254f99363937e4f7704c7 (diff) |
Added transcoder.
-rw-r--r-- | transcode.c | 38 | ||||
-rw-r--r-- | transcode.h | 12 |
2 files changed, 50 insertions, 0 deletions
diff --git a/transcode.c b/transcode.c new file mode 100644 index 0000000..6508b28 --- /dev/null +++ b/transcode.c @@ -0,0 +1,38 @@ +#include "transcode.h" +#include "decode_converter.h" +#include "encode_converter.h" + +#include <glib.h> + +void transcode(GInputStream *input, const struct decoder_plugin *decoder, + GOutputStream *output, const struct encoder_plugin *encoder) { + GError *error = NULL; + + DecodeConverter *dc = decode_converter_new(decoder); + GInputStream *decoded_stream = g_converter_input_stream_new(input, + (GConverter*)dc); + + EncodeConverter *ec = encode_converter_new(encoder); + GInputStream *encoded_stream = g_converter_input_stream_new(decoded_stream, + (GConverter*)ec); + + gssize size = g_output_stream_splice(output, encoded_stream, + G_OUTPUT_STREAM_SPLICE_NONE, NULL, &error); + + if(size == -1) { + if(error) { + g_warning(error->message); + g_error_free(error); + } else { + g_debug("g_output_stream_splice returned -1, but error is NULL!"); + } + } + + g_debug("transcode ended"); + + g_object_unref(encoded_stream); + g_object_unref(ec); + + g_object_unref(decoded_stream); + g_object_unref(dc); +} diff --git a/transcode.h b/transcode.h new file mode 100644 index 0000000..69f19f3 --- /dev/null +++ b/transcode.h @@ -0,0 +1,12 @@ +#ifndef _TRANSCODE_H_ +#define _TRANSCODE_H_ + +#include "decoder.h" +#include "encoder.h" + +#include <gio/gio.h> + +void transcode(GInputStream *input, const struct decoder_plugin *decoder, + GOutputStream *output, const struct encoder_plugin *encoder); + +#endif |