rtmp2/connection: Pass triggering GError in 'error' signal
authorJan Alexander Steffens (heftig) <jan.steffens@ltnglobal.com>
Wed, 1 Dec 2021 15:04:24 +0000 (16:04 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 7 Nov 2022 12:31:08 +0000 (12:31 +0000)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1403>

subprojects/gst-plugins-bad/gst/rtmp2/gstrtmp2sink.c
subprojects/gst-plugins-bad/gst/rtmp2/gstrtmp2src.c
subprojects/gst-plugins-bad/gst/rtmp2/rtmp/rtmpclient.c
subprojects/gst-plugins-bad/gst/rtmp2/rtmp/rtmpconnection.c

index 3cc6983..5feb489 100644 (file)
@@ -1075,13 +1075,16 @@ put_chunk (GstRtmpConnection * connection, gpointer user_data)
 }
 
 static void
-error_callback (GstRtmpConnection * connection, GstRtmp2Sink * self)
+error_callback (GstRtmpConnection * connection, const GError * error,
+    GstRtmp2Sink * self)
 {
   g_mutex_lock (&self->lock);
   if (self->cancellable) {
     g_cancellable_cancel (self->cancellable);
   } else if (self->loop) {
-    GST_ELEMENT_ERROR (self, RESOURCE, WRITE, ("Connection error"), (NULL));
+    GST_ELEMENT_ERROR (self, RESOURCE, WRITE,
+        ("Connection error: %s", error->message),
+        ("domain %s, code %d", g_quark_to_string (error->domain), error->code));
     stop_task (self);
   }
   g_mutex_unlock (&self->lock);
index 960e2da..4945ddd 100644 (file)
@@ -917,13 +917,15 @@ out:
 }
 
 static void
-error_callback (GstRtmpConnection * connection, GstRtmp2Src * self)
+error_callback (GstRtmpConnection * connection, const GError * error,
+    GstRtmp2Src * self)
 {
   g_mutex_lock (&self->lock);
   if (self->cancellable) {
     g_cancellable_cancel (self->cancellable);
   } else if (self->loop) {
-    GST_INFO_OBJECT (self, "Connection error");
+    GST_INFO_OBJECT (self, "Connection error: %s %d %s",
+        g_quark_to_string (error->domain), error->code, error->message);
     stop_task (self);
   }
   g_mutex_unlock (&self->lock);
index 0e57cdd..1eca5c1 100644 (file)
@@ -321,7 +321,7 @@ static void send_stop (GstRtmpConnection * connection, const gchar * stream,
 static void send_secure_token_response (GTask * task,
     GstRtmpConnection * connection, const gchar * challenge);
 static void connection_error (GstRtmpConnection * connection,
-    gpointer user_data);
+    const GError * error, gpointer user_data);
 
 #define DEFAULT_TIMEOUT 5
 
@@ -510,12 +510,13 @@ handshake_done (GObject * source, GAsyncResult * result, gpointer user_data)
 }
 
 static void
-connection_error (GstRtmpConnection * connection, gpointer user_data)
+connection_error (GstRtmpConnection * connection, const GError * error,
+    gpointer user_data)
 {
   GTask *task = user_data;
+
   if (!g_task_had_error (task))
-    g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED,
-        "error during connection attempt");
+    g_task_return_error (task, g_error_copy (error));
 }
 
 static gchar *
index 0f6e08b..3832601 100644 (file)
@@ -245,7 +245,7 @@ gst_rtmp_connection_class_init (GstRtmpConnectionClass * klass)
   gobject_class->finalize = gst_rtmp_connection_finalize;
 
   signals[SIGNAL_ERROR] = g_signal_new ("error", G_TYPE_FROM_CLASS (klass),
-      G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 0);
+      G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_ERROR);
 
   signals[SIGNAL_STREAM_CONTROL] = g_signal_new ("stream-control",
       G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL,
@@ -582,7 +582,7 @@ gst_rtmp_connection_emit_error (GstRtmpConnection * self, GError * error)
   if (!self->error) {
     self->error = TRUE;
     cancel_all_commands (self, error->message);
-    g_signal_emit (self, signals[SIGNAL_ERROR], 0);
+    g_signal_emit (self, signals[SIGNAL_ERROR], 0, error);
   }
 
   g_error_free (error);