summaryrefslogtreecommitdiffstats
path: root/stream/freesdp/priv.h
blob: 4a16830356b77afec37d6f26c18606be32a40196 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
/*
  This file is part of FreeSDP
  Copyright (C) 2001,2002,2003 Federico Montesino Pouzols <fedemp@altern.org>

  FreeSDP is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

  Benjamin Zores, (C) 2006
    added support in parser for the a=control: lines.
    added support in parser for the a=range: lines.
*/

/**
 * @file priv.h
 *
 * @short Common private header for both formatting and parsing modules.
 **/

#ifndef FSDP_PRIV_H
#define FSDP_PRIV_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "common.h"

#define NTP_EPOCH_OFFSET 2208988800UL

#define FSDP_MAX_LENGTH 2000

/* Tags for doxygen documentation */

/**
 * @mainpage FreeSDP Library Reference Manual
 * @section overview Overview (README)
 * @verbinclude ../../README
 *
 **/

/**
 * @example formatdemo.c
 * 
 * A basic SDP descriptions formatter based on FreeSDP.
 **/

/**
 * @example parsedemo.c
 * 
 * A basic SDP descriptions parser based on FreeSDP.
 **/

/* Private routines declarations */

BEGIN_C_DECLS
/**
 * @short bandwidth modifier
 *
 * Holds type of modifier and value. Also holds the literal bandwidth
 * modifier if unknown.
 **/
  typedef struct
{
  fsdp_bw_modifier_type_t b_mod_type;
  unsigned long int b_value;
  char *b_unknown_bw_modt;
} fsdp_bw_modifier_t;

/**
 * @short a=rtpmap: attribute
 *
 * Holds payload type, enconding name, RTP clock rate, and encofing
 * parameters.
 **/
typedef struct
{
  char *pt;
  char *encoding_name;
  unsigned int clock_rate;
  char *parameters;
} fsdp_rtpmap_t;

/**
 * @short Connection address specification
 *
 * Holds address (unicast or multicast) as well as TTL and number of
 * ports, when it is an IP4 multicast address.
 **/
typedef struct fsdp_connection_address_t_s
{
  char *address;
  unsigned int address_ttl;
  unsigned int address_count;
} fsdp_connection_address_t;

/**
 * @short Struct for each media in a session description.
 **/
struct fsdp_media_description_t_s
{
  /* from `m=<media>  <port>  <transport> <fmt list>' line */
  fsdp_media_t media_type;
  unsigned int port;
  unsigned int port_count;
  fsdp_transport_protocol_t transport;
  char **formats;
  unsigned int formats_count;
  /* from i=<media title> */
  char *i_title;
  /* from `c=<network type> <address type> <connection address>' line
     (optional) */
  fsdp_network_type_t c_network_type;
  fsdp_address_type_t c_address_type;
  fsdp_connection_address_t c_address;
  /* from `b=<modifier>:<bandwidth-value>' lines (optional) */
  fsdp_bw_modifier_t *bw_modifiers;
  unsigned int bw_modifiers_count;
  /* from `k=<method>' or `k=<method>:<encryption key>' line
     (optional) */
  fsdp_encryption_method_t k_encryption_method;
  char *k_encryption_content;
  /* from `a=<attribute>' or `a=<attribute>:<value>' lines (opt) */
  unsigned long int a_ptime;
  unsigned long int a_maxptime;
  /* rtpmap */
  fsdp_rtpmap_t **a_rtpmaps;
  unsigned int a_rtpmaps_count;
  fsdp_orient_t a_orient;
  fsdp_sendrecv_mode_t a_sendrecv_mode;

  char **a_sdplangs;
  unsigned int a_sdplangs_count;
  char **a_langs;
  unsigned int a_langs_count;

  char **a_controls;
  unsigned int a_controls_count;

  char *a_range;

  float a_framerate;
  unsigned int a_quality;
  char **a_fmtps;
  unsigned int a_fmtps_count;
  /* rtcp attribute */
  unsigned int a_rtcp_port;
  fsdp_network_type_t a_rtcp_network_type;
  fsdp_address_type_t a_rtcp_address_type;
  char *a_rtcp_address;
  /* media attributes that are not directly supported */
  char **unidentified_attributes;
  unsigned int unidentified_attributes_count;
};

typedef struct fsdp_media_description_t_s fsdp_media_announcement_t;

/**
 * @short Information for a repeat (struct for r= lines)
 **/
typedef struct
{
  /* times in seconds */
  unsigned long int interval;
  unsigned long int duration;
  unsigned long int *offsets;
  unsigned int offsets_count;
} fsdp_repeat_t;

/**
 * @short Information about a time period
 *
 * The start and stop times as well as the information from the r=
 * lines for a t= line are stored in this structures.
 **/
typedef struct
{
  time_t start;
  time_t stop;
  fsdp_repeat_t **repeats;
  unsigned int repeats_count;
} fsdp_time_period_t;

/**
 * @short Struct for session descriptions.
 **/
struct fsdp_description_t_s
{
  /* from v=... line */
  unsigned int version;
  /* from o=... line */
  char *o_username;
  char *o_session_id;
  char *o_announcement_version;
  fsdp_network_type_t o_network_type;
  fsdp_address_type_t o_address_type;
  char *o_address;
  /* from s=... line */
  char *s_name;
  /* from i=... line (opt) */
  char *i_information;
  /* from u=... line (opt) */
  char *u_uri;
  /* from e=... lines (0 or more) */
  const char **emails;
  unsigned int emails_count;
  /* from p=... lines (0 or more) */
  const char **phones;
  unsigned int phones_count;
  /* from `c=<network type> <address type> <connection address>' line */
  fsdp_network_type_t c_network_type;
  fsdp_address_type_t c_address_type;
  fsdp_connection_address_t c_address;
  /* from `b=<modifier>:<bandwidth-value>' lines (optional) */
  fsdp_bw_modifier_t *bw_modifiers;
  unsigned int bw_modifiers_count;
  /* from `t=<start time>  <stop time>' lines (1 or more) */
  /* from `r=<repeat interval> <active duration> <list of offsets from
     start-time>' */
  fsdp_time_period_t **time_periods;
  unsigned int time_periods_count;
  /* from `z=<adjustment time> <offset> <adjustment time> <offset>
     ....' lines */
  char *timezone_adj;
  /* from `k=<method>' or `k=<method>:<encryption key>' line (opt) */
  fsdp_encryption_method_t k_encryption_method;
  char *k_encryption_content;
  /* from `a=<attribute>' or `a=<attribute>:<value>' lines (opt) */
  char *a_category;
  char *a_keywords;
  char *a_tool;
  char *a_range;
  /* rtpmap */
  fsdp_rtpmap_t **a_rtpmaps;
  unsigned int a_rtpmaps_count;
  fsdp_sendrecv_mode_t a_sendrecv_mode;
  fsdp_session_type_t a_type;
  char *a_charset;

  char **a_sdplangs;
  unsigned int a_sdplangs_count;
  char **a_langs;
  unsigned int a_langs_count;

  char **a_controls;
  unsigned int a_controls_count;
  /* from `m=<media> <port>/<number of ports> <transport> <fmt list>'
     lines [one or more] */
  fsdp_media_announcement_t **media_announcements;
  unsigned int media_announcements_count;
  /* session attributes that are not directly supported */
  char **unidentified_attributes;
  unsigned int unidentified_attributes_count;
};

#define MEDIA_RTPMAPS_MAX_COUNT 5
#define SDPLANGS_MAX_COUNT 5
#define SDPCONTROLS_MAX_COUNT 10
#define UNIDENTIFIED_ATTRIBUTES_MAX_COUNT 5

END_C_DECLS
#endif /* FSDP_PRIV_H */