ristrtpext: Update RTP header extension packet to latest spec

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1153>
This commit is contained in:
Olivier Crête 2020-03-18 17:14:14 -04:00 committed by Olivier Crête
parent 03a60a47b5
commit a602eb7eea
2 changed files with 25 additions and 23 deletions

View file

@ -95,9 +95,10 @@ gst_rist_rtp_ext_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
gboolean drop_null = self->drop_null;
gboolean ts_packet_size = 0;
guint ts_packet_count = 0;
guint16 bits = 0;
guint8 npd_bits = 0;
gboolean num_packets_deleted = 0;
guint8 *data;
guint wordlen;
if (!self->drop_null && !self->add_seqnumext)
return gst_pad_push (self->srcpad, buffer);
@ -173,20 +174,19 @@ gst_rist_rtp_ext_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
goto error_mapped;
}
bits = 0;
bits |= drop_null << 15; /* N */
bits |= self->add_seqnumext << 14; /* E */
if (ts_packet_count <= 7)
bits |= (ts_packet_count & 7) << 10; /* Size */
bits |= (ts_packet_size == 204) << 7; /* T */
bits |= (npd_bits & 0x7F);
gst_rtp_buffer_set_extension (&rtp, TRUE);
gst_rtp_buffer_set_extension_data (&rtp, bits, self->add_seqnumext ? 1 : 0);
gst_rtp_buffer_set_extension_data (&rtp, 'R' << 8 | 'I', 1);
gst_rtp_buffer_get_extension_data (&rtp, NULL, (void **) &data, &wordlen);
data[0] = drop_null << 7;
data[0] |= self->add_seqnumext << 6;
if (ts_packet_count <= 7)
data[0] |= (ts_packet_count & 7) << 3; /* Size */
data[1] = (ts_packet_size == 204) << 7;
data[1] |= (npd_bits & 0x7F);
if (self->add_seqnumext) {
guint8 *data;
guint wordlen;
guint16 seqnum = gst_rtp_buffer_get_seq (&rtp);
guint32 extseqnum;
@ -195,9 +195,7 @@ gst_rist_rtp_ext_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
extseqnum = gst_rist_rtp_ext_seq (&self->extseqnum, seqnum);
gst_rtp_buffer_get_extension_data (&rtp, &bits, (void **) &data, &wordlen);
GST_WRITE_UINT16_BE (data, (extseqnum >> 16));
data[2] = data[3] = 0;
GST_WRITE_UINT16_BE (data + 2, (extseqnum >> 16));
}
gst_rtp_buffer_unmap (&rtp);

View file

@ -120,16 +120,22 @@ validate_ext (GstRTPBuffer * rtp, gboolean wanted_has_drop_null,
gboolean has_drop_null;
guint orig_ts_packet_count;
gboolean ts_packet_size;
guint8 *data;
guint8 npd_bits;
fail_unless (gst_rtp_buffer_get_extension_data (rtp, &bits, &extdata,
&extlen));
has_drop_null = (bits >> 15) & 1; /* N */
has_seqnum_ext = (bits >> 14) & 1; /* E */
orig_ts_packet_count = (bits >> 10) & 7; /* Size */
ts_packet_size = ((bits >> 7) & 1) ? 204 : 188;
npd_bits = bits & 0x7F;
fail_unless_equals_int (bits, 'R' << 8 | 'I');
fail_unless (extlen == 1);
data = extdata;
has_drop_null = (data[0] >> 7) & 1; /* N */
has_seqnum_ext = (data[0] >> 6) & 1; /* E */
orig_ts_packet_count = (data[0] >> 3) & 7; /* Size */
ts_packet_size = ((data[1] >> 7) & 1) ? 204 : 188;
npd_bits = data[1] & 0x7F;
fail_unless_equals_int (has_drop_null, wanted_has_drop_null);
fail_unless_equals_int (has_seqnum_ext, wanted_has_seqnum_ext);
@ -140,9 +146,7 @@ validate_ext (GstRTPBuffer * rtp, gboolean wanted_has_drop_null,
if (wanted_has_seqnum_ext) {
guint16 ext;
fail_unless (extlen == 1);
ext = GST_READ_UINT16_BE (extdata);
ext = GST_READ_UINT16_BE (data + 2);
fail_unless_equals_int (ext, wanted_ext);
}
}