rtsp-server: Fix test-onvif-client position calculations

The example was switched to use autovideosink, which broke
current position calculation based on the last video frame.

Add code to retrieve the actual video sink from within autovideosink
to make it work again.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8378>
This commit is contained in:
Jan Schmidt 2025-01-03 15:34:32 +11:00 committed by GStreamer Marge Bot
parent cf2dc2f94c
commit 4fee71907a

View File

@ -156,14 +156,43 @@ done:
return ret;
}
/* Retrieve the actual sink from inside an auto*sink */
static GstElement *
get_actual_sink (GstElement * autosink)
{
GstPad *sinkpad = gst_element_get_static_pad (autosink, "sink");
GstPad *actual_sinkpad = gst_ghost_pad_get_target (GST_GHOST_PAD (sinkpad));
gst_object_unref (GST_OBJECT (sinkpad));
if (actual_sinkpad == NULL) {
return NULL;
}
GstElement *actual_sink =
(GstElement *) gst_object_get_parent (GST_OBJECT (actual_sinkpad));
gst_object_unref (GST_OBJECT (actual_sinkpad));
return actual_sink;
}
static GstClockTime
get_current_position (Context * ctx, gboolean reverse)
{
GstSample *sample;
GstSample *sample = NULL;
GstBuffer *buffer;
GstClockTime ret;
g_object_get (ctx->sink, "last-sample", &sample, NULL);
GstElement *sink = get_actual_sink (ctx->sink);
if (sink == NULL) {
return 0;
}
g_object_get (sink, "last-sample", &sample, NULL);
gst_object_unref (sink);
if (sample == NULL) {
return 0;
}
buffer = gst_sample_get_buffer (sample);