2 * Copyright (C) <2005> Philippe Khalaf <burger@speedy.org>
3 * <2005> Wim Taymans <wim@fluendo.com>
5 * gstrtpbuffer.h: various helper functions to manipulate buffers
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
24 #ifndef __GST_RTPBUFFER_H__
25 #define __GST_RTPBUFFER_H__
28 #include <gst/rtp/gstrtppayloads.h>
35 * The supported RTP version 2.
37 #define GST_RTP_VERSION 2
40 typedef struct _GstRTPBuffer GstRTPBuffer;
44 * @buffer: pointer to RTP buffer
45 * @state: internal state
46 * @data: array of data
47 * @size: array of size
48 * @map: array of #GstMapInfo
50 * Data structure that points to an RTP packet.
51 * The size of the structure is made public to allow stack allocations.
62 #define GST_RTP_BUFFER_INIT { NULL, 0, { NULL, NULL, NULL, NULL}, { 0, 0, 0, 0 }, \
63 { GST_MAP_INFO_INIT, GST_MAP_INFO_INIT, GST_MAP_INFO_INIT, GST_MAP_INFO_INIT} }
65 /* creating buffers */
68 void gst_rtp_buffer_allocate_data (GstBuffer *buffer, guint payload_len,
69 guint8 pad_len, guint8 csrc_count);
72 GstBuffer* gst_rtp_buffer_new_take_data (gpointer data, gsize len);
75 GstBuffer* gst_rtp_buffer_new_copy_data (gconstpointer data, gsize len);
78 GstBuffer* gst_rtp_buffer_new_allocate (guint payload_len, guint8 pad_len, guint8 csrc_count);
81 GstBuffer* gst_rtp_buffer_new_allocate_len (guint packet_len, guint8 pad_len, guint8 csrc_count);
84 guint gst_rtp_buffer_calc_header_len (guint8 csrc_count);
87 guint gst_rtp_buffer_calc_packet_len (guint payload_len, guint8 pad_len, guint8 csrc_count);
90 guint gst_rtp_buffer_calc_payload_len (guint packet_len, guint8 pad_len, guint8 csrc_count);
93 gboolean gst_rtp_buffer_map (GstBuffer *buffer, GstMapFlags flags, GstRTPBuffer *rtp);
96 void gst_rtp_buffer_unmap (GstRTPBuffer *rtp);
99 void gst_rtp_buffer_set_packet_len (GstRTPBuffer *rtp, guint len);
102 guint gst_rtp_buffer_get_packet_len (GstRTPBuffer *rtp);
105 guint gst_rtp_buffer_get_header_len (GstRTPBuffer *rtp);
108 guint8 gst_rtp_buffer_get_version (GstRTPBuffer *rtp);
111 void gst_rtp_buffer_set_version (GstRTPBuffer *rtp, guint8 version);
114 gboolean gst_rtp_buffer_get_padding (GstRTPBuffer *rtp);
117 void gst_rtp_buffer_set_padding (GstRTPBuffer *rtp, gboolean padding);
120 void gst_rtp_buffer_pad_to (GstRTPBuffer *rtp, guint len);
123 gboolean gst_rtp_buffer_get_extension (GstRTPBuffer *rtp);
126 void gst_rtp_buffer_set_extension (GstRTPBuffer *rtp, gboolean extension);
129 gboolean gst_rtp_buffer_get_extension_data (GstRTPBuffer *rtp, guint16 *bits,
130 gpointer *data, guint *wordlen);
133 GBytes* gst_rtp_buffer_get_extension_bytes (GstRTPBuffer *rtp, guint16 *bits);
136 gboolean gst_rtp_buffer_set_extension_data (GstRTPBuffer *rtp, guint16 bits, guint16 length);
139 guint32 gst_rtp_buffer_get_ssrc (GstRTPBuffer *rtp);
142 void gst_rtp_buffer_set_ssrc (GstRTPBuffer *rtp, guint32 ssrc);
145 guint8 gst_rtp_buffer_get_csrc_count (GstRTPBuffer *rtp);
148 guint32 gst_rtp_buffer_get_csrc (GstRTPBuffer *rtp, guint8 idx);
151 void gst_rtp_buffer_set_csrc (GstRTPBuffer *rtp, guint8 idx, guint32 csrc);
154 gboolean gst_rtp_buffer_get_marker (GstRTPBuffer *rtp);
157 void gst_rtp_buffer_set_marker (GstRTPBuffer *rtp, gboolean marker);
160 guint8 gst_rtp_buffer_get_payload_type (GstRTPBuffer *rtp);
163 void gst_rtp_buffer_set_payload_type (GstRTPBuffer *rtp, guint8 payload_type);
166 guint16 gst_rtp_buffer_get_seq (GstRTPBuffer *rtp);
169 void gst_rtp_buffer_set_seq (GstRTPBuffer *rtp, guint16 seq);
172 guint32 gst_rtp_buffer_get_timestamp (GstRTPBuffer *rtp);
175 void gst_rtp_buffer_set_timestamp (GstRTPBuffer *rtp, guint32 timestamp);
178 GstBuffer* gst_rtp_buffer_get_payload_buffer (GstRTPBuffer *rtp);
181 GstBuffer* gst_rtp_buffer_get_payload_subbuffer (GstRTPBuffer *rtp, guint offset, guint len);
184 guint gst_rtp_buffer_get_payload_len (GstRTPBuffer *rtp);
187 gpointer gst_rtp_buffer_get_payload (GstRTPBuffer *rtp);
190 GBytes* gst_rtp_buffer_get_payload_bytes (GstRTPBuffer *rtp);
195 guint32 gst_rtp_buffer_default_clock_rate (guint8 payload_type);
198 gint gst_rtp_buffer_compare_seqnum (guint16 seqnum1, guint16 seqnum2);
201 guint64 gst_rtp_buffer_ext_timestamp (guint64 *exttimestamp, guint32 timestamp);
204 gboolean gst_rtp_buffer_get_extension_onebyte_header (GstRTPBuffer *rtp,
211 gboolean gst_rtp_buffer_get_extension_twobytes_header (GstRTPBuffer *rtp,
219 gboolean gst_rtp_buffer_add_extension_onebyte_header (GstRTPBuffer *rtp,
225 gboolean gst_rtp_buffer_add_extension_twobytes_header (GstRTPBuffer *rtp,
233 * @GST_RTP_BUFFER_FLAG_RETRANSMISSION: The #GstBuffer was once wrapped
234 * in a retransmitted packet as specified by RFC 4588.
235 * @GST_RTP_BUFFER_FLAG_REDUNDANT: The packet represents redundant RTP packet.
236 * The flag is used in gstrtpstorage to be able to hold the packetback
237 * and use it only for recovery from packet loss.
239 * @GST_RTP_BUFFER_FLAG_LAST: Offset to define more flags.
241 * Additional RTP buffer flags. These flags can potentially be used on any
242 * buffers carrying RTP packets.
244 * Note that these are only valid for #GstCaps of type: application/x-rtp (x-rtcp).
245 * They can conflict with other extended buffer flags.
250 GST_RTP_BUFFER_FLAG_RETRANSMISSION = (GST_BUFFER_FLAG_LAST << 0),
251 GST_RTP_BUFFER_FLAG_REDUNDANT = (GST_BUFFER_FLAG_LAST << 1),
252 GST_RTP_BUFFER_FLAG_LAST = (GST_BUFFER_FLAG_LAST << 8)
256 * GstRTPBufferMapFlags:
257 * @GST_RTP_BUFFER_MAP_FLAG_SKIP_PADDING: Skip mapping and validation of RTP
258 * padding and RTP pad count when present. Useful for buffers where
259 * the padding may be encrypted.
260 * @GST_RTP_BUFFER_MAP_FLAG_LAST: Offset to define more flags
262 * Additional mapping flags for gst_rtp_buffer_map().
267 GST_RTP_BUFFER_MAP_FLAG_SKIP_PADDING = (GST_MAP_FLAG_LAST << 0),
268 GST_RTP_BUFFER_MAP_FLAG_LAST = (GST_MAP_FLAG_LAST << 8)
269 /* 8 more flags possible afterwards */
270 } GstRTPBufferMapFlags;
274 #endif /* __GST_RTPBUFFER_H__ */