summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlfred E. Heggestad <aeh@db.org>2015-03-21 18:28:58 +0100
committerAlfred E. Heggestad <aeh@db.org>2015-03-21 18:28:58 +0100
commitd24e5bff254efd7a9f1dbc8d5bf82ed8fd2a52d8 (patch)
tree3267ef00ffb9881f664bde2a4da21a292a633e31 /src
parent02799812b5d8b87630b9f7d6056c4830f6957060 (diff)
add video error handler
Diffstat (limited to 'src')
-rw-r--r--src/call.c15
-rw-r--r--src/core.h5
-rw-r--r--src/video.c20
3 files changed, 37 insertions, 3 deletions
diff --git a/src/call.c b/src/call.c
index 752a2bd..d9a4a94 100644
--- a/src/call.c
+++ b/src/call.c
@@ -391,6 +391,18 @@ static void audio_error_handler(int err, const char *str, void *arg)
}
+static void video_error_handler(int err, const char *str, void *arg)
+{
+ struct call *call = arg;
+ MAGIC_CHECK(call);
+
+ warning("call: video device error: %m (%s)\n", err, str);
+
+ call_stream_stop(call);
+ call_event_handler(call, CALL_EVENT_CLOSED, str);
+}
+
+
static void menc_error_handler(int err, void *arg)
{
struct call *call = arg;
@@ -523,7 +535,8 @@ int call_alloc(struct call **callp, const struct config *cfg, struct list *lst,
acc->mnat, call->mnats,
acc->menc, call->mencs,
"main",
- account_vidcodecl(call->acc));
+ account_vidcodecl(call->acc),
+ video_error_handler, call);
if (err)
goto out;
}
diff --git a/src/core.h b/src/core.h
index 2f64192..4c1c6bb 100644
--- a/src/core.h
+++ b/src/core.h
@@ -403,11 +403,14 @@ struct vidsrc *vidsrc_get(struct vidsrc_st *st);
struct video;
+typedef void (video_err_h)(int err, const char *str, void *arg);
+
int video_alloc(struct video **vp, const struct config *cfg,
struct call *call, struct sdp_session *sdp_sess, int label,
const struct mnat *mnat, struct mnat_sess *mnat_sess,
const struct menc *menc, struct menc_sess *menc_sess,
- const char *content, const struct list *vidcodecl);
+ const char *content, const struct list *vidcodecl,
+ video_err_h *errh, void *arg);
int video_start(struct video *v, const char *peer);
void video_stop(struct video *v);
int video_encoder_set(struct video *v, struct vidcodec *vc,
diff --git a/src/video.c b/src/video.c
index 9829115..39909b5 100644
--- a/src/video.c
+++ b/src/video.c
@@ -149,6 +149,8 @@ struct video {
struct tmr tmr; /**< Timer for frame-rate estimation */
char *peer; /**< Peer URI */
bool nack_pli; /**< Send NACK/PLI to peer */
+ video_err_h *errh;
+ void *arg;
};
@@ -558,6 +560,18 @@ static int video_stream_decode(struct vrx *vrx, const struct rtp_header *hdr,
}
err = vidisp_display(vrx->vidisp, v->peer, &frame);
+ if (err == ENODEV) {
+ warning("video: video-display was closed\n");
+ vrx->vidisp = mem_deref(vrx->vidisp);
+
+ lock_rel(vrx->lock);
+
+ if (v->errh) {
+ v->errh(err, "display closed", v->arg);
+ }
+
+ return err;
+ }
++vrx->frames;
@@ -696,7 +710,8 @@ int video_alloc(struct video **vp, const struct config *cfg,
struct call *call, struct sdp_session *sdp_sess, int label,
const struct mnat *mnat, struct mnat_sess *mnat_sess,
const struct menc *menc, struct menc_sess *menc_sess,
- const char *content, const struct list *vidcodecl)
+ const char *content, const struct list *vidcodecl,
+ video_err_h *errh, void *arg)
{
struct video *v;
struct le *le;
@@ -741,6 +756,9 @@ int video_alloc(struct video **vp, const struct config *cfg,
if (err)
goto out;
+ v->errh = errh;
+ v->arg = arg;
+
err = vtx_alloc(&v->vtx, v);
err |= vrx_alloc(&v->vrx, v);
if (err)