diff options
author | Alfred E. Heggestad <aeh@db.org> | 2015-03-21 18:28:58 +0100 |
---|---|---|
committer | Alfred E. Heggestad <aeh@db.org> | 2015-03-21 18:28:58 +0100 |
commit | d24e5bff254efd7a9f1dbc8d5bf82ed8fd2a52d8 (patch) | |
tree | 3267ef00ffb9881f664bde2a4da21a292a633e31 /src | |
parent | 02799812b5d8b87630b9f7d6056c4830f6957060 (diff) |
add video error handler
Diffstat (limited to 'src')
-rw-r--r-- | src/call.c | 15 | ||||
-rw-r--r-- | src/core.h | 5 | ||||
-rw-r--r-- | src/video.c | 20 |
3 files changed, 37 insertions, 3 deletions
@@ -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; } @@ -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) |