examples: win32-videooverlay-playbin: Add a repeat option

... in order to test pipeline/element reuse cases.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1275>
This commit is contained in:
Seungha Yang 2021-10-30 01:55:38 +09:00 committed by GStreamer Marge Bot
parent aedd5f0dd1
commit cf871f990a

View file

@ -30,6 +30,7 @@ static GMainLoop *loop = NULL;
static gboolean visible = FALSE; static gboolean visible = FALSE;
static HWND hwnd = NULL; static HWND hwnd = NULL;
static gboolean set_handle_on_request = FALSE; static gboolean set_handle_on_request = FALSE;
static gboolean test_reuse = FALSE;
static LRESULT CALLBACK static LRESULT CALLBACK
window_proc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 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_clear_error (&err);
g_free (dbg); g_free (dbg);
test_reuse = FALSE;
g_main_loop_quit (loop); g_main_loop_quit (loop);
break; 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-handle-on-request", 0, 0, G_OPTION_ARG_NONE, &set_handle_on_request,
"Set window handle on \"prepare-window-handle\" message", NULL} "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} {NULL}
}; };
@ -218,22 +224,25 @@ main (gint argc, gchar ** argv)
gst_println ("Will set window handle on \"prepare-window-handle\" message"); 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), gst_bus_set_sync_handler (GST_ELEMENT_BUS (playbin),
bus_sync_handler, NULL, NULL); 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, do {
GST_STATE_PAUSED) == GST_STATE_CHANGE_FAILURE) { if (gst_element_set_state (playbin,
gst_printerrln ("Pipeline doesn't want to pause"); GST_STATE_PAUSED) == GST_STATE_CHANGE_FAILURE) {
gst_bus_remove_watch (GST_ELEMENT_BUS (playbin)); gst_printerrln ("Pipeline doesn't want to pause");
gst_bus_remove_watch (GST_ELEMENT_BUS (playbin));
exitcode = 1; exitcode = 1;
goto terminate; 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)); gst_bus_remove_watch (GST_ELEMENT_BUS (playbin));
terminate: terminate: