diff --git a/validate/gst/validate/gst-validate-scenario.c b/validate/gst/validate/gst-validate-scenario.c index 14a86a7aed..7a9235e1ab 100644 --- a/validate/gst/validate/gst-validate-scenario.c +++ b/validate/gst/validate/gst-validate-scenario.c @@ -426,29 +426,17 @@ gboolean gst_validate_action_get_clocktime (GstValidateScenario * scenario, GstValidateAction * action, const gchar * name, GstClockTime * retval) { - gdouble val; - const gchar *strval; - const GValue *gvalue = gst_structure_get_value (action->structure, name); - - if (gvalue == NULL) { - return -1; - } - - if (G_VALUE_TYPE (gvalue) == GST_TYPE_CLOCK_TIME) { - *retval = g_value_get_uint64 (gvalue); - - return TRUE; - } - - if (!gst_structure_get_double (action->structure, name, &val)) { + if (!gst_validate_utils_get_clocktime (action->structure, name, retval)) { + gdouble val; gchar *error = NULL; + const gchar *strval; if (!(strval = gst_structure_get_string (action->structure, name))) { GST_INFO_OBJECT (scenario, "Could not find %s", name); return -1; } - val = - gst_validate_utils_parse_expression (strval, _set_variable_func, + + val = gst_validate_utils_parse_expression (strval, _set_variable_func, scenario, &error); if (error) { @@ -456,14 +444,14 @@ gst_validate_action_get_clocktime (GstValidateScenario * scenario, g_free (error); return FALSE; + } else if (val == -1.0) { + *retval = GST_CLOCK_TIME_NONE; + } else { + *retval = val * GST_SECOND; + *retval = GST_ROUND_UP_4 (*retval); } - } - if (val == -1.0) - *retval = GST_CLOCK_TIME_NONE; - else { - *retval = val * GST_SECOND; - *retval = GST_ROUND_UP_4 (*retval); + return TRUE; } return TRUE; diff --git a/validate/gst/validate/gst-validate-utils.c b/validate/gst/validate/gst-validate-utils.c index ba4662eec1..e948a10d12 100644 --- a/validate/gst/validate/gst-validate-utils.c +++ b/validate/gst/validate/gst-validate-utils.c @@ -678,3 +678,59 @@ done: g_strfreev (b); return result; } + +gboolean +gst_validate_utils_get_clocktime (GstStructure * structure, const gchar * name, + GstClockTime * retval) +{ + gdouble val; + const GValue *gvalue = gst_structure_get_value (structure, name); + + *retval = GST_CLOCK_TIME_NONE; + if (gvalue == NULL) { + return FALSE; + } + + if (G_VALUE_TYPE (gvalue) == GST_TYPE_CLOCK_TIME) { + *retval = g_value_get_uint64 (gvalue); + + return TRUE; + } + + if (G_VALUE_TYPE (gvalue) == G_TYPE_UINT64) { + *retval = g_value_get_uint64 (gvalue); + + return TRUE; + } + + if (G_VALUE_TYPE (gvalue) == G_TYPE_UINT) { + *retval = (GstClockTime) g_value_get_uint (gvalue); + + return TRUE; + } + + if (G_VALUE_TYPE (gvalue) == G_TYPE_INT) { + *retval = (GstClockTime) g_value_get_int (gvalue); + + return TRUE; + } + + if (G_VALUE_TYPE (gvalue) == G_TYPE_INT64) { + *retval = (GstClockTime) g_value_get_int64 (gvalue); + + return TRUE; + } + + if (!gst_structure_get_double (structure, name, &val)) { + return FALSE; + } + + if (val == -1.0) + *retval = GST_CLOCK_TIME_NONE; + else { + *retval = val * GST_SECOND; + *retval = GST_ROUND_UP_4 (*retval); + } + + return TRUE; +} diff --git a/validate/gst/validate/gst-validate-utils.h b/validate/gst/validate/gst-validate-utils.h index 774f1016d2..a181be60a9 100644 --- a/validate/gst/validate/gst-validate-utils.h +++ b/validate/gst/validate/gst-validate-utils.h @@ -45,5 +45,7 @@ GList * gst_validate_utils_structs_parse_from_filename (const gchar * sc GList * structs_parse_from_gfile (GFile * scenario_file); gboolean gst_validate_element_has_klass (GstElement * element, const gchar * klass); +gboolean gst_validate_utils_get_clocktime (GstStructure *structure, const gchar * name, + GstClockTime * retval); #endif