2009-09-21 10:51:16 +00:00
|
|
|
/* GStreamer Editing Services
|
2009-11-30 14:14:25 +00:00
|
|
|
* Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
|
|
|
|
* 2009 Nokia Corporation
|
2009-09-21 10:51:16 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-04 00:25:20 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2009-09-21 10:51:16 +00:00
|
|
|
*/
|
|
|
|
|
2010-05-19 10:24:44 +00:00
|
|
|
/**
|
2016-08-13 23:54:22 +00:00
|
|
|
* SECTION: gesuriclip
|
2017-03-08 21:13:48 +00:00
|
|
|
* @title: GESUriClip
|
2010-05-31 16:59:12 +00:00
|
|
|
* @short_description: An object for manipulating media files in a GESTimeline
|
2012-11-27 16:53:22 +00:00
|
|
|
*
|
2011-06-25 17:42:29 +00:00
|
|
|
* Represents all the output streams from a particular uri. It is assumed that
|
2010-05-31 16:59:12 +00:00
|
|
|
* the URI points to a file of some type.
|
2010-05-19 10:24:44 +00:00
|
|
|
*/
|
2018-09-24 14:41:24 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2010-05-19 10:24:44 +00:00
|
|
|
|
2009-09-21 10:51:16 +00:00
|
|
|
#include "ges-internal.h"
|
2013-01-20 15:44:57 +00:00
|
|
|
#include "ges-uri-clip.h"
|
2013-01-17 03:35:39 +00:00
|
|
|
#include "ges-source-clip.h"
|
2013-07-09 13:31:15 +00:00
|
|
|
#include "ges-video-uri-source.h"
|
|
|
|
#include "ges-audio-uri-source.h"
|
2013-01-20 15:44:57 +00:00
|
|
|
#include "ges-uri-asset.h"
|
2013-01-26 17:14:57 +00:00
|
|
|
#include "ges-track-element-asset.h"
|
2012-09-10 00:21:21 +00:00
|
|
|
#include "ges-extractable.h"
|
2013-01-26 17:21:56 +00:00
|
|
|
#include "ges-image-source.h"
|
2013-01-26 16:02:02 +00:00
|
|
|
#include "ges-audio-test-source.h"
|
2013-11-12 11:13:31 +00:00
|
|
|
#include "ges-multi-file-source.h"
|
2015-11-20 22:33:12 +00:00
|
|
|
#include "ges-layer.h"
|
2009-09-21 10:51:16 +00:00
|
|
|
|
2012-09-10 00:21:21 +00:00
|
|
|
static void ges_extractable_interface_init (GESExtractableInterface * iface);
|
|
|
|
|
2013-01-20 15:44:57 +00:00
|
|
|
#define parent_class ges_uri_clip_parent_class
|
2013-01-15 13:52:17 +00:00
|
|
|
|
2013-01-20 15:44:57 +00:00
|
|
|
struct _GESUriClipPrivate
|
2011-01-08 14:25:22 +00:00
|
|
|
{
|
|
|
|
gchar *uri;
|
|
|
|
|
|
|
|
gboolean mute;
|
|
|
|
gboolean is_image;
|
|
|
|
};
|
|
|
|
|
2009-09-21 10:51:16 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2009-09-30 14:44:12 +00:00
|
|
|
PROP_URI,
|
2010-05-19 10:24:44 +00:00
|
|
|
PROP_MUTE,
|
2010-08-09 10:01:34 +00:00
|
|
|
PROP_IS_IMAGE,
|
2012-11-18 15:46:05 +00:00
|
|
|
PROP_SUPPORTED_FORMATS,
|
2009-09-21 10:51:16 +00:00
|
|
|
};
|
|
|
|
|
2018-09-06 01:55:02 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GESUriClip, ges_uri_clip,
|
|
|
|
GES_TYPE_SOURCE_CLIP, G_ADD_PRIVATE (GESUriClip)
|
|
|
|
G_IMPLEMENT_INTERFACE (GES_TYPE_EXTRACTABLE,
|
|
|
|
ges_extractable_interface_init));
|
2009-09-30 14:44:12 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
static GList *ges_uri_clip_create_track_elements (GESClip *
|
2013-02-15 02:34:48 +00:00
|
|
|
clip, GESTrackType type);
|
2017-08-07 19:35:58 +00:00
|
|
|
static void ges_uri_clip_set_uri (GESUriClip * self, gchar * uri);
|
2009-09-21 10:51:16 +00:00
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
gboolean
|
2016-08-13 23:54:22 +00:00
|
|
|
uri_clip_set_max_duration (GESTimelineElement * element,
|
2013-01-15 13:52:17 +00:00
|
|
|
GstClockTime maxduration);
|
2012-01-16 12:37:22 +00:00
|
|
|
|
2009-09-21 10:51:16 +00:00
|
|
|
static void
|
2013-01-20 15:44:57 +00:00
|
|
|
ges_uri_clip_get_property (GObject * object, guint property_id,
|
2009-09-21 10:51:16 +00:00
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2013-01-20 15:44:57 +00:00
|
|
|
GESUriClipPrivate *priv = GES_URI_CLIP (object)->priv;
|
2009-09-21 10:51:16 +00:00
|
|
|
|
|
|
|
switch (property_id) {
|
|
|
|
case PROP_URI:
|
2011-01-08 14:25:22 +00:00
|
|
|
g_value_set_string (value, priv->uri);
|
2009-09-21 10:51:16 +00:00
|
|
|
break;
|
2009-09-30 14:44:12 +00:00
|
|
|
case PROP_MUTE:
|
2011-01-08 14:25:22 +00:00
|
|
|
g_value_set_boolean (value, priv->mute);
|
2009-09-30 14:44:12 +00:00
|
|
|
break;
|
2010-08-09 10:01:34 +00:00
|
|
|
case PROP_IS_IMAGE:
|
2011-01-08 14:25:22 +00:00
|
|
|
g_value_set_boolean (value, priv->is_image);
|
2010-08-09 10:01:34 +00:00
|
|
|
break;
|
2012-11-18 15:46:05 +00:00
|
|
|
case PROP_SUPPORTED_FORMATS:
|
|
|
|
g_value_set_flags (value,
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_clip_get_supported_formats (GES_CLIP (object)));
|
2012-11-18 15:46:05 +00:00
|
|
|
break;
|
2009-09-21 10:51:16 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-20 15:44:57 +00:00
|
|
|
ges_uri_clip_set_property (GObject * object, guint property_id,
|
2009-09-21 10:51:16 +00:00
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2013-01-20 15:44:57 +00:00
|
|
|
GESUriClip *uriclip = GES_URI_CLIP (object);
|
2009-09-21 10:51:16 +00:00
|
|
|
|
|
|
|
switch (property_id) {
|
|
|
|
case PROP_URI:
|
2013-01-20 15:44:57 +00:00
|
|
|
ges_uri_clip_set_uri (uriclip, g_value_dup_string (value));
|
2009-09-21 10:51:16 +00:00
|
|
|
break;
|
2009-09-30 14:44:12 +00:00
|
|
|
case PROP_MUTE:
|
2013-01-20 15:44:57 +00:00
|
|
|
ges_uri_clip_set_mute (uriclip, g_value_get_boolean (value));
|
2009-09-30 14:44:12 +00:00
|
|
|
break;
|
2010-08-09 10:01:34 +00:00
|
|
|
case PROP_IS_IMAGE:
|
2013-01-20 15:44:57 +00:00
|
|
|
ges_uri_clip_set_is_image (uriclip, g_value_get_boolean (value));
|
2010-08-09 10:01:34 +00:00
|
|
|
break;
|
2012-11-18 15:46:05 +00:00
|
|
|
case PROP_SUPPORTED_FORMATS:
|
2013-01-20 15:42:29 +00:00
|
|
|
ges_clip_set_supported_formats (GES_CLIP (uriclip),
|
2012-11-18 15:46:05 +00:00
|
|
|
g_value_get_flags (value));
|
|
|
|
break;
|
2009-09-21 10:51:16 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-20 15:44:57 +00:00
|
|
|
ges_uri_clip_finalize (GObject * object)
|
2009-09-21 10:51:16 +00:00
|
|
|
{
|
2013-01-20 15:44:57 +00:00
|
|
|
GESUriClipPrivate *priv = GES_URI_CLIP (object)->priv;
|
2009-11-25 12:13:49 +00:00
|
|
|
|
2011-01-08 14:25:22 +00:00
|
|
|
if (priv->uri)
|
|
|
|
g_free (priv->uri);
|
2013-01-15 13:52:17 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2009-09-21 10:51:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-20 15:44:57 +00:00
|
|
|
ges_uri_clip_class_init (GESUriClipClass * klass)
|
2009-09-21 10:51:16 +00:00
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2020-03-25 01:44:07 +00:00
|
|
|
GESClipClass *clip_class = GES_CLIP_CLASS (klass);
|
2013-01-15 13:52:17 +00:00
|
|
|
GESTimelineElementClass *element_class = GES_TIMELINE_ELEMENT_CLASS (klass);
|
2009-09-21 10:51:16 +00:00
|
|
|
|
2013-01-20 15:44:57 +00:00
|
|
|
object_class->get_property = ges_uri_clip_get_property;
|
|
|
|
object_class->set_property = ges_uri_clip_set_property;
|
|
|
|
object_class->finalize = ges_uri_clip_finalize;
|
2009-09-21 10:51:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2013-01-20 15:44:57 +00:00
|
|
|
* GESUriClip:uri:
|
2009-09-21 10:51:16 +00:00
|
|
|
*
|
|
|
|
* The location of the file/resource to use.
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (object_class, PROP_URI,
|
2012-08-10 16:58:13 +00:00
|
|
|
g_param_spec_string ("uri", "URI", "uri of the resource", NULL,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
2009-09-21 10:51:16 +00:00
|
|
|
|
2010-05-19 10:24:44 +00:00
|
|
|
/**
|
2013-01-20 15:44:57 +00:00
|
|
|
* GESUriClip:mute:
|
2009-09-30 14:44:12 +00:00
|
|
|
*
|
|
|
|
* Whether the sound will be played or not.
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (object_class, PROP_MUTE,
|
|
|
|
g_param_spec_boolean ("mute", "Mute", "Mute audio track",
|
|
|
|
FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
|
|
|
|
2010-08-09 10:01:34 +00:00
|
|
|
/**
|
2013-01-20 15:44:57 +00:00
|
|
|
* GESUriClip:is-image:
|
2010-08-09 10:01:34 +00:00
|
|
|
*
|
2016-08-13 23:54:22 +00:00
|
|
|
* Whether this uri clip represents a still image or not. This must be set
|
2013-01-26 15:31:33 +00:00
|
|
|
* before create_track_elements is called.
|
2010-08-09 10:01:34 +00:00
|
|
|
*/
|
|
|
|
g_object_class_install_property (object_class, PROP_IS_IMAGE,
|
|
|
|
g_param_spec_boolean ("is-image", "Is still image",
|
2013-02-08 20:11:22 +00:00
|
|
|
"Whether the clip represents a still image or not",
|
2010-08-09 10:01:34 +00:00
|
|
|
FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
|
|
|
|
2012-11-18 15:46:05 +00:00
|
|
|
/* Redefine the supported formats property so the default value is UNKNOWN
|
|
|
|
* and not AUDIO | VIDEO */
|
|
|
|
g_object_class_install_property (object_class, PROP_SUPPORTED_FORMATS,
|
|
|
|
g_param_spec_flags ("supported-formats",
|
|
|
|
"Supported formats", "Formats supported by the file",
|
|
|
|
GES_TYPE_TRACK_TYPE, GES_TRACK_TYPE_UNKNOWN,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
|
|
|
|
2016-08-13 23:54:22 +00:00
|
|
|
element_class->set_max_duration = uri_clip_set_max_duration;
|
2013-01-15 13:52:17 +00:00
|
|
|
|
2020-03-25 01:44:07 +00:00
|
|
|
clip_class->create_track_elements = ges_uri_clip_create_track_elements;
|
2012-09-10 00:21:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
|
|
|
extractable_check_id (GType type, const gchar * id)
|
|
|
|
{
|
|
|
|
if (gst_uri_is_valid (id))
|
|
|
|
return g_strdup (id);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-02-07 12:39:39 +00:00
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS; /* Start ignoring GParameter deprecation */
|
|
|
|
|
2012-09-10 00:21:21 +00:00
|
|
|
static GParameter *
|
|
|
|
extractable_get_parameters_from_id (const gchar * id, guint * n_params)
|
|
|
|
{
|
2012-11-18 15:46:05 +00:00
|
|
|
GParameter *params = g_new0 (GParameter, 2);
|
2012-09-10 00:21:21 +00:00
|
|
|
|
2012-12-29 20:52:42 +00:00
|
|
|
params[0].name = "uri";
|
2012-09-10 00:21:21 +00:00
|
|
|
g_value_init (¶ms[0].value, G_TYPE_STRING);
|
|
|
|
g_value_set_string (¶ms[0].value, id);
|
|
|
|
|
2012-12-21 21:51:26 +00:00
|
|
|
*n_params = 1;
|
|
|
|
|
2012-09-10 00:21:21 +00:00
|
|
|
return params;
|
|
|
|
}
|
|
|
|
|
2020-02-07 12:39:39 +00:00
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS; /* End ignoring GParameter deprecation */
|
|
|
|
|
2012-09-10 00:21:21 +00:00
|
|
|
static gchar *
|
|
|
|
extractable_get_id (GESExtractable * self)
|
|
|
|
{
|
2013-01-20 15:44:57 +00:00
|
|
|
return g_strdup (GES_URI_CLIP (self)->priv->uri);
|
2012-09-10 00:21:21 +00:00
|
|
|
}
|
|
|
|
|
2020-09-04 03:32:23 +00:00
|
|
|
static GList *
|
|
|
|
get_auto_transitions_around_source (GESTrackElement * child)
|
|
|
|
{
|
|
|
|
GList *transitions = NULL;
|
|
|
|
GESTimeline *timeline = GES_TIMELINE_ELEMENT_TIMELINE (child);
|
|
|
|
gint i;
|
|
|
|
GESEdge edges[] = { GES_EDGE_START, GES_EDGE_END };
|
|
|
|
|
|
|
|
if (!timeline)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (edges); i++) {
|
|
|
|
GESAutoTransition *transition =
|
|
|
|
ges_timeline_get_auto_transition_at_edge (timeline, child, edges[i]);
|
|
|
|
if (transition)
|
|
|
|
transitions = g_list_prepend (transitions, transition);
|
|
|
|
}
|
|
|
|
|
|
|
|
return transitions;
|
|
|
|
}
|
|
|
|
|
2015-11-20 22:33:12 +00:00
|
|
|
static gboolean
|
2012-09-10 00:21:21 +00:00
|
|
|
extractable_set_asset (GESExtractable * self, GESAsset * asset)
|
|
|
|
{
|
2020-03-25 19:35:11 +00:00
|
|
|
gboolean res = TRUE, contains_core;
|
2013-01-20 15:44:57 +00:00
|
|
|
GESUriClip *uriclip = GES_URI_CLIP (self);
|
2016-08-13 23:54:22 +00:00
|
|
|
GESUriClipAsset *uri_clip_asset;
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClip *clip = GES_CLIP (self);
|
2020-05-21 10:25:30 +00:00
|
|
|
GESContainer *container = GES_CONTAINER (clip);
|
|
|
|
GESTimelineElement *element = GES_TIMELINE_ELEMENT (self);
|
2015-11-20 22:33:12 +00:00
|
|
|
GESLayer *layer = ges_clip_get_layer (clip);
|
2020-03-25 19:35:11 +00:00
|
|
|
GList *tmp, *children;
|
2020-09-04 03:32:23 +00:00
|
|
|
GHashTable *source_by_track, *auto_transitions_on_sources;
|
2020-05-21 10:25:30 +00:00
|
|
|
GstClockTime max_duration;
|
|
|
|
GESAsset *prev_asset;
|
2020-09-04 03:32:23 +00:00
|
|
|
GList *transitions = NULL;
|
|
|
|
GESTimeline *timeline = GES_TIMELINE_ELEMENT_TIMELINE (self);
|
2015-11-20 22:33:12 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GES_IS_URI_CLIP_ASSET (asset), FALSE);
|
2012-09-10 00:21:21 +00:00
|
|
|
|
2016-08-13 23:54:22 +00:00
|
|
|
uri_clip_asset = GES_URI_CLIP_ASSET (asset);
|
2019-03-01 22:32:19 +00:00
|
|
|
|
2020-05-21 10:25:30 +00:00
|
|
|
/* new sources elements will have their max-duration set to
|
|
|
|
* max_duration. Check that this is possible with the new uri
|
|
|
|
* NOTE: we are assuming that all the new core children will end up
|
|
|
|
* in the same tracks as the previous core children */
|
|
|
|
max_duration = ges_uri_clip_asset_get_max_duration (uri_clip_asset);
|
|
|
|
if (!ges_clip_can_set_max_duration_of_all_core (clip, max_duration, NULL)) {
|
|
|
|
GST_INFO_OBJECT (self, "Can not set asset to %p as its max-duration %"
|
|
|
|
GST_TIME_FORMAT " is too low", asset, GST_TIME_ARGS (max_duration));
|
2019-03-01 22:32:19 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-05-21 10:25:30 +00:00
|
|
|
if (!container->children && !GST_CLOCK_TIME_IS_VALID (element->duration)) {
|
|
|
|
if (!ges_timeline_element_set_duration (element,
|
|
|
|
ges_uri_clip_asset_get_duration (uri_clip_asset))) {
|
|
|
|
GST_ERROR_OBJECT (self, "Failed to set the duration using a new "
|
|
|
|
"uri asset when we have no children. This should not happen");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2012-09-10 00:21:21 +00:00
|
|
|
|
2013-01-20 15:44:57 +00:00
|
|
|
ges_uri_clip_set_is_image (uriclip,
|
2016-08-13 23:54:22 +00:00
|
|
|
ges_uri_clip_asset_is_image (uri_clip_asset));
|
2012-09-10 00:21:21 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
if (ges_clip_get_supported_formats (clip) == GES_TRACK_TYPE_UNKNOWN) {
|
|
|
|
ges_clip_set_supported_formats (clip,
|
2016-08-13 23:54:22 +00:00
|
|
|
ges_clip_asset_get_supported_formats (GES_CLIP_ASSET (uri_clip_asset)));
|
2012-09-10 00:21:21 +00:00
|
|
|
}
|
|
|
|
|
2020-05-21 10:25:30 +00:00
|
|
|
prev_asset = element->asset;
|
|
|
|
element->asset = asset;
|
|
|
|
|
|
|
|
/* FIXME: it would be much better if we could have a way to replace
|
|
|
|
* each source one-to-one with a new source in the same track, e.g.
|
|
|
|
* a user supplied
|
|
|
|
* GESSource * ges_uri_clip_swap_source (
|
|
|
|
* GESClip * clip, GESSource * replace, GList * new_sources,
|
|
|
|
* gpointer user_data)
|
|
|
|
*
|
|
|
|
* and they select a new source from new_sources to replace @replace, or
|
|
|
|
* %NULL to remove it without a replacement. The default would swap
|
|
|
|
* one video for another video, etc.
|
|
|
|
*
|
|
|
|
* Then we could use this information with
|
|
|
|
* ges_clip_can_update_duration_limit, using the new max-duration and
|
|
|
|
* replacing each source in the same track, to test that the operation
|
|
|
|
* can succeed (basically extending
|
|
|
|
* ges_clip_can_set_max_duration_of_all_core, but with the added
|
|
|
|
* information that sources without a replacement will not contribute
|
|
|
|
* to the duration-limit, and all of the siblings in the same track will
|
|
|
|
* also be removed from the track).
|
|
|
|
*
|
|
|
|
* Then we can perform the replacement, whilst avoiding track-selection
|
|
|
|
* (similar to GESClip's _transfer_child). */
|
2015-11-20 22:33:12 +00:00
|
|
|
|
2020-04-06 11:28:13 +00:00
|
|
|
source_by_track = g_hash_table_new_full (NULL, NULL,
|
|
|
|
gst_object_unref, gst_object_unref);
|
2020-09-04 03:32:23 +00:00
|
|
|
auto_transitions_on_sources = g_hash_table_new_full (NULL, NULL,
|
|
|
|
gst_object_unref, (GDestroyNotify) g_list_free);
|
|
|
|
|
|
|
|
if (timeline)
|
|
|
|
ges_timeline_freeze_auto_transitions (timeline, TRUE);
|
2016-06-18 20:16:00 +00:00
|
|
|
|
2020-09-04 03:32:23 +00:00
|
|
|
children = ges_container_get_children (container, FALSE);
|
2020-03-25 19:35:11 +00:00
|
|
|
for (tmp = children; tmp; tmp = tmp->next) {
|
2020-04-06 11:28:13 +00:00
|
|
|
GESTrackElement *child = tmp->data;
|
2020-09-04 03:32:23 +00:00
|
|
|
GESTrack *track;
|
|
|
|
|
2020-04-06 11:28:13 +00:00
|
|
|
/* remove our core children */
|
2020-09-04 03:32:23 +00:00
|
|
|
if (!ges_track_element_is_core (child))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
track = ges_track_element_get_track (child);
|
|
|
|
if (track)
|
|
|
|
g_hash_table_insert (source_by_track, gst_object_ref (track),
|
|
|
|
gst_object_ref (child));
|
|
|
|
|
|
|
|
transitions = get_auto_transitions_around_source (child);
|
|
|
|
if (transitions)
|
|
|
|
g_hash_table_insert (auto_transitions_on_sources, gst_object_ref (child),
|
|
|
|
transitions);
|
|
|
|
|
|
|
|
/* removing the track element from its clip whilst it is in a
|
|
|
|
* timeline will remove it from its track */
|
|
|
|
/* removing the core element will also empty its non-core siblings
|
|
|
|
* from the same track */
|
|
|
|
ges_container_remove (container, GES_TIMELINE_ELEMENT (child));
|
2020-03-25 19:35:11 +00:00
|
|
|
}
|
|
|
|
g_list_free_full (children, g_object_unref);
|
|
|
|
|
|
|
|
contains_core = FALSE;
|
2015-11-20 22:33:12 +00:00
|
|
|
|
2020-05-21 10:25:30 +00:00
|
|
|
/* keep alive */
|
|
|
|
gst_object_ref (self);
|
2020-03-25 19:35:11 +00:00
|
|
|
if (layer) {
|
2020-05-21 10:25:30 +00:00
|
|
|
|
|
|
|
res = ges_layer_remove_clip (layer, clip);
|
|
|
|
|
|
|
|
if (res) {
|
|
|
|
/* adding back to the layer will trigger the re-creation of the core
|
|
|
|
* children */
|
|
|
|
res = ges_layer_add_clip (layer, clip);
|
|
|
|
|
|
|
|
if (!res)
|
|
|
|
GST_ERROR_OBJECT (self, "Failed to add the uri clip %s back into "
|
|
|
|
"its layer. This is likely caused by track-selection for the "
|
|
|
|
"core sources and effects failing because the core sources "
|
|
|
|
"were not replaced in the same tracks", element->name);
|
|
|
|
|
|
|
|
/* NOTE: assume that core children in the same tracks correspond to
|
|
|
|
* the same source! */
|
|
|
|
for (tmp = container->children; tmp; tmp = tmp->next) {
|
|
|
|
GESTrackElement *child = tmp->data;
|
2020-09-04 03:32:23 +00:00
|
|
|
GESTrackElement *orig_source;
|
|
|
|
|
|
|
|
if (!ges_track_element_is_core (child))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
contains_core = TRUE;
|
|
|
|
orig_source = g_hash_table_lookup (source_by_track,
|
|
|
|
ges_track_element_get_track (child));
|
|
|
|
|
|
|
|
if (!orig_source)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ges_track_element_copy_properties (GES_TIMELINE_ELEMENT
|
|
|
|
(orig_source), GES_TIMELINE_ELEMENT (child));
|
|
|
|
ges_track_element_copy_bindings (orig_source, child,
|
|
|
|
GST_CLOCK_TIME_NONE);
|
|
|
|
|
|
|
|
transitions =
|
|
|
|
g_hash_table_lookup (auto_transitions_on_sources, orig_source);
|
|
|
|
for (; transitions; transitions = transitions->next) {
|
|
|
|
GESAutoTransition *transition = transitions->data;
|
|
|
|
|
|
|
|
if (transition->previous_source == orig_source)
|
|
|
|
ges_auto_transition_set_source (transition, child, GES_EDGE_START);
|
|
|
|
else if (transition->next_source == orig_source)
|
|
|
|
ges_auto_transition_set_source (transition, child, GES_EDGE_END);
|
2017-11-25 18:56:36 +00:00
|
|
|
}
|
2015-12-17 12:36:42 +00:00
|
|
|
}
|
2020-05-21 10:25:30 +00:00
|
|
|
} else {
|
|
|
|
GST_ERROR_OBJECT (self, "Failed to remove from the layer. This "
|
|
|
|
"should not happen");
|
2015-12-17 12:36:42 +00:00
|
|
|
}
|
2015-11-20 22:33:12 +00:00
|
|
|
gst_object_unref (layer);
|
|
|
|
}
|
2020-04-06 11:28:13 +00:00
|
|
|
g_hash_table_unref (source_by_track);
|
2020-09-04 03:32:23 +00:00
|
|
|
g_hash_table_unref (auto_transitions_on_sources);
|
|
|
|
|
|
|
|
if (timeline)
|
|
|
|
ges_timeline_freeze_auto_transitions (timeline, FALSE);
|
2015-11-20 22:33:12 +00:00
|
|
|
|
|
|
|
if (res) {
|
|
|
|
g_free (uriclip->priv->uri);
|
|
|
|
uriclip->priv->uri = g_strdup (ges_asset_get_id (asset));
|
2020-05-21 10:25:30 +00:00
|
|
|
|
|
|
|
if (!contains_core) {
|
|
|
|
if (!ges_timeline_element_set_max_duration (element, max_duration))
|
|
|
|
GST_ERROR_OBJECT (self, "Failed to set the max-duration on the uri "
|
|
|
|
"clip when it has no children. This should not happen");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
element->asset = prev_asset;
|
2015-11-20 22:33:12 +00:00
|
|
|
}
|
|
|
|
|
2020-05-21 10:25:30 +00:00
|
|
|
/* if re-adding failed, clip may be destroyed */
|
|
|
|
gst_object_unref (self);
|
2020-03-18 16:36:47 +00:00
|
|
|
|
2015-11-20 22:33:12 +00:00
|
|
|
return res;
|
2012-09-10 00:21:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ges_extractable_interface_init (GESExtractableInterface * iface)
|
|
|
|
{
|
2013-01-20 15:44:57 +00:00
|
|
|
iface->asset_type = GES_TYPE_URI_CLIP_ASSET;
|
2012-09-10 00:21:21 +00:00
|
|
|
iface->check_id = (GESExtractableCheckId) extractable_check_id;
|
|
|
|
iface->get_parameters_from_id = extractable_get_parameters_from_id;
|
|
|
|
iface->get_id = extractable_get_id;
|
2015-11-20 22:33:12 +00:00
|
|
|
iface->can_update_asset = TRUE;
|
|
|
|
iface->set_asset_full = extractable_set_asset;
|
2009-09-21 10:51:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-20 15:44:57 +00:00
|
|
|
ges_uri_clip_init (GESUriClip * self)
|
2009-09-21 10:51:16 +00:00
|
|
|
{
|
2018-09-06 01:55:02 +00:00
|
|
|
self->priv = ges_uri_clip_get_instance_private (self);
|
2011-01-08 14:25:22 +00:00
|
|
|
|
2010-05-19 10:24:44 +00:00
|
|
|
/* Setting the duration to -1 by default. */
|
2013-01-15 13:52:17 +00:00
|
|
|
GES_TIMELINE_ELEMENT (self)->duration = GST_CLOCK_TIME_NONE;
|
2009-09-21 10:51:16 +00:00
|
|
|
}
|
|
|
|
|
2011-01-08 14:25:22 +00:00
|
|
|
/**
|
2013-01-20 15:44:57 +00:00
|
|
|
* ges_uri_clip_set_mute:
|
|
|
|
* @self: the #GESUriClip on which to mute or unmute the audio track
|
2011-01-08 14:25:22 +00:00
|
|
|
* @mute: %TRUE to mute @self audio track, %FALSE to unmute it
|
|
|
|
*
|
2013-02-08 20:11:22 +00:00
|
|
|
* Sets whether the audio track of this clip is muted or not.
|
2011-01-08 14:25:22 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
void
|
2013-01-20 15:44:57 +00:00
|
|
|
ges_uri_clip_set_mute (GESUriClip * self, gboolean mute)
|
2009-09-30 14:44:12 +00:00
|
|
|
{
|
2013-03-01 01:27:50 +00:00
|
|
|
GList *tmp;
|
2009-09-30 14:44:12 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("self:%p, mute:%d", self, mute);
|
|
|
|
|
2011-01-08 14:25:22 +00:00
|
|
|
self->priv->mute = mute;
|
2009-09-30 14:44:12 +00:00
|
|
|
|
|
|
|
/* Go over tracked objects, and update 'active' status on all audio objects */
|
2013-03-01 01:27:50 +00:00
|
|
|
for (tmp = GES_CONTAINER_CHILDREN (self); tmp; tmp = g_list_next (tmp)) {
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *trackelement = (GESTrackElement *) tmp->data;
|
2020-04-06 11:28:13 +00:00
|
|
|
GESTrack *track = ges_track_element_get_track (trackelement);
|
2009-09-30 14:44:12 +00:00
|
|
|
|
2020-04-06 11:28:13 +00:00
|
|
|
if (track && track->type == GES_TRACK_TYPE_AUDIO)
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_set_active (trackelement, !mute);
|
2009-09-30 14:44:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
gboolean
|
2016-08-13 23:54:22 +00:00
|
|
|
uri_clip_set_max_duration (GESTimelineElement * element,
|
2013-01-15 13:52:17 +00:00
|
|
|
GstClockTime maxduration)
|
2012-01-16 12:37:22 +00:00
|
|
|
{
|
2020-04-28 17:01:04 +00:00
|
|
|
gboolean ret =
|
2013-01-15 13:52:17 +00:00
|
|
|
GES_TIMELINE_ELEMENT_CLASS (parent_class)->set_max_duration (element,
|
|
|
|
maxduration);
|
2020-04-28 17:01:04 +00:00
|
|
|
|
|
|
|
if (ret) {
|
|
|
|
GstClockTime limit = ges_clip_get_duration_limit (GES_CLIP (element));
|
|
|
|
if (GST_CLOCK_TIME_IS_VALID (limit) && (element->duration == 0))
|
|
|
|
_set_duration0 (element, limit);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2010-05-19 10:24:44 +00:00
|
|
|
}
|
|
|
|
|
2011-01-08 14:25:22 +00:00
|
|
|
/**
|
2013-01-20 15:44:57 +00:00
|
|
|
* ges_uri_clip_set_is_image:
|
|
|
|
* @self: the #GESUriClip
|
2011-06-25 17:42:29 +00:00
|
|
|
* @is_image: %TRUE if @self is a still image, %FALSE otherwise
|
2011-01-08 14:25:22 +00:00
|
|
|
*
|
2013-02-08 20:11:22 +00:00
|
|
|
* Sets whether the clip is a still image or not.
|
2011-01-08 14:25:22 +00:00
|
|
|
*/
|
|
|
|
void
|
2013-01-20 15:44:57 +00:00
|
|
|
ges_uri_clip_set_is_image (GESUriClip * self, gboolean is_image)
|
2011-01-08 14:25:22 +00:00
|
|
|
{
|
|
|
|
self->priv->is_image = is_image;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-01-20 15:44:57 +00:00
|
|
|
* ges_uri_clip_is_muted:
|
|
|
|
* @self: the #GESUriClip
|
2011-01-08 14:25:22 +00:00
|
|
|
*
|
2011-01-10 13:28:35 +00:00
|
|
|
* Lets you know if the audio track of @self is muted or not.
|
2011-01-08 14:25:22 +00:00
|
|
|
*
|
2011-06-25 17:42:29 +00:00
|
|
|
* Returns: %TRUE if the audio track of @self is muted, %FALSE otherwise.
|
2011-01-08 14:25:22 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2013-01-20 15:44:57 +00:00
|
|
|
ges_uri_clip_is_muted (GESUriClip * self)
|
2011-01-08 14:25:22 +00:00
|
|
|
{
|
|
|
|
return self->priv->mute;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-01-20 15:44:57 +00:00
|
|
|
* ges_uri_clip_is_image:
|
|
|
|
* @self: the #GESUriClip
|
2011-01-08 14:25:22 +00:00
|
|
|
*
|
2011-01-10 13:28:35 +00:00
|
|
|
* Lets you know if @self is an image or not.
|
2011-01-08 14:25:22 +00:00
|
|
|
*
|
2011-06-25 17:42:29 +00:00
|
|
|
* Returns: %TRUE if @self is a still image %FALSE otherwise.
|
2011-01-08 14:25:22 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2013-01-20 15:44:57 +00:00
|
|
|
ges_uri_clip_is_image (GESUriClip * self)
|
2011-01-08 14:25:22 +00:00
|
|
|
{
|
|
|
|
return self->priv->is_image;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-01-20 15:44:57 +00:00
|
|
|
* ges_uri_clip_get_uri:
|
|
|
|
* @self: the #GESUriClip
|
2011-01-08 14:25:22 +00:00
|
|
|
*
|
2011-06-25 17:42:29 +00:00
|
|
|
* Get the location of the resource.
|
2011-01-08 14:25:22 +00:00
|
|
|
*
|
2011-06-25 17:42:29 +00:00
|
|
|
* Returns: The location of the resource.
|
2011-01-08 14:25:22 +00:00
|
|
|
*/
|
|
|
|
const gchar *
|
2013-01-20 15:44:57 +00:00
|
|
|
ges_uri_clip_get_uri (GESUriClip * self)
|
2011-01-08 14:25:22 +00:00
|
|
|
{
|
|
|
|
return self->priv->uri;
|
|
|
|
}
|
|
|
|
|
2012-12-21 17:28:16 +00:00
|
|
|
static GList *
|
2013-02-15 02:34:48 +00:00
|
|
|
ges_uri_clip_create_track_elements (GESClip * clip, GESTrackType type)
|
2012-12-21 17:28:16 +00:00
|
|
|
{
|
|
|
|
GList *res = NULL;
|
|
|
|
const GList *tmp, *stream_assets;
|
2020-03-10 11:38:58 +00:00
|
|
|
GESAsset *asset = GES_TIMELINE_ELEMENT (clip)->asset;
|
|
|
|
GESUriClipAsset *uri_asset;
|
|
|
|
GstClockTime max_duration;
|
2012-12-21 17:28:16 +00:00
|
|
|
|
2020-03-10 11:38:58 +00:00
|
|
|
g_return_val_if_fail (asset, NULL);
|
2012-12-21 17:28:16 +00:00
|
|
|
|
2020-03-10 11:38:58 +00:00
|
|
|
uri_asset = GES_URI_CLIP_ASSET (asset);
|
|
|
|
|
|
|
|
max_duration = ges_uri_clip_asset_get_max_duration (uri_asset);
|
|
|
|
stream_assets = ges_uri_clip_asset_get_stream_assets (uri_asset);
|
2012-12-21 17:28:16 +00:00
|
|
|
|
2020-03-10 11:38:58 +00:00
|
|
|
for (tmp = stream_assets; tmp; tmp = tmp->next) {
|
|
|
|
GESTrackElementAsset *element_asset = GES_TRACK_ELEMENT_ASSET (tmp->data);
|
|
|
|
|
|
|
|
if (ges_track_element_asset_get_track_type (element_asset) == type) {
|
|
|
|
GESTrackElement *element =
|
|
|
|
GES_TRACK_ELEMENT (ges_asset_extract (GES_ASSET (element_asset),
|
|
|
|
NULL));
|
|
|
|
ges_timeline_element_set_max_duration (GES_TIMELINE_ELEMENT (element),
|
|
|
|
max_duration);
|
2022-01-22 01:24:23 +00:00
|
|
|
res = g_list_append (res, element);
|
2020-03-10 11:38:58 +00:00
|
|
|
}
|
2012-12-21 17:28:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2009-09-21 10:51:16 +00:00
|
|
|
/**
|
2013-01-20 15:44:57 +00:00
|
|
|
* ges_uri_clip_new:
|
2009-09-21 10:51:16 +00:00
|
|
|
* @uri: the URI the source should control
|
|
|
|
*
|
2013-01-20 15:44:57 +00:00
|
|
|
* Creates a new #GESUriClip for the provided @uri.
|
2009-09-21 10:51:16 +00:00
|
|
|
*
|
2020-06-15 16:23:26 +00:00
|
|
|
* > **WARNING**: This function might 'discover` @uri **synchrounously**, it is
|
|
|
|
* > an IO and processing intensive task that you probably don't want to run in
|
|
|
|
* > an application mainloop. Have a look at #ges_asset_request_async to see how
|
|
|
|
* > to make that operation happen **asynchronously**.
|
|
|
|
*
|
2016-05-14 23:04:17 +00:00
|
|
|
* Returns: (transfer floating) (nullable): The newly created #GESUriClip, or
|
|
|
|
* %NULL if there was an error.
|
2009-09-21 10:51:16 +00:00
|
|
|
*/
|
2013-01-20 15:44:57 +00:00
|
|
|
GESUriClip *
|
2016-05-16 10:06:37 +00:00
|
|
|
ges_uri_clip_new (const gchar * uri)
|
2009-09-21 10:51:16 +00:00
|
|
|
{
|
2021-05-18 15:42:22 +00:00
|
|
|
GError *err = NULL;
|
2013-01-20 15:44:57 +00:00
|
|
|
GESUriClip *res = NULL;
|
2021-05-18 15:42:22 +00:00
|
|
|
GESAsset *asset = GES_ASSET (ges_uri_clip_asset_request_sync (uri, &err));
|
2011-06-25 18:12:46 +00:00
|
|
|
|
2015-10-30 09:52:12 +00:00
|
|
|
if (asset) {
|
2021-05-18 15:42:22 +00:00
|
|
|
res = GES_URI_CLIP (ges_asset_extract (asset, &err));
|
|
|
|
if (!res && err)
|
|
|
|
GST_ERROR ("Could not analyze %s: %s", uri, err->message);
|
|
|
|
|
2015-10-30 09:52:12 +00:00
|
|
|
gst_object_unref (asset);
|
|
|
|
} else
|
|
|
|
GST_ERROR ("Could not create asset for uri: %s", uri);
|
2011-06-25 18:12:46 +00:00
|
|
|
|
|
|
|
return res;
|
2009-09-21 10:51:16 +00:00
|
|
|
}
|
2012-01-04 17:24:05 +00:00
|
|
|
|
|
|
|
void
|
2013-01-20 15:44:57 +00:00
|
|
|
ges_uri_clip_set_uri (GESUriClip * self, gchar * uri)
|
2012-01-04 17:24:05 +00:00
|
|
|
{
|
2013-03-01 01:27:50 +00:00
|
|
|
if (GES_CONTAINER_CHILDREN (self)) {
|
2012-01-04 17:24:05 +00:00
|
|
|
/* FIXME handle this case properly */
|
2013-03-01 01:27:50 +00:00
|
|
|
GST_WARNING_OBJECT (self, "Can not change uri when already"
|
2013-01-26 15:31:33 +00:00
|
|
|
"containing TrackElements");
|
2012-01-04 17:24:05 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
self->priv->uri = uri;
|
|
|
|
}
|