mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-13 23:22:54 +00:00
validate:scenario: Implement a way to execute an action on message
And use it for seek forward and fast forward scenarios
This commit is contained in:
parent
374917b9c4
commit
cd19b10d45
4 changed files with 49 additions and 7 deletions
|
@ -5,5 +5,4 @@ seek, name=Fast-forward-seek, playback-time="min(10.0, $(duration) * 0.0625)", r
|
|||
seek, name=Fast-forward-seek, playback-time="min(20.0, $(duration) * 0.125)", rate=8.0, start=0.0, flags="$(default_flags)"
|
||||
seek, name=Fast-forward-seek, playback-time="min(40.0, $(duration) * 0.25)", rate=16.0, start=0.0, flags="$(default_flags)"
|
||||
seek, name=Fast-forward-seek, playback-time="min(80.0, $(duration) * 0.50)", rate=32.0, start=0.0, flags="$(default_flags)"
|
||||
wait, message-type=eos
|
||||
stop
|
||||
stop, playback-time="min($(duration) - 0.3, 160.0)", on-message="eos"
|
||||
|
|
|
@ -3,4 +3,4 @@ include,location=includes/default-seek-flags.scenario
|
|||
seek, name=First-forward-seek, playback-time="min(5.0, ($(duration)/8))", start="min(10, 2*($(duration)/8))", flags="$(default_flags)"
|
||||
seek, name=Second-forward-seek, playback-time="min(15.0, 3*($(duration)/8))", start="min(20, 4*($(duration)/8))", flags="$(default_flags)"
|
||||
seek, name=Third-forward-seek, playback-time="min(25, 5*($(duration)/8))", start="min(30.0, 6*($(duration)/8))", flags="$(default_flags)"
|
||||
stop, playback-time="min($(duration) - 1, 35)"
|
||||
stop, playback-time="min($(duration) - 1, 35)", on-eos=true
|
|
@ -929,6 +929,19 @@ gst_validate_printf_valist (gpointer source, const gchar * format, va_list args)
|
|||
.def = "0.0"
|
||||
};
|
||||
|
||||
GstValidateActionParameter on_message_param = {
|
||||
.name = "on-message",
|
||||
.description =
|
||||
"Specify on what message type the action will be executed.\n"
|
||||
" If both 'playback-time' and 'on-message' is specified, the action will be executed\n"
|
||||
" on whatever happens first.",
|
||||
.mandatory = FALSE,
|
||||
.types = "string",
|
||||
.possible_variables = NULL,
|
||||
.def = NULL
|
||||
};
|
||||
|
||||
|
||||
GstValidateActionType *type = GST_VALIDATE_ACTION_TYPE (source);
|
||||
|
||||
g_string_assign (string, "\nAction type:");
|
||||
|
@ -947,12 +960,16 @@ gst_validate_printf_valist (gpointer source, const gchar * format, va_list args)
|
|||
g_string_append_printf (string, "\n\n Description: \n %s", desc);
|
||||
g_free (desc);
|
||||
|
||||
if (!IS_CONFIG_ACTION_TYPE (type->flags))
|
||||
if (!IS_CONFIG_ACTION_TYPE (type->flags)) {
|
||||
g_string_append_printf (string, "\n\n Parameters:");
|
||||
print_action_parameter (string, type, &playback_time_param);
|
||||
print_action_parameter (string, type, &on_message_param);
|
||||
}
|
||||
|
||||
if (type->parameters) {
|
||||
if (IS_CONFIG_ACTION_TYPE (type->flags))
|
||||
g_string_append_printf (string, "\n\n Parameters:");
|
||||
has_parameters = TRUE;
|
||||
g_string_append_printf (string, "\n\n Parameters:");
|
||||
for (i = 0; type->parameters[i].name; i++) {
|
||||
print_action_parameter (string, type, &type->parameters[i]);
|
||||
}
|
||||
|
|
|
@ -1681,6 +1681,15 @@ _check_position (GstValidateScenario * scenario, GstValidateAction * act,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_check_message_type (GstValidateScenario * scenario, GstValidateAction * act,
|
||||
GstMessage * message)
|
||||
{
|
||||
return act && message
|
||||
&& !g_strcmp0 (gst_structure_get_string (act->structure, "on-message"),
|
||||
gst_message_type_get_name (GST_MESSAGE_TYPE (message)));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_should_execute_action (GstValidateScenario * scenario, GstValidateAction * act,
|
||||
GstClockTime position, gdouble rate)
|
||||
|
@ -2029,7 +2038,7 @@ done:
|
|||
* synchronously
|
||||
*/
|
||||
static gboolean
|
||||
execute_next_action (GstValidateScenario * scenario)
|
||||
execute_next_action_full (GstValidateScenario * scenario, GstMessage * message)
|
||||
{
|
||||
GList *tmp;
|
||||
gdouble rate = 1.0;
|
||||
|
@ -2104,8 +2113,12 @@ execute_next_action (GstValidateScenario * scenario)
|
|||
}
|
||||
}
|
||||
|
||||
if (!_check_position (scenario, act, &position, &rate))
|
||||
if (message) {
|
||||
if (!_check_message_type (scenario, act, message))
|
||||
return G_SOURCE_CONTINUE;
|
||||
} else if (!_check_position (scenario, act, &position, &rate)) {
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
if (!_should_execute_action (scenario, act, position, rate)) {
|
||||
_add_execute_actions_gsource (scenario);
|
||||
|
@ -2119,6 +2132,11 @@ execute_next_action (GstValidateScenario * scenario)
|
|||
" at %" GST_TIME_FORMAT, act->structure, GST_TIME_ARGS (position));
|
||||
priv->seeked_in_pause = FALSE;
|
||||
|
||||
if (message)
|
||||
gst_structure_remove_field (act->structure, "playback-time");
|
||||
else
|
||||
gst_structure_remove_field (act->structure, "on-message");
|
||||
|
||||
act->priv->state = gst_validate_execute_action (type, act);
|
||||
if (act->priv->state == GST_VALIDATE_EXECUTE_ACTION_ERROR) {
|
||||
gchar *str = gst_structure_to_string (act->structure);
|
||||
|
@ -2187,6 +2205,12 @@ execute_next_action (GstValidateScenario * scenario)
|
|||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
execute_next_action (GstValidateScenario * scenario)
|
||||
{
|
||||
return execute_next_action_full (scenario, NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
stop_waiting (GstValidateAction * action)
|
||||
{
|
||||
|
@ -3338,6 +3362,8 @@ done:
|
|||
if (priv->message_type)
|
||||
_check_waiting_for_message (scenario, message);
|
||||
|
||||
execute_next_action_full (scenario, message);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue