From: Thibault Saunier Date: Wed, 13 Jan 2021 18:18:04 +0000 (-0300) Subject: test-source: Respect asset natural size X-Git-Tag: 1.19.3~493^2~60 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e3a30744e8f684f3aa864512ddd14d68d1f42436;p=platform%2Fupstream%2Fgstreamer.git 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: --- diff --git a/ges/ges-video-source.c b/ges/ges-video-source.c index bd3e38d..a9e11ce 100644 --- a/ges/ges-video-source.c +++ b/ges/ges-video-source.c @@ -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; diff --git a/ges/ges-video-test-source.c b/ges/ges-video-test-source.c index 2f8face..9df3746 100644 --- a/ges/ges-video-test-source.c +++ b/ges/ges-video-test-source.c @@ -91,35 +91,39 @@ 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; - - g_assert (self->priv->capsfilter); - /* Setting the parent ourself as we need it to get the natural size */ - element->parent = parent; - if (!ges_video_source_get_natural_size (GES_VIDEO_SOURCE (self), &width, - &height)) { - 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; - } + if (!parent) + goto done; - caps = gst_caps_new_simple ("video/x-raw", - "width", G_TYPE_INT, width, - "height", G_TYPE_INT, height, - "framerate", GST_TYPE_FRACTION, fps_n, fps_d, NULL); - g_object_set (self->priv->capsfilter, "caps", caps, NULL); - gst_caps_unref (caps); + g_assert (self->priv->capsfilter); + /* Setting the parent ourself as we need it to get the natural size */ + element->parent = parent; + if (!ges_video_source_get_natural_size (GES_VIDEO_SOURCE (self), &width, + &height)) { + width = DEFAULT_WIDTH; + height = DEFAULT_HEIGHT; } - return TRUE; + if (!ges_timeline_element_get_natural_framerate (parent, &fps_n, &fps_d)) { + fps_n = DEFAULT_FRAMERATE_N; + fps_d = DEFAULT_FRAMERATE_D; + } + + caps = gst_caps_new_simple ("video/x-raw", + "width", G_TYPE_INT, width, + "height", G_TYPE_INT, height, + "framerate", GST_TYPE_FRACTION, fps_n, fps_d, NULL); + g_object_set (self->priv->capsfilter, "caps", caps, NULL); + gst_caps_unref (caps); + +done: + return + GES_TIMELINE_ELEMENT_CLASS + (ges_video_test_source_parent_class)->set_parent (element, parent); } static gboolean