From a602eb7eeaca77acb7b7b240c2ff307071ea7d05 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Olivier=20Cr=C3=AAte?= Date: Wed, 18 Mar 2020 17:14:14 -0400 Subject: [PATCH] ristrtpext: Update RTP header extension packet to latest spec Part-of: --- gst/rist/gstristrtpext.c | 26 ++++++++++++-------------- tests/check/elements/ristrtpext.c | 20 ++++++++++++-------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/gst/rist/gstristrtpext.c b/gst/rist/gstristrtpext.c index 29775de..42b2993 100644 --- a/gst/rist/gstristrtpext.c +++ b/gst/rist/gstristrtpext.c @@ -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 */ + gst_rtp_buffer_set_extension (&rtp, TRUE); + 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) - bits |= (ts_packet_count & 7) << 10; /* Size */ - bits |= (ts_packet_size == 204) << 7; /* T */ - bits |= (npd_bits & 0x7F); + data[0] |= (ts_packet_count & 7) << 3; /* Size */ - gst_rtp_buffer_set_extension (&rtp, TRUE); - gst_rtp_buffer_set_extension_data (&rtp, bits, self->add_seqnumext ? 1 : 0); + 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); diff --git a/tests/check/elements/ristrtpext.c b/tests/check/elements/ristrtpext.c index 3022c8d..7cd6540 100644 --- a/tests/check/elements/ristrtpext.c +++ b/tests/check/elements/ristrtpext.c @@ -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); } } -- 2.7.4