docs, gst: typo fixes
[platform/upstream/gstreamer.git] / gst / gstvalue.c
index 2a165ab..eed6e02 100644 (file)
@@ -193,6 +193,7 @@ gst_type_is_fixed (GType type)
   }
   /* our fundamental types that are certainly not fixed */
   if (type == GST_TYPE_INT_RANGE || type == GST_TYPE_DOUBLE_RANGE ||
+      type == GST_TYPE_INT64_RANGE ||
       type == GST_TYPE_LIST || type == GST_TYPE_FRACTION_RANGE) {
     return FALSE;
   }
@@ -308,6 +309,7 @@ gst_value_list_append_value (GValue * value, const GValue * append_value)
   GValue val = { 0, };
 
   g_return_if_fail (GST_VALUE_HOLDS_LIST (value));
+  g_return_if_fail (G_IS_VALUE (append_value));
 
   gst_value_init_and_copy (&val, append_value);
   g_array_append_vals ((GArray *) value->data[0].v_pointer, &val, 1);
@@ -326,6 +328,7 @@ gst_value_list_prepend_value (GValue * value, const GValue * prepend_value)
   GValue val = { 0, };
 
   g_return_if_fail (GST_VALUE_HOLDS_LIST (value));
+  g_return_if_fail (G_IS_VALUE (prepend_value));
 
   gst_value_init_and_copy (&val, prepend_value);
   g_array_prepend_vals ((GArray *) value->data[0].v_pointer, &val, 1);
@@ -333,7 +336,7 @@ gst_value_list_prepend_value (GValue * value, const GValue * prepend_value)
 
 /**
  * gst_value_list_concat:
- * @dest: an uninitialized #GValue to take the result
+ * @dest: (out caller-allocates): an uninitialized #GValue to take the result
  * @value1: a #GValue
  * @value2: a #GValue
  *
@@ -382,6 +385,109 @@ gst_value_list_concat (GValue * dest, const GValue * value1,
 }
 
 /**
+ * gst_value_list_merge:
+ * @dest: (out caller-allocates): an uninitialized #GValue to take the result
+ * @value1: a #GValue
+ * @value2: a #GValue
+ *
+ * Merges copies of @value1 and @value2.  Values that are not
+ * of type #GST_TYPE_LIST are treated as if they were lists of length 1.
+ *
+ * The result will be put into @dest and will either be a list that will not
+ * contain any duplicates, or a non-list type (if @value1 and @value2
+ * were equal).
+ *
+ * Since: 0.10.32
+ */
+void
+gst_value_list_merge (GValue * dest, const GValue * value1,
+    const GValue * value2)
+{
+  guint i, j, k, value1_length, value2_length, skipped;
+  const GValue *src;
+  gboolean skip;
+  GArray *array;
+
+  g_return_if_fail (dest != NULL);
+  g_return_if_fail (G_VALUE_TYPE (dest) == 0);
+  g_return_if_fail (G_IS_VALUE (value1));
+  g_return_if_fail (G_IS_VALUE (value2));
+
+  value1_length =
+      (GST_VALUE_HOLDS_LIST (value1) ? VALUE_LIST_SIZE (value1) : 1);
+  value2_length =
+      (GST_VALUE_HOLDS_LIST (value2) ? VALUE_LIST_SIZE (value2) : 1);
+  g_value_init (dest, GST_TYPE_LIST);
+  array = (GArray *) dest->data[0].v_pointer;
+  g_array_set_size (array, value1_length + value2_length);
+
+  if (GST_VALUE_HOLDS_LIST (value1)) {
+    for (i = 0; i < value1_length; i++) {
+      gst_value_init_and_copy (&g_array_index (array, GValue, i),
+          VALUE_LIST_GET_VALUE (value1, i));
+    }
+  } else {
+    gst_value_init_and_copy (&g_array_index (array, GValue, 0), value1);
+  }
+
+  j = value1_length;
+  skipped = 0;
+  if (GST_VALUE_HOLDS_LIST (value2)) {
+    for (i = 0; i < value2_length; i++) {
+      skip = FALSE;
+      src = VALUE_LIST_GET_VALUE (value2, i);
+      for (k = 0; k < value1_length; k++) {
+        if (gst_value_compare (&g_array_index (array, GValue, k),
+                src) == GST_VALUE_EQUAL) {
+          skip = TRUE;
+          skipped++;
+          break;
+        }
+      }
+      if (!skip) {
+        gst_value_init_and_copy (&g_array_index (array, GValue, j), src);
+        j++;
+      }
+    }
+  } else {
+    skip = FALSE;
+    for (k = 0; k < value1_length; k++) {
+      if (gst_value_compare (&g_array_index (array, GValue, k),
+              value2) == GST_VALUE_EQUAL) {
+        skip = TRUE;
+        skipped++;
+        break;
+      }
+    }
+    if (!skip) {
+      gst_value_init_and_copy (&g_array_index (array, GValue, j), value2);
+    }
+  }
+  if (skipped) {
+    guint new_size = value1_length + (value2_length - skipped);
+
+    if (new_size > 1) {
+      /* shrink list */
+      g_array_set_size (array, new_size);
+    } else {
+      GValue single_dest;
+
+      /* size is 1, take single value in list and make it new dest */
+      single_dest = g_array_index (array, GValue, 0);
+
+      /* clean up old value allocations: must set array size to 0, because
+       * allocated values are not inited meaning g_value_unset() will not
+       * work on them */
+      g_array_set_size (array, 0);
+      g_value_unset (dest);
+
+      /* the single value is our new result */
+      *dest = single_dest;
+    }
+  }
+}
+
+/**
  * gst_value_list_get_size:
  * @value: a #GValue of type #GST_TYPE_LIST
  *
@@ -405,7 +511,7 @@ gst_value_list_get_size (const GValue * value)
  * Gets the value that is a member of the list contained in @value and
  * has the index @index.
  *
- * Returns: the value at the given index
+ * Returns: (transfer none): the value at the given index
  */
 const GValue *
 gst_value_list_get_value (const GValue * value, guint index)
@@ -430,6 +536,7 @@ gst_value_array_append_value (GValue * value, const GValue * append_value)
   GValue val = { 0, };
 
   g_return_if_fail (GST_VALUE_HOLDS_ARRAY (value));
+  g_return_if_fail (G_IS_VALUE (append_value));
 
   gst_value_init_and_copy (&val, append_value);
   g_array_append_vals ((GArray *) value->data[0].v_pointer, &val, 1);
@@ -448,6 +555,7 @@ gst_value_array_prepend_value (GValue * value, const GValue * prepend_value)
   GValue val = { 0, };
 
   g_return_if_fail (GST_VALUE_HOLDS_ARRAY (value));
+  g_return_if_fail (G_IS_VALUE (prepend_value));
 
   gst_value_init_and_copy (&val, prepend_value);
   g_array_prepend_vals ((GArray *) value->data[0].v_pointer, &val, 1);
@@ -477,7 +585,7 @@ gst_value_array_get_size (const GValue * value)
  * Gets the value that is a member of the array contained in @value and
  * has the index @index.
  *
- * Returns: the value at the given index
+ * Returns: (transfer none): the value at the given index
  */
 const GValue *
 gst_value_array_get_value (const GValue * value, guint index)
@@ -502,7 +610,7 @@ gst_value_transform_array_string (const GValue * src_value, GValue * dest_value)
 }
 
 /* Do an unordered compare of the contents of a list */
-static int
+static gint
 gst_value_compare_list (const GValue * value1, const GValue * value2)
 {
   guint i, j;
@@ -557,7 +665,7 @@ gst_value_compare_list (const GValue * value1, const GValue * value2)
 }
 
 /* Perform an ordered comparison of the contents of an array */
-static int
+static gint
 gst_value_compare_array (const GValue * value1, const GValue * value2)
 {
   guint i;
@@ -682,11 +790,17 @@ gst_value_transform_fourcc_string (const GValue * src_value,
     GValue * dest_value)
 {
   guint32 fourcc = src_value->data[0].v_int;
+  gchar fourcc_char[4];
+
+  fourcc_char[0] = (fourcc >> 0) & 0xff;
+  fourcc_char[1] = (fourcc >> 8) & 0xff;
+  fourcc_char[2] = (fourcc >> 16) & 0xff;
+  fourcc_char[3] = (fourcc >> 24) & 0xff;
 
-  if (g_ascii_isprint ((fourcc >> 0) & 0xff) &&
-      g_ascii_isprint ((fourcc >> 8) & 0xff) &&
-      g_ascii_isprint ((fourcc >> 16) & 0xff) &&
-      g_ascii_isprint ((fourcc >> 24) & 0xff)) {
+  if ((g_ascii_isalnum (fourcc_char[0]) || fourcc_char[0] == ' ') &&
+      (g_ascii_isalnum (fourcc_char[1]) || fourcc_char[1] == ' ') &&
+      (g_ascii_isalnum (fourcc_char[2]) || fourcc_char[2] == ' ') &&
+      (g_ascii_isalnum (fourcc_char[3]) || fourcc_char[3] == ' ')) {
     dest_value->data[0].v_pointer =
         g_strdup_printf ("%" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (fourcc));
   } else {
@@ -706,11 +820,17 @@ static gchar *
 gst_value_serialize_fourcc (const GValue * value)
 {
   guint32 fourcc = value->data[0].v_int;
+  gchar fourcc_char[4];
 
-  if (g_ascii_isalnum ((fourcc >> 0) & 0xff) &&
-      g_ascii_isalnum ((fourcc >> 8) & 0xff) &&
-      g_ascii_isalnum ((fourcc >> 16) & 0xff) &&
-      g_ascii_isalnum ((fourcc >> 24) & 0xff)) {
+  fourcc_char[0] = (fourcc >> 0) & 0xff;
+  fourcc_char[1] = (fourcc >> 8) & 0xff;
+  fourcc_char[2] = (fourcc >> 16) & 0xff;
+  fourcc_char[3] = (fourcc >> 24) & 0xff;
+
+  if ((g_ascii_isalnum (fourcc_char[0]) || fourcc_char[0] == ' ') &&
+      (g_ascii_isalnum (fourcc_char[1]) || fourcc_char[1] == ' ') &&
+      (g_ascii_isalnum (fourcc_char[2]) || fourcc_char[2] == ' ') &&
+      (g_ascii_isalnum (fourcc_char[3]) || fourcc_char[3] == ' ')) {
     return g_strdup_printf ("%" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (fourcc));
   } else {
     return g_strdup_printf ("0x%08x", fourcc);
@@ -718,15 +838,25 @@ gst_value_serialize_fourcc (const GValue * value)
 }
 
 static gboolean
-gst_value_deserialize_fourcc (GValue * dest, const char *s)
+gst_value_deserialize_fourcc (GValue * dest, const gchar * s)
 {
   gboolean ret = FALSE;
   guint32 fourcc = 0;
-  char *end;
+  gchar *end;
+  gint l = strlen (s);
 
-  if (strlen (s) == 4) {
+  if (l == 4) {
     fourcc = GST_MAKE_FOURCC (s[0], s[1], s[2], s[3]);
     ret = TRUE;
+  } else if (l == 3) {
+    fourcc = GST_MAKE_FOURCC (s[0], s[1], s[2], ' ');
+    ret = TRUE;
+  } else if (l == 2) {
+    fourcc = GST_MAKE_FOURCC (s[0], s[1], ' ', ' ');
+    ret = TRUE;
+  } else if (l == 1) {
+    fourcc = GST_MAKE_FOURCC (s[0], ' ', ' ', ' ');
+    ret = TRUE;
   } else if (g_ascii_isdigit (*s)) {
     fourcc = strtoul (s, &end, 0);
     if (*end == 0) {
@@ -760,6 +890,13 @@ static gchar *
 gst_value_collect_int_range (GValue * value, guint n_collect_values,
     GTypeCValue * collect_values, guint collect_flags)
 {
+  if (n_collect_values != 2)
+    return g_strdup_printf ("not enough value locations for `%s' passed",
+        G_VALUE_TYPE_NAME (value));
+  if (collect_values[0].v_int >= collect_values[1].v_int)
+    return g_strdup_printf ("range start is not smaller than end for `%s'",
+        G_VALUE_TYPE_NAME (value));
+
   value->data[0].v_int = collect_values[0].v_int;
   value->data[1].v_int = collect_values[1].v_int;
 
@@ -867,6 +1004,149 @@ gst_value_deserialize_int_range (GValue * dest, const gchar * s)
   return FALSE;
 }
 
+/***************
+ * int64 range *
+ ***************/
+
+static void
+gst_value_init_int64_range (GValue * value)
+{
+  value->data[0].v_int64 = 0;
+  value->data[1].v_int64 = 0;
+}
+
+static void
+gst_value_copy_int64_range (const GValue * src_value, GValue * dest_value)
+{
+  dest_value->data[0].v_int64 = src_value->data[0].v_int64;
+  dest_value->data[1].v_int64 = src_value->data[1].v_int64;
+}
+
+static gchar *
+gst_value_collect_int64_range (GValue * value, guint n_collect_values,
+    GTypeCValue * collect_values, guint collect_flags)
+{
+  if (n_collect_values != 2)
+    return g_strdup_printf ("not enough value locations for `%s' passed",
+        G_VALUE_TYPE_NAME (value));
+  if (collect_values[0].v_int64 >= collect_values[1].v_int64)
+    return g_strdup_printf ("range start is not smaller than end for `%s'",
+        G_VALUE_TYPE_NAME (value));
+
+  value->data[0].v_int64 = collect_values[0].v_int64;
+  value->data[1].v_int64 = collect_values[1].v_int64;
+
+  return NULL;
+}
+
+static gchar *
+gst_value_lcopy_int64_range (const GValue * value, guint n_collect_values,
+    GTypeCValue * collect_values, guint collect_flags)
+{
+  guint64 *int_range_start = collect_values[0].v_pointer;
+  guint64 *int_range_end = collect_values[1].v_pointer;
+
+  if (!int_range_start)
+    return g_strdup_printf ("start value location for `%s' passed as NULL",
+        G_VALUE_TYPE_NAME (value));
+  if (!int_range_end)
+    return g_strdup_printf ("end value location for `%s' passed as NULL",
+        G_VALUE_TYPE_NAME (value));
+
+  *int_range_start = value->data[0].v_int64;
+  *int_range_end = value->data[1].v_int64;
+
+  return NULL;
+}
+
+/**
+ * gst_value_set_int64_range:
+ * @value: a GValue initialized to GST_TYPE_INT64_RANGE
+ * @start: the start of the range
+ * @end: the end of the range
+ *
+ * Sets @value to the range specified by @start and @end.
+ *
+ * Since: 0.10.31
+ */
+void
+gst_value_set_int64_range (GValue * value, gint64 start, gint64 end)
+{
+  g_return_if_fail (GST_VALUE_HOLDS_INT64_RANGE (value));
+  g_return_if_fail (start < end);
+
+  value->data[0].v_int64 = start;
+  value->data[1].v_int64 = end;
+}
+
+/**
+ * gst_value_get_int64_range_min:
+ * @value: a GValue initialized to GST_TYPE_INT64_RANGE
+ *
+ * Gets the minimum of the range specified by @value.
+ *
+ * Returns: the minimum of the range
+ *
+ * Since: 0.10.31
+ */
+gint64
+gst_value_get_int64_range_min (const GValue * value)
+{
+  g_return_val_if_fail (GST_VALUE_HOLDS_INT64_RANGE (value), 0);
+
+  return value->data[0].v_int64;
+}
+
+/**
+ * gst_value_get_int64_range_max:
+ * @value: a GValue initialized to GST_TYPE_INT64_RANGE
+ *
+ * Gets the maximum of the range specified by @value.
+ *
+ * Returns: the maxumum of the range
+ *
+ * Since: 0.10.31
+ */
+gint64
+gst_value_get_int64_range_max (const GValue * value)
+{
+  g_return_val_if_fail (GST_VALUE_HOLDS_INT64_RANGE (value), 0);
+
+  return value->data[1].v_int64;
+}
+
+static void
+gst_value_transform_int64_range_string (const GValue * src_value,
+    GValue * dest_value)
+{
+  dest_value->data[0].v_pointer =
+      g_strdup_printf ("(gint64)[%" G_GINT64_FORMAT ",%" G_GINT64_FORMAT "]",
+      src_value->data[0].v_int64, src_value->data[1].v_int64);
+}
+
+static gint
+gst_value_compare_int64_range (const GValue * value1, const GValue * value2)
+{
+  if (value2->data[0].v_int64 == value1->data[0].v_int64 &&
+      value2->data[1].v_int64 == value1->data[1].v_int64)
+    return GST_VALUE_EQUAL;
+  return GST_VALUE_UNORDERED;
+}
+
+static gchar *
+gst_value_serialize_int64_range (const GValue * value)
+{
+  return g_strdup_printf ("[ %" G_GINT64_FORMAT ", %" G_GINT64_FORMAT " ]",
+      value->data[0].v_int64, value->data[1].v_int64);
+}
+
+static gboolean
+gst_value_deserialize_int64_range (GValue * dest, const gchar * s)
+{
+  g_warning ("unimplemented");
+  return FALSE;
+}
+
 /****************
  * double range *
  ****************/
@@ -889,6 +1169,13 @@ static gchar *
 gst_value_collect_double_range (GValue * value, guint n_collect_values,
     GTypeCValue * collect_values, guint collect_flags)
 {
+  if (n_collect_values != 2)
+    return g_strdup_printf ("not enough value locations for `%s' passed",
+        G_VALUE_TYPE_NAME (value));
+  if (collect_values[0].v_double >= collect_values[1].v_double)
+    return g_strdup_printf ("range start is not smaller than end for `%s'",
+        G_VALUE_TYPE_NAME (value));
+
   value->data[0].v_double = collect_values[0].v_double;
   value->data[1].v_double = collect_values[1].v_double;
 
@@ -927,6 +1214,7 @@ void
 gst_value_set_double_range (GValue * value, gdouble start, gdouble end)
 {
   g_return_if_fail (GST_VALUE_HOLDS_DOUBLE_RANGE (value));
+  g_return_if_fail (start < end);
 
   value->data[0].v_double = start;
   value->data[1].v_double = end;
@@ -968,7 +1256,7 @@ static void
 gst_value_transform_double_range_string (const GValue * src_value,
     GValue * dest_value)
 {
-  char s1[G_ASCII_DTOSTR_BUF_SIZE], s2[G_ASCII_DTOSTR_BUF_SIZE];
+  gchar s1[G_ASCII_DTOSTR_BUF_SIZE], s2[G_ASCII_DTOSTR_BUF_SIZE];
 
   dest_value->data[0].v_pointer = g_strdup_printf ("[%s,%s]",
       g_ascii_dtostr (s1, G_ASCII_DTOSTR_BUF_SIZE,
@@ -989,8 +1277,8 @@ gst_value_compare_double_range (const GValue * value1, const GValue * value2)
 static gchar *
 gst_value_serialize_double_range (const GValue * value)
 {
-  char d1[G_ASCII_DTOSTR_BUF_SIZE];
-  char d2[G_ASCII_DTOSTR_BUF_SIZE];
+  gchar d1[G_ASCII_DTOSTR_BUF_SIZE];
+  gchar d2[G_ASCII_DTOSTR_BUF_SIZE];
 
   g_ascii_dtostr (d1, G_ASCII_DTOSTR_BUF_SIZE, value->data[0].v_double);
   g_ascii_dtostr (d2, G_ASCII_DTOSTR_BUF_SIZE, value->data[1].v_double);
@@ -1059,6 +1347,18 @@ gst_value_collect_fraction_range (GValue * value, guint n_collect_values,
   if (n_collect_values != 4)
     return g_strdup_printf ("not enough value locations for `%s' passed",
         G_VALUE_TYPE_NAME (value));
+  if (collect_values[1].v_int == 0)
+    return g_strdup_printf ("passed '0' as first denominator for `%s'",
+        G_VALUE_TYPE_NAME (value));
+  if (collect_values[3].v_int == 0)
+    return g_strdup_printf ("passed '0' as second denominator for `%s'",
+        G_VALUE_TYPE_NAME (value));
+  if (gst_util_fraction_compare (collect_values[0].v_int,
+          collect_values[1].v_int, collect_values[2].v_int,
+          collect_values[3].v_int) >= 0)
+    return g_strdup_printf ("range start is not smaller than end for `%s'",
+        G_VALUE_TYPE_NAME (value));
+
   if (vals == NULL) {
     gst_value_init_fraction_range (value);
     vals = value->data[0].v_pointer;
@@ -1076,8 +1376,8 @@ static gchar *
 gst_value_lcopy_fraction_range (const GValue * value, guint n_collect_values,
     GTypeCValue * collect_values, guint collect_flags)
 {
-  int i;
-  int *dest_values[4];
+  gint i;
+  gint *dest_values[4];
   GValue *vals = (GValue *) value->data[0].v_pointer;
 
   if (G_UNLIKELY (n_collect_values != 4))
@@ -1119,6 +1419,10 @@ gst_value_set_fraction_range (GValue * value, const GValue * start,
   GValue *vals;
 
   g_return_if_fail (GST_VALUE_HOLDS_FRACTION_RANGE (value));
+  g_return_if_fail (GST_VALUE_HOLDS_FRACTION (start));
+  g_return_if_fail (GST_VALUE_HOLDS_FRACTION (end));
+  g_return_if_fail (gst_util_fraction_compare (start->data[0].v_int,
+          start->data[1].v_int, end->data[0].v_int, end->data[1].v_int) < 0);
 
   vals = (GValue *) value->data[0].v_pointer;
   if (vals == NULL) {
@@ -1148,6 +1452,12 @@ gst_value_set_fraction_range_full (GValue * value,
   GValue start = { 0 };
   GValue end = { 0 };
 
+  g_return_if_fail (value != NULL);
+  g_return_if_fail (denominator_start != 0);
+  g_return_if_fail (denominator_end != 0);
+  g_return_if_fail (gst_util_fraction_compare (numerator_start,
+          denominator_start, numerator_end, denominator_end) < 0);
+
   g_value_init (&start, GST_TYPE_FRACTION);
   g_value_init (&end, GST_TYPE_FRACTION);
 
@@ -1172,7 +1482,7 @@ gst_value_get_fraction_range_min (const GValue * value)
 {
   GValue *vals;
 
-  g_return_val_if_fail (GST_VALUE_HOLDS_FRACTION_RANGE (value), FALSE);
+  g_return_val_if_fail (GST_VALUE_HOLDS_FRACTION_RANGE (value), NULL);
 
   vals = (GValue *) value->data[0].v_pointer;
   if (vals != NULL) {
@@ -1195,7 +1505,7 @@ gst_value_get_fraction_range_max (const GValue * value)
 {
   GValue *vals;
 
-  g_return_val_if_fail (GST_VALUE_HOLDS_FRACTION_RANGE (value), FALSE);
+  g_return_val_if_fail (GST_VALUE_HOLDS_FRACTION_RANGE (value), NULL);
 
   vals = (GValue *) value->data[0].v_pointer;
   if (vals != NULL) {
@@ -1205,7 +1515,7 @@ gst_value_get_fraction_range_max (const GValue * value)
   return NULL;
 }
 
-static char *
+static gchar *
 gst_value_serialize_fraction_range (const GValue * value)
 {
   GValue *vals = (GValue *) value->data[0].v_pointer;
@@ -1273,15 +1583,17 @@ gst_value_deserialize_fraction_range (GValue * dest, const gchar * s)
 /**
  * gst_value_set_caps:
  * @value: a GValue initialized to GST_TYPE_CAPS
- * @caps: the caps to set the value to
+ * @caps: (transfer none): the caps to set the value to
  *
- * Sets the contents of @value to @caps.  The actual
- * #GstCaps structure is copied before it is used.
+ * Sets the contents of @value to @caps. A reference to the
+ * provided @caps will be taken by the @value.
  */
 void
 gst_value_set_caps (GValue * value, const GstCaps * caps)
 {
+  g_return_if_fail (G_IS_VALUE (value));
   g_return_if_fail (G_VALUE_TYPE (value) == GST_TYPE_CAPS);
+  g_return_if_fail (caps == NULL || GST_IS_CAPS (caps));
 
   g_value_set_boxed (value, caps);
 }
@@ -1290,19 +1602,22 @@ gst_value_set_caps (GValue * value, const GstCaps * caps)
  * gst_value_get_caps:
  * @value: a GValue initialized to GST_TYPE_CAPS
  *
- * Gets the contents of @value.
+ * Gets the contents of @value. The reference count of the returned
+ * #GstCaps will not be modified, therefore the caller must take one
+ * before getting rid of the @value.
  *
- * Returns: the contents of @value
+ * Returns: (transfer none): the contents of @value
  */
 const GstCaps *
 gst_value_get_caps (const GValue * value)
 {
+  g_return_val_if_fail (G_IS_VALUE (value), NULL);
   g_return_val_if_fail (G_VALUE_TYPE (value) == GST_TYPE_CAPS, NULL);
 
   return (GstCaps *) g_value_get_boxed (value);
 }
 
-static char *
+static gchar *
 gst_value_serialize_caps (const GValue * value)
 {
   GstCaps *caps = g_value_get_boxed (value);
@@ -1340,7 +1655,9 @@ gst_value_deserialize_caps (GValue * dest, const gchar * s)
 void
 gst_value_set_structure (GValue * value, const GstStructure * structure)
 {
+  g_return_if_fail (G_IS_VALUE (value));
   g_return_if_fail (G_VALUE_TYPE (value) == GST_TYPE_STRUCTURE);
+  g_return_if_fail (structure == NULL || GST_IS_STRUCTURE (structure));
 
   g_value_set_boxed (value, structure);
 }
@@ -1351,19 +1668,20 @@ gst_value_set_structure (GValue * value, const GstStructure * structure)
  *
  * Gets the contents of @value.
  *
- * Returns: the contents of @value
+ * Returns: (transfer none): the contents of @value
  *
  * Since: 0.10.15
  */
 const GstStructure *
 gst_value_get_structure (const GValue * value)
 {
+  g_return_val_if_fail (G_IS_VALUE (value), NULL);
   g_return_val_if_fail (G_VALUE_TYPE (value) == GST_TYPE_STRUCTURE, NULL);
 
   return (GstStructure *) g_value_get_boxed (value);
 }
 
-static char *
+static gchar *
 gst_value_serialize_structure (const GValue * value)
 {
   GstStructure *structure = g_value_get_boxed (value);
@@ -1399,7 +1717,7 @@ gst_value_deserialize_structure (GValue * dest, const gchar * s)
  * GstBuffer *
  *************/
 
-static int
+static gint
 gst_value_compare_buffer (const GValue * value1, const GValue * value2)
 {
   GstBuffer *buf1 = GST_BUFFER (gst_value_get_mini_object (value1));
@@ -1418,13 +1736,13 @@ gst_value_compare_buffer (const GValue * value1, const GValue * value2)
   return GST_VALUE_UNORDERED;
 }
 
-static char *
+static gchar *
 gst_value_serialize_buffer (const GValue * value)
 {
   guint8 *data;
-  int i;
-  int size;
-  char *string;
+  gint i;
+  gint size;
+  gchar *string;
   GstBuffer *buffer;
 
   buffer = gst_value_get_buffer (value);
@@ -1447,10 +1765,10 @@ static gboolean
 gst_value_deserialize_buffer (GValue * dest, const gchar * s)
 {
   GstBuffer *buffer;
-  int len;
-  char ts[3];
+  gint len;
+  gchar ts[3];
   guint8 *data;
-  int i;
+  gint i;
 
   len = strlen (s);
   if (len & 1)
@@ -1490,7 +1808,7 @@ wrong_char:
  * boolean *
  ***********/
 
-static int
+static gint
 gst_value_compare_boolean (const GValue * value1, const GValue * value2)
 {
   if ((value1->data[0].v_int != 0) == (value2->data[0].v_int != 0))
@@ -1498,7 +1816,7 @@ gst_value_compare_boolean (const GValue * value1, const GValue * value2)
   return GST_VALUE_UNORDERED;
 }
 
-static char *
+static gchar *
 gst_value_serialize_boolean (const GValue * value)
 {
   if (value->data[0].v_int) {
@@ -1541,7 +1859,7 @@ gst_value_compare_ ## _type                                             \
   return GST_VALUE_EQUAL;                                               \
 }                                                                       \
                                                                         \
-static char *                                                           \
+static gchar *                                                          \
 gst_value_serialize_ ## _type (const GValue * value)                    \
 {                                                                       \
   GValue val = { 0, };                                                  \
@@ -1561,7 +1879,7 @@ gst_value_deserialize_int_helper (gint64 * to, const gchar * s,
     gint64 min, gint64 max, gint size)
 {
   gboolean ret = FALSE;
-  char *end;
+  gchar *end;
   gint64 mask = -1;
 
   errno = 0;
@@ -1638,7 +1956,7 @@ static gboolean                                                         \
 gst_value_deserialize_ ## _type (GValue * dest, const gchar *s)         \
 {                                                                       \
   gint64 x;                                                             \
-  char *end;                                                            \
+  gchar *end;                                                           \
   gboolean ret = FALSE;                                                 \
                                                                         \
   errno = 0;                                                            \
@@ -1699,10 +2017,16 @@ CREATE_USERIALIZATION (uint, UINT);
 CREATE_USERIALIZATION (uint64, UINT64);
 CREATE_USERIALIZATION (ulong, ULONG);
 
+/* FIXME 0.11: remove this again, plugins shouldn't have uchar properties */
+#ifndef G_MAXUCHAR
+#define G_MAXUCHAR 255
+#endif
+CREATE_USERIALIZATION (uchar, UCHAR);
+
 /**********
  * double *
  **********/
-static int
+static gint
 gst_value_compare_double (const GValue * value1, const GValue * value2)
 {
   if (value1->data[0].v_double > value2->data[0].v_double)
@@ -1714,10 +2038,10 @@ gst_value_compare_double (const GValue * value1, const GValue * value2)
   return GST_VALUE_UNORDERED;
 }
 
-static char *
+static gchar *
 gst_value_serialize_double (const GValue * value)
 {
-  char d[G_ASCII_DTOSTR_BUF_SIZE];
+  gchar d[G_ASCII_DTOSTR_BUF_SIZE];
 
   g_ascii_dtostr (d, G_ASCII_DTOSTR_BUF_SIZE, value->data[0].v_double);
   return g_strdup (d);
@@ -1726,9 +2050,9 @@ gst_value_serialize_double (const GValue * value)
 static gboolean
 gst_value_deserialize_double (GValue * dest, const gchar * s)
 {
-  double x;
+  gdouble x;
   gboolean ret = FALSE;
-  char *end;
+  gchar *end;
 
   x = g_ascii_strtod (s, &end);
   if (*end == 0) {
@@ -1776,9 +2100,9 @@ gst_value_serialize_float (const GValue * value)
 static gboolean
 gst_value_deserialize_float (GValue * dest, const gchar * s)
 {
-  double x;
+  gdouble x;
   gboolean ret = FALSE;
-  char *end;
+  gchar *end;
 
   x = g_ascii_strtod (s, &end);
   if (*end == 0) {
@@ -1812,7 +2136,7 @@ gst_value_compare_string (const GValue * value1, const GValue * value2)
     if (value1->data[0].v_pointer != value2->data[0].v_pointer)
       return GST_VALUE_UNORDERED;
   } else {
-    int x = strcmp (value1->data[0].v_pointer, value2->data[0].v_pointer);
+    gint x = strcmp (value1->data[0].v_pointer, value2->data[0].v_pointer);
 
     if (x < 0)
       return GST_VALUE_LESS_THAN;
@@ -1823,10 +2147,10 @@ gst_value_compare_string (const GValue * value1, const GValue * value2)
   return GST_VALUE_EQUAL;
 }
 
-static int
+static gint
 gst_string_measure_wrapping (const gchar * s)
 {
-  int len;
+  gint len;
   gboolean wrap = FALSE;
 
   if (G_UNLIKELY (s == NULL))
@@ -1856,7 +2180,7 @@ gst_string_measure_wrapping (const gchar * s)
 }
 
 static gchar *
-gst_string_wrap_inner (const gchar * s, int len)
+gst_string_wrap_inner (const gchar * s, gint len)
 {
   gchar *d, *e;
 
@@ -1887,7 +2211,7 @@ gst_string_wrap_inner (const gchar * s, int len)
 static gchar *
 gst_string_wrap (const gchar * s)
 {
-  int len = gst_string_measure_wrapping (s);
+  gint len = gst_string_measure_wrapping (s);
 
   if (G_LIKELY (len < 0))
     return g_strdup (s);
@@ -1900,7 +2224,7 @@ static gchar *
 gst_string_take_and_wrap (gchar * s)
 {
   gchar *out;
-  int len = gst_string_measure_wrapping (s);
+  gint len = gst_string_measure_wrapping (s);
 
   if (G_LIKELY (len < 0))
     return s;
@@ -1971,7 +2295,7 @@ gst_string_unwrap (const gchar * s)
 
         read += 3;
       } else {
-        /* if we run into a \0 here, we definately won't get a quote later */
+        /* if we run into a \0 here, we definitely won't get a quote later */
         if (*read == 0)
           goto beach;
 
@@ -2064,7 +2388,7 @@ gst_value_serialize_enum (const GValue * value)
   if (G_UNLIKELY (en == NULL && G_VALUE_TYPE (value) == GST_TYPE_FORMAT)) {
     const GstFormatDefinition *format_def;
 
-    format_def = gst_format_get_details (g_value_get_enum (value));
+    format_def = gst_format_get_details ((GstFormat) g_value_get_enum (value));
     g_return_val_if_fail (format_def != NULL, NULL);
     return g_strdup (format_def->description);
   }
@@ -2310,6 +2634,43 @@ gst_value_intersect_int_range_int_range (GValue * dest, const GValue * src1,
 }
 
 static gboolean
+gst_value_intersect_int64_int64_range (GValue * dest, const GValue * src1,
+    const GValue * src2)
+{
+  if (src2->data[0].v_int64 <= src1->data[0].v_int64 &&
+      src2->data[1].v_int64 >= src1->data[0].v_int64) {
+    gst_value_init_and_copy (dest, src1);
+    return TRUE;
+  }
+
+  return FALSE;
+}
+
+static gboolean
+gst_value_intersect_int64_range_int64_range (GValue * dest, const GValue * src1,
+    const GValue * src2)
+{
+  gint64 min;
+  gint64 max;
+
+  min = MAX (src1->data[0].v_int64, src2->data[0].v_int64);
+  max = MIN (src1->data[1].v_int64, src2->data[1].v_int64);
+
+  if (min < max) {
+    g_value_init (dest, GST_TYPE_INT64_RANGE);
+    gst_value_set_int64_range (dest, min, max);
+    return TRUE;
+  }
+  if (min == max) {
+    g_value_init (dest, G_TYPE_INT64);
+    g_value_set_int64 (dest, min);
+    return TRUE;
+  }
+
+  return FALSE;
+}
+
+static gboolean
 gst_value_intersect_double_double_range (GValue * dest, const GValue * src1,
     const GValue * src2)
 {
@@ -2411,7 +2772,7 @@ static gboolean
 gst_value_intersect_fraction_fraction_range (GValue * dest, const GValue * src1,
     const GValue * src2)
 {
-  int res1, res2;
+  gint res1, res2;
   GValue *vals;
   GstValueCompareFunc compare;
 
@@ -2440,7 +2801,7 @@ gst_value_intersect_fraction_range_fraction_range (GValue * dest,
 {
   GValue *min;
   GValue *max;
-  int res;
+  gint res;
   GValue *vals1, *vals2;
   GstValueCompareFunc compare;
 
@@ -2491,9 +2852,9 @@ static gboolean
 gst_value_subtract_int_int_range (GValue * dest, const GValue * minuend,
     const GValue * subtrahend)
 {
-  int min = gst_value_get_int_range_min (subtrahend);
-  int max = gst_value_get_int_range_max (subtrahend);
-  int val = g_value_get_int (minuend);
+  gint min = gst_value_get_int_range_min (subtrahend);
+  gint max = gst_value_get_int_range_max (subtrahend);
+  gint val = g_value_get_int (minuend);
 
   /* subtracting a range from an int only works if the int is not in the
    * range */
@@ -2603,6 +2964,123 @@ gst_value_subtract_int_range_int_range (GValue * dest, const GValue * minuend,
 }
 
 static gboolean
+gst_value_subtract_int64_int64_range (GValue * dest, const GValue * minuend,
+    const GValue * subtrahend)
+{
+  gint64 min = gst_value_get_int64_range_min (subtrahend);
+  gint64 max = gst_value_get_int64_range_max (subtrahend);
+  gint64 val = g_value_get_int64 (minuend);
+
+  /* subtracting a range from an int64 only works if the int64 is not in the
+   * range */
+  if (val < min || val > max) {
+    /* and the result is the int64 */
+    gst_value_init_and_copy (dest, minuend);
+    return TRUE;
+  }
+  return FALSE;
+}
+
+/* creates a new int64 range based on input values.
+ */
+static gboolean
+gst_value_create_new_int64_range (GValue * dest, gint64 min1, gint64 max1,
+    gint64 min2, gint64 max2)
+{
+  GValue v1 = { 0, };
+  GValue v2 = { 0, };
+  GValue *pv1, *pv2;            /* yeah, hungarian! */
+
+  if (min1 <= max1 && min2 <= max2) {
+    pv1 = &v1;
+    pv2 = &v2;
+  } else if (min1 <= max1) {
+    pv1 = dest;
+    pv2 = NULL;
+  } else if (min2 <= max2) {
+    pv1 = NULL;
+    pv2 = dest;
+  } else {
+    return FALSE;
+  }
+
+  if (min1 < max1) {
+    g_value_init (pv1, GST_TYPE_INT64_RANGE);
+    gst_value_set_int64_range (pv1, min1, max1);
+  } else if (min1 == max1) {
+    g_value_init (pv1, G_TYPE_INT64);
+    g_value_set_int64 (pv1, min1);
+  }
+  if (min2 < max2) {
+    g_value_init (pv2, GST_TYPE_INT64_RANGE);
+    gst_value_set_int64_range (pv2, min2, max2);
+  } else if (min2 == max2) {
+    g_value_init (pv2, G_TYPE_INT64);
+    g_value_set_int64 (pv2, min2);
+  }
+
+  if (min1 <= max1 && min2 <= max2) {
+    gst_value_list_concat (dest, pv1, pv2);
+    g_value_unset (pv1);
+    g_value_unset (pv2);
+  }
+  return TRUE;
+}
+
+static gboolean
+gst_value_subtract_int64_range_int64 (GValue * dest, const GValue * minuend,
+    const GValue * subtrahend)
+{
+  gint64 min = gst_value_get_int64_range_min (minuend);
+  gint64 max = gst_value_get_int64_range_max (minuend);
+  gint64 val = g_value_get_int64 (subtrahend);
+
+  g_return_val_if_fail (min < max, FALSE);
+
+  /* value is outside of the range, return range unchanged */
+  if (val < min || val > max) {
+    gst_value_init_and_copy (dest, minuend);
+    return TRUE;
+  } else {
+    /* max must be MAXINT64 too as val <= max */
+    if (val == G_MAXINT64) {
+      max--;
+      val--;
+    }
+    /* min must be MININT64 too as val >= max */
+    if (val == G_MININT64) {
+      min++;
+      val++;
+    }
+    gst_value_create_new_int64_range (dest, min, val - 1, val + 1, max);
+  }
+  return TRUE;
+}
+
+static gboolean
+gst_value_subtract_int64_range_int64_range (GValue * dest,
+    const GValue * minuend, const GValue * subtrahend)
+{
+  gint64 min1 = gst_value_get_int64_range_min (minuend);
+  gint64 max1 = gst_value_get_int64_range_max (minuend);
+  gint64 min2 = gst_value_get_int64_range_min (subtrahend);
+  gint64 max2 = gst_value_get_int64_range_max (subtrahend);
+
+  if (max2 == G_MAXINT64 && min2 == G_MININT64) {
+    return FALSE;
+  } else if (max2 == G_MAXINT64) {
+    return gst_value_create_new_int64_range (dest, min1, MIN (min2 - 1, max1),
+        1, 0);
+  } else if (min2 == G_MININT64) {
+    return gst_value_create_new_int64_range (dest, MAX (max2 + 1, min1), max1,
+        1, 0);
+  } else {
+    return gst_value_create_new_int64_range (dest, min1, MIN (min2 - 1, max1),
+        MAX (max2 + 1, min1), max1);
+  }
+}
+
+static gboolean
 gst_value_subtract_double_double_range (GValue * dest, const GValue * minuend,
     const GValue * subtrahend)
 {
@@ -2779,7 +3257,7 @@ gst_value_subtract_fraction_range_fraction_range (GValue * dest,
   const GValue *max2 = gst_value_get_fraction_range_max (minuend);
   const GValue *max1 = gst_value_get_fraction_range_min (subtrahend);
   const GValue *min2 = gst_value_get_fraction_range_max (subtrahend);
-  int cmp1, cmp2;
+  gint cmp1, cmp2;
   GValue v1 = { 0, };
   GValue v2 = { 0, };
   GValue *pv1, *pv2;            /* yeah, hungarian! */
@@ -2890,6 +3368,9 @@ gst_value_get_compare_func (const GValue * value1)
 gboolean
 gst_value_can_compare (const GValue * value1, const GValue * value2)
 {
+  g_return_val_if_fail (G_IS_VALUE (value1), FALSE);
+  g_return_val_if_fail (G_IS_VALUE (value2), FALSE);
+
   if (G_VALUE_TYPE (value1) != G_VALUE_TYPE (value2))
     return FALSE;
 
@@ -2913,6 +3394,27 @@ gint
 gst_value_compare (const GValue * value1, const GValue * value2)
 {
   GstValueCompareFunc compare;
+  GType ltype;
+
+  g_return_val_if_fail (G_IS_VALUE (value1), GST_VALUE_LESS_THAN);
+  g_return_val_if_fail (G_IS_VALUE (value2), GST_VALUE_GREATER_THAN);
+
+  /* Special case: lists and scalar values 
+   * "{ 1 }" and "1" are equal */
+  ltype = gst_value_list_get_type ();
+  if (G_VALUE_HOLDS (value1, ltype) && !G_VALUE_HOLDS (value2, ltype)
+      && gst_value_list_get_size (value1) == 1) {
+    const GValue *elt;
+
+    elt = gst_value_list_get_value (value1, 0);
+    return gst_value_compare (elt, value2);
+  } else if (G_VALUE_HOLDS (value2, ltype) && !G_VALUE_HOLDS (value1, ltype)
+      && gst_value_list_get_size (value2) == 1) {
+    const GValue *elt;
+
+    elt = gst_value_list_get_value (value2, 0);
+    return gst_value_compare (elt, value1);
+  }
 
   if (G_VALUE_TYPE (value1) != G_VALUE_TYPE (value2))
     return GST_VALUE_UNORDERED;
@@ -2975,6 +3477,9 @@ gst_value_can_union (const GValue * value1, const GValue * value2)
   GstValueUnionInfo *union_info;
   guint i, len;
 
+  g_return_val_if_fail (G_IS_VALUE (value1), FALSE);
+  g_return_val_if_fail (G_IS_VALUE (value2), FALSE);
+
   len = gst_value_union_funcs->len;
 
   for (i = 0; i < len; i++) {
@@ -2992,7 +3497,7 @@ gst_value_can_union (const GValue * value1, const GValue * value2)
 
 /**
  * gst_value_union:
- * @dest: the destination value
+ * @dest: (out caller-allocates): the destination value
  * @value1: a value to union
  * @value2: another value to union
  *
@@ -3007,6 +3512,10 @@ gst_value_union (GValue * dest, const GValue * value1, const GValue * value2)
   GstValueUnionInfo *union_info;
   guint i, len;
 
+  g_return_val_if_fail (dest != NULL, FALSE);
+  g_return_val_if_fail (G_IS_VALUE (value1), FALSE);
+  g_return_val_if_fail (G_IS_VALUE (value2), FALSE);
+
   len = gst_value_union_funcs->len;
 
   for (i = 0; i < len; i++) {
@@ -3033,7 +3542,7 @@ gst_value_union (GValue * dest, const GValue * value1, const GValue * value2)
  * gst_value_register_union_func:
  * @type1: a type to union
  * @type2: another type to union
- * @func: a function that implments creating a union between the two types
+ * @func: a function that implements creating a union between the two types
  *
  * Registers a union function that can create a union between #GValue items
  * of the type @type1 and @type2.
@@ -3075,6 +3584,9 @@ gst_value_can_intersect (const GValue * value1, const GValue * value2)
   guint i, len;
   GType ltype, type1, type2;
 
+  g_return_val_if_fail (G_IS_VALUE (value1), FALSE);
+  g_return_val_if_fail (G_IS_VALUE (value2), FALSE);
+
   ltype = gst_value_list_get_type ();
 
   /* special cases */
@@ -3104,7 +3616,7 @@ gst_value_can_intersect (const GValue * value1, const GValue * value2)
 
 /**
  * gst_value_intersect:
- * @dest: a uninitialized #GValue that will hold the calculated
+ * @dest: (out caller-allocates): a uninitialized #GValue that will hold the calculated
  * intersection value
  * @value1: a value to intersect
  * @value2: another value to intersect
@@ -3124,6 +3636,10 @@ gst_value_intersect (GValue * dest, const GValue * value1,
   guint i, len;
   GType ltype, type1, type2;
 
+  g_return_val_if_fail (dest != NULL, FALSE);
+  g_return_val_if_fail (G_IS_VALUE (value1), FALSE);
+  g_return_val_if_fail (G_IS_VALUE (value2), FALSE);
+
   ltype = gst_value_list_get_type ();
 
   /* special cases first */
@@ -3186,7 +3702,8 @@ gst_value_register_intersect_func (GType type1, GType type2,
 
 /**
  * gst_value_subtract:
- * @dest: the destination value for the result if the subtraction is not empty
+ * @dest: (out caller-allocates): the destination value for the result if the
+ *     subtraction is not empty
  * @minuend: the value to subtract from
  * @subtrahend: the value to subtract
  *
@@ -3203,6 +3720,10 @@ gst_value_subtract (GValue * dest, const GValue * minuend,
   guint i, len;
   GType ltype, mtype, stype;
 
+  g_return_val_if_fail (dest != NULL, FALSE);
+  g_return_val_if_fail (G_IS_VALUE (minuend), FALSE);
+  g_return_val_if_fail (G_IS_VALUE (subtrahend), FALSE);
+
   ltype = gst_value_list_get_type ();
 
   /* special cases first */
@@ -3260,6 +3781,9 @@ gst_value_can_subtract (const GValue * minuend, const GValue * subtrahend)
   guint i, len;
   GType ltype, mtype, stype;
 
+  g_return_val_if_fail (G_IS_VALUE (minuend), FALSE);
+  g_return_val_if_fail (G_IS_VALUE (subtrahend), FALSE);
+
   ltype = gst_value_list_get_type ();
 
   /* special cases */
@@ -3321,6 +3845,8 @@ gst_value_register (const GstValueTable * table)
 {
   GstValueTable *found;
 
+  g_return_if_fail (table != NULL);
+
   g_array_append_val (gst_value_table, *table);
 
   found = gst_value_hash_lookup_type (table->type);
@@ -3334,7 +3860,7 @@ gst_value_register (const GstValueTable * table)
 
 /**
  * gst_value_init_and_copy:
- * @dest: the target value
+ * @dest: (out caller-allocates): the target value
  * @src: the source value
  *
  * Initialises the target value to be of the same type as source and then copies
@@ -3343,6 +3869,9 @@ gst_value_register (const GstValueTable * table)
 void
 gst_value_init_and_copy (GValue * dest, const GValue * src)
 {
+  g_return_if_fail (G_IS_VALUE (src));
+  g_return_if_fail (dest != NULL);
+
   g_value_init (dest, G_VALUE_TYPE (src));
   g_value_copy (src, dest);
 }
@@ -3354,7 +3883,9 @@ gst_value_init_and_copy (GValue * dest, const GValue * src)
  * tries to transform the given @value into a string representation that allows
  * getting back this string later on using gst_value_deserialize().
  *
- * Returns: the serialization for @value or NULL if none exists
+ * Free-function: g_free
+ *
+ * Returns: (transfer full): the serialization for @value or NULL if none exists
  */
 gchar *
 gst_value_serialize (const GValue * value)
@@ -3362,7 +3893,7 @@ gst_value_serialize (const GValue * value)
   guint i, len;
   GValue s_val = { 0 };
   GstValueTable *table, *best;
-  char *s;
+  gchar *s;
   GType type;
 
   g_return_val_if_fail (G_IS_VALUE (value), NULL);
@@ -3398,7 +3929,8 @@ gst_value_serialize (const GValue * value)
 
 /**
  * gst_value_deserialize:
- * @dest: #GValue to fill with contents of deserialization
+ * @dest: (out caller-allocates): #GValue to fill with contents of
+ *     deserialization
  * @src: string to deserialize
  *
  * Tries to deserialize a string into the type specified by the given GValue.
@@ -3451,7 +3983,11 @@ gst_value_deserialize (GValue * dest, const gchar * src)
 gboolean
 gst_value_is_fixed (const GValue * value)
 {
-  GType type = G_VALUE_TYPE (value);
+  GType type;
+
+  g_return_val_if_fail (G_IS_VALUE (value), FALSE);
+
+  type = G_VALUE_TYPE (value);
 
   /* the most common types are just basic plain glib types */
   if (type <= G_TYPE_MAKE_FUNDAMENTAL (G_TYPE_RESERVED_GLIB_LAST)) {
@@ -3497,6 +4033,23 @@ static gchar *
 gst_value_collect_fraction (GValue * value, guint n_collect_values,
     GTypeCValue * collect_values, guint collect_flags)
 {
+  if (n_collect_values != 2)
+    return g_strdup_printf ("not enough value locations for `%s' passed",
+        G_VALUE_TYPE_NAME (value));
+  if (collect_values[1].v_int == 0)
+    return g_strdup_printf ("passed '0' as denominator for `%s'",
+        G_VALUE_TYPE_NAME (value));
+  if (collect_values[0].v_int < -G_MAXINT)
+    return
+        g_strdup_printf
+        ("passed value smaller than -G_MAXINT as numerator for `%s'",
+        G_VALUE_TYPE_NAME (value));
+  if (collect_values[1].v_int < -G_MAXINT)
+    return
+        g_strdup_printf
+        ("passed value smaller than -G_MAXINT as denominator for `%s'",
+        G_VALUE_TYPE_NAME (value));
+
   gst_value_set_fraction (value,
       collect_values[0].v_int, collect_values[1].v_int);
 
@@ -3612,6 +4165,7 @@ gst_value_fraction_multiply (GValue * product, const GValue * factor1,
   gint n1, n2, d1, d2;
   gint res_n, res_d;
 
+  g_return_val_if_fail (product != NULL, FALSE);
   g_return_val_if_fail (GST_VALUE_HOLDS_FRACTION (factor1), FALSE);
   g_return_val_if_fail (GST_VALUE_HOLDS_FRACTION (factor2), FALSE);
 
@@ -3645,6 +4199,7 @@ gst_value_fraction_subtract (GValue * dest,
   gint n1, n2, d1, d2;
   gint res_n, res_d;
 
+  g_return_val_if_fail (dest != NULL, FALSE);
   g_return_val_if_fail (GST_VALUE_HOLDS_FRACTION (minuend), FALSE);
   g_return_val_if_fail (GST_VALUE_HOLDS_FRACTION (subtrahend), FALSE);
 
@@ -3685,7 +4240,7 @@ static gboolean
 gst_value_deserialize_fraction (GValue * dest, const gchar * s)
 {
   gint num, den;
-  int num_chars;
+  gint num_chars;
 
   if (G_UNLIKELY (s == NULL))
     return FALSE;
@@ -3696,6 +4251,9 @@ gst_value_deserialize_fraction (GValue * dest, const gchar * s)
   if (sscanf (s, "%d/%d%n", &num, &den, &num_chars) >= 2) {
     if (s[num_chars] != 0)
       return FALSE;
+    if (den == 0)
+      return FALSE;
+
     gst_value_set_fraction (dest, num, den);
     return TRUE;
   } else if (g_ascii_strcasecmp (s, "1/max") == 0) {
@@ -3778,9 +4336,7 @@ gst_value_compare_fraction (const GValue * value1, const GValue * value2)
 {
   gint n1, n2;
   gint d1, d2;
-
-  gint64 new_num_1;
-  gint64 new_num_2;
+  gint ret;
 
   n1 = value1->data[0].v_int;
   n2 = value2->data[0].v_int;
@@ -3791,18 +4347,22 @@ gst_value_compare_fraction (const GValue * value1, const GValue * value2)
   if (n1 == n2 && d1 == d2)
     return GST_VALUE_EQUAL;
 
-  /* extend to 64 bits */
-  new_num_1 = ((gint64) n1) * d2;
-  new_num_2 = ((gint64) n2) * d1;
-  if (new_num_1 < new_num_2)
+  if (d1 == 0 && d2 == 0)
+    return GST_VALUE_UNORDERED;
+  else if (d1 == 0)
+    return GST_VALUE_GREATER_THAN;
+  else if (d2 == 0)
+    return GST_VALUE_LESS_THAN;
+
+  ret = gst_util_fraction_compare (n1, d1, n2, d2);
+  if (ret == -1)
     return GST_VALUE_LESS_THAN;
-  if (new_num_1 > new_num_2)
+  else if (ret == 1)
     return GST_VALUE_GREATER_THAN;
 
-  /* new_num_1 == new_num_2 implies that both denominators must have 
-   * been 0, beause otherwise simplification would have caught the
-   * equivalence */
-  return GST_VALUE_UNORDERED;
+  /* Equality can't happen here because we check for that
+   * first already */
+  g_return_val_if_reached (GST_VALUE_UNORDERED);
 }
 
 /*********
@@ -3814,7 +4374,7 @@ gst_value_compare_fraction (const GValue * value1, const GValue * value2)
  * @value: a GValue initialized to GST_TYPE_DATE
  * @date: the date to set the value to
  *
- * Sets the contents of @value to coorespond to @date.  The actual
+ * Sets the contents of @value to correspond to @date.  The actual
  * #GDate structure is copied before it is used.
  */
 void
@@ -3832,7 +4392,7 @@ gst_value_set_date (GValue * value, const GDate * date)
  *
  * Gets the contents of @value.
  *
- * Returns: the contents of @value
+ * Returns: (transfer none): the contents of @value
  */
 const GDate *
 gst_value_get_date (const GValue * value)
@@ -3904,7 +4464,7 @@ gst_value_serialize_date (const GValue * val)
 }
 
 static gboolean
-gst_value_deserialize_date (GValue * dest, const char *s)
+gst_value_deserialize_date (GValue * dest, const gchar * s)
 {
   guint year, month, day;
 
@@ -3918,6 +4478,87 @@ gst_value_deserialize_date (GValue * dest, const char *s)
   return TRUE;
 }
 
+/*************
+ * GstDateTime *
+ *************/
+
+static gint
+gst_value_compare_date_time (const GValue * value1, const GValue * value2)
+{
+  const GstDateTime *date1 = (const GstDateTime *) g_value_get_boxed (value1);
+  const GstDateTime *date2 = (const GstDateTime *) g_value_get_boxed (value2);
+  gint ret;
+
+  if (date1 == date2)
+    return GST_VALUE_EQUAL;
+
+  if ((date1 == NULL) && (date2 != NULL)) {
+    return GST_VALUE_LESS_THAN;
+  }
+  if ((date2 == NULL) && (date1 != NULL)) {
+    return GST_VALUE_LESS_THAN;
+  }
+
+  ret = priv_gst_date_time_compare (date1, date2);
+
+  if (ret == 0)
+    return GST_VALUE_EQUAL;
+  else if (ret < 0)
+    return GST_VALUE_LESS_THAN;
+  else
+    return GST_VALUE_GREATER_THAN;
+}
+
+static gchar *
+gst_value_serialize_date_time (const GValue * val)
+{
+  GstDateTime *date = (GstDateTime *) g_value_get_boxed (val);
+  gfloat offset;
+  gint tzhour, tzminute;
+
+  if (date == NULL)
+    return g_strdup ("null");
+
+  offset = gst_date_time_get_time_zone_offset (date);
+
+  tzhour = (gint) ABS (offset);
+  tzminute = (gint) ((ABS (offset) - tzhour) * 60);
+
+  return g_strdup_printf ("\"%04d-%02d-%02dT%02d:%02d:%02d.%06d"
+      "%c%02d%02d\"", gst_date_time_get_year (date),
+      gst_date_time_get_month (date), gst_date_time_get_day (date),
+      gst_date_time_get_hour (date), gst_date_time_get_minute (date),
+      gst_date_time_get_second (date), gst_date_time_get_microsecond (date),
+      offset >= 0 ? '+' : '-', tzhour, tzminute);
+}
+
+static gboolean
+gst_value_deserialize_date_time (GValue * dest, const gchar * s)
+{
+  gint year, month, day, hour, minute, second, usecond;
+  gchar signal;
+  gint offset = 0;
+  gfloat tzoffset = 0;
+  gint ret;
+
+  if (!s || strcmp (s, "null") == 0) {
+    return FALSE;
+  }
+
+  ret = sscanf (s, "%04d-%02d-%02dT%02d:%02d:%02d.%06d%c%04d",
+      &year, &month, &day, &hour, &minute, &second, &usecond, &signal, &offset);
+  if (ret >= 9) {
+    tzoffset = (offset / 100) + ((offset % 100) / 60.0);
+    if (signal == '-')
+      tzoffset = -tzoffset;
+  } else
+    return FALSE;
+
+  g_value_take_boxed (dest, gst_date_time_new (tzoffset, year, month, day, hour,
+          minute, second + (usecond / 1000000.0)));
+  return TRUE;
+}
+
 static void
 gst_value_transform_date_string (const GValue * src_value, GValue * dest_value)
 {
@@ -3969,13 +4610,15 @@ static GTypeFundamentalInfo _finfo = {
 #define FUNC_VALUE_GET_TYPE(type, name)                         \
 GType gst_ ## type ## _get_type (void)                          \
 {                                                               \
-  static GType gst_ ## type ## _type = 0;                       \
+  static volatile GType gst_ ## type ## _type = 0;                       \
                                                                 \
-  if (G_UNLIKELY (gst_ ## type ## _type == 0)) {               \
+  if (g_once_init_enter (&gst_ ## type ## _type)) {            \
+    GType _type;                                       \
     _info.value_table = & _gst_ ## type ## _value_table;        \
-    gst_ ## type ## _type = g_type_register_fundamental (       \
+    _type = g_type_register_fundamental (       \
         g_type_fundamental_next (),                             \
         name, &_info, &_finfo, 0);                              \
+    g_once_init_leave(&gst_ ## type ## _type, _type);  \
   }                                                             \
                                                                 \
   return gst_ ## type ## _type;                                 \
@@ -3986,9 +4629,9 @@ static const GTypeValueTable _gst_fourcc_value_table = {
   NULL,
   gst_value_copy_fourcc,
   NULL,
-  "i",
+  (char *) "i",
   gst_value_collect_fourcc,
-  "p",
+  (char *) "p",
   gst_value_lcopy_fourcc
 };
 
@@ -3999,22 +4642,35 @@ static const GTypeValueTable _gst_int_range_value_table = {
   NULL,
   gst_value_copy_int_range,
   NULL,
-  "ii",
+  (char *) "ii",
   gst_value_collect_int_range,
-  "pp",
+  (char *) "pp",
   gst_value_lcopy_int_range
 };
 
 FUNC_VALUE_GET_TYPE (int_range, "GstIntRange");
 
+static const GTypeValueTable _gst_int64_range_value_table = {
+  gst_value_init_int64_range,
+  NULL,
+  gst_value_copy_int64_range,
+  NULL,
+  (char *) "qq",
+  gst_value_collect_int64_range,
+  (char *) "pp",
+  gst_value_lcopy_int64_range
+};
+
+FUNC_VALUE_GET_TYPE (int64_range, "GstInt64Range");
+
 static const GTypeValueTable _gst_double_range_value_table = {
   gst_value_init_double_range,
   NULL,
   gst_value_copy_double_range,
   NULL,
-  "dd",
+  (char *) "dd",
   gst_value_collect_double_range,
-  "pp",
+  (char *) "pp",
   gst_value_lcopy_double_range
 };
 
@@ -4025,9 +4681,9 @@ static const GTypeValueTable _gst_fraction_range_value_table = {
   gst_value_free_fraction_range,
   gst_value_copy_fraction_range,
   NULL,
-  "iiii",
+  (char *) "iiii",
   gst_value_collect_fraction_range,
-  "pppp",
+  (char *) "pppp",
   gst_value_lcopy_fraction_range
 };
 
@@ -4038,9 +4694,9 @@ static const GTypeValueTable _gst_value_list_value_table = {
   gst_value_free_list_or_array,
   gst_value_copy_list_or_array,
   gst_value_list_or_array_peek_pointer,
-  "p",
+  (char *) "p",
   gst_value_collect_list_or_array,
-  "p",
+  (char *) "p",
   gst_value_lcopy_list_or_array
 };
 
@@ -4051,9 +4707,9 @@ static const GTypeValueTable _gst_value_array_value_table = {
   gst_value_free_list_or_array,
   gst_value_copy_list_or_array,
   gst_value_list_or_array_peek_pointer,
-  "p",
+  (char *) "p",
   gst_value_collect_list_or_array,
-  "p",
+  (char *) "p",
   gst_value_lcopy_list_or_array
 };
 
@@ -4064,9 +4720,9 @@ static const GTypeValueTable _gst_fraction_value_table = {
   NULL,
   gst_value_copy_fraction,
   NULL,
-  "ii",
+  (char *) "ii",
   gst_value_collect_fraction,
-  "pp",
+  (char *) "pp",
   gst_value_lcopy_fraction
 };
 
@@ -4091,6 +4747,21 @@ gst_date_get_type (void)
   return gst_date_type;
 }
 
+GType
+gst_date_time_get_type (void)
+{
+  static GType gst_date_time_type = 0;
+
+  if (G_UNLIKELY (gst_date_time_type == 0)) {
+    gst_date_time_type = g_boxed_type_register_static ("GstDateTime",
+        (GBoxedCopyFunc) gst_date_time_ref,
+        (GBoxedFreeFunc) gst_date_time_unref);
+  }
+
+  return gst_date_time_type;
+}
+
+
 void
 _gst_value_initialize (void)
 {
@@ -4130,6 +4801,18 @@ _gst_value_initialize (void)
   {
     static GstValueTable gst_value = {
       0,
+      gst_value_compare_int64_range,
+      gst_value_serialize_int64_range,
+      gst_value_deserialize_int64_range,
+    };
+
+    gst_value.type = gst_int64_range_get_type ();
+    gst_value_register (&gst_value);
+  }
+
+  {
+    static GstValueTable gst_value = {
+      0,
       gst_value_compare_double_range,
       gst_value_serialize_double_range,
       gst_value_deserialize_double_range,
@@ -4242,6 +4925,17 @@ _gst_value_initialize (void)
     gst_value.type = gst_date_get_type ();
     gst_value_register (&gst_value);
   }
+  {
+    static GstValueTable gst_value = {
+      0,
+      gst_value_compare_date_time,
+      gst_value_serialize_date_time,
+      gst_value_deserialize_date_time,
+    };
+
+    gst_value.type = gst_date_time_get_type ();
+    gst_value_register (&gst_value);
+  }
 
   REGISTER_SERIALIZATION (G_TYPE_DOUBLE, double);
   REGISTER_SERIALIZATION (G_TYPE_FLOAT, float);
@@ -4261,10 +4955,14 @@ _gst_value_initialize (void)
   REGISTER_SERIALIZATION (G_TYPE_UINT64, uint64);
   REGISTER_SERIALIZATION (G_TYPE_ULONG, ulong);
 
+  REGISTER_SERIALIZATION (G_TYPE_UCHAR, uchar);
+
   g_value_register_transform_func (GST_TYPE_FOURCC, G_TYPE_STRING,
       gst_value_transform_fourcc_string);
   g_value_register_transform_func (GST_TYPE_INT_RANGE, G_TYPE_STRING,
       gst_value_transform_int_range_string);
+  g_value_register_transform_func (GST_TYPE_INT64_RANGE, G_TYPE_STRING,
+      gst_value_transform_int64_range_string);
   g_value_register_transform_func (GST_TYPE_DOUBLE_RANGE, G_TYPE_STRING,
       gst_value_transform_double_range_string);
   g_value_register_transform_func (GST_TYPE_FRACTION_RANGE, G_TYPE_STRING,
@@ -4296,6 +4994,10 @@ _gst_value_initialize (void)
       gst_value_intersect_int_int_range);
   gst_value_register_intersect_func (GST_TYPE_INT_RANGE, GST_TYPE_INT_RANGE,
       gst_value_intersect_int_range_int_range);
+  gst_value_register_intersect_func (G_TYPE_INT64, GST_TYPE_INT64_RANGE,
+      gst_value_intersect_int64_int64_range);
+  gst_value_register_intersect_func (GST_TYPE_INT64_RANGE, GST_TYPE_INT64_RANGE,
+      gst_value_intersect_int64_range_int64_range);
   gst_value_register_intersect_func (G_TYPE_DOUBLE, GST_TYPE_DOUBLE_RANGE,
       gst_value_intersect_double_double_range);
   gst_value_register_intersect_func (GST_TYPE_DOUBLE_RANGE,
@@ -4314,6 +5016,12 @@ _gst_value_initialize (void)
       gst_value_subtract_int_range_int);
   gst_value_register_subtract_func (GST_TYPE_INT_RANGE, GST_TYPE_INT_RANGE,
       gst_value_subtract_int_range_int_range);
+  gst_value_register_subtract_func (G_TYPE_INT64, GST_TYPE_INT64_RANGE,
+      gst_value_subtract_int64_int64_range);
+  gst_value_register_subtract_func (GST_TYPE_INT64_RANGE, G_TYPE_INT64,
+      gst_value_subtract_int64_range_int64);
+  gst_value_register_subtract_func (GST_TYPE_INT64_RANGE, GST_TYPE_INT64_RANGE,
+      gst_value_subtract_int64_range_int64_range);
   gst_value_register_subtract_func (G_TYPE_DOUBLE, GST_TYPE_DOUBLE_RANGE,
       gst_value_subtract_double_double_range);
   gst_value_register_subtract_func (GST_TYPE_DOUBLE_RANGE, G_TYPE_DOUBLE,