From cf871f990ac1ee06e5a44f66628e3f9335ae3e9d Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Sat, 30 Oct 2021 01:55:38 +0900 Subject: [PATCH] examples: win32-videooverlay-playbin: Add a repeat option ... in order to test pipeline/element reuse cases. Part-of: --- .../overlay/win32-videooverlay-playbin.c | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/subprojects/gst-plugins-base/tests/examples/overlay/win32-videooverlay-playbin.c b/subprojects/gst-plugins-base/tests/examples/overlay/win32-videooverlay-playbin.c index 15e3b9de8e..a34ffddfc4 100644 --- a/subprojects/gst-plugins-base/tests/examples/overlay/win32-videooverlay-playbin.c +++ b/subprojects/gst-plugins-base/tests/examples/overlay/win32-videooverlay-playbin.c @@ -30,6 +30,7 @@ static GMainLoop *loop = NULL; static gboolean visible = FALSE; static HWND hwnd = NULL; static gboolean set_handle_on_request = FALSE; +static gboolean test_reuse = FALSE; static LRESULT CALLBACK window_proc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) @@ -115,6 +116,8 @@ bus_sync_handler (GstBus * bus, GstMessage * msg, gpointer user_data) g_clear_error (&err); g_free (dbg); + test_reuse = FALSE; + g_main_loop_quit (loop); break; } @@ -145,6 +148,9 @@ main (gint argc, gchar ** argv) {"set-handle-on-request", 0, 0, G_OPTION_ARG_NONE, &set_handle_on_request, "Set window handle on \"prepare-window-handle\" message", NULL} , + {"repeat", 0, 0, G_OPTION_ARG_NONE, &test_reuse, + "Repeat and reuse pipeline per EOS", NULL} + , {NULL} }; @@ -218,22 +224,25 @@ main (gint argc, gchar ** argv) gst_println ("Will set window handle on \"prepare-window-handle\" message"); } - g_object_set (playbin, "uri", uri, NULL); + gst_bus_add_watch (GST_ELEMENT_BUS (playbin), bus_msg, playbin); gst_bus_set_sync_handler (GST_ELEMENT_BUS (playbin), bus_sync_handler, NULL, NULL); - gst_bus_add_watch (GST_ELEMENT_BUS (playbin), bus_msg, playbin); + g_object_set (playbin, "uri", uri, NULL); - if (gst_element_set_state (playbin, - GST_STATE_PAUSED) == GST_STATE_CHANGE_FAILURE) { - gst_printerrln ("Pipeline doesn't want to pause"); - gst_bus_remove_watch (GST_ELEMENT_BUS (playbin)); + do { + if (gst_element_set_state (playbin, + GST_STATE_PAUSED) == GST_STATE_CHANGE_FAILURE) { + gst_printerrln ("Pipeline doesn't want to pause"); + gst_bus_remove_watch (GST_ELEMENT_BUS (playbin)); - exitcode = 1; - goto terminate; - } + exitcode = 1; + goto terminate; + } + + g_main_loop_run (loop); + gst_element_set_state (playbin, GST_STATE_NULL); + } while (test_reuse); - g_main_loop_run (loop); - gst_element_set_state (playbin, GST_STATE_NULL); gst_bus_remove_watch (GST_ELEMENT_BUS (playbin)); terminate: