videoflip: fix setting of method property at construction time

Since c2f890ab, element properties are gathered from the parse-launch
line and passed at object construction.

This caused the following issue to happen in videoflip:

* videoflip installed a CONSTRUCT property named method, now deprecated
* videoflip now also overrides that property with a video-direction
  property

GObject construction causes method to be set first at construct time,
with the user-provided value, then video-direction with the default
value.

The user-provided value was thus overridden, causing a regression.

Fix by not installing the properties as CONSTRUCT, and explicitly
implementing constructed() instead in order to ensure that we do still
call gst_video_flip_set_method() at least once during construction.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/2529

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4536>
This commit is contained in:
Mathieu Duponchelle 2023-05-03 15:42:01 +02:00 committed by GStreamer Marge Bot
parent 0cee3cd833
commit 020fd3d14d
2 changed files with 20 additions and 2 deletions

View file

@ -26640,7 +26640,7 @@
"method": { "method": {
"blurb": "method (deprecated, use video-direction instead)", "blurb": "method (deprecated, use video-direction instead)",
"conditionally-available": false, "conditionally-available": false,
"construct": true, "construct": false,
"construct-only": false, "construct-only": false,
"controllable": true, "controllable": true,
"default": "none (0)", "default": "none (0)",

View file

@ -1912,6 +1912,17 @@ gst_video_flip_change_state (GstElement * element, GstStateChange transition)
return result; return result;
} }
static void
gst_video_flip_constructed (GObject * object)
{
GstVideoFlip *self = GST_VIDEO_FLIP (object);
if (self->method == (GstVideoOrientationMethod) PROP_METHOD_DEFAULT) {
gst_video_flip_set_method (self,
(GstVideoOrientationMethod) PROP_METHOD_DEFAULT, FALSE);
}
}
static void static void
gst_video_flip_class_init (GstVideoFlipClass * klass) gst_video_flip_class_init (GstVideoFlipClass * klass)
{ {
@ -1925,6 +1936,7 @@ gst_video_flip_class_init (GstVideoFlipClass * klass)
gobject_class->set_property = gst_video_flip_set_property; gobject_class->set_property = gst_video_flip_set_property;
gobject_class->get_property = gst_video_flip_get_property; gobject_class->get_property = gst_video_flip_get_property;
gobject_class->constructed = gst_video_flip_constructed;
gobject_class->finalize = gst_video_flip_finalize; gobject_class->finalize = gst_video_flip_finalize;
g_object_class_install_property (gobject_class, PROP_METHOD, g_object_class_install_property (gobject_class, PROP_METHOD,
@ -1932,7 +1944,7 @@ gst_video_flip_class_init (GstVideoFlipClass * klass)
"method (deprecated, use video-direction instead)", "method (deprecated, use video-direction instead)",
GST_TYPE_VIDEO_FLIP_METHOD, PROP_METHOD_DEFAULT, GST_TYPE_VIDEO_FLIP_METHOD, PROP_METHOD_DEFAULT,
GST_PARAM_CONTROLLABLE | GST_PARAM_MUTABLE_PLAYING | GST_PARAM_CONTROLLABLE | GST_PARAM_MUTABLE_PLAYING |
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS)); G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_override_property (gobject_class, PROP_VIDEO_DIRECTION, g_object_class_override_property (gobject_class, PROP_VIDEO_DIRECTION,
"video-direction"); "video-direction");
/* override the overriden property's flags to include the mutable in playing /* override the overriden property's flags to include the mutable in playing
@ -1968,6 +1980,12 @@ gst_video_flip_class_init (GstVideoFlipClass * klass)
static void static void
gst_video_flip_init (GstVideoFlip * videoflip) gst_video_flip_init (GstVideoFlip * videoflip)
{ {
/* We initialize to the default and call set_method() from constructed
* if the value hasn't changed, this ensures set_method() does get called
* even if the non-construct method / direction properties aren't set
*/
videoflip->method = (GstVideoOrientationMethod) PROP_METHOD_DEFAULT;
/* AUTO is not valid for active method, this is just to ensure we setup the /* AUTO is not valid for active method, this is just to ensure we setup the
* method in gst_video_flip_set_method() */ * method in gst_video_flip_set_method() */
videoflip->active_method = GST_VIDEO_ORIENTATION_AUTO; videoflip->active_method = GST_VIDEO_ORIENTATION_AUTO;