mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
ristrtpdeext: 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:
parent
a602eb7eea
commit
f2e8d4dcf2
2 changed files with 38 additions and 33 deletions
|
@ -103,9 +103,9 @@ gst_rist_rtp_deext_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||
guint16 bits;
|
||||
guint8 npd_bits;
|
||||
guint8 num_packets_deleted;
|
||||
guint16 seqnumext_val = 0;
|
||||
guint extlen;
|
||||
gpointer extdata;
|
||||
gpointer extdata = NULL;
|
||||
guint8 *data = NULL;
|
||||
guint8 *payload;
|
||||
guint plen;
|
||||
guint i;
|
||||
|
@ -127,24 +127,32 @@ gst_rist_rtp_deext_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||
return gst_pad_push (self->srcpad, buffer);
|
||||
}
|
||||
|
||||
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;
|
||||
if (bits != ('R' << 8 | 'I')) {
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
GST_LOG_OBJECT (self, "Buffer %" GST_PTR_FORMAT
|
||||
" has an extension that's not the RIST one, ignoring", buffer);
|
||||
return gst_pad_push (self->srcpad, buffer);
|
||||
}
|
||||
|
||||
if (extlen != 1) {
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
GST_LOG_OBJECT (self, "Buffer %" GST_PTR_FORMAT
|
||||
" has a RIST extension that's not of length 1, ignoring", buffer);
|
||||
return gst_pad_push (self->srcpad, buffer);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
num_packets_deleted = bit_count (npd_bits);
|
||||
|
||||
if (has_seqnum_ext && extlen >= 1) {
|
||||
seqnumext_val = GST_READ_UINT16_BE (extdata);
|
||||
GST_LOG_OBJECT (self, "Seqnum ext is %d\n", seqnumext_val);
|
||||
} else if (has_seqnum_ext && extlen == 0) {
|
||||
GST_WARNING_OBJECT (self, "Has seqnum flag, but extension is too short");
|
||||
has_seqnum_ext = FALSE;
|
||||
seqnumext_val = 0;
|
||||
}
|
||||
|
||||
if (has_seqnum_ext) {
|
||||
guint16 seqnumext_val = GST_READ_UINT16_BE (data + 2);
|
||||
guint32 extseqnum = seqnumext_val << 16 | gst_rtp_buffer_get_seq (&rtp);
|
||||
|
||||
if (extseqnum < self->max_extseqnum &&
|
||||
|
|
|
@ -628,27 +628,24 @@ alloc_ts_buffer_with_ext (guint num_ts_packets, gboolean has_drop_null,
|
|||
GstBuffer *buf = alloc_ts_buffer (num_ts_packets);
|
||||
GstRTPBuffer rtp = GST_RTP_BUFFER_INIT;
|
||||
guint8 *payload;
|
||||
guint16 bits;
|
||||
guint8 *data;
|
||||
guint i;
|
||||
|
||||
bits = 0;
|
||||
bits |= has_drop_null << 15; /* N */
|
||||
bits |= has_seqnum_ext << 14; /* E */
|
||||
bits |= (MIN (orig_ts_packet_count, 7) & 7) << 10; /* Size */
|
||||
bits |= (ts_packet_size == 204) << 7; /* T */
|
||||
bits |= (npd_bits & 0x7F);
|
||||
|
||||
gst_rtp_buffer_map (buf, GST_MAP_READWRITE, &rtp);
|
||||
gst_rtp_buffer_set_extension_data (&rtp, bits,
|
||||
(has_seqnum_ext && extseq != 0xFFFF) ? 1 : 0);
|
||||
if (has_seqnum_ext && extseq != 0xFFFF) {
|
||||
guint8 *data;
|
||||
guint wordlen;
|
||||
gst_rtp_buffer_set_extension_data (&rtp, 'R' << 8 | 'I', 1);
|
||||
gst_rtp_buffer_get_extension_data (&rtp, NULL, (void **) &data, NULL);
|
||||
|
||||
data[0] = has_drop_null << 7; /* N */
|
||||
data[0] |= has_seqnum_ext << 6; /* E */
|
||||
data[0] |= (MIN (orig_ts_packet_count, 7) & 7) << 2; /* Size */
|
||||
data[1] = (ts_packet_size == 204) << 7; /* T */
|
||||
data[1] |= (npd_bits & 0x7F);
|
||||
|
||||
if (has_seqnum_ext && extseq != 0xFFFF)
|
||||
GST_WRITE_UINT16_BE (data + 2, extseq);
|
||||
else
|
||||
GST_WRITE_UINT16_BE (data + 2, 0);
|
||||
|
||||
gst_rtp_buffer_get_extension_data (&rtp, &bits, (void **) &data, &wordlen);
|
||||
GST_WRITE_UINT16_BE (data, extseq);
|
||||
data[2] = data[3] = 0;
|
||||
}
|
||||
|
||||
payload = gst_rtp_buffer_get_payload (&rtp);
|
||||
for (i = 0; i < num_ts_packets; i++) {
|
||||
|
|
Loading…
Reference in a new issue