From 63ce3c8da6f0884fddfbd7b85060f23cf0a7ed50 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Thu, 1 Feb 2024 17:59:59 -0300 Subject: [PATCH] nlecomposition: Let parent compositions tell if they will send initialization seeks Part-of: --- .../plugins/nle/nlecomposition.c | 15 ++++----- .../tests/validate/meson.build | 1 + ..._unnecessary_stack_init_seeks.validatetest | 31 +++++++++++++++++++ .../log-overlay-src-expected | 12 +++++++ .../log-source_L0-src-expected | 16 ++++++++++ .../log-source_L1-src-expected | 14 +++++++++ .../log-source_L2-src-expected | 14 +++++++++ .../log-source_L3-src-expected | 14 +++++++++ 8 files changed, 108 insertions(+), 9 deletions(-) create mode 100644 subprojects/gst-editing-services/tests/validate/nle/ensure_no_unnecessary_stack_init_seeks.validatetest create mode 100644 subprojects/gst-editing-services/tests/validate/nle/ensure_no_unnecessary_stack_init_seeks/flow-expectations/log-overlay-src-expected create mode 100644 subprojects/gst-editing-services/tests/validate/nle/ensure_no_unnecessary_stack_init_seeks/flow-expectations/log-source_L0-src-expected create mode 100644 subprojects/gst-editing-services/tests/validate/nle/ensure_no_unnecessary_stack_init_seeks/flow-expectations/log-source_L1-src-expected create mode 100644 subprojects/gst-editing-services/tests/validate/nle/ensure_no_unnecessary_stack_init_seeks/flow-expectations/log-source_L2-src-expected create mode 100644 subprojects/gst-editing-services/tests/validate/nle/ensure_no_unnecessary_stack_init_seeks/flow-expectations/log-source_L3-src-expected diff --git a/subprojects/gst-editing-services/plugins/nle/nlecomposition.c b/subprojects/gst-editing-services/plugins/nle/nlecomposition.c index cb217e0e60..2a8b0e4426 100644 --- a/subprojects/gst-editing-services/plugins/nle/nlecomposition.c +++ b/subprojects/gst-editing-services/plugins/nle/nlecomposition.c @@ -219,7 +219,6 @@ typedef struct { GMutex lock; gboolean needs_initialization_seek; - gboolean answered; } NleCompositionQueryNeedsInitializationSeek; /* *INDENT-OFF* */ @@ -1063,13 +1062,15 @@ nle_composition_handle_message (GstBin * bin, GstMessage * message) && GST_MESSAGE_SRC (message) != GST_OBJECT_CAST (comp)) { NleCompositionQueryNeedsInitializationSeek *q; + /* First let parents answer */ + GST_BIN_CLASS (parent_class)->handle_message (bin, message); + gst_structure_get (structure, "query", NLE_TYPE_COMPOSITION_QUERY_NEEDS_INITIALIZATION_SEEK, &q, NULL); g_assert (q); g_mutex_lock (&q->lock); - if (!q->answered || q->needs_initialization_seek) { - q->answered = TRUE; + if (q->needs_initialization_seek) { q->needs_initialization_seek = priv->stack_initialization_seek == NULL; } g_mutex_unlock (&q->lock); @@ -1781,6 +1782,7 @@ nle_composition_query_needs_topelevel_initializing_seek (NleComposition * comp) { NleCompositionQueryNeedsInitializationSeek *q = g_atomic_rc_box_new0 (NleCompositionQueryNeedsInitializationSeek); + q->needs_initialization_seek = TRUE; GstMessage *m = gst_message_new_element (GST_OBJECT_CAST (comp), gst_structure_new (QUERY_NEEDS_INITIALIZATION_SEEK_MESSAGE_STRUCT_NAME, @@ -1794,12 +1796,7 @@ nle_composition_query_needs_topelevel_initializing_seek (NleComposition * comp) gboolean res = TRUE; g_mutex_lock (&q->lock); - if (q->answered) { - res = q->needs_initialization_seek; - if (!res) { - GST_INFO_OBJECT (comp, "Parent composition is going to seek us"); - } - } + res = q->needs_initialization_seek; g_mutex_unlock (&q->lock); g_atomic_rc_box_release (q); diff --git a/subprojects/gst-editing-services/tests/validate/meson.build b/subprojects/gst-editing-services/tests/validate/meson.build index ec4c883176..da74d3fdf0 100644 --- a/subprojects/gst-editing-services/tests/validate/meson.build +++ b/subprojects/gst-editing-services/tests/validate/meson.build @@ -16,6 +16,7 @@ endif tests = [ 'nle/simple_source_playback', 'nle/simple_source_in_composition_playback', + 'nle/ensure_no_unnecessary_stack_init_seeks', ] env = environment() diff --git a/subprojects/gst-editing-services/tests/validate/nle/ensure_no_unnecessary_stack_init_seeks.validatetest b/subprojects/gst-editing-services/tests/validate/nle/ensure_no_unnecessary_stack_init_seeks.validatetest new file mode 100644 index 0000000000..1cae05d79c --- /dev/null +++ b/subprojects/gst-editing-services/tests/validate/nle/ensure_no_unnecessary_stack_init_seeks.validatetest @@ -0,0 +1,31 @@ +# Sets up 3 levels of nested composition and verify the dataflow. +# This allows us to verify that we do not end up seeking nested +# timelines unnecessarily. +meta, + handles-states=true, + ignore-eos=true, + args={ + "nlecomposition name=compo ! video/x-raw,format=(string)YUY2,framerate=(fraction)30/1,height=(int)240,interlace-mode=(string)progressive, multiview-mode=(string)mono, pixel-aspect-ratio=(fraction)1/1, width=(int)320 ! videoconvert ! $(videosink)", + }, + configs = { + "$(validateflow), pad=overlay:src, buffers-checksum=as-id, ignored-event-types={ tag }, ignored-fields = \"buffer={meta}\"", + "$(validateflow), pad=source_L0:src, buffers-checksum=as-id, ignored-event-types={ tag }", + "$(validateflow), pad=source_L1:src, buffers-checksum=as-id, ignored-event-types={ tag }", + "$(validateflow), pad=source_L2:src, buffers-checksum=as-id, ignored-event-types={ tag }", + "$(validateflow), pad=source_L3:src, buffers-checksum=as-id, ignored-event-types={ tag }", + } + +nle-add-child, object-name="compo", desc="nlesource name=source_L0 inpoint=0 duration=200000000" +nle-add-child, object-name="source_L0", desc="nlecomposition name=compo_L1" +nle-add-child, object-name="compo_L1", desc="nlesource name=source_L1 inpoint=0 duration=200000000" +nle-add-child, object-name="source_L1", desc="nlecomposition name=compo_L2" +nle-add-child, object-name="compo_L2", desc="nlesource name=source_L2 inpoint=0 duration=200000000" +nle-add-child, object-name="source_L2", desc="nlecomposition name=compo_L3" +nle-add-child, object-name="compo_L3", desc="nlesource name=source_L3 inpoint=200000000 duration=200000000" +nle-add-child, object-name="source_L3", desc="videotestsrc ! timeoverlay name=overlay" + +play +check-position, on-message=eos, expected-position=0.2 + +stop + diff --git a/subprojects/gst-editing-services/tests/validate/nle/ensure_no_unnecessary_stack_init_seeks/flow-expectations/log-overlay-src-expected b/subprojects/gst-editing-services/tests/validate/nle/ensure_no_unnecessary_stack_init_seeks/flow-expectations/log-overlay-src-expected new file mode 100644 index 0000000000..acd2c561b0 --- /dev/null +++ b/subprojects/gst-editing-services/tests/validate/nle/ensure_no_unnecessary_stack_init_seeks/flow-expectations/log-overlay-src-expected @@ -0,0 +1,12 @@ +event stream-start: GstEventStreamStart, flags=(GstStreamFlags)GST_STREAM_FLAG_NONE, group-id=(uint)1; +event caps: video/x-raw, format=(string)YUY2, framerate=(fraction)30/1, height=(int)240, interlace-mode=(string)progressive, multiview-mode=(string)mono, pixel-aspect-ratio=(fraction)1/1, width=(int)320; +event flush-start: (no structure) +event flush-stop: GstEventFlushStop, reset-time=(boolean)true; +event segment: format=TIME, start=0:00:00.200000000, offset=0:00:00.000000000, stop=0:00:00.400000000, flags=0x01, time=0:00:00.200000000, base=0:00:00.000000000, position=0:00:00.200000000 +buffer: content-id=0, pts=0:00:00.200000000, dur=0:00:00.033333333, flags=discont +buffer: content-id=1, pts=0:00:00.233333333, dur=0:00:00.033333333 +buffer: content-id=2, pts=0:00:00.266666666, dur=0:00:00.033333334 +buffer: content-id=3, pts=0:00:00.300000000, dur=0:00:00.033333333 +buffer: content-id=4, pts=0:00:00.333333333, dur=0:00:00.033333333 +buffer: content-id=5, pts=0:00:00.366666666, dur=0:00:00.033333334 +event eos: (no structure) diff --git a/subprojects/gst-editing-services/tests/validate/nle/ensure_no_unnecessary_stack_init_seeks/flow-expectations/log-source_L0-src-expected b/subprojects/gst-editing-services/tests/validate/nle/ensure_no_unnecessary_stack_init_seeks/flow-expectations/log-source_L0-src-expected new file mode 100644 index 0000000000..6012d3bfe9 --- /dev/null +++ b/subprojects/gst-editing-services/tests/validate/nle/ensure_no_unnecessary_stack_init_seeks/flow-expectations/log-source_L0-src-expected @@ -0,0 +1,16 @@ +event stream-start: GstEventStreamStart, flags=(GstStreamFlags)GST_STREAM_FLAG_NONE; +event caps: video/x-raw, format=(string)YUY2, framerate=(fraction)30/1, height=(int)240, interlace-mode=(string)progressive, multiview-mode=(string)mono, pixel-aspect-ratio=(fraction)1/1, width=(int)320; +event caps: video/x-raw, format=(string)YUY2, framerate=(fraction)30/1, height=(int)240, interlace-mode=(string)progressive, multiview-mode=(string)mono, pixel-aspect-ratio=(fraction)1/1, width=(int)320; +event flush-start: (no structure) +event flush-stop: GstEventFlushStop, reset-time=(boolean)true; +event caps: video/x-raw, format=(string)YUY2, framerate=(fraction)30/1, height=(int)240, interlace-mode=(string)progressive, multiview-mode=(string)mono, pixel-aspect-ratio=(fraction)1/1, width=(int)320; +event segment: format=TIME, start=0:00:00.200000000, offset=0:00:00.000000000, stop=0:00:00.400000000, flags=0x01, time=0:00:00.000000000, base=0:00:00.000000000, position=0:00:00.200000000 +buffer: content-id=0, pts=0:00:00.200000000, dur=0:00:00.033333333, flags=discont +buffer: content-id=1, pts=0:00:00.233333333, dur=0:00:00.033333333 +buffer: content-id=2, pts=0:00:00.266666666, dur=0:00:00.033333334 +buffer: content-id=3, pts=0:00:00.300000000, dur=0:00:00.033333333 +buffer: content-id=4, pts=0:00:00.333333333, dur=0:00:00.033333333 +buffer: content-id=5, pts=0:00:00.366666666, dur=0:00:00.033333334 +event eos: (no structure) +event flush-start: (no structure) +event flush-stop: GstEventFlushStop, reset-time=(boolean)true; diff --git a/subprojects/gst-editing-services/tests/validate/nle/ensure_no_unnecessary_stack_init_seeks/flow-expectations/log-source_L1-src-expected b/subprojects/gst-editing-services/tests/validate/nle/ensure_no_unnecessary_stack_init_seeks/flow-expectations/log-source_L1-src-expected new file mode 100644 index 0000000000..8dcc03ed50 --- /dev/null +++ b/subprojects/gst-editing-services/tests/validate/nle/ensure_no_unnecessary_stack_init_seeks/flow-expectations/log-source_L1-src-expected @@ -0,0 +1,14 @@ +event stream-start: GstEventStreamStart, flags=(GstStreamFlags)GST_STREAM_FLAG_NONE; +event caps: video/x-raw, format=(string)YUY2, framerate=(fraction)30/1, height=(int)240, interlace-mode=(string)progressive, multiview-mode=(string)mono, pixel-aspect-ratio=(fraction)1/1, width=(int)320; +event flush-start: (no structure) +event flush-stop: GstEventFlushStop, reset-time=(boolean)true; +event segment: format=TIME, start=0:00:00.200000000, offset=0:00:00.000000000, stop=0:00:00.400000000, flags=0x01, time=0:00:00.000000000, base=0:00:00.000000000, position=0:00:00.200000000 +buffer: content-id=0, pts=0:00:00.200000000, dur=0:00:00.033333333, flags=discont +buffer: content-id=1, pts=0:00:00.233333333, dur=0:00:00.033333333 +buffer: content-id=2, pts=0:00:00.266666666, dur=0:00:00.033333334 +buffer: content-id=3, pts=0:00:00.300000000, dur=0:00:00.033333333 +buffer: content-id=4, pts=0:00:00.333333333, dur=0:00:00.033333333 +buffer: content-id=5, pts=0:00:00.366666666, dur=0:00:00.033333334 +event eos: (no structure) +event flush-start: (no structure) +event flush-stop: GstEventFlushStop, reset-time=(boolean)true; diff --git a/subprojects/gst-editing-services/tests/validate/nle/ensure_no_unnecessary_stack_init_seeks/flow-expectations/log-source_L2-src-expected b/subprojects/gst-editing-services/tests/validate/nle/ensure_no_unnecessary_stack_init_seeks/flow-expectations/log-source_L2-src-expected new file mode 100644 index 0000000000..8dcc03ed50 --- /dev/null +++ b/subprojects/gst-editing-services/tests/validate/nle/ensure_no_unnecessary_stack_init_seeks/flow-expectations/log-source_L2-src-expected @@ -0,0 +1,14 @@ +event stream-start: GstEventStreamStart, flags=(GstStreamFlags)GST_STREAM_FLAG_NONE; +event caps: video/x-raw, format=(string)YUY2, framerate=(fraction)30/1, height=(int)240, interlace-mode=(string)progressive, multiview-mode=(string)mono, pixel-aspect-ratio=(fraction)1/1, width=(int)320; +event flush-start: (no structure) +event flush-stop: GstEventFlushStop, reset-time=(boolean)true; +event segment: format=TIME, start=0:00:00.200000000, offset=0:00:00.000000000, stop=0:00:00.400000000, flags=0x01, time=0:00:00.000000000, base=0:00:00.000000000, position=0:00:00.200000000 +buffer: content-id=0, pts=0:00:00.200000000, dur=0:00:00.033333333, flags=discont +buffer: content-id=1, pts=0:00:00.233333333, dur=0:00:00.033333333 +buffer: content-id=2, pts=0:00:00.266666666, dur=0:00:00.033333334 +buffer: content-id=3, pts=0:00:00.300000000, dur=0:00:00.033333333 +buffer: content-id=4, pts=0:00:00.333333333, dur=0:00:00.033333333 +buffer: content-id=5, pts=0:00:00.366666666, dur=0:00:00.033333334 +event eos: (no structure) +event flush-start: (no structure) +event flush-stop: GstEventFlushStop, reset-time=(boolean)true; diff --git a/subprojects/gst-editing-services/tests/validate/nle/ensure_no_unnecessary_stack_init_seeks/flow-expectations/log-source_L3-src-expected b/subprojects/gst-editing-services/tests/validate/nle/ensure_no_unnecessary_stack_init_seeks/flow-expectations/log-source_L3-src-expected new file mode 100644 index 0000000000..2d7c2b806b --- /dev/null +++ b/subprojects/gst-editing-services/tests/validate/nle/ensure_no_unnecessary_stack_init_seeks/flow-expectations/log-source_L3-src-expected @@ -0,0 +1,14 @@ +event stream-start: GstEventStreamStart, flags=(GstStreamFlags)GST_STREAM_FLAG_NONE, group-id=(uint)1; +event caps: video/x-raw, format=(string)YUY2, framerate=(fraction)30/1, height=(int)240, interlace-mode=(string)progressive, multiview-mode=(string)mono, pixel-aspect-ratio=(fraction)1/1, width=(int)320; +event flush-start: (no structure) +event flush-stop: GstEventFlushStop, reset-time=(boolean)true; +event segment: format=TIME, start=0:00:00.200000000, offset=0:00:00.000000000, stop=0:00:00.400000000, flags=0x01, time=0:00:00.000000000, base=0:00:00.000000000, position=0:00:00.200000000 +buffer: content-id=0, pts=0:00:00.200000000, dur=0:00:00.033333333, flags=discont +buffer: content-id=1, pts=0:00:00.233333333, dur=0:00:00.033333333 +buffer: content-id=2, pts=0:00:00.266666666, dur=0:00:00.033333334 +buffer: content-id=3, pts=0:00:00.300000000, dur=0:00:00.033333333 +buffer: content-id=4, pts=0:00:00.333333333, dur=0:00:00.033333333 +buffer: content-id=5, pts=0:00:00.366666666, dur=0:00:00.033333334 +event eos: (no structure) +event flush-start: (no structure) +event flush-stop: GstEventFlushStop, reset-time=(boolean)true;