summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAlfred E. Heggestad <alfred.heggestad@gmail.com>2016-11-30 10:20:12 +0100
committerAlfred E. Heggestad <alfred.heggestad@gmail.com>2016-11-30 10:20:12 +0100
commit5c8629c2ccd0d23efdfe40ca03bcf6127e8afd90 (patch)
tree46e3761f4015409a76cbe4f3507ceaa9757684f5 /modules
parentc777ff5e8cf4026e189b35739dd51b0576cafb31 (diff)
vidloop: add command vidloop_codec for using a Codec
Diffstat (limited to 'modules')
-rw-r--r--modules/vidloop/vidloop.c63
1 files changed, 39 insertions, 24 deletions
diff --git a/modules/vidloop/vidloop.c b/modules/vidloop/vidloop.c
index 6a90318..ec7fb6f 100644
--- a/modules/vidloop/vidloop.c
+++ b/modules/vidloop/vidloop.c
@@ -280,15 +280,6 @@ static int enable_codec(struct video_loop *vl)
}
-static void disable_codec(struct video_loop *vl)
-{
- vl->enc = mem_deref(vl->enc);
- vl->dec = mem_deref(vl->dec);
- vl->vc_enc = NULL;
- vl->vc_dec = NULL;
-}
-
-
static void print_status(struct video_loop *vl)
{
(void)re_fprintf(stderr,
@@ -436,21 +427,34 @@ static int vidloop_start(struct re_printf *pf, void *arg)
size.h = cfg->video.height;
if (gvl) {
- if (gvl->vc_enc)
- disable_codec(gvl);
- else {
- err = enable_codec(gvl);
- if (err) {
- gvl = mem_deref(gvl);
- return err;
- }
- }
+ return re_hprintf(pf, "video-loop already running.\n");
+ }
+
+ (void)re_hprintf(pf, "Enable video-loop on %s,%s: %u x %u\n",
+ cfg->video.src_mod, cfg->video.src_dev,
+ size.w, size.h);
- (void)re_hprintf(pf, "%sabled codec: %s\n",
- gvl->vc_enc ? "En" : "Dis",
- gvl->vc_enc ? gvl->vc_enc->name : "");
+ err = video_loop_alloc(&gvl, &size);
+ if (err) {
+ warning("vidloop: alloc: %m\n", err);
}
- else {
+
+ return err;
+}
+
+
+static int vidloop_codec_start(struct re_printf *pf, void *arg)
+{
+ struct vidsz size;
+ struct config *cfg = conf_config();
+ int err = 0;
+
+ (void)arg;
+
+ size.w = cfg->video.width;
+ size.h = cfg->video.height;
+
+ if (!gvl) {
(void)re_hprintf(pf, "Enable video-loop on %s,%s: %u x %u\n",
cfg->video.src_mod, cfg->video.src_dev,
size.w, size.h);
@@ -461,6 +465,16 @@ static int vidloop_start(struct re_printf *pf, void *arg)
}
}
+ err = enable_codec(gvl);
+ if (err) {
+ gvl = mem_deref(gvl);
+ return err;
+ }
+
+ (void)re_hprintf(pf, "%sabled codec: %s\n",
+ gvl->vc_enc ? "En" : "Dis",
+ gvl->vc_enc ? gvl->vc_enc->name : "");
+
return err;
}
@@ -477,8 +491,9 @@ static int vidloop_stop(struct re_printf *pf, void *arg)
static const struct cmd cmdv[] = {
- {"vidloop", 0, 0, "Start video-loop", vidloop_start },
- {"vidloop_stop", 0, 0, "Stop video-loop", vidloop_stop },
+ {"vidloop", 0, 0, "Start video-loop", vidloop_start },
+ {"vidloop_codec",0, 0, "Start codec video-loop", vidloop_codec_start},
+ {"vidloop_stop", 0, 0, "Stop video-loop", vidloop_stop },
};