mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 17:20:36 +00:00
rtpgstdepay: Only store the current caps and drop old caps immediately
Otherwise it can happen that we already collected 7 caps, miss the 8th caps packet (packet loss) and then re-use the 1st caps for the following buffers instead of the 8th caps which will likely cause errors further downstream unless both caps are accidentally the same. Keeping old caps around does not seem to have any value other than potentially causing errors. We would always receive new caps whenever they change (even if they were previous ones) and it's very unlikely that they happen to be exactly the same as the previous ones. Also after having received new caps or a buffer with a next caps version, no buffers with old caps version will arrive anymore.
This commit is contained in:
parent
53b3f2ddbb
commit
44a697deba
2 changed files with 12 additions and 34 deletions
|
@ -116,31 +116,13 @@ gst_rtp_gst_depay_finalize (GObject * object)
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
store_cache (GstRtpGSTDepay * rtpgstdepay, guint CV, GstCaps * caps)
|
|
||||||
{
|
|
||||||
gboolean changed = FALSE;
|
|
||||||
|
|
||||||
if (caps && rtpgstdepay->CV_cache[CV])
|
|
||||||
changed = !gst_caps_is_strictly_equal (caps, rtpgstdepay->CV_cache[CV]);
|
|
||||||
|
|
||||||
if (rtpgstdepay->CV_cache[CV])
|
|
||||||
gst_caps_unref (rtpgstdepay->CV_cache[CV]);
|
|
||||||
rtpgstdepay->CV_cache[CV] = caps;
|
|
||||||
|
|
||||||
return changed;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_rtp_gst_depay_reset (GstRtpGSTDepay * rtpgstdepay, gboolean full)
|
gst_rtp_gst_depay_reset (GstRtpGSTDepay * rtpgstdepay, gboolean full)
|
||||||
{
|
{
|
||||||
guint i;
|
|
||||||
|
|
||||||
gst_adapter_clear (rtpgstdepay->adapter);
|
gst_adapter_clear (rtpgstdepay->adapter);
|
||||||
if (full) {
|
if (full) {
|
||||||
rtpgstdepay->current_CV = 0;
|
rtpgstdepay->current_CV = 0;
|
||||||
for (i = 0; i < 8; i++)
|
gst_caps_replace (&rtpgstdepay->current_caps, NULL);
|
||||||
store_cache (rtpgstdepay, i, NULL);
|
|
||||||
g_free (rtpgstdepay->stream_id);
|
g_free (rtpgstdepay->stream_id);
|
||||||
rtpgstdepay->stream_id = NULL;
|
rtpgstdepay->stream_id = NULL;
|
||||||
if (rtpgstdepay->tags)
|
if (rtpgstdepay->tags)
|
||||||
|
@ -189,14 +171,14 @@ gst_rtp_gst_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
||||||
}
|
}
|
||||||
/* store in cache */
|
/* store in cache */
|
||||||
rtpgstdepay->current_CV = CV;
|
rtpgstdepay->current_CV = CV;
|
||||||
gst_caps_ref (outcaps);
|
gst_caps_replace (&rtpgstdepay->current_caps, outcaps);
|
||||||
store_cache (rtpgstdepay, CV, outcaps);
|
|
||||||
|
|
||||||
res = gst_pad_set_caps (depayload->srcpad, outcaps);
|
res = gst_pad_set_caps (depayload->srcpad, outcaps);
|
||||||
gst_caps_unref (outcaps);
|
gst_caps_unref (outcaps);
|
||||||
} else {
|
} else {
|
||||||
GST_WARNING_OBJECT (depayload, "no caps given");
|
GST_WARNING_OBJECT (depayload, "no caps given");
|
||||||
rtpgstdepay->current_CV = -1;
|
rtpgstdepay->current_CV = -1;
|
||||||
|
gst_caps_replace (&rtpgstdepay->current_caps, NULL);
|
||||||
res = TRUE;
|
res = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -471,8 +453,12 @@ gst_rtp_gst_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
|
||||||
GST_DEBUG_OBJECT (rtpgstdepay,
|
GST_DEBUG_OBJECT (rtpgstdepay,
|
||||||
"inline caps %u, length %u, %" GST_PTR_FORMAT, CV, size, outcaps);
|
"inline caps %u, length %u, %" GST_PTR_FORMAT, CV, size, outcaps);
|
||||||
|
|
||||||
if (store_cache (rtpgstdepay, CV, outcaps))
|
if (!rtpgstdepay->current_caps
|
||||||
|
|| !gst_caps_is_strictly_equal (rtpgstdepay->current_caps, outcaps))
|
||||||
gst_pad_set_caps (depayload->srcpad, outcaps);
|
gst_pad_set_caps (depayload->srcpad, outcaps);
|
||||||
|
gst_caps_replace (&rtpgstdepay->current_caps, outcaps);
|
||||||
|
gst_caps_unref (outcaps);
|
||||||
|
rtpgstdepay->current_CV = CV;
|
||||||
|
|
||||||
/* skip caps */
|
/* skip caps */
|
||||||
offset += size;
|
offset += size;
|
||||||
|
@ -512,17 +498,9 @@ gst_rtp_gst_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
|
||||||
|
|
||||||
/* see what caps we need */
|
/* see what caps we need */
|
||||||
if (CV != rtpgstdepay->current_CV) {
|
if (CV != rtpgstdepay->current_CV) {
|
||||||
/* we need to switch caps, check if we have the caps */
|
/* we need to switch caps but didn't receive the new caps yet */
|
||||||
if ((outcaps = rtpgstdepay->CV_cache[CV]) == NULL)
|
gst_caps_replace (&rtpgstdepay->current_caps, NULL);
|
||||||
goto missing_caps;
|
goto missing_caps;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (rtpgstdepay,
|
|
||||||
"need caps switch from %u to %u, %" GST_PTR_FORMAT,
|
|
||||||
rtpgstdepay->current_CV, CV, outcaps);
|
|
||||||
|
|
||||||
/* and set caps */
|
|
||||||
if (gst_pad_set_caps (depayload->srcpad, outcaps))
|
|
||||||
rtpgstdepay->current_CV = CV;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (payload[0] & 0x8)
|
if (payload[0] & 0x8)
|
||||||
|
|
|
@ -46,7 +46,7 @@ struct _GstRtpGSTDepay
|
||||||
|
|
||||||
GstAdapter *adapter;
|
GstAdapter *adapter;
|
||||||
guint current_CV;
|
guint current_CV;
|
||||||
GstCaps *CV_cache[8];
|
GstCaps *current_caps;
|
||||||
|
|
||||||
GstTagList *tags;
|
GstTagList *tags;
|
||||||
gchar *stream_id;
|
gchar *stream_id;
|
||||||
|
|
Loading…
Reference in a new issue