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.
This commit is contained in:
Thibault Saunier 2014-04-23 13:24:23 +02:00
parent 7133e4b4e0
commit 2d7d03d2f7
5 changed files with 52 additions and 0 deletions

View file

@ -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,

View file

@ -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)

View file

@ -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,

View file

@ -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;
}

View file

@ -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;
}