Esempio n. 1
0
/**
 * ges_track_remove_object:
 * @track: a #GESTrack
 * @object: the #GESTrackObject to remove
 *
 * Removes the object from the track and unparents it.
 * Unparenting it means the reference owned by @track on the @object will be
 * removed. If you wish to use the @object after this function, make sure you
 * call g_object_ref() before removing it from the @track.
 *
 * Returns: #TRUE if the object was removed, else #FALSE if the track
 * could not remove the object (like if it didn't belong to the track).
 */
gboolean
ges_track_remove_object (GESTrack * track, GESTrackObject * object)
{
  GESTrackPrivate *priv;
  GstElement *gnlobject;

  g_return_val_if_fail (GES_IS_TRACK (track), FALSE);
  g_return_val_if_fail (GES_IS_TRACK_OBJECT (object), FALSE);

  GST_DEBUG ("track:%p, object:%p", track, object);

  priv = track->priv;

  if (G_UNLIKELY (ges_track_object_get_track (object) != track)) {
    GST_WARNING ("Object belongs to another track");
    return FALSE;
  }

  if ((gnlobject = ges_track_object_get_gnlobject (object))) {
    GST_DEBUG ("Removing GnlObject '%s' from composition '%s'",
        GST_ELEMENT_NAME (gnlobject), GST_ELEMENT_NAME (priv->composition));
    if (!gst_bin_remove (GST_BIN (priv->composition), gnlobject)) {
      GST_WARNING ("Failed to remove gnlobject from composition");
      return FALSE;
    }
  }

  ges_track_object_set_track (object, NULL);
  priv->trackobjects = g_list_remove (priv->trackobjects, object);

  g_object_unref (object);

  return TRUE;
}
Esempio n. 2
0
/**
 * ges_track_set_caps:
 * @track: a #GESTrack
 * @caps: the #GstCaps to set
 *
 * Sets the given @caps on the track.
 */
void
ges_track_set_caps (GESTrack * track, const GstCaps * caps)
{
  GESTrackPrivate *priv;

  g_return_if_fail (GES_IS_TRACK (track));
  g_return_if_fail (GST_IS_CAPS (caps));

  GST_DEBUG ("track:%p, caps:%" GST_PTR_FORMAT, track, caps);

  priv = track->priv;

  if (priv->caps)
    gst_caps_unref (priv->caps);
  priv->caps = gst_caps_copy (caps);

  g_object_set (priv->composition, "caps", caps, NULL);
  /* FIXME : update all trackobjects ? */
}
static void
bin_element_added (GstTracer * runner, GstClockTime ts,
    GstBin * bin, GstElement * element, gboolean result)
{
  GstObject *parent;
  GstValidateElementMonitor *monitor =
      g_object_get_data (G_OBJECT (element), "validate-monitor");

  if (!monitor)
    return;

  if (!monitor->is_decoder)
    return;


  parent = gst_object_get_parent (GST_OBJECT (element));
  do {
    if (GES_IS_TRACK (parent)) {
      GstElementClass *klass = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element));
      const gchar *klassname =
          gst_element_class_get_metadata (klass, GST_ELEMENT_METADATA_KLASS);

      if (GES_IS_AUDIO_TRACK (parent) && strstr (klassname, "Audio") == NULL) {
        GST_VALIDATE_REPORT (monitor, WRONG_DECODER_ADDED,
            "Adding non audio decoder %s in audio track %s.",
            GST_OBJECT_NAME (element), GST_OBJECT_NAME (parent));
      } else if (GES_IS_VIDEO_TRACK (parent)
          && strstr (klassname, "Video") == NULL
          && strstr (klassname, "Image") == NULL) {
        GST_VALIDATE_REPORT (monitor, WRONG_DECODER_ADDED,
            "Adding non video decoder %s in video track %s.",
            GST_OBJECT_NAME (element), GST_OBJECT_NAME (parent));

      }
      gst_object_unref (parent);
      break;
    }

    gst_object_unref (parent);
    parent = gst_object_get_parent (parent);
  } while (parent);
}
Esempio n. 4
0
/**
 * ges_track_add_object:
 * @track: a #GESTrack
 * @object: (transfer full): the #GESTrackObject to add
 *
 * Adds the given object to the track. Sets the object's controlling track,
 * and thus takes ownership of the @object.
 *
 * An object can only be added to one track.
 *
 * Returns: #TRUE if the object was properly added. #FALSE if the track does not
 * want to accept the object.
 */
gboolean
ges_track_add_object (GESTrack * track, GESTrackObject * object)
{
  g_return_val_if_fail (GES_IS_TRACK (track), FALSE);
  g_return_val_if_fail (GES_IS_TRACK_OBJECT (object), FALSE);

  GST_DEBUG ("track:%p, object:%p", track, object);

  if (G_UNLIKELY (ges_track_object_get_track (object) != NULL)) {
    GST_WARNING ("Object already belongs to another track");
    return FALSE;
  }

  /* At this point, the track object shouldn't have any gnlobject since
   * it hasn't been added to a track yet.
   * FIXME : This check seems a bit obsolete */
  if (G_UNLIKELY (ges_track_object_get_gnlobject (object) != NULL)) {
    GST_ERROR ("TrackObject already controls a gnlobject !");
    return FALSE;
  }

  if (G_UNLIKELY (!ges_track_object_set_track (object, track))) {
    GST_ERROR ("Couldn't properly add the object to the Track");
    return FALSE;
  }

  GST_DEBUG ("Adding object to ourself");

  if (G_UNLIKELY (!gst_bin_add (GST_BIN (track->priv->composition),
              ges_track_object_get_gnlobject (object)))) {
    GST_WARNING ("Couldn't add object to the GnlComposition");
    return FALSE;
  }

  g_object_ref_sink (object);

  track->priv->trackobjects = g_list_append (track->priv->trackobjects, object);

  return TRUE;
}