From f2d7b98ea4087b93f25ca59aec7d3f5d83071ca4 Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Wed, 1 Dec 2021 16:04:24 +0100 Subject: [PATCH] rtmp2/connection: Pass triggering GError in 'error' signal Part-of: --- subprojects/gst-plugins-bad/gst/rtmp2/gstrtmp2sink.c | 7 +++++-- subprojects/gst-plugins-bad/gst/rtmp2/gstrtmp2src.c | 6 ++++-- subprojects/gst-plugins-bad/gst/rtmp2/rtmp/rtmpclient.c | 9 +++++---- subprojects/gst-plugins-bad/gst/rtmp2/rtmp/rtmpconnection.c | 4 ++-- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst/rtmp2/gstrtmp2sink.c b/subprojects/gst-plugins-bad/gst/rtmp2/gstrtmp2sink.c index 3cc6983..5feb489 100644 --- a/subprojects/gst-plugins-bad/gst/rtmp2/gstrtmp2sink.c +++ b/subprojects/gst-plugins-bad/gst/rtmp2/gstrtmp2sink.c @@ -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); diff --git a/subprojects/gst-plugins-bad/gst/rtmp2/gstrtmp2src.c b/subprojects/gst-plugins-bad/gst/rtmp2/gstrtmp2src.c index 960e2da..4945ddd 100644 --- a/subprojects/gst-plugins-bad/gst/rtmp2/gstrtmp2src.c +++ b/subprojects/gst-plugins-bad/gst/rtmp2/gstrtmp2src.c @@ -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); diff --git a/subprojects/gst-plugins-bad/gst/rtmp2/rtmp/rtmpclient.c b/subprojects/gst-plugins-bad/gst/rtmp2/rtmp/rtmpclient.c index 0e57cdd..1eca5c1 100644 --- a/subprojects/gst-plugins-bad/gst/rtmp2/rtmp/rtmpclient.c +++ b/subprojects/gst-plugins-bad/gst/rtmp2/rtmp/rtmpclient.c @@ -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 * diff --git a/subprojects/gst-plugins-bad/gst/rtmp2/rtmp/rtmpconnection.c b/subprojects/gst-plugins-bad/gst/rtmp2/rtmp/rtmpconnection.c index 0f6e08b..3832601 100644 --- a/subprojects/gst-plugins-bad/gst/rtmp2/rtmp/rtmpconnection.c +++ b/subprojects/gst-plugins-bad/gst/rtmp2/rtmp/rtmpconnection.c @@ -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); -- 2.7.4