scenario: Actions order in xml file is the order in which they must be executed

When seeking we might want to execute seeks at a playback time inferior than previous
seek, so we need to be able to define the order in which actions have to be
executed, the simplest way is to just concider that actions are always
order in the XML files.

+ Add some more debugs

Conflicts:

	gst/validate/gst-validate-scenario.c
This commit is contained in:
Thibault Saunier 2013-08-15 12:33:23 +02:00 committed by Thiago Santos
parent 15b3049764
commit ddd00741fd

View file

@ -65,6 +65,8 @@ typedef struct _ScenarioAction
ScenarioActionType type; ScenarioActionType type;
gchar *name; gchar *name;
GstClockTime playback_time; GstClockTime playback_time;
guint action_number; /* The sequential number on which the action should
be executed */
} ScenarioAction; } ScenarioAction;
#define SCENARIO_ACTION(act) ((ScenarioAction *)act) #define SCENARIO_ACTION(act) ((ScenarioAction *)act)
@ -104,6 +106,8 @@ struct _GstValidateScenarioPrivate
gint64 seeked_position; /* last seeked position */ gint64 seeked_position; /* last seeked position */
GstClockTime seek_pos_tol; GstClockTime seek_pos_tol;
guint num_actions;
/* markup parser context */ /* markup parser context */
gboolean in_scenario; gboolean in_scenario;
gboolean in_actions; gboolean in_actions;
@ -253,13 +257,16 @@ _parse_seek (GMarkupParseContext * context, const gchar * element_name,
if (!g_markup_collect_attributes (element_name, attribute_names, if (!g_markup_collect_attributes (element_name, attribute_names,
attribute_values, error, attribute_values, error,
G_MARKUP_COLLECT_STRDUP | G_MARKUP_COLLECT_OPTIONAL, "name", G_MARKUP_COLLECT_STRDUP | G_MARKUP_COLLECT_OPTIONAL, "name",
&info->action.name, G_MARKUP_COLLECT_STRING, "playback_time", &info->action.name,
&playback_time, G_MARKUP_COLLECT_STRING, "format", &format, G_MARKUP_COLLECT_STRING, "playback_time",
G_MARKUP_COLLECT_STRING, "rate", &rate, G_MARKUP_COLLECT_STRING, &playback_time,
"flags", &flags, G_MARKUP_COLLECT_STRING, "start_type", &start_type, G_MARKUP_COLLECT_STRING, "format", &format,
G_MARKUP_COLLECT_STRING, "start", &start, G_MARKUP_COLLECT_STRING, G_MARKUP_COLLECT_STRING, "rate", &rate,
"stop_type", &stop_type, G_MARKUP_COLLECT_STRING, "stop", &stop, G_MARKUP_COLLECT_STRING, "flags", &flags,
G_MARKUP_COLLECT_INVALID)) G_MARKUP_COLLECT_STRING, "start_type", &start_type,
G_MARKUP_COLLECT_STRING, "start", &start,
G_MARKUP_COLLECT_STRING, "stop_type", &stop_type,
G_MARKUP_COLLECT_STRING, "stop", &stop, G_MARKUP_COLLECT_INVALID))
return; return;
get_enum_from_string (GST_TYPE_FORMAT, format, &info->format); get_enum_from_string (GST_TYPE_FORMAT, format, &info->format);
@ -272,6 +279,7 @@ _parse_seek (GMarkupParseContext * context, const gchar * element_name,
info->start = g_ascii_strtoull (start, NULL, 10); info->start = g_ascii_strtoull (start, NULL, 10);
get_enum_from_string (GST_TYPE_SEEK_TYPE, stop_type, &info->stop_type); get_enum_from_string (GST_TYPE_SEEK_TYPE, stop_type, &info->stop_type);
info->stop = g_ascii_strtoull (stop, NULL, 10); info->stop = g_ascii_strtoull (stop, NULL, 10);
info->action.action_number = priv->num_actions++;
priv->actions = g_list_append (priv->actions, info); priv->actions = g_list_append (priv->actions, info);
} }
@ -298,6 +306,9 @@ _parse_pause (GMarkupParseContext * context, const gchar * element_name,
if (playback_time) if (playback_time)
info->action.playback_time = g_ascii_strtoull (playback_time, NULL, 10); info->action.playback_time = g_ascii_strtoull (playback_time, NULL, 10);
info->duration = g_ascii_strtoull (duration, NULL, 10); info->duration = g_ascii_strtoull (duration, NULL, 10);
info->action.action_number = priv->num_actions++;
priv->actions = g_list_append (priv->actions, info); priv->actions = g_list_append (priv->actions, info);
} }
@ -321,6 +332,8 @@ _parse_eos (GMarkupParseContext * context, const gchar * element_name,
if (playback_time) if (playback_time)
info->action.playback_time = g_ascii_strtoull (playback_time, NULL, 10); info->action.playback_time = g_ascii_strtoull (playback_time, NULL, 10);
info->action.action_number = priv->num_actions++;
priv->actions = g_list_append (priv->actions, info); priv->actions = g_list_append (priv->actions, info);
} }
@ -397,8 +410,10 @@ _execute_action (GstValidateScenario * scenario, ScenarioAction * act)
if (act->type == SCENARIO_ACTION_SEEK) { if (act->type == SCENARIO_ACTION_SEEK) {
SeekInfo *seek = (SeekInfo *) act; SeekInfo *seek = (SeekInfo *) act;
GST_DEBUG ("seeking to: %" GST_TIME_FORMAT " stop: %" GST_TIME_FORMAT, GST_DEBUG ("%s (num %u), seeking to: %" GST_TIME_FORMAT " stop: %"
GST_TIME_ARGS (seek->start), GST_TIME_ARGS (seek->stop)); GST_TIME_FORMAT, SCENARIO_ACTION (seek)->name,
SCENARIO_ACTION (seek)->action_number, GST_TIME_ARGS (seek->start),
GST_TIME_ARGS (seek->stop));
if (gst_element_seek (pipeline, seek->rate, if (gst_element_seek (pipeline, seek->rate,
seek->format, seek->flags, seek->format, seek->flags,
@ -410,7 +425,6 @@ _execute_action (GstValidateScenario * scenario, ScenarioAction * act)
GST_TIME_ARGS (priv->seeked_position)); GST_TIME_ARGS (priv->seeked_position));
} }
priv->seeked_position = seek->start; priv->seeked_position = seek->start;
} else if (act->type == SCENARIO_ACTION_PAUSE) { } else if (act->type == SCENARIO_ACTION_PAUSE) {
PauseInfo *pause = (PauseInfo *) act; PauseInfo *pause = (PauseInfo *) act;
@ -422,10 +436,12 @@ _execute_action (GstValidateScenario * scenario, ScenarioAction * act)
GST_VALIDATE_REPORT (scenario, GST_VALIDATE_ISSUE_ID_STATE_CHANGE_FAILURE, GST_VALIDATE_REPORT (scenario, GST_VALIDATE_ISSUE_ID_STATE_CHANGE_FAILURE,
"Failed to set state to paused"); "Failed to set state to paused");
} }
gst_element_get_state (pipeline, NULL, NULL, -1);
g_timeout_add (pause->duration / GST_MSECOND, g_timeout_add (pause->duration / GST_MSECOND,
(GSourceFunc) _pause_action_restore_playing, scenario); (GSourceFunc) _pause_action_restore_playing, scenario);
} else if (act->type == SCENARIO_ACTION_EOS) { } else if (act->type == SCENARIO_ACTION_EOS) {
GST_DEBUG ("Sending eos to pipeline"); GST_DEBUG ("Sending eos to pipeline at %" GST_TIME_FORMAT,
GST_TIME_ARGS (act->playback_time));
gst_element_send_event (priv->pipeline, gst_event_new_eos ()); gst_element_send_event (priv->pipeline, gst_event_new_eos ());
} }
} }
@ -436,34 +452,40 @@ get_position (GstValidateScenario * scenario)
GList *tmp; GList *tmp;
gint64 position; gint64 position;
GstFormat format = GST_FORMAT_TIME; GstFormat format = GST_FORMAT_TIME;
ScenarioAction *act;
GstValidateScenarioPrivate *priv = scenario->priv; GstValidateScenarioPrivate *priv = scenario->priv;
GstElement *pipeline = scenario->priv->pipeline; GstElement *pipeline = scenario->priv->pipeline;
if (scenario->priv->actions == NULL) {
GST_DEBUG_OBJECT (scenario,
"No more actions to execute, stop calling get_position");
return FALSE;
}
act = scenario->priv->actions->data;
gst_element_query_position (pipeline, format, &position); gst_element_query_position (pipeline, format, &position);
GST_LOG ("Current position: %" GST_TIME_FORMAT, GST_TIME_ARGS (position)); GST_LOG ("Current position: %" GST_TIME_FORMAT, GST_TIME_ARGS (position));
for (tmp = scenario->priv->actions; tmp; tmp = g_list_next (tmp)) { if (((position >= MAX (0,
ScenarioAction *act = tmp->data; ((gint64) (act->playback_time - priv->seek_pos_tol))))
&& (position <= (act->playback_time + priv->seek_pos_tol)))) {
if ((position >= (act->playback_time - priv->seek_pos_tol)) /* TODO what about non flushing seeks? */
&& (position <= (act->playback_time + priv->seek_pos_tol))) { /* TODO why is this inside the action time if ? */
if (GST_CLOCK_TIME_IS_VALID (priv->seeked_position))
GST_VALIDATE_REPORT (scenario,
GST_VALIDATE_ISSUE_ID_EVENT_SEEK_NOT_HANDLED,
"Previous seek to %" GST_TIME_FORMAT " was not handled",
GST_TIME_ARGS (priv->seeked_position));
/* TODO what about non flushing seeks? */ _execute_action (scenario, act);
/* TODO why is this inside the action time if ? */
if (GST_CLOCK_TIME_IS_VALID (priv->seeked_position))
GST_VALIDATE_REPORT (scenario,
GST_VALIDATE_ISSUE_ID_EVENT_SEEK_NOT_HANDLED,
"Previous seek to %" GST_TIME_FORMAT " was not handled",
GST_TIME_ARGS (priv->seeked_position));
_execute_action (scenario, act); tmp = priv->actions;
priv->actions = g_list_remove_link (priv->actions, tmp);
priv->actions = g_list_remove_link (priv->actions, tmp); _free_scenario_action (act);
_free_scenario_action (act); g_list_free (tmp);
g_list_free (tmp);
break;
}
} }
return TRUE; return TRUE;
} }