From a6fa53b7b1150585a0927d64f12fd0f7c204e167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Brzezi=C5=84ski?= Date: Wed, 18 Sep 2024 12:34:39 +0200 Subject: [PATCH] rtppassthroughpay: Fix reading clock-rate and payload type from caps They were using wrong types - while uint is correct technically, for compatibility reasons caps have them as signed int. Values are now correctly read + added simple guards just to be sure. Part-of: --- .../gst-plugins-good/docs/gst_plugins_cache.json | 2 +- .../gst-plugins-good/gst/rtp/gstrtppassthroughpay.c | 12 ++++++++---- .../gst-plugins-good/gst/rtp/gstrtppassthroughpay.h | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/subprojects/gst-plugins-good/docs/gst_plugins_cache.json b/subprojects/gst-plugins-good/docs/gst_plugins_cache.json index 15e9d92f9e..6655e2a11a 100644 --- a/subprojects/gst-plugins-good/docs/gst_plugins_cache.json +++ b/subprojects/gst-plugins-good/docs/gst_plugins_cache.json @@ -16344,7 +16344,7 @@ "construct": false, "construct-only": false, "controllable": false, - "default": "application/x-rtp-payload-stats, clock-rate=(uint)0, running-time=(guint64)0, seqnum=(uint)0, timestamp=(uint)0, ssrc=(uint)0, pt=(uint)128, seqnum-offset=(uint)0, timestamp-offset=(uint)0;", + "default": "application/x-rtp-payload-stats, clock-rate=(int)0, running-time=(guint64)0, seqnum=(uint)0, timestamp=(uint)0, ssrc=(uint)0, pt=(int)128, seqnum-offset=(uint)0, timestamp-offset=(uint)0;", "mutable": "null", "readable": true, "type": "GstStructure", diff --git a/subprojects/gst-plugins-good/gst/rtp/gstrtppassthroughpay.c b/subprojects/gst-plugins-good/gst/rtp/gstrtppassthroughpay.c index c53105e1b8..48514ff20f 100644 --- a/subprojects/gst-plugins-good/gst/rtp/gstrtppassthroughpay.c +++ b/subprojects/gst-plugins-good/gst/rtp/gstrtppassthroughpay.c @@ -502,8 +502,12 @@ gst_rtp_passthrough_pay_sink_event (GstPad * pad, s = gst_caps_get_structure (caps, 0); - gst_structure_get_uint (s, "payload", &self->pt); - gst_structure_get_uint (s, "clock-rate", &self->clock_rate); + if (!self->pt_override + && !gst_structure_get_int (s, "payload", &self->pt)) { + GST_WARNING_OBJECT (self, "Caps are missing payload type!"); + } + if (!gst_structure_get_int (s, "clock-rate", &self->clock_rate)) + GST_WARNING_OBJECT (self, "Caps are missing clock-rate!"); if (gst_structure_get_uint (s, "ssrc", &self->ssrc)) self->ssrc_set = TRUE; if (gst_structure_get_uint (s, "clock-base", &self->timestamp_offset)) @@ -551,10 +555,10 @@ gst_rtp_passthrough_pay_create_stats (GstRtpPassthroughPay * self) } return gst_structure_new ("application/x-rtp-payload-stats", "clock-rate", - G_TYPE_UINT, (guint) self->clock_rate, "running-time", G_TYPE_UINT64, + G_TYPE_INT, self->clock_rate, "running-time", G_TYPE_UINT64, running_time, "seqnum", G_TYPE_UINT, (guint) self->seqnum, "timestamp", G_TYPE_UINT, (guint) self->timestamp, "ssrc", G_TYPE_UINT, self->ssrc, - "pt", G_TYPE_UINT, self->pt, "seqnum-offset", G_TYPE_UINT, + "pt", G_TYPE_INT, self->pt, "seqnum-offset", G_TYPE_UINT, (guint) self->seqnum_offset, "timestamp-offset", G_TYPE_UINT, (guint) self->timestamp_offset, NULL); diff --git a/subprojects/gst-plugins-good/gst/rtp/gstrtppassthroughpay.h b/subprojects/gst-plugins-good/gst/rtp/gstrtppassthroughpay.h index 52601401b6..9ecd4f2ccc 100644 --- a/subprojects/gst-plugins-good/gst/rtp/gstrtppassthroughpay.h +++ b/subprojects/gst-plugins-good/gst/rtp/gstrtppassthroughpay.h @@ -66,8 +66,8 @@ struct _GstRtpPassthroughPay GstCaps *caps; GstSegment segment; - guint clock_rate; - guint pt; + gint clock_rate; + gint pt; gboolean pt_override; guint ssrc; gboolean ssrc_set;