Merge branch 'master' into 0.11
[platform/upstream/gstreamer.git] / gst-libs / gst / rtp / gstrtpbuffer.h
1 /* GStreamer
2  * Copyright (C) <2005> Philippe Khalaf <burger@speedy.org>
3  *               <2005> Wim Taymans <wim@fluendo.com>
4  *
5  * gstrtpbuffer.h: various helper functions to manipulate buffers
6  *     with RTP payload.
7  *
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.
12  *
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.
17  *
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., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23
24 #ifndef __GST_RTPBUFFER_H__
25 #define __GST_RTPBUFFER_H__
26
27 #include <gst/gst.h>
28 #include <gst/rtp/gstrtppayloads.h>
29
30 G_BEGIN_DECLS
31
32 /**
33  * GST_RTP_VERSION:
34  *
35  * The supported RTP version 2.
36  */
37 #define GST_RTP_VERSION 2
38
39
40 typedef struct _GstRTPBuffer GstRTPBuffer;
41
42 /**
43  * GstRTPBuffer:
44  * @buffer: pointer to RTP buffer
45  *
46  * Data structure that points to an RTP packet.
47  * The size of the structure is made public to allow stack allocations.
48  */
49 struct _GstRTPBuffer
50 {
51   GstBuffer   *buffer;
52   GstMapFlags  flags;
53   guint8      *data;
54   gsize        size;
55   gsize        maxsize;
56 };
57
58 /* creating buffers */
59 void            gst_rtp_buffer_allocate_data         (GstBuffer *buffer, guint payload_len,
60                                                       guint8 pad_len, guint8 csrc_count);
61
62 GstBuffer*      gst_rtp_buffer_new_take_data         (gpointer data, gsize len);
63 GstBuffer*      gst_rtp_buffer_new_copy_data         (gpointer data, gsize len);
64 GstBuffer*      gst_rtp_buffer_new_allocate          (guint payload_len, guint8 pad_len, guint8 csrc_count);
65 GstBuffer*      gst_rtp_buffer_new_allocate_len      (guint packet_len, guint8 pad_len, guint8 csrc_count);
66
67 guint           gst_rtp_buffer_calc_header_len       (guint8 csrc_count);
68 guint           gst_rtp_buffer_calc_packet_len       (guint payload_len, guint8 pad_len, guint8 csrc_count);
69 guint           gst_rtp_buffer_calc_payload_len      (guint packet_len, guint8 pad_len, guint8 csrc_count);
70
71 gboolean        gst_rtp_buffer_validate_data         (guint8 *data, gsize len);
72 gboolean        gst_rtp_buffer_validate              (GstBuffer *buffer);
73
74
75 gboolean        gst_rtp_buffer_map                   (GstBuffer *buffer, GstMapFlags flags, GstRTPBuffer *rtp);
76 gboolean        gst_rtp_buffer_unmap                 (GstRTPBuffer *rtp);
77
78 void            gst_rtp_buffer_set_packet_len        (GstRTPBuffer *rtp, guint len);
79 guint           gst_rtp_buffer_get_packet_len        (GstRTPBuffer *rtp);
80
81 guint           gst_rtp_buffer_get_header_len        (GstRTPBuffer *rtp);
82
83 guint8          gst_rtp_buffer_get_version           (GstRTPBuffer *rtp);
84 void            gst_rtp_buffer_set_version           (GstRTPBuffer *rtp, guint8 version);
85
86 gboolean        gst_rtp_buffer_get_padding           (GstRTPBuffer *rtp);
87 void            gst_rtp_buffer_set_padding           (GstRTPBuffer *rtp, gboolean padding);
88 void            gst_rtp_buffer_pad_to                (GstRTPBuffer *rtp, guint len);
89
90 gboolean        gst_rtp_buffer_get_extension         (GstRTPBuffer *rtp);
91 void            gst_rtp_buffer_set_extension         (GstRTPBuffer *rtp, gboolean extension);
92 gboolean        gst_rtp_buffer_get_extension_data    (GstRTPBuffer *rtp, guint16 *bits,
93                                                       gpointer *data, guint *wordlen);
94 gboolean        gst_rtp_buffer_set_extension_data    (GstRTPBuffer *rtp, guint16 bits, guint16 length);
95
96 guint32         gst_rtp_buffer_get_ssrc              (GstRTPBuffer *rtp);
97 void            gst_rtp_buffer_set_ssrc              (GstRTPBuffer *rtp, guint32 ssrc);
98
99 guint8          gst_rtp_buffer_get_csrc_count        (GstRTPBuffer *rtp);
100 guint32         gst_rtp_buffer_get_csrc              (GstRTPBuffer *rtp, guint8 idx);
101 void            gst_rtp_buffer_set_csrc              (GstRTPBuffer *rtp, guint8 idx, guint32 csrc);
102
103 gboolean        gst_rtp_buffer_get_marker            (GstRTPBuffer *rtp);
104 void            gst_rtp_buffer_set_marker            (GstRTPBuffer *rtp, gboolean marker);
105
106 guint8          gst_rtp_buffer_get_payload_type      (GstRTPBuffer *rtp);
107 void            gst_rtp_buffer_set_payload_type      (GstRTPBuffer *rtp, guint8 payload_type);
108
109 guint16         gst_rtp_buffer_get_seq               (GstRTPBuffer *rtp);
110 void            gst_rtp_buffer_set_seq               (GstRTPBuffer *rtp, guint16 seq);
111
112 guint32         gst_rtp_buffer_get_timestamp         (GstRTPBuffer *rtp);
113 void            gst_rtp_buffer_set_timestamp         (GstRTPBuffer *rtp, guint32 timestamp);
114
115 GstBuffer*      gst_rtp_buffer_get_payload_buffer    (GstRTPBuffer *rtp);
116 GstBuffer*      gst_rtp_buffer_get_payload_subbuffer (GstRTPBuffer *rtp, guint offset, guint len);
117
118 guint           gst_rtp_buffer_get_payload_len       (GstRTPBuffer *rtp);
119 gpointer        gst_rtp_buffer_get_payload           (GstRTPBuffer *rtp);
120
121 /* some helpers */
122 guint32         gst_rtp_buffer_default_clock_rate    (guint8 payload_type);
123 gint            gst_rtp_buffer_compare_seqnum        (guint16 seqnum1, guint16 seqnum2);
124 guint64         gst_rtp_buffer_ext_timestamp         (guint64 *exttimestamp, guint32 timestamp);
125
126 gboolean        gst_rtp_buffer_get_extension_onebyte_header  (GstRTPBuffer *rtp,
127                                                               guint8 id,
128                                                               guint nth,
129                                                               gpointer * data,
130                                                               guint * size);
131 gboolean        gst_rtp_buffer_get_extension_twobytes_header (GstRTPBuffer *rtp,
132                                                               guint8 * appbits,
133                                                               guint8 id,
134                                                               guint nth,
135                                                               gpointer * data,
136                                                               guint * size);
137
138 gboolean       gst_rtp_buffer_add_extension_onebyte_header  (GstRTPBuffer *rtp,
139                                                              guint8 id,
140                                                              gpointer data,
141                                                              guint size);
142 gboolean       gst_rtp_buffer_add_extension_twobytes_header (GstRTPBuffer *rtp,
143                                                              guint8 appbits,
144                                                              guint8 id,
145                                                              gpointer data,
146                                                              guint size);
147
148
149 G_END_DECLS
150
151 #endif /* __GST_RTPBUFFER_H__ */
152