Beispiel #1
0
static gboolean
check_bin (KmsTreeBin * tree_bin, const GstCaps * caps)
{
  gboolean ret = FALSE;
  GstElement *output_tee = kms_tree_bin_get_output_tee (tree_bin);
  GstPad *tee_sink = gst_element_get_static_pad (output_tee, "sink");
  GstCaps *current_caps = kms_tree_bin_get_input_caps (tree_bin);

  if (current_caps == NULL) {
    current_caps = gst_pad_get_allowed_caps (tee_sink);
    GST_TRACE_OBJECT (tree_bin, "Allowed caps are: %" GST_PTR_FORMAT,
        current_caps);
  } else {
    GST_TRACE_OBJECT (tree_bin, "Current caps are: %" GST_PTR_FORMAT,
        current_caps);
  }

  if (current_caps != NULL) {
    //TODO: Remove this when problem in negotiation with features will be
    //resolved
    GstCaps *caps_without_features = gst_caps_make_writable (current_caps);

    gst_caps_set_features (caps_without_features, 0,
        gst_caps_features_new_empty ());
    if (gst_caps_can_intersect (caps, caps_without_features)) {
      ret = TRUE;
    }
    gst_caps_unref (caps_without_features);
  }

  g_object_unref (tee_sink);

  return ret;
}
Beispiel #2
0
/**
 * gst_caps_features_new_any:
 *
 * Creates a new, ANY #GstCapsFeatures. This will be equal
 * to any other #GstCapsFeatures but caps with these are
 * unfixed.
 *
 * Free-function: gst_caps_features_free
 *
 * Returns: (transfer full): a new, ANY #GstCapsFeatures
 *
 * Since: 1.2
 */
GstCapsFeatures *
gst_caps_features_new_any (void)
{
  GstCapsFeatures *features;

  features = gst_caps_features_new_empty ();
  features->is_any = TRUE;

  return features;
}
Beispiel #3
0
/**
 * gst_caps_features_copy:
 * @features: a #GstCapsFeatures to duplicate
 *
 * Duplicates a #GstCapsFeatures and all its values.
 *
 * Free-function: gst_caps_features_free
 *
 * Returns: (transfer full): a new #GstCapsFeatures.
 *
 * Since: 1.2
 */
GstCapsFeatures *
gst_caps_features_copy (const GstCapsFeatures * features)
{
  GstCapsFeatures *copy;
  guint i, n;

  g_return_val_if_fail (features != NULL, NULL);

  copy = gst_caps_features_new_empty ();
  n = gst_caps_features_get_size (features);
  for (i = 0; i < n; i++)
    gst_caps_features_add_id (copy, gst_caps_features_get_nth_id (features, i));
  copy->is_any = features->is_any;

  return copy;
}
Beispiel #4
0
/**
 * gst_caps_features_new_id_valist:
 * @feature1: name of first feature to set
 * @varargs: variable argument list
 *
 * Creates a new #GstCapsFeatures with the given features.
 *
 * Free-function: gst_caps_features_free
 *
 * Returns: (transfer full): a new, empty #GstCapsFeatures
 *
 * Since: 1.2
 */
GstCapsFeatures *
gst_caps_features_new_id_valist (GQuark feature1, va_list varargs)
{
  GstCapsFeatures *features;

  g_return_val_if_fail (feature1 != 0, NULL);

  features = gst_caps_features_new_empty ();

  while (feature1) {
    gst_caps_features_add_id (features, feature1);
    feature1 = va_arg (varargs, GQuark);
  }

  return features;
}
Beispiel #5
0
/**
 * gst_caps_features_new_valist:
 * @feature1: name of first feature to set
 * @varargs: variable argument list
 *
 * Creates a new #GstCapsFeatures with the given features.
 *
 * Free-function: gst_caps_features_free
 *
 * Returns: (transfer full): a new, empty #GstCapsFeatures
 *
 * Since: 1.2
 */
GstCapsFeatures *
gst_caps_features_new_valist (const gchar * feature1, va_list varargs)
{
  GstCapsFeatures *features;

  g_return_val_if_fail (feature1 != NULL, NULL);

  features = gst_caps_features_new_empty ();

  while (feature1) {
    gst_caps_features_add (features, feature1);
    feature1 = va_arg (varargs, const gchar *);
  }

  return features;
}
Beispiel #6
0
/**
 * gst_caps_features_from_string:
 * @features: a string representation of a #GstCapsFeatures.
 *
 * Creates a #GstCapsFeatures from a string representation.
 *
 * Free-function: gst_caps_features_free
 *
 * Returns: (transfer full): a new #GstCapsFeatures or NULL when the string could
 *     not be parsed. Free with gst_caps_features_free() after use.
 *
 * Since: 1.2
 */
GstCapsFeatures *
gst_caps_features_from_string (const gchar * features)
{
  GstCapsFeatures *ret;
  gboolean escape = FALSE;
  const gchar *features_orig = features;
  const gchar *feature;

  ret = gst_caps_features_new_empty ();

  if (!features || *features == '\0')
    return ret;

  if (strcmp (features, "ANY") == 0) {
    ret->is_any = TRUE;
    return ret;
  }

  /* Skip trailing spaces */
  while (*features == ' ')
    features++;

  feature = features;
  while (TRUE) {
    gchar c = *features;

    if (c == '\\') {
      escape = TRUE;
      features++;
      continue;
    } else if ((!escape && c == ',') || c == '\0') {
      guint len = features - feature + 1;
      gchar *tmp;
      gchar *p;

      if (len == 1) {
        g_warning ("Failed deserialize caps features '%s'", features_orig);
        gst_caps_features_free (ret);
        return NULL;
      }

      tmp = g_malloc (len);
      memcpy (tmp, feature, len - 1);
      tmp[len - 1] = '\0';

      p = tmp + len - 1;
      while (*p == ' ') {
        *p = '\0';
        p--;
      }

      if (strstr (tmp, " ") != NULL || *tmp == '\0') {
        g_free (tmp);
        g_warning ("Failed deserialize caps features '%s'", features_orig);
        gst_caps_features_free (ret);
        return NULL;
      }

      gst_caps_features_add (ret, tmp);
      g_free (tmp);

      if (c == '\0')
        break;

      /* Skip to the next value */
      features++;
      while (*features == ' ')
        features++;
      feature = features;
    } else {
      escape = FALSE;
      features++;
    }
  }

  return ret;
}