From 1bd5b7356df1fcc819ce277763cb2948bc6ef448 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Thu, 27 Jan 2022 23:54:34 +0900 Subject: [PATCH] fakevideosink,fakeaudiosink: Proxy handoff and preroll-handoff signals Proxy signals for application to be able to consume them Part-of: --- .../docs/plugins/gst_plugins_cache.json | 64 ++++++++++++++++++++- .../gst/debugutils/gstfakeaudiosink.c | 63 ++++++++++++++++++++- .../gst/debugutils/gstfakeaudiosink.h | 5 ++ .../gst/debugutils/gstfakevideosink.c | 65 +++++++++++++++++++++- .../gst/debugutils/gstfakevideosink.h | 5 ++ 5 files changed, 198 insertions(+), 4 deletions(-) diff --git a/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json b/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json index 9332d2c..7294e09 100644 --- a/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json +++ b/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json @@ -9794,7 +9794,37 @@ "writable": true } }, - "rank": "none" + "rank": "none", + "signals": { + "handoff": { + "args": [ + { + "name": "arg0", + "type": "GstBuffer" + }, + { + "name": "arg1", + "type": "GstPad" + } + ], + "return-type": "void", + "when": "last" + }, + "preroll-handoff": { + "args": [ + { + "name": "arg0", + "type": "GstBuffer" + }, + { + "name": "arg1", + "type": "GstPad" + } + ], + "return-type": "void", + "when": "last" + } + } }, "fakevideosink": { "author": "Nicolas Dufresne ", @@ -10112,7 +10142,37 @@ "writable": true } }, - "rank": "none" + "rank": "none", + "signals": { + "handoff": { + "args": [ + { + "name": "arg0", + "type": "GstBuffer" + }, + { + "name": "arg1", + "type": "GstPad" + } + ], + "return-type": "void", + "when": "last" + }, + "preroll-handoff": { + "args": [ + { + "name": "arg0", + "type": "GstBuffer" + }, + { + "name": "arg1", + "type": "GstPad" + } + ], + "return-type": "void", + "when": "last" + } + } }, "fpsdisplaysink": { "author": "Zeeshan Ali , Stefan Kost ", diff --git a/subprojects/gst-plugins-bad/gst/debugutils/gstfakeaudiosink.c b/subprojects/gst-plugins-bad/gst/debugutils/gstfakeaudiosink.c index 5b962a2..1493965 100644 --- a/subprojects/gst-plugins-bad/gst/debugutils/gstfakeaudiosink.c +++ b/subprojects/gst-plugins-bad/gst/debugutils/gstfakeaudiosink.c @@ -51,6 +51,14 @@ enum PROP_LAST }; +enum +{ + SIGNAL_HANDOFF, + SIGNAL_PREROLL_HANDOFF, + LAST_SIGNAL +}; + +static guint gst_fake_audio_sink_signals[LAST_SIGNAL] = { 0 }; static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, @@ -75,6 +83,22 @@ gst_fake_audio_sink_proxy_properties (GstFakeAudioSink * self, } static void +gst_fake_audio_sink_proxy_handoff (GstElement * element, GstBuffer * buffer, + GstPad * pad, GstFakeAudioSink * self) +{ + g_signal_emit (self, gst_fake_audio_sink_signals[SIGNAL_HANDOFF], 0, + buffer, self->sinkpad); +} + +static void +gst_fake_audio_sink_proxy_preroll_handoff (GstElement * element, + GstBuffer * buffer, GstPad * pad, GstFakeAudioSink * self) +{ + g_signal_emit (self, gst_fake_audio_sink_signals[SIGNAL_PREROLL_HANDOFF], 0, + buffer, self->sinkpad); +} + +static void gst_fake_audio_sink_init (GstFakeAudioSink * self) { GstElement *child; @@ -94,7 +118,8 @@ gst_fake_audio_sink_init (GstFakeAudioSink * self) gst_bin_add (GST_BIN_CAST (self), child); - ghost_pad = gst_ghost_pad_new_from_template ("sink", sink_pad, template); + self->sinkpad = ghost_pad = + gst_ghost_pad_new_from_template ("sink", sink_pad, template); gst_object_unref (template); gst_element_add_pad (GST_ELEMENT_CAST (self), ghost_pad); gst_object_unref (sink_pad); @@ -102,6 +127,10 @@ gst_fake_audio_sink_init (GstFakeAudioSink * self) self->child = child; gst_fake_audio_sink_proxy_properties (self, child); + g_signal_connect (child, "handoff", + G_CALLBACK (gst_fake_audio_sink_proxy_handoff), self); + g_signal_connect (child, "preroll-handoff", + G_CALLBACK (gst_fake_audio_sink_proxy_preroll_handoff), self); } else { g_warning ("Check your GStreamer installation, " "core element 'fakesink' is missing."); @@ -180,6 +209,38 @@ gst_fake_audio_sink_class_init (GstFakeAudioSinkClass * klass) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /** + * GstFakeAudioSink::handoff: + * @fakeaudiosink: the fakeaudiosink instance + * @buffer: the buffer that just has been received + * @pad: the pad that received it + * + * This signal gets emitted before unreffing the buffer. + * + * Since: 1.22 + */ + gst_fake_audio_sink_signals[SIGNAL_HANDOFF] = + g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstFakeAudioSinkClass, handoff), NULL, NULL, + NULL, G_TYPE_NONE, 2, GST_TYPE_BUFFER | G_SIGNAL_TYPE_STATIC_SCOPE, + GST_TYPE_PAD); + + /** + * GstFakeAudioSink::preroll-handoff: + * @fakeaudiosink: the fakeaudiosink instance + * @buffer: the buffer that just has been received + * @pad: the pad that received it + * + * This signal gets emitted before unreffing the buffer. + * + * Since: 1.22 + */ + gst_fake_audio_sink_signals[SIGNAL_PREROLL_HANDOFF] = + g_signal_new ("preroll-handoff", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstFakeAudioSinkClass, + preroll_handoff), NULL, NULL, NULL, G_TYPE_NONE, 2, + GST_TYPE_BUFFER | G_SIGNAL_TYPE_STATIC_SCOPE, GST_TYPE_PAD); + gst_element_class_add_static_pad_template (element_class, &sink_factory); gst_element_class_set_static_metadata (element_class, "Fake Audio Sink", "Audio/Sink", "Fake audio renderer", diff --git a/subprojects/gst-plugins-bad/gst/debugutils/gstfakeaudiosink.h b/subprojects/gst-plugins-bad/gst/debugutils/gstfakeaudiosink.h index 8fd70d9..bdb0e67 100644 --- a/subprojects/gst-plugins-bad/gst/debugutils/gstfakeaudiosink.h +++ b/subprojects/gst-plugins-bad/gst/debugutils/gstfakeaudiosink.h @@ -47,6 +47,7 @@ struct _GstFakeAudioSink { GstBin parent; GstElement *child; + GstPad *sinkpad; gdouble volume; gboolean mute; }; @@ -54,6 +55,10 @@ struct _GstFakeAudioSink struct _GstFakeAudioSinkClass { GstBinClass parent; + + /* signals */ + void (*handoff) (GstElement *element, GstBuffer *buf, GstPad *pad); + void (*preroll_handoff) (GstElement *element, GstBuffer *buf, GstPad *pad); }; GType gst_fake_audio_sink_get_type (void); diff --git a/subprojects/gst-plugins-bad/gst/debugutils/gstfakevideosink.c b/subprojects/gst-plugins-bad/gst/debugutils/gstfakevideosink.c index 571c20a..4e47e69 100644 --- a/subprojects/gst-plugins-bad/gst/debugutils/gstfakevideosink.c +++ b/subprojects/gst-plugins-bad/gst/debugutils/gstfakevideosink.c @@ -77,6 +77,15 @@ enum PROP_LAST }; +enum +{ + SIGNAL_HANDOFF, + SIGNAL_PREROLL_HANDOFF, + LAST_SIGNAL +}; + +static guint gst_fake_video_sink_signals[LAST_SIGNAL] = { 0 }; + #define ALLOCATION_META_DEFAULT_FLAGS GST_ALLOCATION_FLAG_CROP_META | GST_ALLOCATION_FLAG_OVERLAY_COMPOSITION_META static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink", @@ -140,6 +149,22 @@ gst_fake_video_sink_proxy_properties (GstFakeVideoSink * self, } static void +gst_fake_video_sink_proxy_handoff (GstElement * element, GstBuffer * buffer, + GstPad * pad, GstFakeVideoSink * self) +{ + g_signal_emit (self, gst_fake_video_sink_signals[SIGNAL_HANDOFF], 0, + buffer, self->sinkpad); +} + +static void +gst_fake_video_sink_proxy_preroll_handoff (GstElement * element, + GstBuffer * buffer, GstPad * pad, GstFakeVideoSink * self) +{ + g_signal_emit (self, gst_fake_video_sink_signals[SIGNAL_PREROLL_HANDOFF], 0, + buffer, self->sinkpad); +} + +static void gst_fake_video_sink_init (GstFakeVideoSink * self) { GstElement *child; @@ -160,7 +185,8 @@ gst_fake_video_sink_init (GstFakeVideoSink * self) gst_bin_add (GST_BIN (self), child); - ghost_pad = gst_ghost_pad_new_from_template ("sink", sink_pad, template); + self->sinkpad = ghost_pad = + gst_ghost_pad_new_from_template ("sink", sink_pad, template); gst_object_unref (template); gst_element_add_pad (GST_ELEMENT (self), ghost_pad); gst_object_unref (sink_pad); @@ -170,6 +196,10 @@ gst_fake_video_sink_init (GstFakeVideoSink * self) self->child = child; gst_fake_video_sink_proxy_properties (self, child); + g_signal_connect (child, "handoff", + G_CALLBACK (gst_fake_video_sink_proxy_handoff), self); + g_signal_connect (child, "preroll-handoff", + G_CALLBACK (gst_fake_video_sink_proxy_preroll_handoff), self); } else { g_warning ("Check your GStreamer installation, " "core element 'fakesink' is missing."); @@ -240,6 +270,39 @@ gst_fake_video_sink_class_init (GstFakeVideoSinkClass * klass) ALLOCATION_META_DEFAULT_FLAGS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + /** + * GstFakeVideoSink::handoff: + * @fakevideosink: the fakevideosink instance + * @buffer: the buffer that just has been received + * @pad: the pad that received it + * + * This signal gets emitted before unreffing the buffer. + * + * Since: 1.22 + */ + gst_fake_video_sink_signals[SIGNAL_HANDOFF] = + g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstFakeVideoSinkClass, handoff), NULL, NULL, + NULL, G_TYPE_NONE, 2, GST_TYPE_BUFFER | G_SIGNAL_TYPE_STATIC_SCOPE, + GST_TYPE_PAD); + + /** + * GstFakeVideoSink::preroll-handoff: + * @fakevideosink: the fakevideosink instance + * @buffer: the buffer that just has been received + * @pad: the pad that received it + * + * This signal gets emitted before unreffing the buffer. + * + * Since: 1.22 + */ + gst_fake_video_sink_signals[SIGNAL_PREROLL_HANDOFF] = + g_signal_new ("preroll-handoff", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstFakeVideoSinkClass, + preroll_handoff), NULL, NULL, NULL, G_TYPE_NONE, 2, + GST_TYPE_BUFFER | G_SIGNAL_TYPE_STATIC_SCOPE, GST_TYPE_PAD); + gst_type_mark_as_plugin_api (GST_TYPE_FAKE_VIDEO_SINK_ALLOCATION_META_FLAGS, 0); } diff --git a/subprojects/gst-plugins-bad/gst/debugutils/gstfakevideosink.h b/subprojects/gst-plugins-bad/gst/debugutils/gstfakevideosink.h index 688b534..b5bcfd7 100644 --- a/subprojects/gst-plugins-bad/gst/debugutils/gstfakevideosink.h +++ b/subprojects/gst-plugins-bad/gst/debugutils/gstfakevideosink.h @@ -65,11 +65,16 @@ struct _GstFakeVideoSink GstBin parent; GstElement *child; GstFakeVideoSinkAllocationMetaFlags allocation_meta_flags; + GstPad *sinkpad; }; struct _GstFakeVideoSinkClass { GstBinClass parent; + + /* signals */ + void (*handoff) (GstElement *element, GstBuffer *buf, GstPad *pad); + void (*preroll_handoff) (GstElement *element, GstBuffer *buf, GstPad *pad); }; GType gst_fake_video_sink_get_type (void); -- 2.7.4