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.
This commit is contained in:
Peter Kjellerstedt 2009-06-16 18:38:02 +02:00
parent ab8bea4555
commit e5ec74c7a9
2 changed files with 23 additions and 8 deletions

View file

@ -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) {

View file

@ -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,