From e7575bc525861f5aca5d29ddd7c33b7e72e3f161 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 24 Jan 2012 14:37:12 +0100 Subject: [PATCH] rtp: improve structures Remove flags that is in the mapinfo now --- gst-libs/gst/rtp/gstrtcpbuffer.c | 97 +++++++++++++++++----------------- gst-libs/gst/rtp/gstrtcpbuffer.h | 24 ++++----- gst-libs/gst/rtp/gstrtpbuffer.c | 111 +++++++++++++++++++-------------------- gst-libs/gst/rtp/gstrtpbuffer.h | 7 +-- 4 files changed, 118 insertions(+), 121 deletions(-) diff --git a/gst-libs/gst/rtp/gstrtcpbuffer.c b/gst-libs/gst/rtp/gstrtcpbuffer.c index 4356fd7..317c35d 100644 --- a/gst-libs/gst/rtp/gstrtcpbuffer.c +++ b/gst-libs/gst/rtp/gstrtcpbuffer.c @@ -204,13 +204,13 @@ gboolean gst_rtcp_buffer_validate (GstBuffer * buffer) { gboolean res; - GstMapInfo info; + GstMapInfo map; g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE); - gst_buffer_map (buffer, &info, GST_MAP_READ); - res = gst_rtcp_buffer_validate_data (info.data, info.size); - gst_buffer_unmap (buffer, &info); + gst_buffer_map (buffer, &map, GST_MAP_READ); + res = gst_rtcp_buffer_validate_data (map.data, map.size); + gst_buffer_unmap (buffer, &map); return res; } @@ -256,13 +256,12 @@ gst_rtcp_buffer_map (GstBuffer * buffer, GstMapFlags flags, g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE); rtcp->buffer = buffer; - rtcp->flags = flags; - gst_buffer_map (buffer, &rtcp->info, flags); + gst_buffer_map (buffer, &rtcp->map, flags); /* allow for expansion, e.g. adding packets, if needed */ if ((flags & GST_MAP_WRITE) != 0) { /* adjust to max available */ - rtcp->info.size = rtcp->info.maxsize; + rtcp->map.size = rtcp->map.maxsize; } return TRUE; @@ -292,7 +291,7 @@ gst_rtcp_buffer_unmap (GstRTCPBuffer * rtcp) /* shrink size */ gst_buffer_resize (rtcp->buffer, 0, packet.offset); - gst_buffer_unmap (rtcp->buffer, &rtcp->info); + gst_buffer_unmap (rtcp->buffer, &rtcp->map); rtcp->buffer = NULL; return TRUE; @@ -342,8 +341,8 @@ read_packet_header (GstRTCPPacket * packet) g_return_val_if_fail (packet != NULL, FALSE); - data = packet->rtcp->info.data; - size = packet->rtcp->info.size; + data = packet->rtcp->map.data; + size = packet->rtcp->map.size; offset = packet->offset; @@ -462,7 +461,7 @@ gst_rtcp_buffer_add_packet (GstRTCPBuffer * rtcp, GstRTCPType type, if (gst_rtcp_buffer_get_first_packet (rtcp, packet)) while (gst_rtcp_packet_move_to_next (packet)); - size = rtcp->info.size; + size = rtcp->map.size; /* packet->offset is now pointing to the next free offset in the buffer to * start a compount packet. Next we figure out if we have enough free space in @@ -495,7 +494,7 @@ gst_rtcp_buffer_add_packet (GstRTCPBuffer * rtcp, GstRTCPType type, if (packet->offset + len >= size) goto no_space; - data = rtcp->info.data + packet->offset; + data = rtcp->map.data + packet->offset; data[0] = (GST_RTCP_VERSION << 6); data[1] = type; @@ -544,8 +543,8 @@ gst_rtcp_packet_remove (GstRTCPPacket * packet) offset = packet->offset + (packet->length << 2) + 4; /* Overwrite this packet with the rest of the data */ - memmove (packet->rtcp->info.data + packet->offset, - packet->rtcp->info.data + offset, packet->rtcp->info.size - offset); + memmove (packet->rtcp->map.data + packet->offset, + packet->rtcp->map.data + offset, packet->rtcp->map.size - offset); /* try to read next header */ ret = read_packet_header (packet); @@ -646,7 +645,7 @@ gst_rtcp_packet_sr_get_sender_info (GstRTCPPacket * packet, guint32 * ssrc, g_return_if_fail (packet != NULL); g_return_if_fail (packet->type == GST_RTCP_TYPE_SR); - data = packet->rtcp->info.data; + data = packet->rtcp->map.data; /* skip header */ data += packet->offset + 4; @@ -686,7 +685,7 @@ gst_rtcp_packet_sr_set_sender_info (GstRTCPPacket * packet, guint32 ssrc, g_return_if_fail (packet != NULL); g_return_if_fail (packet->type == GST_RTCP_TYPE_SR); - data = packet->rtcp->info.data; + data = packet->rtcp->map.data; /* skip header */ data += packet->offset + 4; @@ -718,7 +717,7 @@ gst_rtcp_packet_rr_get_ssrc (GstRTCPPacket * packet) g_return_val_if_fail (packet != NULL, 0); g_return_val_if_fail (packet->type == GST_RTCP_TYPE_RR, 0); - data = packet->rtcp->info.data; + data = packet->rtcp->map.data; /* skip header */ data += packet->offset + 4; @@ -742,7 +741,7 @@ gst_rtcp_packet_rr_set_ssrc (GstRTCPPacket * packet, guint32 ssrc) g_return_if_fail (packet != NULL); g_return_if_fail (packet->type == GST_RTCP_TYPE_RR); - data = packet->rtcp->info.data; + data = packet->rtcp->map.data; /* skip header */ data += packet->offset + 4; @@ -794,7 +793,7 @@ gst_rtcp_packet_get_rb (GstRTCPPacket * packet, guint nth, guint32 * ssrc, g_return_if_fail (packet->type == GST_RTCP_TYPE_RR || packet->type == GST_RTCP_TYPE_SR); - data = packet->rtcp->info.data; + data = packet->rtcp->map.data; /* skip header */ data += packet->offset + 4; @@ -866,8 +865,8 @@ gst_rtcp_packet_add_rb (GstRTCPPacket * packet, guint32 ssrc, if (packet->count >= GST_RTCP_MAX_RB_COUNT) goto no_space; - data = packet->rtcp->info.data; - size = packet->rtcp->info.size; + data = packet->rtcp->map.data; + size = packet->rtcp->map.size; /* skip header */ offset = packet->offset + 4; @@ -1006,7 +1005,7 @@ gst_rtcp_packet_sdes_next_item (GstRTCPPacket * packet) return FALSE; /* move to SDES */ - data = packet->rtcp->info.data; + data = packet->rtcp->map.data; data += packet->offset; /* move to item */ offset = packet->item_offset; @@ -1052,7 +1051,7 @@ gst_rtcp_packet_sdes_get_ssrc (GstRTCPPacket * packet) g_return_val_if_fail (packet->type == GST_RTCP_TYPE_SDES, 0); /* move to SDES */ - data = packet->rtcp->info.data; + data = packet->rtcp->map.data; data += packet->offset; /* move to item */ data += packet->item_offset; @@ -1080,7 +1079,7 @@ gst_rtcp_packet_sdes_first_entry (GstRTCPPacket * packet) g_return_val_if_fail (packet->type == GST_RTCP_TYPE_SDES, FALSE); /* move to SDES */ - data = packet->rtcp->info.data; + data = packet->rtcp->map.data; data += packet->offset; /* move to item */ offset = packet->item_offset; @@ -1118,7 +1117,7 @@ gst_rtcp_packet_sdes_next_entry (GstRTCPPacket * packet) g_return_val_if_fail (packet->type == GST_RTCP_TYPE_SDES, FALSE); /* move to SDES */ - data = packet->rtcp->info.data; + data = packet->rtcp->map.data; data += packet->offset; /* move to item */ offset = packet->item_offset; @@ -1171,7 +1170,7 @@ gst_rtcp_packet_sdes_get_entry (GstRTCPPacket * packet, g_return_val_if_fail (packet->type == GST_RTCP_TYPE_SDES, FALSE); /* move to SDES */ - bdata = packet->rtcp->info.data; + bdata = packet->rtcp->map.data; bdata += packet->offset; /* move to item */ offset = packet->item_offset; @@ -1254,8 +1253,8 @@ gst_rtcp_packet_sdes_add_item (GstRTCPPacket * packet, guint32 ssrc) gst_rtcp_packet_sdes_next_item (packet); /* move to SDES */ - data = packet->rtcp->info.data; - size = packet->rtcp->info.size; + data = packet->rtcp->map.data; + size = packet->rtcp->map.size; data += packet->offset; /* move to current item */ offset = packet->item_offset; @@ -1313,8 +1312,8 @@ gst_rtcp_packet_sdes_add_entry (GstRTCPPacket * packet, GstRTCPSDESType type, g_return_val_if_fail (packet->type == GST_RTCP_TYPE_SDES, FALSE); /* move to SDES */ - bdata = packet->rtcp->info.data; - size = packet->rtcp->info.size; + bdata = packet->rtcp->map.data; + size = packet->rtcp->map.size; bdata += packet->offset; /* move to item */ offset = packet->item_offset; @@ -1403,10 +1402,10 @@ gst_rtcp_packet_bye_get_nth_ssrc (GstRTCPPacket * packet, guint nth) offset += packet->offset; /* check if the packet is valid */ - if (offset + 4 > packet->rtcp->info.size) + if (offset + 4 > packet->rtcp->map.size) return 0; - data = packet->rtcp->info.data; + data = packet->rtcp->map.data; data += offset; ssrc = GST_READ_UINT32_BE (data); @@ -1437,8 +1436,8 @@ gst_rtcp_packet_bye_add_ssrc (GstRTCPPacket * packet, guint32 ssrc) if (packet->count >= GST_RTCP_MAX_BYE_SSRC_COUNT) goto no_space; - data = packet->rtcp->info.data; - size = packet->rtcp->info.size; + data = packet->rtcp->map.data; + size = packet->rtcp->map.size; /* skip header */ offset = packet->offset + 4; @@ -1516,7 +1515,7 @@ get_reason_offset (GstRTCPPacket * packet) offset += packet->offset; /* check if the packet is valid */ - if (offset + 1 > packet->rtcp->info.size) + if (offset + 1 > packet->rtcp->map.size) return 0; return offset; @@ -1544,7 +1543,7 @@ gst_rtcp_packet_bye_get_reason_len (GstRTCPPacket * packet) if (roffset == 0) return 0; - data = packet->rtcp->info.data; + data = packet->rtcp->map.data; return data[roffset]; } @@ -1572,7 +1571,7 @@ gst_rtcp_packet_bye_get_reason (GstRTCPPacket * packet) if (roffset == 0) return NULL; - data = packet->rtcp->info.data; + data = packet->rtcp->map.data; /* get length of reason string */ len = data[roffset]; @@ -1583,7 +1582,7 @@ gst_rtcp_packet_bye_get_reason (GstRTCPPacket * packet) roffset += 1; /* check if enough data to copy */ - if (roffset + len > packet->rtcp->info.size) + if (roffset + len > packet->rtcp->map.size) return NULL; return g_strndup ((gconstpointer) (data + roffset), len); @@ -1622,8 +1621,8 @@ gst_rtcp_packet_bye_set_reason (GstRTCPPacket * packet, const gchar * reason) if (roffset == 0) goto no_space; - data = packet->rtcp->info.data; - size = packet->rtcp->info.size; + data = packet->rtcp->map.data; + size = packet->rtcp->map.size; /* we have 1 byte length and we need to pad to 4 bytes */ padded = ((len + 1) + 3) & ~3; @@ -1670,7 +1669,7 @@ gst_rtcp_packet_fb_get_sender_ssrc (GstRTCPPacket * packet) g_return_val_if_fail ((packet->type == GST_RTCP_TYPE_RTPFB || packet->type == GST_RTCP_TYPE_PSFB), 0); - data = packet->rtcp->info.data; + data = packet->rtcp->map.data; /* skip header */ data += packet->offset + 4; @@ -1697,7 +1696,7 @@ gst_rtcp_packet_fb_set_sender_ssrc (GstRTCPPacket * packet, guint32 ssrc) g_return_if_fail (packet->type == GST_RTCP_TYPE_RTPFB || packet->type == GST_RTCP_TYPE_PSFB); - data = packet->rtcp->info.data; + data = packet->rtcp->map.data; /* skip header */ data += packet->offset + 4; @@ -1724,7 +1723,7 @@ gst_rtcp_packet_fb_get_media_ssrc (GstRTCPPacket * packet) g_return_val_if_fail ((packet->type == GST_RTCP_TYPE_RTPFB || packet->type == GST_RTCP_TYPE_PSFB), 0); - data = packet->rtcp->info.data; + data = packet->rtcp->map.data; /* skip header and sender ssrc */ data += packet->offset + 8; @@ -1751,7 +1750,7 @@ gst_rtcp_packet_fb_set_media_ssrc (GstRTCPPacket * packet, guint32 ssrc) g_return_if_fail (packet->type == GST_RTCP_TYPE_RTPFB || packet->type == GST_RTCP_TYPE_PSFB); - data = packet->rtcp->info.data; + data = packet->rtcp->map.data; /* skip header and sender ssrc */ data += packet->offset + 8; @@ -1796,7 +1795,7 @@ gst_rtcp_packet_fb_set_type (GstRTCPPacket * packet, GstRTCPFBType type) g_return_if_fail (packet->type == GST_RTCP_TYPE_RTPFB || packet->type == GST_RTCP_TYPE_PSFB); - data = packet->rtcp->info.data; + data = packet->rtcp->map.data; data[packet->offset] = (data[packet->offset] & 0xe0) | type; packet->count = type; @@ -1968,7 +1967,7 @@ gst_rtcp_packet_fb_get_fci_length (GstRTCPPacket * packet) g_return_val_if_fail (packet->type == GST_RTCP_TYPE_RTPFB || packet->type == GST_RTCP_TYPE_PSFB, 0); - data = packet->rtcp->info.data + packet->offset + 2; + data = packet->rtcp->map.data + packet->offset + 2; return GST_READ_UINT16_BE (data) - 2; } @@ -1994,10 +1993,10 @@ gst_rtcp_packet_fb_set_fci_length (GstRTCPPacket * packet, guint16 wordlen) g_return_val_if_fail (packet->type == GST_RTCP_TYPE_RTPFB || packet->type == GST_RTCP_TYPE_PSFB, FALSE); - if (packet->rtcp->info.size < packet->offset + ((wordlen + 3) * 4)) + if (packet->rtcp->map.size < packet->offset + ((wordlen + 3) * 4)) return FALSE; - data = packet->rtcp->info.data + packet->offset + 2; + data = packet->rtcp->map.data + packet->offset + 2; wordlen += 2; GST_WRITE_UINT16_BE (data, wordlen); @@ -2023,7 +2022,7 @@ gst_rtcp_packet_fb_get_fci (GstRTCPPacket * packet) g_return_val_if_fail (packet->type == GST_RTCP_TYPE_RTPFB || packet->type == GST_RTCP_TYPE_PSFB, NULL); - data = packet->rtcp->info.data + packet->offset; + data = packet->rtcp->map.data + packet->offset; if (GST_READ_UINT16_BE (data + 2) <= 2) return NULL; diff --git a/gst-libs/gst/rtp/gstrtcpbuffer.h b/gst-libs/gst/rtp/gstrtcpbuffer.h index 613d62e..18bd6ab 100644 --- a/gst-libs/gst/rtp/gstrtcpbuffer.h +++ b/gst-libs/gst/rtp/gstrtcpbuffer.h @@ -177,12 +177,10 @@ typedef struct _GstRTCPPacket GstRTCPPacket; struct _GstRTCPBuffer { GstBuffer *buffer; - - GstMapFlags flags; - GstMapInfo info; + GstMapInfo map; }; -#define GST_RTCP_BUFFER_INIT { NULL, 0, NULL, 0, 0 } +#define GST_RTCP_BUFFER_INIT { NULL, GST_MAP_INFO_INIT } /** * GstRTCPPacket: @@ -195,17 +193,17 @@ struct _GstRTCPBuffer struct _GstRTCPPacket { GstRTCPBuffer *rtcp; - guint offset; + guint offset; /*< private >*/ - gboolean padding; /* padding field of current packet */ - guint8 count; /* count field of current packet */ - GstRTCPType type; /* type of current packet */ - guint16 length; /* length of current packet in 32-bits words */ - - guint item_offset; /* current item offset for navigating SDES */ - guint item_count; /* current item count */ - guint entry_offset; /* current entry offset for navigating SDES items */ + gboolean padding; /* padding field of current packet */ + guint8 count; /* count field of current packet */ + GstRTCPType type; /* type of current packet */ + guint16 length; /* length of current packet in 32-bits words */ + + guint item_offset; /* current item offset for navigating SDES */ + guint item_count; /* current item count */ + guint entry_offset; /* current entry offset for navigating SDES items */ }; /* creating buffers */ diff --git a/gst-libs/gst/rtp/gstrtpbuffer.c b/gst-libs/gst/rtp/gstrtpbuffer.c index 30d3b23..b12e9e3 100644 --- a/gst-libs/gst/rtp/gstrtpbuffer.c +++ b/gst-libs/gst/rtp/gstrtpbuffer.c @@ -99,7 +99,7 @@ void gst_rtp_buffer_allocate_data (GstBuffer * buffer, guint payload_len, guint8 pad_len, guint8 csrc_count) { - GstMapInfo info; + GstMapInfo map; GstMemory *mem; gsize len; @@ -111,20 +111,20 @@ gst_rtp_buffer_allocate_data (GstBuffer * buffer, guint payload_len, mem = gst_allocator_alloc (NULL, len, 0); - gst_memory_map (mem, &info, GST_MAP_WRITE); + gst_memory_map (mem, &map, GST_MAP_WRITE); /* fill in defaults */ - GST_RTP_HEADER_VERSION (info.data) = GST_RTP_VERSION; - GST_RTP_HEADER_PADDING (info.data) = FALSE; - GST_RTP_HEADER_EXTENSION (info.data) = FALSE; - GST_RTP_HEADER_CSRC_COUNT (info.data) = csrc_count; - memset (GST_RTP_HEADER_CSRC_LIST_OFFSET (info.data, 0), 0, + GST_RTP_HEADER_VERSION (map.data) = GST_RTP_VERSION; + GST_RTP_HEADER_PADDING (map.data) = FALSE; + GST_RTP_HEADER_EXTENSION (map.data) = FALSE; + GST_RTP_HEADER_CSRC_COUNT (map.data) = csrc_count; + memset (GST_RTP_HEADER_CSRC_LIST_OFFSET (map.data, 0), 0, csrc_count * sizeof (guint32)); - GST_RTP_HEADER_MARKER (info.data) = FALSE; - GST_RTP_HEADER_PAYLOAD_TYPE (info.data) = 0; - GST_RTP_HEADER_SEQ (info.data) = 0; - GST_RTP_HEADER_TIMESTAMP (info.data) = 0; - GST_RTP_HEADER_SSRC (info.data) = 0; - gst_memory_unmap (mem, &info); + GST_RTP_HEADER_MARKER (map.data) = FALSE; + GST_RTP_HEADER_PAYLOAD_TYPE (map.data) = 0; + GST_RTP_HEADER_SEQ (map.data) = 0; + GST_RTP_HEADER_TIMESTAMP (map.data) = 0; + GST_RTP_HEADER_SSRC (map.data) = 0; + gst_memory_unmap (mem, &map); gst_buffer_take_memory (buffer, -1, mem); } @@ -411,13 +411,13 @@ gboolean gst_rtp_buffer_validate (GstBuffer * buffer) { gboolean res; - GstMapInfo info; + GstMapInfo map; g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE); - gst_buffer_map (buffer, &info, GST_MAP_READ); - res = validate_data (info.data, info.size, NULL, 0); - gst_buffer_unmap (buffer, &info); + gst_buffer_map (buffer, &map, GST_MAP_READ); + res = validate_data (map.data, map.size, NULL, 0); + gst_buffer_unmap (buffer, &map); return res; } @@ -429,11 +429,10 @@ gst_rtp_buffer_map (GstBuffer * buffer, GstMapFlags flags, GstRTPBuffer * rtp) g_return_val_if_fail (rtp != NULL, FALSE); g_return_val_if_fail (rtp->buffer == NULL, FALSE); - if (!gst_buffer_map (buffer, &rtp->info, flags)) + if (!gst_buffer_map (buffer, &rtp->map, flags)) return FALSE; rtp->buffer = buffer; - rtp->flags = flags; return TRUE; } @@ -444,7 +443,7 @@ gst_rtp_buffer_unmap (GstRTPBuffer * rtp) g_return_val_if_fail (rtp != NULL, FALSE); g_return_val_if_fail (rtp->buffer != NULL, FALSE); - gst_buffer_unmap (rtp->buffer, &rtp->info); + gst_buffer_unmap (rtp->buffer, &rtp->map); rtp->buffer = NULL; return TRUE; @@ -464,15 +463,15 @@ gst_rtp_buffer_set_packet_len (GstRTPBuffer * rtp, guint len) { guint8 *data; - data = rtp->info.data; + data = rtp->map.data; - if (rtp->info.maxsize <= len) { + if (rtp->map.maxsize <= len) { /* FIXME, realloc bigger space */ g_warning ("not implemented"); } gst_buffer_set_size (rtp->buffer, len); - rtp->info.size = len; + rtp->map.size = len; /* remove any padding */ GST_RTP_HEADER_PADDING (data) = FALSE; @@ -507,7 +506,7 @@ gst_rtp_buffer_get_header_len (GstRTPBuffer * rtp) guint len; guint8 *data; - data = rtp->info.data; + data = rtp->map.data; len = GST_RTP_HEADER_LEN + GST_RTP_HEADER_CSRC_SIZE (data); if (GST_RTP_HEADER_EXTENSION (data)) @@ -527,7 +526,7 @@ gst_rtp_buffer_get_header_len (GstRTPBuffer * rtp) guint8 gst_rtp_buffer_get_version (GstRTPBuffer * rtp) { - return GST_RTP_HEADER_VERSION (rtp->info.data); + return GST_RTP_HEADER_VERSION (rtp->map.data); } /** @@ -542,7 +541,7 @@ gst_rtp_buffer_set_version (GstRTPBuffer * rtp, guint8 version) { g_return_if_fail (version < 0x04); - GST_RTP_HEADER_VERSION (rtp->info.data) = version; + GST_RTP_HEADER_VERSION (rtp->map.data) = version; } /** @@ -556,7 +555,7 @@ gst_rtp_buffer_set_version (GstRTPBuffer * rtp, guint8 version) gboolean gst_rtp_buffer_get_padding (GstRTPBuffer * rtp) { - return GST_RTP_HEADER_PADDING (rtp->info.data); + return GST_RTP_HEADER_PADDING (rtp->map.data); } /** @@ -569,7 +568,7 @@ gst_rtp_buffer_get_padding (GstRTPBuffer * rtp) void gst_rtp_buffer_set_padding (GstRTPBuffer * rtp, gboolean padding) { - GST_RTP_HEADER_PADDING (rtp->info.data) = padding; + GST_RTP_HEADER_PADDING (rtp->map.data) = padding; } /** @@ -587,7 +586,7 @@ gst_rtp_buffer_pad_to (GstRTPBuffer * rtp, guint len) { guint8 *data; - data = rtp->info.data; + data = rtp->map.data; if (len > 0) GST_RTP_HEADER_PADDING (data) = TRUE; @@ -608,7 +607,7 @@ gst_rtp_buffer_pad_to (GstRTPBuffer * rtp, guint len) gboolean gst_rtp_buffer_get_extension (GstRTPBuffer * rtp) { - return GST_RTP_HEADER_EXTENSION (rtp->info.data); + return GST_RTP_HEADER_EXTENSION (rtp->map.data); } /** @@ -621,7 +620,7 @@ gst_rtp_buffer_get_extension (GstRTPBuffer * rtp) void gst_rtp_buffer_set_extension (GstRTPBuffer * rtp, gboolean extension) { - GST_RTP_HEADER_EXTENSION (rtp->info.data) = extension; + GST_RTP_HEADER_EXTENSION (rtp->map.data) = extension; } /** @@ -649,7 +648,7 @@ gst_rtp_buffer_get_extension_data (GstRTPBuffer * rtp, guint16 * bits, guint len; guint8 *pdata; - pdata = rtp->info.data; + pdata = rtp->map.data; if (!GST_RTP_HEADER_EXTENSION (pdata)) return FALSE; @@ -691,17 +690,17 @@ gst_rtp_buffer_set_extension_data (GstRTPBuffer * rtp, guint16 bits, guint32 min_size = 0; guint8 *data; - data = rtp->info.data; + data = rtp->map.data; /* check if the buffer is big enough to hold the extension */ min_size = GST_RTP_HEADER_LEN + GST_RTP_HEADER_CSRC_SIZE (data) + 4 + length * sizeof (guint32); - if (G_UNLIKELY (min_size > rtp->info.size)) + if (G_UNLIKELY (min_size > rtp->map.size)) goto too_small; /* now we can set the extension bit */ - GST_RTP_HEADER_EXTENSION (rtp->info.data) = TRUE; + GST_RTP_HEADER_EXTENSION (rtp->map.data) = TRUE; data += GST_RTP_HEADER_LEN + GST_RTP_HEADER_CSRC_SIZE (data); GST_WRITE_UINT16_BE (data, bits); @@ -714,7 +713,7 @@ too_small: { g_warning ("rtp buffer too small: need more than %d bytes but only have %" - G_GSIZE_FORMAT " bytes", min_size, rtp->info.size); + G_GSIZE_FORMAT " bytes", min_size, rtp->map.size); return FALSE; } } @@ -730,7 +729,7 @@ too_small: guint32 gst_rtp_buffer_get_ssrc (GstRTPBuffer * rtp) { - return g_ntohl (GST_RTP_HEADER_SSRC (rtp->info.data)); + return g_ntohl (GST_RTP_HEADER_SSRC (rtp->map.data)); } /** @@ -743,7 +742,7 @@ gst_rtp_buffer_get_ssrc (GstRTPBuffer * rtp) void gst_rtp_buffer_set_ssrc (GstRTPBuffer * rtp, guint32 ssrc) { - GST_RTP_HEADER_SSRC (rtp->info.data) = g_htonl (ssrc); + GST_RTP_HEADER_SSRC (rtp->map.data) = g_htonl (ssrc); } /** @@ -757,7 +756,7 @@ gst_rtp_buffer_set_ssrc (GstRTPBuffer * rtp, guint32 ssrc) guint8 gst_rtp_buffer_get_csrc_count (GstRTPBuffer * rtp) { - return GST_RTP_HEADER_CSRC_COUNT (rtp->info.data); + return GST_RTP_HEADER_CSRC_COUNT (rtp->map.data); } /** @@ -774,7 +773,7 @@ gst_rtp_buffer_get_csrc (GstRTPBuffer * rtp, guint8 idx) { guint8 *data; - data = rtp->info.data; + data = rtp->map.data; g_return_val_if_fail (idx < GST_RTP_HEADER_CSRC_COUNT (data), 0); @@ -794,7 +793,7 @@ gst_rtp_buffer_set_csrc (GstRTPBuffer * rtp, guint8 idx, guint32 csrc) { guint8 *data; - data = rtp->info.data; + data = rtp->map.data; g_return_if_fail (idx < GST_RTP_HEADER_CSRC_COUNT (data)); @@ -812,7 +811,7 @@ gst_rtp_buffer_set_csrc (GstRTPBuffer * rtp, guint8 idx, guint32 csrc) gboolean gst_rtp_buffer_get_marker (GstRTPBuffer * rtp) { - return GST_RTP_HEADER_MARKER (rtp->info.data); + return GST_RTP_HEADER_MARKER (rtp->map.data); } /** @@ -825,7 +824,7 @@ gst_rtp_buffer_get_marker (GstRTPBuffer * rtp) void gst_rtp_buffer_set_marker (GstRTPBuffer * rtp, gboolean marker) { - GST_RTP_HEADER_MARKER (rtp->info.data) = marker; + GST_RTP_HEADER_MARKER (rtp->map.data) = marker; } /** @@ -839,7 +838,7 @@ gst_rtp_buffer_set_marker (GstRTPBuffer * rtp, gboolean marker) guint8 gst_rtp_buffer_get_payload_type (GstRTPBuffer * rtp) { - return GST_RTP_HEADER_PAYLOAD_TYPE (rtp->info.data); + return GST_RTP_HEADER_PAYLOAD_TYPE (rtp->map.data); } /** @@ -854,7 +853,7 @@ gst_rtp_buffer_set_payload_type (GstRTPBuffer * rtp, guint8 payload_type) { g_return_if_fail (payload_type < 0x80); - GST_RTP_HEADER_PAYLOAD_TYPE (rtp->info.data) = payload_type; + GST_RTP_HEADER_PAYLOAD_TYPE (rtp->map.data) = payload_type; } /** @@ -868,7 +867,7 @@ gst_rtp_buffer_set_payload_type (GstRTPBuffer * rtp, guint8 payload_type) guint16 gst_rtp_buffer_get_seq (GstRTPBuffer * rtp) { - return g_ntohs (GST_RTP_HEADER_SEQ (rtp->info.data)); + return g_ntohs (GST_RTP_HEADER_SEQ (rtp->map.data)); } /** @@ -881,7 +880,7 @@ gst_rtp_buffer_get_seq (GstRTPBuffer * rtp) void gst_rtp_buffer_set_seq (GstRTPBuffer * rtp, guint16 seq) { - GST_RTP_HEADER_SEQ (rtp->info.data) = g_htons (seq); + GST_RTP_HEADER_SEQ (rtp->map.data) = g_htons (seq); } /** @@ -895,7 +894,7 @@ gst_rtp_buffer_set_seq (GstRTPBuffer * rtp, guint16 seq) guint32 gst_rtp_buffer_get_timestamp (GstRTPBuffer * rtp) { - return g_ntohl (GST_RTP_HEADER_TIMESTAMP (rtp->info.data)); + return g_ntohl (GST_RTP_HEADER_TIMESTAMP (rtp->map.data)); } /** @@ -908,7 +907,7 @@ gst_rtp_buffer_get_timestamp (GstRTPBuffer * rtp) void gst_rtp_buffer_set_timestamp (GstRTPBuffer * rtp, guint32 timestamp) { - GST_RTP_HEADER_TIMESTAMP (rtp->info.data) = g_htonl (timestamp); + GST_RTP_HEADER_TIMESTAMP (rtp->map.data) = g_htonl (timestamp); } @@ -986,8 +985,8 @@ gst_rtp_buffer_get_payload_len (GstRTPBuffer * rtp) guint len, size; guint8 *data; - size = rtp->info.size; - data = rtp->info.data; + size = rtp->map.size; + data = rtp->map.data; len = size - gst_rtp_buffer_get_header_len (rtp); @@ -1009,7 +1008,7 @@ gst_rtp_buffer_get_payload_len (GstRTPBuffer * rtp) gpointer gst_rtp_buffer_get_payload (GstRTPBuffer * rtp) { - return rtp->info.data + gst_rtp_buffer_get_header_len (rtp); + return rtp->map.data + gst_rtp_buffer_get_header_len (rtp); } /** @@ -1349,10 +1348,10 @@ gst_rtp_buffer_add_extension_onebyte_header (GstRTPBuffer * rtp, guint8 id, return FALSE; nextext = pdata + offset; - offset = nextext - rtp->info.data; + offset = nextext - rtp->map.data; /* Don't add extra header if there isn't enough space */ - if (rtp->info.size < offset + size + 1) + if (rtp->map.size < offset + size + 1) return FALSE; nextext[0] = (id << 4) | (0x0F & (size - 1)); @@ -1469,10 +1468,10 @@ gst_rtp_buffer_add_extension_twobytes_header (GstRTPBuffer * rtp, nextext = pdata + offset; - offset = nextext - rtp->info.data; + offset = nextext - rtp->map.data; /* Don't add extra header if there isn't enough space */ - if (rtp->info.size < offset + size + 2) + if (rtp->map.size < offset + size + 2) return FALSE; nextext[0] = id; diff --git a/gst-libs/gst/rtp/gstrtpbuffer.h b/gst-libs/gst/rtp/gstrtpbuffer.h index a9d9b30..3f255ea 100644 --- a/gst-libs/gst/rtp/gstrtpbuffer.h +++ b/gst-libs/gst/rtp/gstrtpbuffer.h @@ -42,6 +42,8 @@ typedef struct _GstRTPBuffer GstRTPBuffer; /** * GstRTPBuffer: * @buffer: pointer to RTP buffer + * @flags: flags used when mapping + * @map: the #GstMapInfo * * Data structure that points to an RTP packet. * The size of the structure is made public to allow stack allocations. @@ -49,11 +51,10 @@ typedef struct _GstRTPBuffer GstRTPBuffer; struct _GstRTPBuffer { GstBuffer *buffer; - GstMapFlags flags; - GstMapInfo info; + GstMapInfo map; }; -#define GST_RTP_BUFFER_INIT {NULL,0,NULL,0,0} +#define GST_RTP_BUFFER_INIT { NULL, GST_MAP_INFO_INIT} /* creating buffers */ void gst_rtp_buffer_allocate_data (GstBuffer *buffer, guint payload_len, -- 2.7.4