rtsp: Add error_full callback to GstRTSPWatchFuncs.
authorPeter Kjellerstedt <pkj@axis.com>
Tue, 16 Jun 2009 16:38:02 +0000 (18:38 +0200)
committerPeter Kjellerstedt <pkj@axis.com>
Mon, 24 Aug 2009 11:19:45 +0000 (13:19 +0200)
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
gst-libs/gst/rtsp/gstrtspconnection.h

index 3970587..44f65c5 100644 (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) {
index 4f95447..50549af 100644 (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,