summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--decoder.c9
-rw-r--r--decoder.h1
-rw-r--r--decoders/decoder_mpg123.c2
-rw-r--r--encoder.c16
-rw-r--r--encoder.h3
-rw-r--r--encoders/encoder_lame.c2
6 files changed, 29 insertions, 4 deletions
diff --git a/decoder.c b/decoder.c
index 2f866c6..dbb373b 100644
--- a/decoder.c
+++ b/decoder.c
@@ -21,6 +21,15 @@ static const struct decoder_plugin *decoder_plugins[] = {
NULL,
};
+const struct decoder_plugin *decoder_get(const gchar *name) {
+ for(int i = 0; decoder_plugins[i]; i++) {
+ if(g_strcmp0(decoder_plugins[i]->name, name) == 0) {
+ return decoder_plugins[i];
+ }
+ }
+ return NULL;
+}
+
const struct decoder_plugin *decoder_find(const gchar *filename) {
gchar *ext = g_strrstr(filename, ".");
if(ext == NULL) {
diff --git a/decoder.h b/decoder.h
index 9139a84..05e4aeb 100644
--- a/decoder.h
+++ b/decoder.h
@@ -25,6 +25,7 @@ gssize decoder_decode(struct decoder *decoder, const guchar *inbuf,
gsize inbuf_size, guchar *outbuf, gsize outbuf_size);
void decoder_close(struct decoder *decoder);
+const struct decoder_plugin *decoder_get(const gchar *name);
const struct decoder_plugin *decoder_find(const gchar *filename);
#endif
diff --git a/decoders/decoder_mpg123.c b/decoders/decoder_mpg123.c
index 4d93f27..e80bac3 100644
--- a/decoders/decoder_mpg123.c
+++ b/decoders/decoder_mpg123.c
@@ -71,7 +71,7 @@ static const gchar * const decoder_mpg123_extensions[] = {
};
const struct decoder_plugin decoder_mpg123_decoder = {
- .name = "mpg123 decoder",
+ .name = "mpg123",
.extensions = decoder_mpg123_extensions,
.init = mpg123_decoder_init,
.decode = mpg123_decoder_decode,
diff --git a/encoder.c b/encoder.c
index 72bca9d..4e0ffb8 100644
--- a/encoder.c
+++ b/encoder.c
@@ -13,3 +13,19 @@ gssize encoder_encode(struct encoder *encoder, const guchar *inbuf, gsize inbuf_
void encoder_close(struct encoder *encoder) {
encoder->encoder->close(encoder->data);
}
+
+extern const struct encoder_plugin encoder_lame_encoder;
+
+static const struct encoder_plugin *encoder_plugins[] = {
+ &encoder_lame_encoder,
+ NULL,
+};
+
+const struct encoder_plugin *encoder_get(const gchar *name) {
+ for(int i = 0; encoder_plugins[i]; i++) {
+ if(g_strcmp0(encoder_plugins[i]->name, name) == 0) {
+ return encoder_plugins[i];
+ }
+ }
+ return NULL;
+}
diff --git a/encoder.h b/encoder.h
index e55dfb0..c7848bf 100644
--- a/encoder.h
+++ b/encoder.h
@@ -19,11 +19,10 @@ struct 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);
+const struct encoder_plugin *encoder_get(const gchar *name);
#endif
diff --git a/encoders/encoder_lame.c b/encoders/encoder_lame.c
index 5c48913..ec50047 100644
--- a/encoders/encoder_lame.c
+++ b/encoders/encoder_lame.c
@@ -28,7 +28,7 @@ static void lame_encoder_close(gpointer data) {
}
const struct encoder_plugin encoder_lame_encoder = {
- .name = "lame encoder",
+ .name = "lame",
.init = lame_encoder_init,
.encode = lame_encoder_encode,
.close = lame_encoder_close,