diff options
-rw-r--r-- | decoder.c | 9 | ||||
-rw-r--r-- | decoder.h | 1 | ||||
-rw-r--r-- | decoders/decoder_mpg123.c | 2 | ||||
-rw-r--r-- | encoder.c | 16 | ||||
-rw-r--r-- | encoder.h | 3 | ||||
-rw-r--r-- | encoders/encoder_lame.c | 2 |
6 files changed, 29 insertions, 4 deletions
@@ -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) { @@ -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, @@ -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; +} @@ -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, |