069eb38d70ae3adb6aa4c3fd2270317af6b1c567
[mafwsubrenderer] / gst-plugins-base-subtitles0.10 / gst-libs / gst / sdp / gstsdpmessage.h
1 /* GStreamer
2  * Copyright (C) <2005,2006> Wim Taymans <wim@fluendo.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 /*
20  * Unless otherwise indicated, Source Code is licensed under MIT license.
21  * See further explanation attached in License Statement (distributed in the file
22  * LICENSE).
23  *
24  * Permission is hereby granted, free of charge, to any person obtaining a copy of
25  * this software and associated documentation files (the "Software"), to deal in
26  * the Software without restriction, including without limitation the rights to
27  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
28  * of the Software, and to permit persons to whom the Software is furnished to do
29  * so, subject to the following conditions:
30  *
31  * The above copyright notice and this permission notice shall be included in all
32  * copies or substantial portions of the Software.
33  *
34  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
37  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
38  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
39  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
40  * SOFTWARE.
41  */
42
43 #ifndef __GST_SDP_MESSAGE_H__
44 #define __GST_SDP_MESSAGE_H__
45
46 #include <glib.h>
47
48 #include <gst/sdp/gstsdp.h>
49
50 G_BEGIN_DECLS
51
52 /**
53  * GstSDPOrigin:
54  * @username: the user's login on the originating host, or it is "-"
55  *    if the originating host does not support the concept of user ids.
56  * @sess_id: is a numeric string such that the tuple of @username, @sess_id,
57  *    @nettype, @addrtype and @addr form a globally unique identifier for the
58  *    session.
59  * @sess_version: a version number for this announcement
60  * @nettype: the type of network. "IN" is defined to have the meaning
61  *    "Internet".
62  * @addrtype: the type of @addr.
63  * @addr: the globally unique address of the machine from which the session was
64  *     created.
65  *
66  * The contents of the SDP "o=" field which gives the originator of the session
67  * (their username and the address of the user's host) plus a session id and
68  * session version number.
69  */
70 typedef struct {
71   gchar *username;
72   gchar *sess_id;
73   gchar *sess_version;
74   gchar *nettype;
75   gchar *addrtype;
76   gchar *addr;
77 } GstSDPOrigin;
78
79 /**
80  * GstSDPConnection:
81  * @nettype: the type of network. "IN" is defined to have the meaning
82  *    "Internet".
83  * @addrtype: the type of @address.
84  * @address: the address
85  * @ttl: the time to live of the address
86  * @addr_number: the number of layers
87  *
88  * The contents of the SDP "c=" field which contains connection data.
89  */
90 typedef struct {
91   gchar *nettype;
92   gchar *addrtype;
93   gchar *address;
94   guint  ttl;
95   guint  addr_number;
96 } GstSDPConnection;
97
98 /**
99  * GST_SDP_BWTYPE_CT:
100  *
101  * The Conference Total bandwidth modifier.
102  */
103 #define GST_SDP_BWTYPE_CT               "CT"
104 /**
105  * GST_SDP_BWTYPE_AS:
106  *
107  * The Application-Specific Maximum bandwidth modifier.
108  */
109 #define GST_SDP_BWTYPE_AS               "AS"
110 /**
111  * GST_SDP_BWTYPE_EXT_PREFIX:
112  *
113  * The extension prefix bandwidth modifier.
114  */
115 #define GST_SDP_BWTYPE_EXT_PREFIX       "X-"
116
117 /**
118  * GST_SDP_BWTYPE_RS:
119  *
120  * RTCP bandwidth allocated to active data senders (RFC 3556).
121  *
122  * Since: 0.10.15
123  */
124 #define GST_SDP_BWTYPE_RS               "RS"
125 /**
126  * GST_SDP_BWTYPE_RR:
127  *
128  * RTCP bandwidth allocated to data receivers (RFC 3556).
129  *
130  * Since: 0.10.15
131  */
132 #define GST_SDP_BWTYPE_RR               "RR"
133 /**
134  * GST_SDP_BWTYPE_TIAS:
135  *
136  * Transport Independent Application Specific Maximum bandwidth (RFC 3890).
137  *
138  * Since: 0.10.30
139  */
140 #define GST_SDP_BWTYPE_TIAS             "TIAS"
141
142
143 /**
144  * GstSDPBandwidth:
145  * @bwtype: the bandwidth modifier type
146  * @bandwidth: the bandwidth in kilobits per second
147  *
148  * The contents of the SDP "b=" field which specifies the proposed bandwidth to
149  * be used by the session or media.
150  */
151 typedef struct {
152   gchar *bwtype;
153   guint  bandwidth;
154 } GstSDPBandwidth;
155
156 /**
157  * GstSDPTime:
158  * @start: start time for the conference. The value is the decimal
159  *     representation of Network Time Protocol (NTP) time values in seconds
160  * @stop: stop time for the conference. The value is the decimal
161  *     representation of Network Time Protocol (NTP) time values in seconds
162  * @repeat: repeat times for a session
163  *
164  * The contents of the SDP "t=" field which specify the start and stop times for
165  * a conference session.
166  */
167 typedef struct {
168   gchar  *start;
169   gchar  *stop;
170   GArray *repeat;
171 } GstSDPTime;
172
173 /**
174  * GstSDPZone:
175  * @time: the NTP time that a time zone adjustment happens
176  * @typed_time: the offset from the time when the session was first scheduled
177  *
178  * The contents of the SDP "z=" field which allows the sender to
179  * specify a list of time zone adjustments and offsets from the base
180  * time.
181  */
182 typedef struct {
183   gchar *time;
184   gchar *typed_time;
185 } GstSDPZone;
186
187 /**
188  * GstSDPKey:
189  * @type: the encryption type
190  * @data: the encryption data
191  *
192  * The contents of the SDP "k=" field which is used to convey encryption
193  * keys.
194  */
195 typedef struct {
196   gchar *type;
197   gchar *data;
198 } GstSDPKey;
199
200 /**
201  * GstSDPAttribute:
202  * @key: the attribute key
203  * @value: the attribute value or NULL when it was a property attribute
204  *
205  * The contents of the SDP "a=" field which contains a key/value pair.
206  */
207 typedef struct {
208   gchar *key;
209   gchar *value;
210 } GstSDPAttribute;
211
212 /**
213  * GstSDPMedia:
214  * @media: the media type
215  * @port: the transport port to which the media stream will be sent
216  * @num_ports: the number of ports or -1 if only one port was specified
217  * @proto: the transport protocol
218  * @fmts: an array of #gchar formats
219  * @information: the media title
220  * @connections: array of #GstSDPConnection with media connection information
221  * @bandwidths: array of #GstSDPBandwidth with media bandwidth information
222  * @key: the encryption key
223  * @attributes: array of #GstSDPAttribute with the additional media attributes
224  *
225  * The contents of the SDP "m=" field with all related fields.
226  */
227 typedef struct {
228   gchar            *media;
229   guint             port;
230   guint             num_ports;
231   gchar            *proto;
232   GArray           *fmts;
233   gchar            *information;
234   GArray           *connections;
235   GArray           *bandwidths;
236   GstSDPKey         key;
237   GArray           *attributes;
238 } GstSDPMedia;
239
240 /**
241  * GstSDPMessage:
242  * @version: the protocol version
243  * @origin: owner/creator and session identifier
244  * @session_name: session name
245  * @information: session information
246  * @uri: URI of description
247  * @emails: array of #gchar with email addresses
248  * @phones: array of #gchar with phone numbers
249  * @connection: connection information for the session
250  * @bandwidths: array of #GstSDPBandwidth with bandwidth information
251  * @times: array of #GstSDPTime with time descriptions
252  * @zones: array of #GstSDPZone with time zone adjustments
253  * @key: encryption key
254  * @attributes: array of #GstSDPAttribute with session attributes
255  * @medias: array of #GstSDPMedia with media descriptions
256  *
257  * The contents of the SDP message.
258  */
259 typedef struct {
260   gchar            *version;
261   GstSDPOrigin      origin;
262   gchar            *session_name;
263   gchar            *information;
264   gchar            *uri;
265   GArray           *emails;
266   GArray           *phones;
267   GstSDPConnection  connection;
268   GArray           *bandwidths;
269   GArray           *times;
270   GArray           *zones;
271   GstSDPKey         key;
272   GArray           *attributes;
273   GArray           *medias;
274 } GstSDPMessage;
275
276 /* Session descriptions */
277 GstSDPResult            gst_sdp_message_new                 (GstSDPMessage **msg);
278 GstSDPResult            gst_sdp_message_init                (GstSDPMessage *msg);
279 GstSDPResult            gst_sdp_message_uninit              (GstSDPMessage *msg);
280 GstSDPResult            gst_sdp_message_free                (GstSDPMessage *msg);
281
282 GstSDPResult            gst_sdp_message_parse_buffer        (const guint8 *data, guint size, GstSDPMessage *msg);
283 gchar*                  gst_sdp_message_as_text             (const GstSDPMessage *msg);
284
285 /* convert from/to uri */
286 GstSDPResult            gst_sdp_message_parse_uri           (const gchar *uri, GstSDPMessage *msg);
287 gchar*                  gst_sdp_message_as_uri              (const gchar *scheme, const GstSDPMessage *msg);
288
289 /* utils */
290 gboolean                gst_sdp_address_is_multicast        (const gchar *nettype, const gchar *addrtype,
291                                                              const gchar *addr);
292 /* v=.. */
293 const gchar*            gst_sdp_message_get_version         (const GstSDPMessage *msg);
294 GstSDPResult            gst_sdp_message_set_version         (GstSDPMessage *msg, const gchar *version);
295
296 /* o=<username> <sess-id> <sess-version> <nettype> <addrtype> <unicast-address> */
297 const GstSDPOrigin*     gst_sdp_message_get_origin          (const GstSDPMessage *msg);
298 GstSDPResult            gst_sdp_message_set_origin          (GstSDPMessage *msg, const gchar *username,
299                                                              const gchar *sess_id, const gchar *sess_version,
300                                                              const gchar *nettype, const gchar *addrtype,
301                                                              const gchar *addr);
302
303 /* s=<session name> */
304 const gchar*            gst_sdp_message_get_session_name    (const GstSDPMessage *msg);
305 GstSDPResult            gst_sdp_message_set_session_name    (GstSDPMessage *msg, const gchar *session_name);
306
307 /* i=<session description> */
308 const gchar*            gst_sdp_message_get_information     (const GstSDPMessage *msg);
309 GstSDPResult            gst_sdp_message_set_information     (GstSDPMessage *msg, const gchar *information);
310
311 /* u=<uri> */
312 const gchar*            gst_sdp_message_get_uri             (const GstSDPMessage *msg);
313 GstSDPResult            gst_sdp_message_set_uri             (GstSDPMessage *msg, const gchar *uri);
314
315 /* e=<email-address> */
316 guint                   gst_sdp_message_emails_len          (const GstSDPMessage *msg);
317 const gchar*            gst_sdp_message_get_email           (const GstSDPMessage *msg, guint idx);
318 GstSDPResult            gst_sdp_message_add_email           (GstSDPMessage *msg, const gchar *email);
319
320 /* p=<phone-number> */
321 guint                   gst_sdp_message_phones_len          (const GstSDPMessage *msg);
322 const gchar*            gst_sdp_message_get_phone           (const GstSDPMessage *msg, guint idx);
323 GstSDPResult            gst_sdp_message_add_phone           (GstSDPMessage *msg, const gchar *phone);
324
325 /* c=<nettype> <addrtype> <connection-address>[/<ttl>][/<number of addresses>] */
326 const GstSDPConnection* gst_sdp_message_get_connection      (const GstSDPMessage *msg);
327 GstSDPResult            gst_sdp_message_set_connection      (GstSDPMessage *msg, const gchar *nettype,
328                                                              const gchar *addrtype, const gchar *address,
329                                                              guint ttl, guint addr_number);
330 /* b=<bwtype>:<bandwidth> */
331 guint                   gst_sdp_message_bandwidths_len      (const GstSDPMessage *msg);
332 const GstSDPBandwidth*  gst_sdp_message_get_bandwidth       (const GstSDPMessage *msg, guint idx);
333 GstSDPResult            gst_sdp_message_add_bandwidth       (GstSDPMessage *msg, const gchar *bwtype,
334                                                              guint bandwidth);
335 /* t=<start-time> <stop-time> and
336  * r=<repeat interval> <active duration> <offsets from start-time> */
337 guint                   gst_sdp_message_times_len           (const GstSDPMessage *msg);
338 const GstSDPTime*       gst_sdp_message_get_time            (const GstSDPMessage *msg, guint idx);
339 GstSDPResult            gst_sdp_message_add_time            (GstSDPMessage *msg, const gchar *start, const gchar *stop, const gchar **repeat);
340
341 /* z=<adjustment time> <offset> <adjustment time> <offset> .... */
342 guint                   gst_sdp_message_zones_len           (const GstSDPMessage *msg);
343 const GstSDPZone*       gst_sdp_message_get_zone            (const GstSDPMessage *msg, guint idx);
344 GstSDPResult            gst_sdp_message_add_zone            (GstSDPMessage *msg, const gchar *adj_time,
345                                                              const gchar *typed_time);
346
347 /* k=<method>[:<encryption key>] */
348 const GstSDPKey*        gst_sdp_message_get_key             (const GstSDPMessage *msg);
349 GstSDPResult            gst_sdp_message_set_key             (GstSDPMessage *msg, const gchar *type,
350                                                              const gchar *data);
351 /* a=... */
352 guint                   gst_sdp_message_attributes_len      (const GstSDPMessage *msg);
353 const GstSDPAttribute*  gst_sdp_message_get_attribute       (const GstSDPMessage *msg, guint idx);
354 const gchar*            gst_sdp_message_get_attribute_val   (const GstSDPMessage *msg, const gchar *key);
355 const gchar*            gst_sdp_message_get_attribute_val_n (const GstSDPMessage *msg, const gchar *key,
356                                                              guint nth);
357 GstSDPResult            gst_sdp_message_add_attribute       (GstSDPMessage *msg, const gchar *key,
358                                                              const gchar *value);
359
360 /* m=.. sections */
361 guint                   gst_sdp_message_medias_len          (const GstSDPMessage *msg);
362 const GstSDPMedia*      gst_sdp_message_get_media           (const GstSDPMessage *msg, guint idx);
363 GstSDPResult            gst_sdp_message_add_media           (GstSDPMessage *msg, GstSDPMedia *media);
364
365 GstSDPResult            gst_sdp_message_dump                (const GstSDPMessage *msg);
366
367 /* Media descriptions */
368 GstSDPResult            gst_sdp_media_new                   (GstSDPMedia **media);
369 GstSDPResult            gst_sdp_media_init                  (GstSDPMedia *media);
370 GstSDPResult            gst_sdp_media_uninit                (GstSDPMedia *media);
371 GstSDPResult            gst_sdp_media_free                  (GstSDPMedia *media);
372
373 gchar*                  gst_sdp_media_as_text               (const GstSDPMedia *media);
374
375 /* m=<media> <port>/<number of ports> <proto> <fmt> ... */
376 const gchar*            gst_sdp_media_get_media             (const GstSDPMedia *media);
377 GstSDPResult            gst_sdp_media_set_media             (GstSDPMedia *media, const gchar *med);
378
379 guint                   gst_sdp_media_get_port              (const GstSDPMedia *media);
380 guint                   gst_sdp_media_get_num_ports         (const GstSDPMedia *media);
381 GstSDPResult            gst_sdp_media_set_port_info         (GstSDPMedia *media, guint port,
382                                                              guint num_ports);
383
384 const gchar*            gst_sdp_media_get_proto             (const GstSDPMedia *media);
385 GstSDPResult            gst_sdp_media_set_proto             (GstSDPMedia *media, const gchar *proto);
386
387 guint                   gst_sdp_media_formats_len           (const GstSDPMedia *media);
388 const gchar*            gst_sdp_media_get_format            (const GstSDPMedia *media, guint idx);
389 GstSDPResult            gst_sdp_media_add_format            (GstSDPMedia *media, const gchar *format);
390
391 /* i=<session description> */
392 const gchar*            gst_sdp_media_get_information       (const GstSDPMedia *media);
393 GstSDPResult            gst_sdp_media_set_information       (GstSDPMedia *media, const gchar *information);
394
395 /* c=<nettype> <addrtype> <connection-address>[/<ttl>][/<number of addresses>] */
396 guint                   gst_sdp_media_connections_len       (const GstSDPMedia *media);
397 const GstSDPConnection* gst_sdp_media_get_connection        (const GstSDPMedia *media, guint idx);
398 GstSDPResult            gst_sdp_media_add_connection        (GstSDPMedia *media, const gchar *nettype,
399                                                              const gchar *addrtype, const gchar *address,
400                                                              guint ttl, guint addr_number);
401
402 /* b=<bwtype>:<bandwidth> */
403 guint                   gst_sdp_media_bandwidths_len        (const GstSDPMedia *media);
404 const GstSDPBandwidth*  gst_sdp_media_get_bandwidth         (const GstSDPMedia *media, guint idx);
405 GstSDPResult            gst_sdp_media_add_bandwidth         (GstSDPMedia *media, const gchar *bwtype,
406                                                              guint bandwidth);
407
408 /* k=<method>:<encryption key> */
409 const GstSDPKey*        gst_sdp_media_get_key               (const GstSDPMedia *media);
410 GstSDPResult            gst_sdp_media_set_key               (GstSDPMedia *media, const gchar *type,
411                                                              const gchar *data);
412 /* a=... */
413 guint                   gst_sdp_media_attributes_len        (const GstSDPMedia *media);
414 const GstSDPAttribute * gst_sdp_media_get_attribute         (const GstSDPMedia *media, guint idx);
415 const gchar*            gst_sdp_media_get_attribute_val     (const GstSDPMedia *media, const gchar *key);
416 const gchar*            gst_sdp_media_get_attribute_val_n   (const GstSDPMedia *media, const gchar *key,
417                                                              guint nth);
418 GstSDPResult            gst_sdp_media_add_attribute         (GstSDPMedia *media, const gchar *key,
419                                                              const gchar *value);
420
421 G_END_DECLS
422
423 #endif /* __GST_SDP_MESSAGE_H__ */