rtptwcc: don't assume all PacketInfo->data are buffers
authorMathieu Duponchelle <mathieu@centricular.com>
Fri, 29 Oct 2021 01:46:25 +0000 (03:46 +0200)
committerMathieu Duponchelle <mathieu@centricular.com>
Fri, 29 Oct 2021 01:46:25 +0000 (03:46 +0200)
They can also be buffer lists

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1268>

subprojects/gst-plugins-good/gst/rtpmanager/rtptwcc.c

index 691428c..f843465 100644 (file)
@@ -272,10 +272,27 @@ static guint16
 rtp_twcc_manager_set_send_twcc_seqnum (RTPTWCCManager * twcc,
     RTPPacketInfo * pinfo)
 {
-  guint16 seqnum = twcc->send_seqnum++;
-  pinfo->data = gst_buffer_make_writable (pinfo->data);
-  _set_twcc_seqnum_data (pinfo->data, twcc->send_ext_id, seqnum);
-  return seqnum;
+  guint16 first_seqnum = twcc->send_seqnum;
+
+  if (GST_IS_BUFFER_LIST (pinfo->data)) {
+    GstBufferList *list;
+    guint i = 0;
+
+    pinfo->data = gst_buffer_list_make_writable (pinfo->data);
+
+    list = GST_BUFFER_LIST (pinfo->data);
+
+    for (i = 0; i < gst_buffer_list_length (list); i++) {
+      GstBuffer *buffer = gst_buffer_list_get_writable (list, i);
+
+      _set_twcc_seqnum_data (buffer, twcc->send_ext_id, twcc->send_seqnum++);
+    }
+  } else {
+    pinfo->data = gst_buffer_make_writable (pinfo->data);
+    _set_twcc_seqnum_data (pinfo->data, twcc->send_ext_id, twcc->send_seqnum++);
+  }
+
+  return first_seqnum;
 }
 
 static gint32