mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
validate:utils: Add a utility to get a GstClockTime from a structure
Summary: Properly handling the different types that can represent ClockTime Make use of it in gst_validate_action_get_clocktime API: gst_validate_utils_get_clocktime Depends on D209 Reviewers: Mathieu_Du Differential Revision: http://phabricator.freedesktop.org/D210
This commit is contained in:
parent
6ddf55eaa2
commit
bf610de0d6
3 changed files with 69 additions and 23 deletions
|
@ -426,29 +426,17 @@ gboolean
|
||||||
gst_validate_action_get_clocktime (GstValidateScenario * scenario,
|
gst_validate_action_get_clocktime (GstValidateScenario * scenario,
|
||||||
GstValidateAction * action, const gchar * name, GstClockTime * retval)
|
GstValidateAction * action, const gchar * name, GstClockTime * retval)
|
||||||
{
|
{
|
||||||
gdouble val;
|
if (!gst_validate_utils_get_clocktime (action->structure, name, retval)) {
|
||||||
const gchar *strval;
|
gdouble val;
|
||||||
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)) {
|
|
||||||
gchar *error = NULL;
|
gchar *error = NULL;
|
||||||
|
const gchar *strval;
|
||||||
|
|
||||||
if (!(strval = gst_structure_get_string (action->structure, name))) {
|
if (!(strval = gst_structure_get_string (action->structure, name))) {
|
||||||
GST_INFO_OBJECT (scenario, "Could not find %s", name);
|
GST_INFO_OBJECT (scenario, "Could not find %s", name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
val =
|
|
||||||
gst_validate_utils_parse_expression (strval, _set_variable_func,
|
val = gst_validate_utils_parse_expression (strval, _set_variable_func,
|
||||||
scenario, &error);
|
scenario, &error);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
@ -456,14 +444,14 @@ gst_validate_action_get_clocktime (GstValidateScenario * scenario,
|
||||||
g_free (error);
|
g_free (error);
|
||||||
|
|
||||||
return FALSE;
|
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)
|
return TRUE;
|
||||||
*retval = GST_CLOCK_TIME_NONE;
|
|
||||||
else {
|
|
||||||
*retval = val * GST_SECOND;
|
|
||||||
*retval = GST_ROUND_UP_4 (*retval);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
@ -678,3 +678,59 @@ done:
|
||||||
g_strfreev (b);
|
g_strfreev (b);
|
||||||
return result;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -45,5 +45,7 @@ GList * gst_validate_utils_structs_parse_from_filename (const gchar * sc
|
||||||
GList * structs_parse_from_gfile (GFile * scenario_file);
|
GList * structs_parse_from_gfile (GFile * scenario_file);
|
||||||
|
|
||||||
gboolean gst_validate_element_has_klass (GstElement * element, const gchar * klass);
|
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
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue