2011-02-10 15:15:50 +00:00
|
|
|
/* GStreamer Editing Services
|
|
|
|
* Copyright (C) 2011 Thibault Saunier <thibault.saunier@collabora.co.uk>
|
|
|
|
*
|
|
|
|
* 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.
|
2011-02-10 15:15:50 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2014-04-07 19:02:48 +00:00
|
|
|
* SECTION: geseffectclip
|
2017-03-08 21:13:48 +00:00
|
|
|
* @title: GESEffectClip
|
2011-02-10 15:15:50 +00:00
|
|
|
* @short_description: An effect created by parse-launch style bin descriptions
|
2014-02-26 03:17:36 +00:00
|
|
|
* in a GESLayer
|
2011-02-10 15:15:50 +00:00
|
|
|
*
|
|
|
|
* The effect will be applied on the sources that have lower priorities
|
|
|
|
* (higher number) between the inpoint and the end of it.
|
2019-08-17 15:59:02 +00:00
|
|
|
*
|
|
|
|
* The asset ID of an effect clip is in the form:
|
|
|
|
*
|
|
|
|
* ```
|
|
|
|
* "audio ! bin ! description || video ! bin ! description"
|
|
|
|
* ```
|
2011-02-10 15:15:50 +00:00
|
|
|
*/
|
2018-09-24 14:41:24 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2011-02-10 15:15:50 +00:00
|
|
|
|
|
|
|
#include <ges/ges.h>
|
|
|
|
#include "ges-internal.h"
|
|
|
|
#include "ges-types.h"
|
|
|
|
|
2013-01-25 18:51:02 +00:00
|
|
|
struct _GESEffectClipPrivate
|
2011-02-10 15:15:50 +00:00
|
|
|
{
|
|
|
|
gchar *video_bin_description;
|
|
|
|
gchar *audio_bin_description;
|
|
|
|
};
|
|
|
|
|
2019-08-17 15:59:02 +00:00
|
|
|
static void ges_extractable_interface_init (GESExtractableInterface * iface);
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GESEffectClip, ges_effect_clip,
|
|
|
|
GES_TYPE_BASE_EFFECT_CLIP, G_ADD_PRIVATE (GESEffectClip)
|
|
|
|
G_IMPLEMENT_INTERFACE (GES_TYPE_EXTRACTABLE,
|
|
|
|
ges_extractable_interface_init));
|
2018-09-06 01:55:02 +00:00
|
|
|
|
2011-02-10 15:15:50 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_VIDEO_BIN_DESCRIPTION,
|
|
|
|
PROP_AUDIO_BIN_DESCRIPTION,
|
|
|
|
};
|
|
|
|
|
2013-01-25 18:51:02 +00:00
|
|
|
static void ges_effect_clip_finalize (GObject * object);
|
2013-02-10 00:49:16 +00:00
|
|
|
static GESTrackElement *_create_track_element (GESClip * self,
|
2012-12-20 23:23:54 +00:00
|
|
|
GESTrackType type);
|
2011-02-10 15:15:50 +00:00
|
|
|
|
2020-02-07 12:39:39 +00:00
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS; /* Start ignoring GParameter deprecation */
|
2019-08-17 15:59:02 +00:00
|
|
|
static GParameter *
|
|
|
|
extractable_get_parameters_from_id (const gchar * id, guint * n_params)
|
|
|
|
{
|
|
|
|
gchar *bin_desc;
|
|
|
|
GESTrackType ttype;
|
|
|
|
GParameter *params = g_new0 (GParameter, 2);
|
|
|
|
gchar **effects_desc = g_strsplit (id, "||", -1);
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
*n_params = 0;
|
|
|
|
|
|
|
|
if (g_strv_length (effects_desc) > 2)
|
|
|
|
GST_ERROR ("EffectClip id %s contains too many effect descriptions", id);
|
|
|
|
|
|
|
|
for (i = 0; effects_desc[i] && i < 2; i++) {
|
|
|
|
bin_desc =
|
2020-06-09 04:03:57 +00:00
|
|
|
ges_effect_asset_id_get_type_and_bindesc (effects_desc[i], &ttype,
|
2019-08-17 15:59:02 +00:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (ttype == GES_TRACK_TYPE_AUDIO) {
|
|
|
|
*n_params = *n_params + 1;
|
|
|
|
params[*n_params - 1].name = "audio-bin-description";
|
|
|
|
} else if (ttype == GES_TRACK_TYPE_VIDEO) {
|
|
|
|
*n_params = *n_params + 1;
|
|
|
|
params[i].name = "video-bin-description";
|
|
|
|
} else {
|
|
|
|
g_free (bin_desc);
|
|
|
|
GST_ERROR ("Could not find effect type for %s", effects_desc[i]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_value_init (¶ms[*n_params - 1].value, G_TYPE_STRING);
|
|
|
|
g_value_set_string (¶ms[*n_params - 1].value, bin_desc);
|
|
|
|
g_free (bin_desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_strfreev (effects_desc);
|
|
|
|
return params;
|
|
|
|
}
|
|
|
|
|
2020-02-07 12:39:39 +00:00
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS; /* End ignoring GParameter deprecation */
|
|
|
|
|
2019-08-17 15:59:02 +00:00
|
|
|
static gchar *
|
|
|
|
extractable_check_id (GType type, const gchar * id, GError ** error)
|
|
|
|
{
|
|
|
|
return g_strdup (id);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
|
|
|
extractable_get_id (GESExtractable * self)
|
|
|
|
{
|
|
|
|
GString *id = g_string_new (NULL);
|
|
|
|
GESEffectClipPrivate *priv = GES_EFFECT_CLIP (self)->priv;
|
|
|
|
|
|
|
|
if (priv->audio_bin_description)
|
|
|
|
g_string_append_printf (id, "audio %s ||", priv->audio_bin_description);
|
|
|
|
if (priv->video_bin_description)
|
|
|
|
g_string_append_printf (id, "video %s", priv->video_bin_description);
|
|
|
|
|
|
|
|
return g_string_free (id, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ges_extractable_interface_init (GESExtractableInterface * iface)
|
|
|
|
{
|
|
|
|
iface->asset_type = GES_TYPE_ASSET;
|
|
|
|
iface->check_id = extractable_check_id;
|
|
|
|
iface->get_parameters_from_id = extractable_get_parameters_from_id;
|
|
|
|
iface->get_id = extractable_get_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-05-06 20:18:58 +00:00
|
|
|
static void
|
2013-01-25 18:51:02 +00:00
|
|
|
ges_effect_clip_finalize (GObject * object)
|
2011-05-06 20:18:58 +00:00
|
|
|
{
|
2013-01-25 18:51:02 +00:00
|
|
|
GESEffectClipPrivate *priv = GES_EFFECT_CLIP (object)->priv;
|
2011-05-06 20:18:58 +00:00
|
|
|
|
|
|
|
g_free (priv->audio_bin_description);
|
|
|
|
g_free (priv->video_bin_description);
|
|
|
|
|
2013-01-25 18:51:02 +00:00
|
|
|
G_OBJECT_CLASS (ges_effect_clip_parent_class)->finalize (object);
|
2011-05-06 20:18:58 +00:00
|
|
|
}
|
|
|
|
|
2011-02-10 15:15:50 +00:00
|
|
|
static void
|
2013-01-25 18:51:02 +00:00
|
|
|
ges_effect_clip_get_property (GObject * object,
|
2011-02-10 15:15:50 +00:00
|
|
|
guint property_id, GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2013-01-25 18:51:02 +00:00
|
|
|
GESEffectClipPrivate *priv = GES_EFFECT_CLIP (object)->priv;
|
2011-02-10 15:15:50 +00:00
|
|
|
|
|
|
|
switch (property_id) {
|
|
|
|
case PROP_VIDEO_BIN_DESCRIPTION:
|
|
|
|
g_value_set_string (value, priv->video_bin_description);
|
|
|
|
break;
|
|
|
|
case PROP_AUDIO_BIN_DESCRIPTION:
|
|
|
|
g_value_set_string (value, priv->audio_bin_description);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-25 18:51:02 +00:00
|
|
|
ges_effect_clip_set_property (GObject * object,
|
2011-02-10 15:15:50 +00:00
|
|
|
guint property_id, const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2013-01-25 18:51:02 +00:00
|
|
|
GESEffectClip *self = GES_EFFECT_CLIP (object);
|
2011-02-10 15:15:50 +00:00
|
|
|
|
|
|
|
switch (property_id) {
|
|
|
|
case PROP_VIDEO_BIN_DESCRIPTION:
|
|
|
|
self->priv->video_bin_description = g_value_dup_string (value);
|
|
|
|
break;
|
|
|
|
case PROP_AUDIO_BIN_DESCRIPTION:
|
|
|
|
self->priv->audio_bin_description = g_value_dup_string (value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-25 18:51:02 +00:00
|
|
|
ges_effect_clip_class_init (GESEffectClipClass * klass)
|
2011-02-10 15:15:50 +00:00
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClipClass *timobj_class = GES_CLIP_CLASS (klass);
|
2011-02-10 15:15:50 +00:00
|
|
|
|
2013-01-25 18:51:02 +00:00
|
|
|
object_class->get_property = ges_effect_clip_get_property;
|
|
|
|
object_class->set_property = ges_effect_clip_set_property;
|
|
|
|
object_class->finalize = ges_effect_clip_finalize;
|
2011-02-10 15:15:50 +00:00
|
|
|
|
|
|
|
/**
|
2013-01-25 18:51:02 +00:00
|
|
|
* GESEffectClip:video-bin-description:
|
2011-02-10 15:15:50 +00:00
|
|
|
*
|
|
|
|
* The description of the video track of the effect bin with a gst-launch-style
|
|
|
|
* pipeline description. This should be used for test purposes.
|
2011-05-06 17:38:26 +00:00
|
|
|
*
|
|
|
|
* Example: "videobalance saturation=1.5 hue=+0.5"
|
2011-02-10 15:15:50 +00:00
|
|
|
*/
|
|
|
|
g_object_class_install_property (object_class, PROP_VIDEO_BIN_DESCRIPTION,
|
|
|
|
g_param_spec_string ("video-bin-description",
|
|
|
|
"Video bin description",
|
|
|
|
"Description of the video track of the effect",
|
|
|
|
NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
|
|
|
/**
|
2013-01-25 18:51:02 +00:00
|
|
|
* GESEffectClip:audio-bin-description:
|
2011-02-10 15:15:50 +00:00
|
|
|
*
|
|
|
|
* The description of the audio track of the effect bin with a gst-launch-style
|
|
|
|
* pipeline description. This should be used for test purposes.
|
2011-05-06 17:38:26 +00:00
|
|
|
*
|
|
|
|
* Example: "audiopanorama panorama=1.0"
|
2011-02-10 15:15:50 +00:00
|
|
|
*/
|
|
|
|
g_object_class_install_property (object_class, PROP_AUDIO_BIN_DESCRIPTION,
|
|
|
|
g_param_spec_string ("audio-bin-description",
|
|
|
|
"bin description",
|
|
|
|
"Bin description of the audio track of the effect",
|
|
|
|
NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
2013-02-10 00:49:16 +00:00
|
|
|
timobj_class->create_track_element = _create_track_element;
|
2011-02-10 15:15:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-25 18:51:02 +00:00
|
|
|
ges_effect_clip_init (GESEffectClip * self)
|
2011-02-10 15:15:50 +00:00
|
|
|
{
|
2018-09-06 01:55:02 +00:00
|
|
|
self->priv = ges_effect_clip_get_instance_private (self);
|
2011-02-10 15:15:50 +00:00
|
|
|
}
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
static GESTrackElement *
|
2013-02-10 00:49:16 +00:00
|
|
|
_create_track_element (GESClip * self, GESTrackType type)
|
2011-02-10 15:15:50 +00:00
|
|
|
{
|
2012-12-20 23:23:54 +00:00
|
|
|
const gchar *bin_description = NULL;
|
2013-01-25 18:51:02 +00:00
|
|
|
GESEffectClip *effect = GES_EFFECT_CLIP (self);
|
2011-02-10 15:15:50 +00:00
|
|
|
|
2012-12-20 23:23:54 +00:00
|
|
|
if (type == GES_TRACK_TYPE_VIDEO) {
|
|
|
|
bin_description = effect->priv->video_bin_description;
|
|
|
|
} else if (type == GES_TRACK_TYPE_AUDIO) {
|
|
|
|
bin_description = effect->priv->audio_bin_description;
|
2011-02-10 15:15:50 +00:00
|
|
|
}
|
2012-12-20 23:23:54 +00:00
|
|
|
|
2020-03-25 01:23:16 +00:00
|
|
|
if (bin_description)
|
|
|
|
return GES_TRACK_ELEMENT (ges_effect_new (bin_description));
|
2011-02-10 15:15:50 +00:00
|
|
|
|
|
|
|
GST_WARNING ("Effect doesn't handle this track type");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-01-25 18:51:02 +00:00
|
|
|
* ges_effect_clip_new:
|
2021-09-25 13:34:49 +00:00
|
|
|
* @video_bin_description: (nullable): The gst-launch like bin description of the effect
|
|
|
|
* @audio_bin_description: (nullable): The gst-launch like bin description of the effect
|
2011-05-07 14:59:06 +00:00
|
|
|
*
|
2013-01-25 18:51:02 +00:00
|
|
|
* Creates a new #GESEffectClip from the description of the bin.
|
2011-05-07 14:59:06 +00:00
|
|
|
*
|
2016-05-14 23:04:17 +00:00
|
|
|
* Returns: (transfer floating) (nullable): a newly created #GESEffectClip, or
|
2011-05-07 14:59:06 +00:00
|
|
|
* %NULL if something went wrong.
|
|
|
|
*/
|
2013-01-25 18:51:02 +00:00
|
|
|
GESEffectClip *
|
|
|
|
ges_effect_clip_new (const gchar * video_bin_description,
|
2011-02-10 15:15:50 +00:00
|
|
|
const gchar * audio_bin_description)
|
|
|
|
{
|
2019-08-17 15:59:02 +00:00
|
|
|
GESAsset *asset;
|
|
|
|
GESEffectClip *res;
|
|
|
|
GString *id = g_string_new (NULL);
|
|
|
|
|
|
|
|
if (audio_bin_description)
|
|
|
|
g_string_append_printf (id, "audio %s ||", audio_bin_description);
|
|
|
|
if (video_bin_description)
|
|
|
|
g_string_append_printf (id, "video %s", video_bin_description);
|
|
|
|
|
|
|
|
asset = ges_asset_request (GES_TYPE_EFFECT_CLIP, id->str, NULL);
|
|
|
|
res = GES_EFFECT_CLIP (ges_asset_extract (asset, NULL));
|
|
|
|
g_string_free (id, TRUE);
|
|
|
|
gst_object_unref (asset);
|
|
|
|
|
|
|
|
return res;
|
2011-02-10 15:15:50 +00:00
|
|
|
}
|