summaryrefslogtreecommitdiff
path: root/encode_converter.c
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2010-09-05 18:26:30 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2010-09-05 18:26:30 +0200
commit30aa38e29a03250192c3c0d4faa3c37a9d4d0357 (patch)
treee18de4873a9f3e993086b9cfdd1b5c2a3dcc171f /encode_converter.c
parentb6567cbdf77f0ebf1790b1e7d800ad4df88253ca (diff)
Rewrote encoder/decoder setup to use streams instead of buffers.
Diffstat (limited to 'encode_converter.c')
-rw-r--r--encode_converter.c87
1 files changed, 0 insertions, 87 deletions
diff --git a/encode_converter.c b/encode_converter.c
deleted file mode 100644
index e113351..0000000
--- a/encode_converter.c
+++ /dev/null
@@ -1,87 +0,0 @@
-#include "encode_converter.h"
-
-#include <gio/gio.h>
-
-static void encode_converter_interface_init(GConverterIface *iface);
-static void encode_converter_finalize(GObject *object);
-
-static GConverterResult encoder_converter_convert(GConverter *converter,
- const void *inbuf, gsize inbuf_size, void *outbuf, gsize outbuf_size,
- GConverterFlags flags, gsize *bytes_read, gsize *bytes_written,
- GError **error);
-static void encode_converter_reset(GConverter *converter);
-
-static GObjectClass *parent_class = NULL;
-
-G_DEFINE_TYPE_WITH_CODE(EncodeConverter, encode_converter, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE(G_TYPE_CONVERTER,
- encode_converter_interface_init));
-
-static void encode_converter_class_init(EncodeConverterClass *klass) {
- GObjectClass *object_class;
-
- parent_class = (GObjectClass*)g_type_class_peek_parent(klass);
- object_class = (GObjectClass*)klass;
- object_class->finalize = encode_converter_finalize;
-}
-
-static void encode_converter_interface_init(GConverterIface *iface) {
- iface->convert = encoder_converter_convert;
- iface->reset = encode_converter_reset;
-}
-
-static void encode_converter_init(EncodeConverter *self) {
-}
-
-static void encode_converter_finalize(GObject *object) {
- EncodeConverter *dc;
-
- g_assert(CONVERTER_IS_ENCODE(object));
-
- dc = ENCODE_CONVERTER(object);
-
- dc->encoder.encoder->close(dc->encoder.data);
-}
-
-static GConverterResult encoder_converter_convert(GConverter *converter,
- const void *inbuf, gsize inbuf_size, void *outbuf, gsize outbuf_size,
- GConverterFlags flags, gsize *bytes_read, gsize *bytes_written,
- GError **error) {
- EncodeConverter *dc;
-
- dc = (EncodeConverter*)converter;
-
- gssize size = dc->encoder.encoder->encode(dc->encoder.data, inbuf, inbuf_size, outbuf, outbuf_size);
-
- if(size < 0) {
- *error = g_error_new(g_quark_from_string("EncodeConverter"),
- size, "encode() returned %ld", size);
- return G_CONVERTER_ERROR;
- } else if(size == 0) {
- return G_CONVERTER_FINISHED;
- }
- *bytes_read = inbuf_size;
- *bytes_written = size;
- return G_CONVERTER_CONVERTED;
-}
-
-static void encode_converter_reset(GConverter *converter) {
- EncodeConverter *ec;
-
- ec = (EncodeConverter*)converter;
-
- ec->encoder.encoder->close(&ec->encoder.data);
-}
-
-EncodeConverter *encode_converter_new(const struct encoder_plugin *encoder_plugin) {
- EncodeConverter *dc;
-
- dc = (EncodeConverter*)g_object_new(CONVERTER_TYPE_ENCODE, NULL);
-
- g_assert(dc != NULL);
-
- dc->encoder.encoder = encoder_plugin;
- dc->encoder.encoder->init(&dc->encoder.data);
-
- return dc;
-}