2010-06-10 11:21:06 +00:00
|
|
|
/* GStreamer Editing Services
|
|
|
|
* Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
|
|
|
|
* 2009 Nokia Corporation
|
2020-04-22 17:39:21 +00:00
|
|
|
* Copyright (C) 2020 Igalia S.L
|
|
|
|
* Author: 2020 Thibault Saunier <tsaunier@igalia.com>
|
2010-06-10 11:21:06 +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.
|
2010-06-10 11:21:06 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2014-04-07 19:02:48 +00:00
|
|
|
* SECTION:gestestclip
|
2017-03-08 21:13:48 +00:00
|
|
|
* @title: GESTestClip
|
2014-02-26 03:17:36 +00:00
|
|
|
* @short_description: Render video and audio test patterns in a GESLayer
|
2012-09-19 20:36:38 +00:00
|
|
|
*
|
|
|
|
* Useful for testing purposes.
|
|
|
|
*
|
2020-02-28 14:47:25 +00:00
|
|
|
* ## Asset
|
|
|
|
*
|
|
|
|
* The default asset ID is GESTestClip, but the framerate and video
|
2020-04-22 17:39:21 +00:00
|
|
|
* size can be overridden using an ID of the form:
|
2020-02-28 14:47:25 +00:00
|
|
|
*
|
|
|
|
* ```
|
|
|
|
* framerate=60/1, width=1920, height=1080, max-duration=5.0
|
|
|
|
* ```
|
|
|
|
* Note: `max-duration` can be provided in seconds as float, or as GstClockTime
|
|
|
|
* as guint64 or gint.
|
2010-06-10 11:21:06 +00:00
|
|
|
*/
|
2018-09-24 14:41:24 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2010-06-10 11:21:06 +00:00
|
|
|
|
|
|
|
#include "ges-internal.h"
|
2013-01-17 03:58:28 +00:00
|
|
|
#include "ges-test-clip.h"
|
2013-01-17 03:35:39 +00:00
|
|
|
#include "ges-source-clip.h"
|
2013-01-26 15:31:33 +00:00
|
|
|
#include "ges-track-element.h"
|
2013-01-26 16:03:39 +00:00
|
|
|
#include "ges-video-test-source.h"
|
2013-01-26 16:02:02 +00:00
|
|
|
#include "ges-audio-test-source.h"
|
2010-06-11 14:51:44 +00:00
|
|
|
#include <string.h>
|
2010-06-10 11:21:06 +00:00
|
|
|
|
2013-04-27 06:44:40 +00:00
|
|
|
#define DEFAULT_VOLUME 1.0
|
|
|
|
#define DEFAULT_VPATTERN GES_VIDEO_TEST_PATTERN_SMPTE
|
|
|
|
|
2020-02-28 14:47:25 +00:00
|
|
|
G_DECLARE_FINAL_TYPE (GESTestClipAsset, ges_test_clip_asset, GES,
|
2020-03-17 14:53:47 +00:00
|
|
|
TEST_CLIP_ASSET, GESSourceClipAsset);
|
2020-02-28 14:47:25 +00:00
|
|
|
|
|
|
|
struct _GESTestClipAsset
|
|
|
|
{
|
2020-03-17 14:53:47 +00:00
|
|
|
GESSourceClipAsset parent;
|
2020-02-28 14:47:25 +00:00
|
|
|
|
|
|
|
gint natural_framerate_n;
|
|
|
|
gint natural_framerate_d;
|
|
|
|
gint natural_width;
|
|
|
|
gint natural_height;
|
|
|
|
GstClockTime max_duration;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define GES_TYPE_TEST_CLIP_ASSET (ges_test_clip_asset_get_type())
|
2020-03-17 14:53:47 +00:00
|
|
|
G_DEFINE_TYPE (GESTestClipAsset, ges_test_clip_asset,
|
|
|
|
GES_TYPE_SOURCE_CLIP_ASSET);
|
2020-02-28 14:47:25 +00:00
|
|
|
|
|
|
|
static gboolean
|
|
|
|
_get_natural_framerate (GESClipAsset * asset, gint * framerate_n,
|
|
|
|
gint * framerate_d)
|
|
|
|
{
|
|
|
|
GESTestClipAsset *self = GES_TEST_CLIP_ASSET (asset);
|
|
|
|
|
|
|
|
*framerate_n = self->natural_framerate_n;
|
|
|
|
*framerate_d = self->natural_framerate_d;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstClockTime
|
|
|
|
ges_test_clip_asset_get_max_duration (GESAsset * asset)
|
|
|
|
{
|
|
|
|
GESTestClipAsset *self = GES_TEST_CLIP_ASSET (asset);
|
|
|
|
|
|
|
|
return GES_TEST_CLIP_ASSET (self)->max_duration;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
ges_test_clip_asset_get_natural_size (GESAsset * asset, gint * width,
|
|
|
|
gint * height)
|
|
|
|
{
|
|
|
|
GESTestClipAsset *self = GES_TEST_CLIP_ASSET (asset);
|
|
|
|
|
|
|
|
*width = self->natural_width;
|
|
|
|
*height = self->natural_height;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ges_test_clip_asset_constructed (GObject * gobject)
|
|
|
|
{
|
|
|
|
GESFrameNumber fmax_dur = GES_FRAME_NUMBER_NONE;
|
|
|
|
GESTestClipAsset *self = GES_TEST_CLIP_ASSET (gobject);
|
|
|
|
GstStructure *structure =
|
|
|
|
gst_structure_from_string (ges_asset_get_id (GES_ASSET (self)), NULL);
|
|
|
|
|
|
|
|
g_assert (structure);
|
|
|
|
|
|
|
|
gst_structure_get_int (structure, "width", &self->natural_width);
|
|
|
|
gst_structure_get_int (structure, "height", &self->natural_height);
|
|
|
|
gst_structure_get_fraction (structure, "framerate",
|
|
|
|
&self->natural_framerate_n, &self->natural_framerate_d);
|
|
|
|
ges_util_structure_get_clocktime (structure, "max-duration",
|
|
|
|
&self->max_duration, &fmax_dur);
|
|
|
|
if (GES_FRAME_NUMBER_IS_VALID (fmax_dur))
|
|
|
|
self->max_duration =
|
|
|
|
gst_util_uint64_scale (fmax_dur, self->natural_framerate_d * GST_SECOND,
|
|
|
|
self->natural_framerate_n);
|
|
|
|
gst_structure_free (structure);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (ges_test_clip_asset_parent_class)->constructed (gobject);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ges_test_clip_asset_class_init (GESTestClipAssetClass * klass)
|
|
|
|
{
|
|
|
|
GESClipAssetClass *clip_asset_class = GES_CLIP_ASSET_CLASS (klass);
|
|
|
|
|
|
|
|
clip_asset_class->get_natural_framerate = _get_natural_framerate;
|
|
|
|
G_OBJECT_CLASS (klass)->constructed = ges_test_clip_asset_constructed;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ges_test_clip_asset_init (GESTestClipAsset * self)
|
|
|
|
{
|
|
|
|
self->natural_width = DEFAULT_WIDTH;
|
|
|
|
self->natural_height = DEFAULT_HEIGHT;
|
|
|
|
self->natural_framerate_n = DEFAULT_FRAMERATE_N;
|
|
|
|
self->natural_framerate_d = DEFAULT_FRAMERATE_D;
|
|
|
|
self->max_duration = GST_CLOCK_TIME_NONE;
|
|
|
|
}
|
|
|
|
|
2013-01-17 03:58:28 +00:00
|
|
|
struct _GESTestClipPrivate
|
2010-12-04 18:54:13 +00:00
|
|
|
{
|
2011-01-07 18:36:31 +00:00
|
|
|
gboolean mute;
|
|
|
|
GESVideoTestPattern vpattern;
|
|
|
|
gdouble freq;
|
|
|
|
gdouble volume;
|
2010-12-04 18:54:13 +00:00
|
|
|
};
|
|
|
|
|
2010-06-10 11:21:06 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_MUTE,
|
2010-06-11 13:17:42 +00:00
|
|
|
PROP_VPATTERN,
|
2010-07-02 13:42:48 +00:00
|
|
|
PROP_FREQ,
|
|
|
|
PROP_VOLUME,
|
2010-06-10 11:21:06 +00:00
|
|
|
};
|
|
|
|
|
2020-02-28 14:47:25 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const gchar *name;
|
|
|
|
GType type;
|
|
|
|
} ValidField;
|
|
|
|
|
2020-04-22 17:39:21 +00:00
|
|
|
gchar *
|
|
|
|
ges_test_source_asset_check_id (GType type, const gchar * id, GError ** error)
|
2020-02-28 14:47:25 +00:00
|
|
|
{
|
|
|
|
if (id && g_strcmp0 (id, g_type_name (type))) {
|
|
|
|
gchar *res = NULL;
|
2020-04-22 17:39:21 +00:00
|
|
|
GstStructure *structure = gst_structure_from_string (id, NULL);
|
2020-02-28 14:47:25 +00:00
|
|
|
|
2020-04-22 17:39:21 +00:00
|
|
|
if (!structure) {
|
|
|
|
gchar *struct_str = g_strdup_printf ("%s,%s", g_type_name (type), id);
|
|
|
|
|
|
|
|
structure = gst_structure_from_string (struct_str, NULL);
|
|
|
|
g_free (struct_str);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_INFO ("Test source ID: %" GST_PTR_FORMAT, structure);
|
2020-02-28 14:47:25 +00:00
|
|
|
if (!structure) {
|
|
|
|
g_set_error (error, GES_ERROR, GES_ERROR_ASSET_WRONG_ID,
|
|
|
|
"GESTestClipAsset ID should be in the form: `framerate=30/1, "
|
|
|
|
"width=1920, height=1080, got %s", id);
|
|
|
|
} else {
|
|
|
|
static ValidField valid_fields[] = {
|
|
|
|
{"width", G_TYPE_INT},
|
|
|
|
{"height", G_TYPE_INT},
|
|
|
|
{"framerate", G_TYPE_NONE}, /* GST_TYPE_FRACTION is not constant */
|
|
|
|
{"max-duration", GST_TYPE_CLOCK_TIME},
|
2020-04-22 17:39:21 +00:00
|
|
|
{"disable-timecodestamper", G_TYPE_BOOLEAN},
|
2020-02-28 14:47:25 +00:00
|
|
|
};
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (valid_fields); i++) {
|
|
|
|
if (gst_structure_has_field (structure, valid_fields[i].name)) {
|
|
|
|
GstClockTime ts;
|
|
|
|
GESFrameNumber fn;
|
|
|
|
ValidField field = valid_fields[i];
|
|
|
|
GType type =
|
|
|
|
field.type == G_TYPE_NONE ? GST_TYPE_FRACTION : field.type;
|
|
|
|
|
|
|
|
if (!(gst_structure_has_field_typed (structure, field.name,
|
|
|
|
type) ||
|
|
|
|
(type == GST_TYPE_CLOCK_TIME &&
|
|
|
|
ges_util_structure_get_clocktime (structure, field.name,
|
|
|
|
&ts, &fn)))) {
|
|
|
|
|
|
|
|
g_set_error (error, GES_ERROR, GES_ERROR_ASSET_WRONG_ID,
|
|
|
|
"Field %s has wrong type, %s, expected %s", field.name,
|
|
|
|
g_type_name (gst_structure_get_field_type (structure,
|
|
|
|
field.name)), g_type_name (type));
|
|
|
|
|
|
|
|
gst_structure_free (structure);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
res = gst_structure_to_string (structure);
|
|
|
|
gst_structure_free (structure);
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
return g_strdup (g_type_name (type));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ges_extractable_interface_init (GESExtractableInterface * iface)
|
|
|
|
{
|
|
|
|
iface->asset_type = GES_TYPE_TEST_CLIP_ASSET;
|
2020-04-22 17:39:21 +00:00
|
|
|
iface->check_id = ges_test_source_asset_check_id;
|
2020-02-28 14:47:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GESTestClip, ges_test_clip, GES_TYPE_SOURCE_CLIP,
|
|
|
|
G_ADD_PRIVATE (GESTestClip)
|
|
|
|
G_IMPLEMENT_INTERFACE (GES_TYPE_EXTRACTABLE,
|
|
|
|
ges_extractable_interface_init));
|
|
|
|
|
2018-09-06 01:55:02 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
static GESTrackElement
|
2013-02-15 02:34:48 +00:00
|
|
|
* ges_test_clip_create_track_element (GESClip * clip, GESTrackType type);
|
2010-06-10 11:21:06 +00:00
|
|
|
|
|
|
|
static void
|
2013-01-17 03:58:28 +00:00
|
|
|
ges_test_clip_get_property (GObject * object, guint property_id,
|
2010-06-10 11:21:06 +00:00
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2013-01-17 03:58:28 +00:00
|
|
|
GESTestClipPrivate *priv = GES_TEST_CLIP (object)->priv;
|
2010-06-10 11:21:06 +00:00
|
|
|
|
|
|
|
switch (property_id) {
|
|
|
|
case PROP_MUTE:
|
2011-01-07 18:36:31 +00:00
|
|
|
g_value_set_boolean (value, priv->mute);
|
2010-06-10 11:21:06 +00:00
|
|
|
break;
|
2010-06-11 13:17:42 +00:00
|
|
|
case PROP_VPATTERN:
|
2011-01-07 18:36:31 +00:00
|
|
|
g_value_set_enum (value, priv->vpattern);
|
2010-06-11 13:17:42 +00:00
|
|
|
break;
|
2010-07-02 13:42:48 +00:00
|
|
|
case PROP_FREQ:
|
2011-01-07 18:36:31 +00:00
|
|
|
g_value_set_double (value, priv->freq);
|
2010-07-02 13:42:48 +00:00
|
|
|
break;
|
|
|
|
case PROP_VOLUME:
|
2011-01-07 18:36:31 +00:00
|
|
|
g_value_set_double (value, priv->volume);
|
2010-07-02 13:42:48 +00:00
|
|
|
break;
|
2010-06-10 11:21:06 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-17 03:58:28 +00:00
|
|
|
ges_test_clip_set_property (GObject * object, guint property_id,
|
2010-06-10 11:21:06 +00:00
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2013-01-17 03:58:28 +00:00
|
|
|
GESTestClip *uriclip = GES_TEST_CLIP (object);
|
2010-06-10 11:21:06 +00:00
|
|
|
|
|
|
|
switch (property_id) {
|
|
|
|
case PROP_MUTE:
|
2013-01-17 03:58:28 +00:00
|
|
|
ges_test_clip_set_mute (uriclip, g_value_get_boolean (value));
|
2010-06-10 11:21:06 +00:00
|
|
|
break;
|
2010-06-11 13:17:42 +00:00
|
|
|
case PROP_VPATTERN:
|
2013-01-17 03:58:28 +00:00
|
|
|
ges_test_clip_set_vpattern (uriclip, g_value_get_enum (value));
|
2010-06-11 13:17:42 +00:00
|
|
|
break;
|
2010-07-02 13:42:48 +00:00
|
|
|
case PROP_FREQ:
|
2013-01-17 03:58:28 +00:00
|
|
|
ges_test_clip_set_frequency (uriclip, g_value_get_double (value));
|
2010-07-02 13:42:48 +00:00
|
|
|
break;
|
|
|
|
case PROP_VOLUME:
|
2013-01-17 03:58:28 +00:00
|
|
|
ges_test_clip_set_volume (uriclip, g_value_get_double (value));
|
2010-07-02 13:42:48 +00:00
|
|
|
break;
|
2010-06-10 11:21:06 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-17 03:58:28 +00:00
|
|
|
ges_test_clip_class_init (GESTestClipClass * klass)
|
2010-06-10 11:21:06 +00:00
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClipClass *timobj_class = GES_CLIP_CLASS (klass);
|
2010-06-10 11:21:06 +00:00
|
|
|
|
2013-01-17 03:58:28 +00:00
|
|
|
object_class->get_property = ges_test_clip_get_property;
|
|
|
|
object_class->set_property = ges_test_clip_set_property;
|
2010-06-10 11:21:06 +00:00
|
|
|
|
2010-06-11 13:17:42 +00:00
|
|
|
/**
|
2013-01-17 03:58:28 +00:00
|
|
|
* GESTestClip:vpattern:
|
2010-06-11 13:17:42 +00:00
|
|
|
*
|
2013-02-08 19:39:18 +00:00
|
|
|
* Video pattern to display in video track elements.
|
2010-06-11 13:17:42 +00:00
|
|
|
*/
|
|
|
|
g_object_class_install_property (object_class, PROP_VPATTERN,
|
|
|
|
g_param_spec_enum ("vpattern", "VPattern",
|
|
|
|
"Which video pattern to display. See videotestsrc element",
|
2010-07-02 10:48:11 +00:00
|
|
|
GES_VIDEO_TEST_PATTERN_TYPE,
|
2013-04-27 06:44:40 +00:00
|
|
|
DEFAULT_VPATTERN, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
2010-06-11 13:17:42 +00:00
|
|
|
|
2010-07-02 13:42:48 +00:00
|
|
|
/**
|
2013-01-17 03:58:28 +00:00
|
|
|
* GESTestClip:freq:
|
2010-07-02 13:42:48 +00:00
|
|
|
*
|
2013-02-08 19:39:18 +00:00
|
|
|
* The frequency to generate for audio track elements.
|
2010-07-02 13:42:48 +00:00
|
|
|
*/
|
|
|
|
g_object_class_install_property (object_class, PROP_FREQ,
|
|
|
|
g_param_spec_double ("freq", "Audio Frequency",
|
|
|
|
"The frequency to generate. See audiotestsrc element",
|
|
|
|
0, 20000, 440, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
|
|
|
|
|
|
|
/**
|
2013-01-17 03:58:28 +00:00
|
|
|
* GESTestClip:volume:
|
2010-07-02 13:42:48 +00:00
|
|
|
*
|
2013-02-08 19:39:18 +00:00
|
|
|
* The volume for the audio track elements.
|
2010-07-02 13:42:48 +00:00
|
|
|
*/
|
|
|
|
g_object_class_install_property (object_class, PROP_VOLUME,
|
|
|
|
g_param_spec_double ("volume", "Audio Volume",
|
|
|
|
"The volume of the test audio signal.",
|
2013-04-27 06:44:40 +00:00
|
|
|
0, 1, DEFAULT_VOLUME, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
2010-07-02 13:42:48 +00:00
|
|
|
|
|
|
|
|
2010-06-10 11:21:06 +00:00
|
|
|
/**
|
2013-01-17 03:58:28 +00:00
|
|
|
* GESTestClip:mute:
|
2010-06-10 11:21:06 +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));
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
timobj_class->create_track_element = ges_test_clip_create_track_element;
|
2010-06-10 11:21:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-17 03:58:28 +00:00
|
|
|
ges_test_clip_init (GESTestClip * self)
|
2010-06-10 11:21:06 +00:00
|
|
|
{
|
2020-02-28 14:47:25 +00:00
|
|
|
SUPRESS_UNUSED_WARNING (GES_IS_TEST_CLIP_ASSET);
|
2018-09-06 01:55:02 +00:00
|
|
|
self->priv = ges_test_clip_get_instance_private (self);
|
2010-12-04 18:54:13 +00:00
|
|
|
|
2011-01-07 18:36:31 +00:00
|
|
|
self->priv->freq = 0;
|
|
|
|
self->priv->volume = 0;
|
2013-01-15 13:52:17 +00:00
|
|
|
GES_TIMELINE_ELEMENT (self)->duration = 0;
|
2010-06-10 11:21:06 +00:00
|
|
|
}
|
|
|
|
|
2011-01-07 18:36:31 +00:00
|
|
|
/**
|
2013-01-17 03:58:28 +00:00
|
|
|
* ges_test_clip_set_mute:
|
|
|
|
* @self: the #GESTestClip on which to mute or unmute the audio track
|
2011-01-07 18:36:31 +00:00
|
|
|
* @mute: %TRUE to mute the 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-07 18:36:31 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
void
|
2013-01-17 03:58:28 +00:00
|
|
|
ges_test_clip_set_mute (GESTestClip * self, gboolean mute)
|
2010-06-10 11:21:06 +00:00
|
|
|
{
|
2013-03-01 01:27:50 +00:00
|
|
|
GList *tmp;
|
2010-06-10 11:21:06 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("self:%p, mute:%d", self, mute);
|
|
|
|
|
2011-01-07 18:36:31 +00:00
|
|
|
self->priv->mute = mute;
|
2010-06-10 11:21:06 +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 = tmp->next) {
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *trackelement = (GESTrackElement *) tmp->data;
|
2010-06-10 11:21:06 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
if (ges_track_element_get_track (trackelement)->type ==
|
|
|
|
GES_TRACK_TYPE_AUDIO)
|
|
|
|
ges_track_element_set_active (trackelement, !mute);
|
2010-06-10 11:21:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-07 18:36:31 +00:00
|
|
|
/**
|
2013-01-17 03:58:28 +00:00
|
|
|
* ges_test_clip_set_vpattern:
|
|
|
|
* @self: the #GESTestClip to set the pattern on
|
2011-01-07 18:36:31 +00:00
|
|
|
* @vpattern: the #GESVideoTestPattern to use on @self
|
|
|
|
*
|
|
|
|
* Sets which video pattern to display on @self.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void
|
2013-01-17 03:58:28 +00:00
|
|
|
ges_test_clip_set_vpattern (GESTestClip * self, GESVideoTestPattern vpattern)
|
2010-06-11 13:17:42 +00:00
|
|
|
{
|
2013-03-01 01:27:50 +00:00
|
|
|
GList *tmp;
|
2010-06-11 13:17:42 +00:00
|
|
|
|
2011-01-07 18:36:31 +00:00
|
|
|
self->priv->vpattern = vpattern;
|
2010-06-11 13:17:42 +00:00
|
|
|
|
2013-03-01 01:27:50 +00:00
|
|
|
for (tmp = GES_CONTAINER_CHILDREN (self); tmp; tmp = tmp->next) {
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *trackelement = (GESTrackElement *) tmp->data;
|
2013-01-26 16:03:39 +00:00
|
|
|
if (GES_IS_VIDEO_TEST_SOURCE (trackelement))
|
|
|
|
ges_video_test_source_set_pattern (
|
|
|
|
(GESVideoTestSource *) trackelement, vpattern);
|
2010-06-11 13:17:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-07 18:36:31 +00:00
|
|
|
/**
|
2013-01-17 03:58:28 +00:00
|
|
|
* ges_test_clip_set_frequency:
|
|
|
|
* @self: the #GESTestClip to set the frequency on
|
2011-01-07 18:36:31 +00:00
|
|
|
* @freq: the frequency you want to use on @self
|
|
|
|
*
|
|
|
|
* Sets the frequency to generate. See audiotestsrc element.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void
|
2013-01-17 03:58:28 +00:00
|
|
|
ges_test_clip_set_frequency (GESTestClip * self, gdouble freq)
|
2010-07-02 13:42:48 +00:00
|
|
|
{
|
2013-03-01 01:27:50 +00:00
|
|
|
GList *tmp;
|
2010-07-02 13:42:48 +00:00
|
|
|
|
2011-01-07 18:36:31 +00:00
|
|
|
self->priv->freq = freq;
|
2010-07-02 13:42:48 +00:00
|
|
|
|
2013-03-01 01:27:50 +00:00
|
|
|
for (tmp = GES_CONTAINER_CHILDREN (self); tmp; tmp = tmp->next) {
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *trackelement = (GESTrackElement *) tmp->data;
|
2013-01-26 16:02:02 +00:00
|
|
|
if (GES_IS_AUDIO_TEST_SOURCE (trackelement))
|
|
|
|
ges_audio_test_source_set_freq (
|
|
|
|
(GESAudioTestSource *) trackelement, freq);
|
2010-07-02 13:42:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-07 18:36:31 +00:00
|
|
|
/**
|
2013-01-17 03:58:28 +00:00
|
|
|
* ges_test_clip_set_volume:
|
|
|
|
* @self: the #GESTestClip to set the volume on
|
2011-01-07 18:36:31 +00:00
|
|
|
* @volume: the volume of the audio signal you want to use on @self
|
|
|
|
*
|
|
|
|
* Sets the volume of the test audio signal.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void
|
2013-01-17 03:58:28 +00:00
|
|
|
ges_test_clip_set_volume (GESTestClip * self, gdouble volume)
|
2010-07-02 13:42:48 +00:00
|
|
|
{
|
2013-03-01 01:27:50 +00:00
|
|
|
GList *tmp;
|
2010-07-02 13:42:48 +00:00
|
|
|
|
2011-01-07 18:36:31 +00:00
|
|
|
self->priv->volume = volume;
|
2010-07-02 13:42:48 +00:00
|
|
|
|
2013-03-01 01:27:50 +00:00
|
|
|
for (tmp = GES_CONTAINER_CHILDREN (self); tmp; tmp = tmp->next) {
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *trackelement = (GESTrackElement *) tmp->data;
|
2013-01-26 16:02:02 +00:00
|
|
|
if (GES_IS_AUDIO_TEST_SOURCE (trackelement))
|
|
|
|
ges_audio_test_source_set_volume (
|
|
|
|
(GESAudioTestSource *) trackelement, volume);
|
2010-07-02 13:42:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-07 18:36:31 +00:00
|
|
|
/**
|
2013-01-17 03:58:28 +00:00
|
|
|
* ges_test_clip_get_vpattern:
|
|
|
|
* @self: a #GESTestClip
|
2011-01-07 18:36:31 +00:00
|
|
|
*
|
2011-01-10 13:28:35 +00:00
|
|
|
* Get the #GESVideoTestPattern which is applied on @self.
|
|
|
|
*
|
2011-01-07 18:36:31 +00:00
|
|
|
* Returns: The #GESVideoTestPattern which is applied on @self.
|
|
|
|
*/
|
|
|
|
GESVideoTestPattern
|
2013-01-17 03:58:28 +00:00
|
|
|
ges_test_clip_get_vpattern (GESTestClip * self)
|
2011-01-07 18:36:31 +00:00
|
|
|
{
|
|
|
|
return self->priv->vpattern;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-01-17 03:58:28 +00:00
|
|
|
* ges_test_clip_is_muted:
|
|
|
|
* @self: a #GESTestClip
|
2011-01-07 18:36:31 +00:00
|
|
|
*
|
2011-01-10 13:28:35 +00:00
|
|
|
* Let you know if the audio track of @self is muted or not.
|
|
|
|
*
|
2011-01-07 18:36:31 +00:00
|
|
|
* Returns: Whether the audio track of @self is muted or not.
|
|
|
|
*/
|
|
|
|
gboolean
|
2013-01-17 03:58:28 +00:00
|
|
|
ges_test_clip_is_muted (GESTestClip * self)
|
2011-01-07 18:36:31 +00:00
|
|
|
{
|
|
|
|
return self->priv->mute;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-01-17 03:58:28 +00:00
|
|
|
* ges_test_clip_get_frequency:
|
|
|
|
* @self: a #GESTestClip
|
2011-01-07 18:36:31 +00:00
|
|
|
*
|
2011-01-10 13:28:35 +00:00
|
|
|
* Get the frequency @self generates.
|
|
|
|
*
|
2011-01-07 18:36:31 +00:00
|
|
|
* Returns: The frequency @self generates. See audiotestsrc element.
|
|
|
|
*/
|
|
|
|
gdouble
|
2013-01-17 03:58:28 +00:00
|
|
|
ges_test_clip_get_frequency (GESTestClip * self)
|
2011-01-07 18:36:31 +00:00
|
|
|
{
|
|
|
|
return self->priv->freq;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-01-17 03:58:28 +00:00
|
|
|
* ges_test_clip_get_volume:
|
|
|
|
* @self: a #GESTestClip
|
2011-01-07 18:36:31 +00:00
|
|
|
*
|
2011-01-10 13:28:35 +00:00
|
|
|
* Get the volume of the test audio signal applied on @self.
|
2011-01-07 18:36:31 +00:00
|
|
|
*
|
2011-01-10 13:28:35 +00:00
|
|
|
* Returns: The volume of the test audio signal applied on @self.
|
2011-01-07 18:36:31 +00:00
|
|
|
*/
|
|
|
|
gdouble
|
2013-01-17 03:58:28 +00:00
|
|
|
ges_test_clip_get_volume (GESTestClip * self)
|
2011-01-07 18:36:31 +00:00
|
|
|
{
|
|
|
|
return self->priv->volume;
|
|
|
|
}
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
static GESTrackElement *
|
2013-02-15 02:34:48 +00:00
|
|
|
ges_test_clip_create_track_element (GESClip * clip, GESTrackType type)
|
2010-06-10 11:21:06 +00:00
|
|
|
{
|
2020-02-28 14:47:25 +00:00
|
|
|
GESAsset *asset = ges_extractable_get_asset (GES_EXTRACTABLE (clip));
|
2013-02-15 02:34:48 +00:00
|
|
|
GESTestClipPrivate *priv = GES_TEST_CLIP (clip)->priv;
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *res = NULL;
|
2010-06-10 11:21:06 +00:00
|
|
|
|
2012-12-20 23:23:54 +00:00
|
|
|
GST_DEBUG ("Creating a GESTrackTestSource for type: %s",
|
|
|
|
ges_track_type_name (type));
|
2010-06-10 11:21:06 +00:00
|
|
|
|
2012-12-20 23:23:54 +00:00
|
|
|
if (type == GES_TRACK_TYPE_VIDEO) {
|
2020-04-22 17:39:21 +00:00
|
|
|
gchar *id = NULL;
|
|
|
|
GESAsset *videoasset;
|
|
|
|
|
|
|
|
if (asset) {
|
|
|
|
GstStructure *structure =
|
|
|
|
gst_structure_from_string (ges_asset_get_id (asset), NULL);
|
|
|
|
|
|
|
|
if (structure) {
|
|
|
|
id = g_strdup (gst_structure_get_name (structure));
|
|
|
|
gst_structure_free (structure);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Our asset ID has been verified and thus this should not fail ever */
|
|
|
|
videoasset = ges_asset_request (GES_TYPE_VIDEO_TEST_SOURCE, id, NULL);
|
|
|
|
g_assert (videoasset);
|
|
|
|
g_free (id);
|
|
|
|
|
|
|
|
res = (GESTrackElement *) ges_asset_extract (videoasset, NULL);
|
|
|
|
gst_object_unref (videoasset);
|
2013-01-26 16:03:39 +00:00
|
|
|
ges_video_test_source_set_pattern (
|
|
|
|
(GESVideoTestSource *) res, priv->vpattern);
|
2012-12-20 23:23:54 +00:00
|
|
|
} else if (type == GES_TRACK_TYPE_AUDIO) {
|
2013-01-26 16:02:02 +00:00
|
|
|
res = (GESTrackElement *) ges_audio_test_source_new ();
|
2010-07-06 16:58:16 +00:00
|
|
|
|
2011-01-07 18:36:31 +00:00
|
|
|
if (priv->mute)
|
2013-01-26 15:31:33 +00:00
|
|
|
ges_track_element_set_active (res, FALSE);
|
2010-06-10 11:21:06 +00:00
|
|
|
|
2013-01-26 16:02:02 +00:00
|
|
|
ges_audio_test_source_set_freq ((GESAudioTestSource *) res, priv->freq);
|
|
|
|
ges_audio_test_source_set_volume ((GESAudioTestSource *) res, priv->volume);
|
2010-07-06 16:58:16 +00:00
|
|
|
}
|
2010-06-10 11:21:06 +00:00
|
|
|
|
2020-02-28 14:47:25 +00:00
|
|
|
if (asset)
|
|
|
|
ges_timeline_element_set_max_duration (GES_TIMELINE_ELEMENT (res),
|
|
|
|
ges_test_clip_asset_get_max_duration (asset));
|
|
|
|
|
2010-06-10 11:21:06 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-01-17 03:58:28 +00:00
|
|
|
* ges_test_clip_new:
|
2010-06-10 11:21:06 +00:00
|
|
|
*
|
2013-01-17 03:58:28 +00:00
|
|
|
* Creates a new #GESTestClip.
|
2010-06-10 11:21:06 +00:00
|
|
|
*
|
2016-05-14 23:04:17 +00:00
|
|
|
* Returns: (transfer floating) (nullable): The newly created #GESTestClip,
|
|
|
|
* or %NULL if there was an error.
|
2010-06-10 11:21:06 +00:00
|
|
|
*/
|
2013-01-17 03:58:28 +00:00
|
|
|
GESTestClip *
|
|
|
|
ges_test_clip_new (void)
|
2010-06-10 11:21:06 +00:00
|
|
|
{
|
2013-03-03 14:50:10 +00:00
|
|
|
GESTestClip *new_clip;
|
|
|
|
GESAsset *asset = ges_asset_request (GES_TYPE_TEST_CLIP, NULL, NULL);
|
|
|
|
|
|
|
|
new_clip = GES_TEST_CLIP (ges_asset_extract (asset, NULL));
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (asset);
|
2013-03-03 14:50:10 +00:00
|
|
|
|
|
|
|
return new_clip;
|
2010-06-10 11:21:06 +00:00
|
|
|
}
|
2010-06-11 14:51:44 +00:00
|
|
|
|
2011-01-10 13:28:35 +00:00
|
|
|
/**
|
2013-01-17 03:58:28 +00:00
|
|
|
* ges_test_clip_new_for_nick:
|
|
|
|
* @nick: the nickname for which to create the #GESTestClip
|
2011-01-10 13:28:35 +00:00
|
|
|
*
|
2013-01-17 03:58:28 +00:00
|
|
|
* Creates a new #GESTestClip for the provided @nick.
|
2011-01-10 13:28:35 +00:00
|
|
|
*
|
2016-05-14 23:04:17 +00:00
|
|
|
* Returns: (transfer floating) (nullable): The newly created #GESTestClip,
|
|
|
|
* or %NULL if there was an error.
|
2011-01-10 13:28:35 +00:00
|
|
|
*/
|
2013-01-17 03:58:28 +00:00
|
|
|
GESTestClip *
|
|
|
|
ges_test_clip_new_for_nick (gchar * nick)
|
2010-06-11 14:51:44 +00:00
|
|
|
{
|
|
|
|
GEnumValue *value;
|
2010-07-08 14:35:43 +00:00
|
|
|
GEnumClass *klass;
|
2013-01-17 03:58:28 +00:00
|
|
|
GESTestClip *ret = NULL;
|
2010-07-08 14:35:43 +00:00
|
|
|
|
|
|
|
klass = G_ENUM_CLASS (g_type_class_ref (GES_VIDEO_TEST_PATTERN_TYPE));
|
|
|
|
if (!klass)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
value = g_enum_get_value_by_nick (klass, nick);
|
|
|
|
if (value) {
|
2013-03-03 14:50:10 +00:00
|
|
|
ret = ges_test_clip_new ();
|
|
|
|
ges_test_clip_set_vpattern (ret, value->value);
|
2010-06-11 14:51:44 +00:00
|
|
|
}
|
|
|
|
|
2010-07-08 14:35:43 +00:00
|
|
|
g_type_class_unref (klass);
|
|
|
|
return ret;
|
2010-06-11 14:51:44 +00:00
|
|
|
}
|