From e5ec74c7a9e71760e55744a2a90dd28ee1ef7cc3 Mon Sep 17 00:00:00 2001 From: Peter Kjellerstedt Date: Tue, 16 Jun 2009 18:38:02 +0200 Subject: [PATCH] rtsp: Add error_full callback to GstRTSPWatchFuncs. The error_full callback is similar to the error callback, but allows for better error handling. For read errors a partial message is provided to help an RTSP server generate a more correct error response, and for write errors the write queue id of the failed message is returned. --- gst-libs/gst/rtsp/gstrtspconnection.c | 24 +++++++++++++++++------- gst-libs/gst/rtsp/gstrtspconnection.h | 7 ++++++- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/gst-libs/gst/rtsp/gstrtspconnection.c b/gst-libs/gst/rtsp/gstrtspconnection.c index 3970587..44f65c5 100644 --- a/gst-libs/gst/rtsp/gstrtspconnection.c +++ b/gst-libs/gst/rtsp/gstrtspconnection.c @@ -3025,8 +3025,13 @@ gst_rtsp_source_dispatch (GSource * source, GSourceFunc callback G_GNUC_UNUSED, if (watch->funcs.message_received) watch->funcs.message_received (watch, &watch->message, watch->user_data); - } else - goto error; + } else { + if (watch->funcs.error_full) + GST_RTSP_CHECK (watch->funcs.error_full (watch, res, &watch->message, + 0, watch->user_data), error); + else + goto error; + } read_done: gst_rtsp_message_unset (&watch->message); @@ -3056,11 +3061,16 @@ gst_rtsp_source_dispatch (GSource * source, GSourceFunc callback G_GNUC_UNUSED, &watch->write_off, watch->write_size); if (res == GST_RTSP_EINTR) break; - if (G_UNLIKELY (res != GST_RTSP_OK)) - goto error; - - if (watch->funcs.message_sent) - watch->funcs.message_sent (watch, watch->write_id, watch->user_data); + else if (G_LIKELY (res == GST_RTSP_OK)) { + if (watch->funcs.message_sent) + watch->funcs.message_sent (watch, watch->write_id, watch->user_data); + } else { + if (watch->funcs.error_full) + GST_RTSP_CHECK (watch->funcs.error_full (watch, res, NULL, + watch->write_id, watch->user_data), error); + else + goto error; + } done: if (g_async_queue_length (watch->messages) == 0 && watch->write_added) { diff --git a/gst-libs/gst/rtsp/gstrtspconnection.h b/gst-libs/gst/rtsp/gstrtspconnection.h index 4f95447..50549af 100644 --- a/gst-libs/gst/rtsp/gstrtspconnection.h +++ b/gst-libs/gst/rtsp/gstrtspconnection.h @@ -148,6 +148,8 @@ typedef struct _GstRTSPWatch GstRTSPWatch; * @tunnel_complete: a client finished a tunneled connection. In this callback * you usually pair the tunnelid of this connection with the saved one using * gst_rtsp_connection_do_tunnel(). + * @error_full: callback when an error occured with more information than + * the @error callback * * Callback functions from a #GstRTSPWatch. * @@ -163,9 +165,12 @@ typedef struct { gpointer user_data); GstRTSPStatusCode (*tunnel_start) (GstRTSPWatch *watch, gpointer user_data); GstRTSPResult (*tunnel_complete) (GstRTSPWatch *watch, gpointer user_data); + GstRTSPResult (*error_full) (GstRTSPWatch *watch, GstRTSPResult result, + GstRTSPMessage *message, guint id, + gpointer user_data); /*< private >*/ - gpointer _gst_reserved[GST_PADDING]; + gpointer _gst_reserved[GST_PADDING - 1]; } GstRTSPWatchFuncs; GstRTSPWatch * gst_rtsp_watch_new (GstRTSPConnection *conn, -- 2.7.4