Recreate the pipeline on errors

parent db5888a7
......@@ -52,6 +52,9 @@ static MssStream streams_data[] = {
VIDEO_SINK, 2500,1242, NULL },
};
static gboolean setup_stream (MssStream *stream);
static void
validate_system (void)
{
......@@ -105,9 +108,10 @@ error_cb (GstBus * bus, GstMessage * msg, gpointer user_data)
g_print ("Debug details: %s\n", debug);
gst_element_set_state (stream->pipeline, GST_STATE_NULL);
g_clear_object (&stream->pipeline);
/* Retry in 3s...*/
g_timeout_add_seconds (3, (GSourceFunc) play_stream, stream);
g_timeout_add_seconds (3, (GSourceFunc) setup_stream, stream);
}
static GstBusSyncReply
......@@ -149,33 +153,43 @@ drop:
return GST_BUS_DROP;
}
static gboolean
setup_stream (MssStream *stream)
{
g_autoptr (GError) error = NULL;
g_autoptr (GstBus) bus = NULL;
stream->pipeline = gst_parse_launch (stream->description, &error);
if (!stream->pipeline) {
GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (player.window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
"Failed to create stream pipeline: %s", error->message);
gtk_dialog_run (GTK_DIALOG (dialog));
g_application_quit (player.app);
return G_SOURCE_REMOVE;
}
bus = gst_pipeline_get_bus (GST_PIPELINE (stream->pipeline));
gst_bus_add_signal_watch (bus);
g_signal_connect (bus, "message::error", G_CALLBACK (error_cb), stream);
gst_bus_set_sync_handler (bus, bus_sync_handler, stream, NULL);
play_stream (stream);
return G_SOURCE_REMOVE;
}
static void
setup_streams ()
{
gint i;
for (i = 0; i < G_N_ELEMENTS (streams_data); i++) {
g_autoptr (GError) error = NULL;
MssStream *stream = &streams_data[i];
g_autoptr (GstBus) bus = NULL;
stream->pipeline = gst_parse_launch (stream->description, &error);
if (!stream->pipeline) {
GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (player.window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
"Failed to create stream pipeline: %s", error->message);
gtk_dialog_run (GTK_DIALOG (dialog));
g_application_quit (player.app);
return;
}
bus = gst_pipeline_get_bus (GST_PIPELINE (stream->pipeline));
gst_bus_add_signal_watch (bus);
g_signal_connect (bus, "message::error", G_CALLBACK (error_cb), stream);
gst_bus_set_sync_handler (bus, bus_sync_handler, stream, NULL);
play_stream (stream);
setup_stream (stream);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment