test-source: Respect asset natural size

We had cases where the frame positioner had the default natural size for
video test sources instead of the user provided one.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/227>
This commit is contained in:
Thibault Saunier 2021-01-13 15:18:04 -03:00
parent 8bbd06c7c6
commit e3a30744e8
2 changed files with 47 additions and 23 deletions

View file

@ -89,6 +89,25 @@ _set_priority (GESTimelineElement * element, guint32 priority)
return res;
}
static gboolean
_set_parent (GESTimelineElement * element, GESTimelineElement * parent)
{
GESVideoSource *self = GES_VIDEO_SOURCE (element);
if (!parent)
return TRUE;
/* Some subclass might have different access to its natural size only
* once it knows its parent */
ges_video_source_get_natural_size (GES_VIDEO_SOURCE (self),
&self->priv->positioner->natural_width,
&self->priv->positioner->natural_height);
return TRUE;
}
static gboolean
ges_video_source_create_filters (GESVideoSource * self, GPtrArray * elements,
gboolean needs_converters)
@ -223,6 +242,7 @@ ges_video_source_class_init (GESVideoSourceClass * klass)
element_class->set_priority = _set_priority;
element_class->lookup_child = _lookup_child;
element_class->set_parent = _set_parent;
track_element_class->nleobject_factorytype = "nlesource";
track_element_class->create_element = ges_video_source_create_element;

View file

@ -91,12 +91,13 @@ get_natural_size (GESVideoSource * source, gint * width, gint * height)
static gboolean
_set_parent (GESTimelineElement * element, GESTimelineElement * parent)
{
gint width, height, fps_n, fps_d;
GstCaps *caps;
GESVideoTestSource *self = GES_VIDEO_TEST_SOURCE (element);
if (parent) {
gint width, height, fps_n, fps_d;
GstCaps *caps;
if (!parent)
goto done;
g_assert (self->priv->capsfilter);
/* Setting the parent ourself as we need it to get the natural size */
@ -106,6 +107,7 @@ _set_parent (GESTimelineElement * element, GESTimelineElement * parent)
width = DEFAULT_WIDTH;
height = DEFAULT_HEIGHT;
}
if (!ges_timeline_element_get_natural_framerate (parent, &fps_n, &fps_d)) {
fps_n = DEFAULT_FRAMERATE_N;
fps_d = DEFAULT_FRAMERATE_D;
@ -117,9 +119,11 @@ _set_parent (GESTimelineElement * element, GESTimelineElement * parent)
"framerate", GST_TYPE_FRACTION, fps_n, fps_d, NULL);
g_object_set (self->priv->capsfilter, "caps", caps, NULL);
gst_caps_unref (caps);
}
return TRUE;
done:
return
GES_TIMELINE_ELEMENT_CLASS
(ges_video_test_source_parent_class)->set_parent (element, parent);
}
static gboolean