From eb543b8ddb00761de3a52f6da024ffacf5ba9b92 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Tue, 17 Aug 2010 18:17:41 +0200 Subject: Added encoder API. --- encoder.c | 15 +++++++++++++++ encoder.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 encoder.c create mode 100644 encoder.h diff --git a/encoder.c b/encoder.c new file mode 100644 index 0000000..72bca9d --- /dev/null +++ b/encoder.c @@ -0,0 +1,15 @@ +#include "encoder.h" + +gboolean encoder_init(struct encoder *encoder) { + return encoder->encoder->init(&encoder->data); +} + +gssize encoder_encode(struct encoder *encoder, const guchar *inbuf, gsize inbuf_size, + guchar *outbuf, gsize outbuf_size) { + return encoder->encoder->encode(encoder->data, inbuf, inbuf_size, + outbuf, outbuf_size); +} + +void encoder_close(struct encoder *encoder) { + encoder->encoder->close(encoder->data); +} diff --git a/encoder.h b/encoder.h new file mode 100644 index 0000000..e55dfb0 --- /dev/null +++ b/encoder.h @@ -0,0 +1,29 @@ +#ifndef _ENCODER_H_ +#define _ENCODER_H_ + +#include +#include + +struct encoder_plugin { + const gchar *name; + + gboolean (*init)(gpointer *data); + gssize (*encode)(gpointer data, const guchar *inbuf, gsize inbuf_size, + guchar *outbuf, gsize outbuf_size); + void (*close)(gpointer data); +}; + +struct encoder { + const struct encoder_plugin *encoder; + + gpointer data; +}; + +extern struct encoder_plugin *encoder_plugniss; + +gboolean encoder_init(struct encoder *encoder); +gssize encoder_encode(struct encoder *encoder, const guchar *inbuf, gsize inbuf_size, + guchar *outbuf, gsize outbuf_size); +void encoder_close(struct encoder *encoder); + +#endif -- cgit v1.2.3