mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-26 09:08:14 +00:00
Check in TimelineObject what tracks are supported before creating TrackObject-s
We used to do it in TimelineFileSource which does not make sense. At the same time we set AUDIO | VIDEO as default supported types as it is more likely to be what subclasses support. If it is not the case, they need to specify it as shown in ges-timeline-custom-timeline-source.c + Fix the tests accordingly
This commit is contained in:
parent
8ff97af65d
commit
9a2ba1f9f7
4 changed files with 41 additions and 11 deletions
|
@ -65,8 +65,8 @@ static GParameter *
|
|||
extractable_get_parameters_from_id (const gchar * id, guint * n_params)
|
||||
{
|
||||
gchar **func_udata;
|
||||
GParameter *params = g_new0 (GParameter, 2);
|
||||
*n_params = 2;
|
||||
GParameter *params = g_new0 (GParameter, 3);
|
||||
*n_params = 3;
|
||||
|
||||
/* We already know that we have a valid ID here */
|
||||
func_udata = g_strsplit (id, "!", -1);
|
||||
|
@ -81,6 +81,10 @@ extractable_get_parameters_from_id (const gchar * id, guint * n_params)
|
|||
g_value_set_pointer (¶ms[1].value,
|
||||
GUINT_TO_POINTER (g_ascii_strtoll (func_udata[1], NULL, 10)));
|
||||
|
||||
params[2].name = g_strdup ("supported-formats");
|
||||
g_value_init (¶ms[2].value, G_TYPE_ENUM);
|
||||
g_value_set_enum (¶ms[2].value, GES_TRACK_TYPE_CUSTOM);
|
||||
|
||||
g_strfreev (func_udata);
|
||||
|
||||
return params;
|
||||
|
@ -231,7 +235,8 @@ ges_custom_timeline_source_new (GESFillTrackObjectUserFunc func,
|
|||
{
|
||||
GESCustomTimelineSource *src;
|
||||
|
||||
src = g_object_new (GES_TYPE_CUSTOM_TIMELINE_SOURCE, NULL);
|
||||
src = g_object_new (GES_TYPE_CUSTOM_TIMELINE_SOURCE, "supported-formats",
|
||||
GES_TRACK_TYPE_CUSTOM, NULL);
|
||||
src->priv->filltrackobjectfunc = func;
|
||||
src->priv->user_data = user_data;
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ enum
|
|||
PROP_URI,
|
||||
PROP_MUTE,
|
||||
PROP_IS_IMAGE,
|
||||
PROP_SUPPORTED_FORMATS,
|
||||
};
|
||||
|
||||
|
||||
|
@ -86,6 +87,11 @@ ges_timeline_filesource_get_property (GObject * object, guint property_id,
|
|||
case PROP_IS_IMAGE:
|
||||
g_value_set_boolean (value, priv->is_image);
|
||||
break;
|
||||
case PROP_SUPPORTED_FORMATS:
|
||||
g_value_set_flags (value,
|
||||
ges_timeline_object_get_supported_formats (GES_TIMELINE_OBJECT
|
||||
(object)));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
|
@ -107,6 +113,10 @@ ges_timeline_filesource_set_property (GObject * object, guint property_id,
|
|||
case PROP_IS_IMAGE:
|
||||
ges_timeline_filesource_set_is_image (tfs, g_value_get_boolean (value));
|
||||
break;
|
||||
case PROP_SUPPORTED_FORMATS:
|
||||
ges_timeline_object_set_supported_formats (GES_TIMELINE_OBJECT (tfs),
|
||||
g_value_get_flags (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
|
@ -164,6 +174,14 @@ ges_timeline_filesource_class_init (GESTimelineFileSourceClass * klass)
|
|||
"Whether the timeline object represents a still image or not",
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
||||
|
||||
/* 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));
|
||||
|
||||
timobj_class->create_track_object =
|
||||
ges_timeline_filesource_create_track_object;
|
||||
timobj_class->set_max_duration = filesource_set_max_duration;
|
||||
|
@ -183,7 +201,7 @@ extractable_check_id (GType type, const gchar * id)
|
|||
static GParameter *
|
||||
extractable_get_parameters_from_id (const gchar * id, guint * n_params)
|
||||
{
|
||||
GParameter *params = g_new0 (GParameter, 3);
|
||||
GParameter *params = g_new0 (GParameter, 2);
|
||||
|
||||
params[0].name = g_strdup ("uri");
|
||||
g_value_init (¶ms[0].value, G_TYPE_STRING);
|
||||
|
@ -418,12 +436,6 @@ ges_timeline_filesource_create_track_object (GESTimelineObject * obj,
|
|||
GESTimelineFileSourcePrivate *priv = GES_TIMELINE_FILE_SOURCE (obj)->priv;
|
||||
GESTrackObject *res;
|
||||
|
||||
if (!(ges_timeline_object_get_supported_formats (obj) & track->type)) {
|
||||
GST_DEBUG ("We don't support this track format (caps %" GST_PTR_FORMAT
|
||||
")", ges_track_get_caps (track));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (priv->is_image) {
|
||||
if (track->type != GES_TRACK_TYPE_VIDEO) {
|
||||
GST_DEBUG ("Object is still image, not adding any audio source");
|
||||
|
|
|
@ -314,7 +314,7 @@ ges_timeline_object_class_init (GESTimelineObjectClass * klass)
|
|||
*/
|
||||
properties[PROP_SUPPORTED_FORMATS] = g_param_spec_flags ("supported-formats",
|
||||
"Supported formats", "Formats supported by the file",
|
||||
GES_TYPE_TRACK_TYPE, GES_TRACK_TYPE_UNKNOWN,
|
||||
GES_TYPE_TRACK_TYPE, GES_TRACK_TYPE_AUDIO | GES_TRACK_TYPE_VIDEO,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
|
||||
|
||||
g_object_class_install_property (object_class, PROP_SUPPORTED_FORMATS,
|
||||
|
@ -473,6 +473,13 @@ ges_timeline_object_create_track_object (GESTimelineObject * object,
|
|||
g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), NULL);
|
||||
g_return_val_if_fail (GES_IS_TRACK (track), NULL);
|
||||
|
||||
if (!(track->type & object->priv->supportedformats)) {
|
||||
GST_DEBUG ("We don't support this track format (supported: %i caps %"
|
||||
GST_PTR_FORMAT ")", object->priv->supportedformats,
|
||||
ges_track_get_caps (track));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
class = GES_TIMELINE_OBJECT_GET_CLASS (object);
|
||||
|
||||
if (G_UNLIKELY (class->create_track_object == NULL)) {
|
||||
|
|
|
@ -165,12 +165,18 @@ GST_START_TEST (test_layer_priorities)
|
|||
object1 =
|
||||
GES_TIMELINE_OBJECT (ges_custom_timeline_source_new (my_fill_track_func,
|
||||
NULL));
|
||||
ges_timeline_object_set_supported_formats (object1,
|
||||
GES_TRACK_TYPE_AUDIO | GES_TRACK_TYPE_VIDEO);
|
||||
object2 =
|
||||
GES_TIMELINE_OBJECT (ges_custom_timeline_source_new (my_fill_track_func,
|
||||
NULL));
|
||||
ges_timeline_object_set_supported_formats (object2,
|
||||
GES_TRACK_TYPE_AUDIO | GES_TRACK_TYPE_VIDEO);
|
||||
object3 =
|
||||
GES_TIMELINE_OBJECT (ges_custom_timeline_source_new (my_fill_track_func,
|
||||
NULL));
|
||||
ges_timeline_object_set_supported_formats (object3,
|
||||
GES_TRACK_TYPE_AUDIO | GES_TRACK_TYPE_VIDEO);
|
||||
fail_unless (object1 != NULL);
|
||||
fail_unless (object2 != NULL);
|
||||
fail_unless (object3 != NULL);
|
||||
|
|
Loading…
Reference in a new issue