From db5b4e6a06d1f74fc078a83cad6ca4af14764aa7 Mon Sep 17 00:00:00 2001
From: Fabian Orccon <forccon@fluendo.com>
Date: Mon, 17 Oct 2022 19:45:30 -0500
Subject: [PATCH] ges: transition: Notify vtype change on
 ges_extractable_set_asset call

Fixes #1454

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3215>
---
 .../ges/ges-transition-clip.c                 |  1 +
 .../tests/check/ges/transition.c              | 31 +++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/subprojects/gst-editing-services/ges/ges-transition-clip.c b/subprojects/gst-editing-services/ges/ges-transition-clip.c
index 0ffc60f1a8..e3f5fff288 100644
--- a/subprojects/gst-editing-services/ges/ges-transition-clip.c
+++ b/subprojects/gst-editing-services/ges/ges-transition-clip.c
@@ -188,6 +188,7 @@ extractable_set_asset (GESExtractable * self, GESAsset * asset)
       }
     }
     ges_transition_clip_update_vtype_internal (GES_CLIP (self), value, FALSE);
+    g_object_notify (G_OBJECT (self), "vtype");
   }
 
   if (!prev_asset)
diff --git a/subprojects/gst-editing-services/tests/check/ges/transition.c b/subprojects/gst-editing-services/tests/check/ges/transition.c
index 16b2880be4..82690af9a3 100644
--- a/subprojects/gst-editing-services/tests/check/ges/transition.c
+++ b/subprojects/gst-editing-services/tests/check/ges/transition.c
@@ -176,7 +176,37 @@ GST_START_TEST (test_transition_properties)
 
 GST_END_TEST;
 
+static void
+notify_vtype_cb (GESTransitionClip * clip, GParamSpec * pspec,
+    GESVideoStandardTransitionType * vtype)
+{
+  g_object_get (clip, "vtype", vtype, NULL);
+}
 
+GST_START_TEST (test_transition_notify_vtype)
+{
+  GESTransitionClip *tclip;
+  GESAsset *asset;
+  GESVideoStandardTransitionType vtype =
+      GES_VIDEO_STANDARD_TRANSITION_TYPE_NONE;
+
+  tclip = ges_transition_clip_new (vtype);
+  g_signal_connect (tclip, "notify::vtype", G_CALLBACK (notify_vtype_cb),
+      &vtype);
+
+  g_object_set (tclip, "vtype", GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE,
+      NULL);
+  assert_equals_int (vtype, GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE);
+
+  asset = ges_asset_request (GES_TYPE_TRANSITION_CLIP, "fade-in", NULL);
+  g_assert (ges_extractable_set_asset (GES_EXTRACTABLE (tclip), asset));
+  assert_equals_int (vtype, GES_VIDEO_STANDARD_TRANSITION_TYPE_FADE_IN);
+
+  gst_object_unref (asset);
+  gst_object_unref (tclip);
+}
+
+GST_END_TEST;
 
 static Suite *
 ges_suite (void)
@@ -188,6 +218,7 @@ ges_suite (void)
 
   tcase_add_test (tc_chain, test_transition_basic);
   tcase_add_test (tc_chain, test_transition_properties);
+  tcase_add_test (tc_chain, test_transition_notify_vtype);
 
   return s;
 }