summaryrefslogtreecommitdiff
path: root/encoder.h
blob: 0ff21b2cf78d51916c28897ebb2c0a0af45683ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef ENCODER_H
#define ENCODER_H

#include <glib.h>
#include <gio/gio.h>

struct encoder_plugin {
	const gchar *name;

	gboolean (*init)(gpointer *data);
	gssize (*encode)(gpointer data, GInputStream *input,
			GOutputStream *output, GError **error);
	void (*close)(gpointer data);
};

struct encoder {
	const struct encoder_plugin *encoder;

	gpointer data;
};

gboolean encoder_init(struct encoder *encoder);
gssize encoder_encode(struct encoder *encoder, GInputStream *input,
			GOutputStream *output, GError **error);
void encoder_close(struct encoder *encoder);
const struct encoder_plugin *encoder_get(const gchar *name);

static inline GQuark encoder_quark() {
	return g_quark_from_string("encoder");
}

enum {
	ENCODER_CODE_ERROR = 0,
	ENCODER_CODE_DONE,
};

#endif