From 5490189b9b4dd0ece075ee6fb4785bf90c2dd67a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Piotrek=20Brzezi=C5=84ski?= Date: Wed, 25 May 2022 13:00:58 +0200 Subject: [PATCH] cutter: Include running/stream-time in messages Part-of: --- .../gst-plugins-good/gst/cutter/gstcutter.c | 25 ++++++++++++++++++++-- .../gst-plugins-good/gst/cutter/gstcutter.h | 1 + 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-good/gst/cutter/gstcutter.c b/subprojects/gst-plugins-good/gst/cutter/gstcutter.c index aa1424f..760a9c9 100644 --- a/subprojects/gst-plugins-good/gst/cutter/gstcutter.c +++ b/subprojects/gst-plugins-good/gst/cutter/gstcutter.c @@ -26,9 +26,11 @@ * silence is signalled by bus messages named * `cutter`. * - * The message's structure contains two fields: + * The message's structure contains these fields: * * * #GstClockTime `timestamp`: the timestamp of the buffer that triggered the message. + * * #GstClockTime `stream-time`: the stream time of the buffer. + * * #GstClockTime `running-time`: the running time of the buffer. * * gboolean `above`: %TRUE for begin of silence and %FALSE for end of silence. * * ## Example launch line @@ -161,6 +163,8 @@ gst_cutter_init (GstCutter * filter) gst_pad_use_fixed_caps (filter->srcpad); gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad); + gst_segment_init (&filter->segment, GST_FORMAT_UNDEFINED); + filter->threshold_level = CUTTER_DEFAULT_THRESHOLD_LEVEL; filter->threshold_length = CUTTER_DEFAULT_THRESHOLD_LENGTH; filter->silent_run_length = 0 * GST_SECOND; @@ -177,10 +181,18 @@ static GstMessage * gst_cutter_message_new (GstCutter * c, gboolean above, GstClockTime timestamp) { GstStructure *s; + GstClockTime running_time, stream_time; + + running_time = gst_segment_to_running_time (&c->segment, GST_FORMAT_TIME, + timestamp); + stream_time = gst_segment_to_stream_time (&c->segment, GST_FORMAT_TIME, + timestamp); s = gst_structure_new ("cutter", "above", G_TYPE_BOOLEAN, above, - "timestamp", GST_TYPE_CLOCK_TIME, timestamp, NULL); + "timestamp", G_TYPE_UINT64, timestamp, + "stream-time", G_TYPE_UINT64, stream_time, + "running-time", G_TYPE_UINT64, running_time, NULL); return gst_message_new_element (GST_OBJECT (c), s); } @@ -265,6 +277,15 @@ gst_cutter_event (GstPad * pad, GstObject * parent, GstEvent * event) gst_event_unref (event); break; } + case GST_EVENT_SEGMENT: + { + const GstSegment *segment; + + gst_event_parse_segment (event, &segment); + gst_segment_copy_into (segment, &filter->segment); + ret = gst_pad_event_default (pad, parent, event); + break; + } default: ret = gst_pad_event_default (pad, parent, event); break; diff --git a/subprojects/gst-plugins-good/gst/cutter/gstcutter.h b/subprojects/gst-plugins-good/gst/cutter/gstcutter.h index 31c135b..3167cea 100644 --- a/subprojects/gst-plugins-good/gst/cutter/gstcutter.h +++ b/subprojects/gst-plugins-good/gst/cutter/gstcutter.h @@ -64,6 +64,7 @@ struct _GstCutter gboolean leaky; /* do we leak an overflowing prebuffer ? */ GstAudioInfo info; + GstSegment segment; }; struct _GstCutterClass -- 2.7.4