From 5e4499b1543f62ba82f9e4f66c921bafe24bf497 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Thu, 25 Dec 2014 17:28:27 +0100 Subject: vidcodec: add support for encode- or decode-only vidcodec modules --- src/vidcodec.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/video.c | 12 ++++++++++++ 2 files changed, 64 insertions(+) (limited to 'src') diff --git a/src/vidcodec.c b/src/vidcodec.c index 7624ae7..620674a 100644 --- a/src/vidcodec.c +++ b/src/vidcodec.c @@ -70,6 +70,58 @@ const struct vidcodec *vidcodec_find(const char *name, const char *variant) } +/** + * Find a Video Encoder by name + * + * @param name Name of the Video Encoder to find + * + * @return Matching Video Encoder if found, otherwise NULL + */ +const struct vidcodec *vidcodec_find_encoder(const char *name) +{ + struct le *le; + + for (le=vidcodecl.head; le; le=le->next) { + + struct vidcodec *vc = le->data; + + if (name && 0 != str_casecmp(name, vc->name)) + continue; + + if (vc->ench) + return vc; + } + + return NULL; +} + + +/** + * Find a Video Decoder by name + * + * @param name Name of the Video Decoder to find + * + * @return Matching Video Decoder if found, otherwise NULL + */ +const struct vidcodec *vidcodec_find_decoder(const char *name) +{ + struct le *le; + + for (le=vidcodecl.head; le; le=le->next) { + + struct vidcodec *vc = le->data; + + if (name && 0 != str_casecmp(name, vc->name)) + continue; + + if (vc->dech) + return vc; + } + + return NULL; +} + + /** * Get the list of Video Codecs * diff --git a/src/video.c b/src/video.c index b9b9282..9c1ea80 100644 --- a/src/video.c +++ b/src/video.c @@ -895,6 +895,18 @@ int video_decoder_set(struct video *v, struct vidcodec *vc, int pt_rx, if (!v) return EINVAL; + /* handle vidcodecs without a decoder */ + if (!vc->decupdh) { + info("video: vidcodec '%s' has no decoder\n", vc->name); + + vc = (struct vidcodec *)vidcodec_find_decoder(vc->name); + if (!vc) { + warning("video: could not find decoder (%s)\n", + vc->name); + return ENOENT; + } + } + vrx = &v->vrx; vrx->pt_rx = pt_rx; -- cgit v1.2.3