summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlfred E. Heggestad <aeh@db.org>2014-12-25 17:28:27 +0100
committerAlfred E. Heggestad <aeh@db.org>2014-12-25 17:28:27 +0100
commit5e4499b1543f62ba82f9e4f66c921bafe24bf497 (patch)
tree5a863e6915a260aea29044d64fd1d0233a4a37c0 /src
parent6c8ba7db8c417f1a457dc1a2e22ac11c17860a90 (diff)
vidcodec: add support for encode- or decode-only vidcodec modules
Diffstat (limited to 'src')
-rw-r--r--src/vidcodec.c52
-rw-r--r--src/video.c12
2 files changed, 64 insertions, 0 deletions
diff --git a/src/vidcodec.c b/src/vidcodec.c
index 7624ae7..620674a 100644
--- a/src/vidcodec.c
+++ b/src/vidcodec.c
@@ -71,6 +71,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
*
* @return 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;