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;
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;
-
- num_packets_deleted = bit_count (npd_bits);
+ 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 (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 (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) {
+ 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 &&
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_get_extension_data (&rtp, &bits, (void **) &data, &wordlen);
- GST_WRITE_UINT16_BE (data, extseq);
- data[2] = data[3] = 0;
- }
+ 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);
+
payload = gst_rtp_buffer_get_payload (&rtp);
for (i = 0; i < num_ts_packets; i++) {