summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2010-08-17 18:17:23 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2010-08-17 18:17:23 +0200
commit12e7f431ba4baf18b47ea2fced4091c61457069c (patch)
tree8098e45f87b2fa4ccb2763330baf0619d1067339
parent0949095bce712a44c82a3ea0c527df6e810e48f6 (diff)
Added decoder API.
-rw-r--r--decoder.c15
-rw-r--r--decoder.h30
2 files changed, 45 insertions, 0 deletions
diff --git a/decoder.c b/decoder.c
new file mode 100644
index 0000000..555757d
--- /dev/null
+++ b/decoder.c
@@ -0,0 +1,15 @@
+#include "decoder.h"
+
+gboolean decoder_init(struct decoder *decoder) {
+ return decoder->decoder->init(&(decoder->data));
+}
+
+gssize decoder_decode(struct decoder *decoder, const guchar *inbuf,
+ gsize inbuf_size, guchar *outbuf, gsize outbuf_size) {
+ return decoder->decoder->decode(decoder->data, inbuf, inbuf_size,
+ outbuf, outbuf_size);
+}
+
+void decoder_close(struct decoder *decoder) {
+ decoder->decoder->close(decoder->data);
+}
diff --git a/decoder.h b/decoder.h
new file mode 100644
index 0000000..0a29c64
--- /dev/null
+++ b/decoder.h
@@ -0,0 +1,30 @@
+#ifndef _DECODER_H_
+#define _DECODER_H_
+
+#include <glib.h>
+#include <gio/gio.h>
+
+struct decoder_plugin {
+ const gchar *name;
+ const gchar * const *extensions;
+
+ gboolean (*init)(gpointer *data);
+ gssize (*decode)(gpointer data, const guchar *inbuf, gsize inbuf_size,
+ guchar *outbuf, gsize outbuf_size);
+ void (*close)(gpointer data);
+};
+
+struct decoder {
+ const struct decoder_plugin *decoder;
+
+ gpointer data;
+};
+
+extern struct decoder_plugin *decoder_plugins;
+
+gboolean decoder_init(struct decoder *decoder);
+gssize decoder_decode(struct decoder *decoder, const guchar *inbuf,
+ gsize inbuf_size, guchar *outbuf, gsize outbuf_size);
+void decoder_close(struct decoder *decoder);
+
+#endif