summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlfred E. Heggestad <alfred.heggestad@gmail.com>2016-12-07 22:57:23 +0100
committerAlfred E. Heggestad <alfred.heggestad@gmail.com>2016-12-07 22:57:23 +0100
commit1ddcc5cceab0441cf6161176cc81e3f6186c473d (patch)
treee3e82e922c409efa3a9750185ffef4178788282b /src
parent0be214da35d9d13ce5487cc814f0c4f03040adfa (diff)
video: start video on update
- if we receive an updated SDP from re-INVITE which has the video line enabled, start the video stream Thanks to Gary Metalle for the original patch
Diffstat (limited to 'src')
-rw-r--r--src/call.c12
-rw-r--r--src/core.h1
-rw-r--r--src/video.c11
3 files changed, 23 insertions, 1 deletions
diff --git a/src/call.c b/src/call.c
index 20b2ff1..48baaf0 100644
--- a/src/call.c
+++ b/src/call.c
@@ -158,7 +158,7 @@ static void call_stream_start(struct call *call, bool active)
sc->params);
err |= video_decoder_set(call->video, sc->data, sc->pt,
sc->rparams);
- if (!err) {
+ if (!err && !video_is_started(call->video)) {
err = video_start(call->video, call->peer_uri);
}
if (err) {
@@ -332,10 +332,20 @@ static int update_media(struct call *call)
sc->pt, sc->params);
if (err) {
warning("call: video stream error: %m\n", err);
+ return err;
+ }
+
+ if (!video_is_started(call->video)) {
+ err = video_start(call->video, call->peer_uri);
+ if (err) {
+ warning("call: update: failed to"
+ " start video (%m)\n", err);
+ }
}
}
else if (call->video) {
info("video stream is disabled..\n");
+ video_stop(call->video);
}
#endif
diff --git a/src/core.h b/src/core.h
index 123a7cf..ac1efd8 100644
--- a/src/core.h
+++ b/src/core.h
@@ -424,6 +424,7 @@ int video_alloc(struct video **vp, const struct config *cfg,
video_err_h *errh, void *arg);
int video_start(struct video *v, const char *peer);
void video_stop(struct video *v);
+bool video_is_started(const struct video *v);
int video_encoder_set(struct video *v, struct vidcodec *vc,
int pt_tx, const char *params);
int video_decoder_set(struct video *v, struct vidcodec *vc, int pt_rx,
diff --git a/src/video.c b/src/video.c
index c13b6e9..baadc60 100644
--- a/src/video.c
+++ b/src/video.c
@@ -151,6 +151,7 @@ struct video {
struct vtx vtx; /**< Transmit/encoder direction */
struct vrx vrx; /**< Receive/decoder direction */
struct tmr tmr; /**< Timer for frame-rate estimation */
+ bool started; /**< True if video is started */
char *peer; /**< Peer URI */
bool nack_pli; /**< Send NACK/PLI to peer */
video_err_h *errh;
@@ -972,6 +973,8 @@ int video_start(struct video *v, const char *peer)
vrx_print_pipeline, &v->vrx);
}
+ v->started = true;
+
return 0;
}
@@ -981,10 +984,17 @@ void video_stop(struct video *v)
if (!v)
return;
+ v->started = false;
v->vtx.vsrc = mem_deref(v->vtx.vsrc);
}
+bool video_is_started(const struct video *v)
+{
+ return v ? v->started : false;
+}
+
+
/**
* Mute the video stream
*
@@ -1260,6 +1270,7 @@ int video_debug(struct re_printf *pf, const struct video *v)
vrx = &v->vrx;
err = re_hprintf(pf, "\n--- Video stream ---\n");
+ err |= re_hprintf(pf, " started: %s\n", v->started ? "yes" : "no");
err |= re_hprintf(pf, " tx: %u x %u, fps=%d\n",
vtx->vsrc_size.w,
vtx->vsrc_size.h, vtx->vsrc_prm.fps);