From ae6124e282d011026237c8f750d762459185622b Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Fri, 28 Feb 2020 11:56:22 -0300 Subject: [PATCH] validate: Add support to seek in frames --- ges/ges-validate.c | 60 +++++++++++++++++++ ...in_frames_with_framerate_mismatch.scenario | 2 +- 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/ges/ges-validate.c b/ges/ges-validate.c index 56ae607da2..052f37213c 100644 --- a/ges/ges-validate.c +++ b/ges/ges-validate.c @@ -1188,15 +1188,75 @@ fail: } +static gboolean +prepare_seek_action (GstValidateAction * action) +{ + GESFrameNumber fstart, fstop; + GstValidateScenario *scenario = gst_validate_action_get_scenario (action); + GstValidateActionType *type = gst_validate_get_action_type (action->type); + GError *err = NULL; + + DECLARE_AND_GET_TIMELINE (scenario, action); + + if (timeline + && ges_util_structure_get_clocktime (action->structure, "start", NULL, + &fstart)) { + GstClockTime start = ges_timeline_get_frame_time (timeline, fstart); + + if (err) { + GST_VALIDATE_REPORT_ACTION (scenario, action, + SCENARIO_ACTION_EXECUTION_ERROR, + "Invalid seeking frame number '%" G_GINT64_FORMAT "': %s", fstart, + err->message); + goto err; + } + gst_structure_set (action->structure, "start", G_TYPE_UINT64, start, NULL); + } + + if (timeline + && ges_util_structure_get_clocktime (action->structure, "stop", NULL, + &fstop)) { + GstClockTime stop = ges_timeline_get_frame_time (timeline, fstop); + + if (err) { + GST_VALIDATE_REPORT_ACTION (scenario, action, + SCENARIO_ACTION_EXECUTION_ERROR, + "Invalid seeking frame number '%" G_GINT64_FORMAT "': %s", fstop, + err->message); + goto err; + } + gst_structure_set (action->structure, "stop", G_TYPE_UINT64, stop, NULL); + } + + gst_object_unref (scenario); + gst_object_unref (timeline); + return type->overriden_type->prepare (action); + +err: + gst_object_unref (scenario); + gst_object_unref (timeline); + return FALSE; +} + #endif gboolean ges_validate_register_action_types (void) { #ifdef HAVE_GST_VALIDATE + GstValidateActionType *validate_seek, *seek_override; + + gst_validate_init (); + validate_seek = gst_validate_get_action_type ("seek"); /* *INDENT-OFF* */ + seek_override = gst_validate_register_action_type("seek", "ges", validate_seek->execute, + validate_seek->parameters, validate_seek->description, + validate_seek->flags); + gst_mini_object_unref(GST_MINI_OBJECT(validate_seek)); + seek_override->prepare = prepare_seek_action; + gst_validate_register_action_type ("edit-container", "ges", _edit, (GstValidateActionParameter []) { { diff --git a/tests/check/scenarios/check_edit_in_frames_with_framerate_mismatch.scenario b/tests/check/scenarios/check_edit_in_frames_with_framerate_mismatch.scenario index fefa4c902b..483ea10d33 100644 --- a/tests/check/scenarios/check_edit_in_frames_with_framerate_mismatch.scenario +++ b/tests/check/scenarios/check_edit_in_frames_with_framerate_mismatch.scenario @@ -2,7 +2,7 @@ description, handles-states=true, ges-options={\ --track-types, video, --disable-mixing, - "--videosink=fakevideosink"\ + "--videosink=fakesink"\ } add-clip, name=clip, asset-id="framerate=120/1", layer-priority=0, type=GESTestClip, pattern=blue, duration=f240, inpoint=f100 -- 2.34.1