From 2d7d03d2f78e518a7d23c16aedd4ae247fcdb64f Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Wed, 23 Apr 2014 13:24:23 +0200 Subject: [PATCH] validate: Add a 'stop' action to stop a pipeline It uses the GST_MESSAGE_REQUEST state with the scenario as a source so that application can stop running when they receive it on the bus. --- validate/gst/validate/gst-validate-report.c | 2 ++ validate/gst/validate/gst-validate-report.h | 1 + validate/gst/validate/gst-validate-scenario.c | 16 ++++++++++++++++ validate/tools/gst-validate-transcoding.c | 19 +++++++++++++++++++ validate/tools/gst-validate.c | 14 ++++++++++++++ 5 files changed, 52 insertions(+) diff --git a/validate/gst/validate/gst-validate-report.c b/validate/gst/validate/gst-validate-report.c index 038cfc46b7..51a33ca09b 100644 --- a/validate/gst/validate/gst-validate-report.c +++ b/validate/gst/validate/gst-validate-report.c @@ -218,6 +218,8 @@ gst_validate_report_load_issues (void) _("All the actions were not executed before the program stoped"), NULL); REGISTER_VALIDATE_ISSUE (CRITICAL, SCENARIO_ACTION_EXECUTION_ERROR, _("The execution of an action did not properly happen"), NULL); + REGISTER_VALIDATE_ISSUE (ISSUE, SCENARIO_ACTION_EXECUTION_ISSUE, + _("An issue happend during the execution of a scenario"), NULL); REGISTER_VALIDATE_ISSUE (WARNING, G_LOG_WARNING, _("We got a g_log warning"), NULL); REGISTER_VALIDATE_ISSUE (WARNING, G_LOG_CRITICAL, diff --git a/validate/gst/validate/gst-validate-report.h b/validate/gst/validate/gst-validate-report.h index e7a9626bb5..313de84d37 100644 --- a/validate/gst/validate/gst-validate-report.h +++ b/validate/gst/validate/gst-validate-report.h @@ -112,6 +112,7 @@ typedef enum { #define GST_VALIDATE_ISSUE_ID_SCENARIO_NOT_ENDED (((GstValidateIssueId) GST_VALIDATE_AREA_SCENARIO) << GST_VALIDATE_ISSUE_ID_SHIFT | 1) #define GST_VALIDATE_ISSUE_ID_SCENARIO_ACTION_EXECUTION_ERROR (((GstValidateIssueId) GST_VALIDATE_AREA_SCENARIO) << GST_VALIDATE_ISSUE_ID_SHIFT | 2) +#define GST_VALIDATE_ISSUE_ID_SCENARIO_ACTION_EXECUTION_ISSUE (((GstValidateIssueId) GST_VALIDATE_AREA_SCENARIO) << GST_VALIDATE_ISSUE_ID_SHIFT | 3) #define GST_VALIDATE_ISSUE_ID_G_LOG_ISSUE (((GstValidateIssueId) GST_VALIDATE_AREA_OTHER) << GST_VALIDATE_ISSUE_ID_SHIFT | 1) #define GST_VALIDATE_ISSUE_ID_G_LOG_WARNING (((GstValidateIssueId) GST_VALIDATE_AREA_OTHER) << GST_VALIDATE_ISSUE_ID_SHIFT | 2) diff --git a/validate/gst/validate/gst-validate-scenario.c b/validate/gst/validate/gst-validate-scenario.c index a503044e07..693e5c2f0c 100644 --- a/validate/gst/validate/gst-validate-scenario.c +++ b/validate/gst/validate/gst-validate-scenario.c @@ -334,6 +334,20 @@ _execute_play (GstValidateScenario * scenario, GstValidateAction * action) return TRUE; } +static gboolean +_execute_stop (GstValidateScenario * scenario, GstValidateAction * action) +{ + GstBus *bus = gst_element_get_bus (scenario->pipeline); + + gst_validate_printf (action, "Stoping pipeline"); + + gst_bus_post (bus, + gst_message_new_request_state (GST_OBJECT_CAST (scenario), + GST_STATE_NULL)); + + return TRUE; +} + static gboolean _execute_eos (GstValidateScenario * scenario, GstValidateAction * action) { @@ -1448,6 +1462,8 @@ init_scenarios (void) " (in second)", FALSE); gst_validate_add_action_type ("play", _execute_play, NULL, "Make it possible to set the pipeline state to PLAYING", FALSE); + gst_validate_add_action_type ("stop", _execute_stop, NULL, + "Make it possible to set the pipeline state to NULL", FALSE); gst_validate_add_action_type ("eos", _execute_eos, NULL, "Make it possible to send an EOS to the pipeline", FALSE); gst_validate_add_action_type ("switch-track", _execute_switch_track, NULL, diff --git a/validate/tools/gst-validate-transcoding.c b/validate/tools/gst-validate-transcoding.c index fb6864e9fe..76d88f1a95 100644 --- a/validate/tools/gst-validate-transcoding.c +++ b/validate/tools/gst-validate-transcoding.c @@ -495,6 +495,25 @@ bus_callback (GstBus * bus, GstMessage * message, gpointer data) } break; } + case GST_MESSAGE_REQUEST_STATE: + { + GstState state; + + gst_message_parse_request_state (message, &state); + + if (GST_IS_VALIDATE_SCENARIO (GST_MESSAGE_SRC (message)) + && state == GST_STATE_NULL) { + GST_VALIDATE_REPORT (GST_MESSAGE_SRC (message), + SCENARIO_ACTION_EXECUTION_ISSUE, + "Force stopping a transcoding pipeline is not recommanded" + " you should make sure to finalize it using a EOS event"); + + gst_validate_printf (pipeline, "State change request NULL, " + "quiting mainloop\n"); + g_main_loop_quit (mainloop); + } + break; + } default: break; } diff --git a/validate/tools/gst-validate.c b/validate/tools/gst-validate.c index 7521f9fd52..2ffe23065a 100644 --- a/validate/tools/gst-validate.c +++ b/validate/tools/gst-validate.c @@ -127,6 +127,20 @@ bus_callback (GstBus * bus, GstMessage * message, gpointer data) } break; } + case GST_MESSAGE_REQUEST_STATE: + { + GstState state; + + gst_message_parse_request_state (message, &state); + + if (GST_IS_VALIDATE_SCENARIO (GST_MESSAGE_SRC (message)) + && state == GST_STATE_NULL) { + gst_validate_printf (GST_MESSAGE_SRC (message), "State change request NULL, " + "quiting mainloop\n"); + g_main_loop_quit (mainloop); + } + break; + } default: break; }