scenario: Have GstClockTime as second (in double) inside scenario files

Making it easier to read
This commit is contained in:
Thibault Saunier 2013-08-19 10:02:35 -04:00 committed by Thiago Santos
parent 9fd62ba798
commit 0609de7156
2 changed files with 54 additions and 15 deletions

View file

@ -1,15 +1,35 @@
<xml> <xml>
<scenario name="Simple Seeks"> <scenario name="Simple Seeks">
<actions> <actions>
<seek name='First seek' playback_time="1000000000" format="time" <seek name='First seek'
rate="1.0" flags="accurate+flush" start_type="set" playback_time="1.0"
start="2000000000" stop_type="set" stop="-1" /> format="time"
<seek name='Second seek' playback_time="3000000000" format="time" rate="1.0"
rate="1.0" flags="accurate+flush" start_type="set" flags="accurate+flush"
start="0" stop_type="set" stop="-1" /> start_type="set"
<seek name='Third seek' playback_time="1000000000" format="time" start="2.0"
rate="1.0" flags="accurate+flush" start_type="set" stop_type="set"
start="2000000000" stop_type="set" stop="3000000000" /> stop="-1.0" />
<seek name='Second seek'
playback_time="3.0"
format="time"
rate="1.0"
flags="accurate+flush"
start_type="set"
start="0.0"
stop_type="set"
stop="-1.0" />
<seek name='Third seek'
playback_time="1.0"
format="time"
rate="1.0"
flags="accurate+flush"
start_type="set"
start="2.0"
stop_type="set"
stop="3.0" />
</actions> </actions>
</scenario> </scenario>
</xml> </xml>

View file

@ -115,6 +115,25 @@ struct _GstValidateScenarioPrivate
guint get_pos_id; guint get_pos_id;
}; };
static GstClockTime
str_to_gst_time (const gchar * str)
{
gchar *end_of_valid_d;
gdouble double_value = 0;
double_value = g_ascii_strtod (str, &end_of_valid_d);
if (*end_of_valid_d != '\0' || end_of_valid_d == str) {
GST_ERROR ("%s could not be converted to GstClockTime", str);
return GST_CLOCK_TIME_NONE;
}
if (double_value < 0)
return GST_CLOCK_TIME_NONE;
return double_value * GST_SECOND;
}
/* Some helper method that are missing iin Json itscenario */ /* Some helper method that are missing iin Json itscenario */
static guint static guint
get_flags_from_string (GType type, const gchar * str_flags) get_flags_from_string (GType type, const gchar * str_flags)
@ -274,13 +293,13 @@ _parse_seek (GMarkupParseContext * context, const gchar * element_name,
get_enum_from_string (GST_TYPE_FORMAT, format, &info->format); get_enum_from_string (GST_TYPE_FORMAT, format, &info->format);
if (playback_time) if (playback_time)
info->action.playback_time = g_ascii_strtoull (playback_time, NULL, 10); info->action.playback_time = str_to_gst_time (playback_time);
info->rate = g_ascii_strtod (rate, NULL); info->rate = g_ascii_strtod (rate, NULL);
info->flags = get_flags_from_string (GST_TYPE_SEEK_FLAGS, flags); info->flags = get_flags_from_string (GST_TYPE_SEEK_FLAGS, flags);
get_enum_from_string (GST_TYPE_SEEK_TYPE, start_type, &info->start_type); get_enum_from_string (GST_TYPE_SEEK_TYPE, start_type, &info->start_type);
info->start = g_ascii_strtoull (start, NULL, 10); info->start = str_to_gst_time (start);
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 = str_to_gst_time (stop);
info->action.action_number = priv->num_actions++; info->action.action_number = priv->num_actions++;
priv->actions = g_list_append (priv->actions, info); priv->actions = g_list_append (priv->actions, info);
@ -306,8 +325,8 @@ _parse_pause (GMarkupParseContext * context, const gchar * element_name,
return; return;
if (playback_time) if (playback_time)
info->action.playback_time = g_ascii_strtoull (playback_time, NULL, 10); info->action.playback_time = str_to_gst_time (playback_time);
info->duration = g_ascii_strtoull (duration, NULL, 10); info->duration = str_to_gst_time (duration);
info->action.action_number = priv->num_actions++; info->action.action_number = priv->num_actions++;
@ -332,7 +351,7 @@ _parse_eos (GMarkupParseContext * context, const gchar * element_name,
return; return;
if (playback_time) if (playback_time)
info->action.playback_time = g_ascii_strtoull (playback_time, NULL, 10); info->action.playback_time = str_to_gst_time (playback_time);
info->action.action_number = priv->num_actions++; info->action.action_number = priv->num_actions++;