1sdp_add_origCionm(m3uCnOiMcMaPtUiToInL)Protocol Parser Utilities Lisbdrpa_rayddF_uonrcitgiionn(s3COMMPUTIL)
2
3
4

NAME

6       sdp_add_origin,    sdp_add_name,    sdp_add_information,   sdp_add_uri,
7       sdp_add_email,  sdp_add_phone,  sdp_add_connection,  sdp_add_bandwidth,
8       sdp_add_repeat,      sdp_add_time,      sdp_add_zone,      sdp_add_key,
9       sdp_add_attribute, sdp_add_media - add specific SDP fields to  the  SDP
10       session structure
11

SYNOPSIS

13       cc [ flag...] file... -lcommputil [ library...]
14       #include <sdp.h>
15
16       int sdp_add_origin(sdp_session_t *session, const char *name,
17            uint64_t id, uint64_t ver, const char *nettype,
18            const char *addrtype, const char *address);
19
20
21       int sdp_add_name(sdp_session_t *session, const char *name);
22
23
24       int sdp_add_information(char **information, const char *value);
25
26
27       int sdp_add_uri(sdp_session_t *session, const char *uri);
28
29
30       int sdp_add_email(sdp_session_t *session, const char *email);
31
32
33       int sdp_add_phone(sdp_session_t *session, const char *phone);
34
35
36       int sdp_add_connection(sdp_conn_t **conn, const char *nettype,
37            const char *addrtype, const char *address, uint8_t ttl,
38            int addrcount);
39
40
41       int sdp_add_bandwidth(sdp_bandwidth_t **bw, const char *type,
42            uint64_t value);
43
44
45       int sdp_add_repeat(sdp_time_t *time, uint64_t interval,
46            uint64_t duration, const char *offset);
47
48
49       int sdp_add_time(sdp_session_t *session, uint64_t starttime,
50            uint64_t stoptime, sdp_time_t **time);
51
52
53       int sdp_add_zone(sdp_session_t *session, uint64_t time,
54            const char *offset);
55
56
57       int sdp_add_key(sdp_key_t **key, const char *method,
58            const char *enckey);
59
60
61       int sdp_add_attribute(sdp_attr_t **attr, const char *name,
62            const char *value);
63
64
65       int sdp_add_media(sdp_session_t *session, const char *name,
66            uint_t port, int portcount, const char *protocol,
67            const char *format, sdp_media_t **media);
68
69

DESCRIPTION

71       The  caller  has  to  first  call  sdp_new_session(3COMMPUTIL)  and get
72       pointer to a session structure. Then that pointer is used  as  argument
73       in  the  following  functions and the session structure is constructed.
74       Once the structure is built the caller converts it to a  string  repre‐
75       sentation using sdp_session_to_str(3COMMPUTIL).
76
77
78       The sdp_add_origin() function adds ORIGIN (o=) SDP field to the session
79       structure (sdp_session_t) using name, id, ver, nettype,  addrtype,  and
80       address.
81
82
83       The  sdp_add_name()  function  adds  NAME (s=) SDP field to the session
84       structure (sdp_session_t) using name.
85
86
87       The sdp_add_information() function adds INFO (i=) SDP field to the ses‐
88       sion  structure  (sdp_session_t) or media structure (sdp_media_t) using
89       value. Since this field can be either in the media section or the  ses‐
90       sion  section  of  an  SDP  description  the  caller  has to pass &ses‐
91       sions_info or &mediam_info as the first argument.
92
93
94       The sdp_add_uri() function adds URI  (u=)  SDP  field  to  the  session
95       structure (sdp_session_t) using uri.
96
97
98       The  sdp_add_email()  function adds EMAIL (e=) SDP field to the session
99       structure (sdp_session_t) using email.
100
101
102       The sdp_add_phone() function adds PHONE (p=) SDP field to  the  session
103       structure (sdp_session_t) using phone.
104
105
106       The sdp_add_connection() function adds CONNECTION (c=) SDP field to the
107       session structure (sdp_session_t) or the media structure  (sdp_media_t)
108       using  nettype,  addrtype, address, ttl, and addrcount. While adding an
109       IP4 or IP6 unicast address the ttl and addrcount should be  set  to  0.
110       For  multicast  address  the  ttl should be set a reasonable value (0 -
111       255) and addrcount cannot be 0. Also since this field can be either  in
112       the  media  section  or  the session section of an SDP description, the
113       caller has to pass &sessions_conn or &mediam_conn as the first  argu‐
114       ment.
115
116
117       The  sdp_add_bandwidth()  function adds BANDWIDTH (b=) SDP field to the
118       session structure (sdp_session_t) or the media structure  (sdp_media_t)
119       using  type and value. Since this field can be either in the media sec‐
120       tion or the session section of an SDP description, the  caller  has  to
121       pass &sessions_bw or &mediam_bw as the first argument.
122
123
124       The sdp_add_time() function adds the TIME (t=) SDP field to the session
125       structure using startime and stoptime. The pointer to the newly created
126       time  structure  is  returned  in  time.  This  pointer is then used in
127       sdp_add_repeat() function.
128
129
130       The sdp_add_repeat() function adds the REPEAT (r=)  SDP  field  to  the
131       session  structure using interval, duration and offset. Here, offset is
132       a string holding one or more offset values, for example "60" or "60  1d
133       3h".
134
135
136       The sdp_add_zone() function adds the ZONE (z=) SDP field to the session
137       structure using time and offset. To add multiple time and offset values
138       in  a single zone field, call this function once for each pair. See the
139       example below.
140
141
142       The sdp_add_key() function adds the KEY (k=) SDP field to  the  session
143       structure (sdp_session_t) or media structure (sdp_media_t) using method
144       and enckey.  Since this field can be either in the media section or the
145       session  section  of  an  SDP description, the caller has to pass &ses‐
146       sions_key or &mediam_key as the first argument.
147
148
149       The sdp_add_attribute() function adds the ATTRIBUTE (a=) SDP  field  to
150       the  session structure (sdp_session_t) or media structure (sdp_media_t)
151       using name and value. Since this field can be either in the media  sec‐
152       tion  or  the  session section of an SDP description, the caller has to
153       pass &sessions_attr or &mediam_attr as the first argument.
154
155
156       The sdp_add_media() function adds the MEDIA (m=) SDP field to the  ses‐
157       sion  structure  (sdp_session_t) using name, port, portcount, protocol,
158       and format. Here, format is a string holding  possibly  more  than  one
159       value,  for  example,  "0  31  32 97". The pointer to the newly created
160       media structure is returned in media. This pointer is then used to  add
161       SDP fields specific to that media section.
162

RETURN VALUES

164       These  functions return 0 on success and the appropriate error value on
165       failure. The value of errno is not changed by these calls in the  event
166       of an error.
167

ERRORS

169       These functions will fail if:
170
171       EINVAL    Mandatory parameters are not provided (they are null).
172
173
174       ENOMEM    The allocation of memory failed.
175
176

EXAMPLES

178       Example 1 Build an SDP session structure
179
180
181       In  the  following example we see how to build an SDP session structure
182       using the functions described on this  manual  page.  We  first  get  a
183       pointer  to  sdp_session_t structure by calling sdp_new_session(). Then
184       to this newly created structure we add various  SDP  fields.  Once  the
185       structure  is  built we obtain a string representation of the structure
186       using sdp_session_to_str() function. Since its caller responsibility to
187       free the session we call sdp_free_session() towards the end.
188
189
190         /* SDP Message we will be building
191         "v=0\r\n\
192         o=Alice 2890844526 2890842807 IN IP4 10.47.16.5\r\n\
193         s=-\r\n\
194         i=A Seminar on the session description protocol\r\n\
195         u=http://www.example.com/seminars/sdp.pdf\r\n\
196         e=alice@example.com (Alice Smith)\r\n\
197         p=+1 911-345-1160\r\n\
198         c=IN IP4 10.47.16.5\r\n\
199         b=CT:1024\r\n\
200         t=2854678930 2854679000\r\n\
201         r=604800 3600 0 90000\r\n\
202         z=2882844526 -1h 2898848070 0h\r\n\
203         a=recvonly\r\n\
204         m=audio 49170 RTP/AVP 0\r\n\
205         i=audio media\r\n\
206         b=CT:1000\r\n\
207         k=prompt\r\n\
208         m=video 51372 RTP/AVP 99 90\r\n\
209         i=video media\r\n\
210         a=rtpmap:99 h232-199/90000\r\n\
211         a=rtpmap:90 h263-1998/90000\r\n"
212         */
213
214         #include stdio.h>
215         #include string.h>
216         #include errno.h>
217         #include sdp.h>
218
219         int main ()
220         {
221             sdp_session_t         *my_sess;
222             sdp_media_t           *my_media;
223             sdp_time_t            *my_time;
224             char *b_sdp;
225
226             my_sess = sdp_new_session();
227             if (my_sess == NULL) {
228                 return (ENOMEM);
229             }
230             my_sess->version = 0;
231             if (sdp_add_name(my_sess, "-") != 0)
232                 goto err_ret;
233             if (sdp_add_origin(my_sess, "Alice", 2890844526ULL, 2890842807ULL,
234                  "IN", "IP4", "10.47.16.5") != 0)
235                 goto err_ret;
236             if (sdp_add_information(&my_sess->s_info, "A Seminar on the session"
237                         "description protocol") != 0)
238                 goto err_ret;
239             if (sdp_add_uri (my_sess, "http://www.example.com/seminars/sdp.pdf")
240                         != 0)
241                 goto err_ret;
242             if (sdp_add_email(my_sess, "alice@example.com (Alice smith)") != 0)
243                 goto err_ret;
244             if (sdp_add_phone(my_sess, "+1 911-345-1160") != 0)
245                 goto err_ret;
246             if (sdp_add_connection(&my_sess->s_conn, "IN", "IP4", "10.47.16.5",
247                        0, 0) != 0)
248                 goto err_ret;
249             if (sdp_add_bandwidth(&my_sess->s_bw, "CT", 1024) != 0)
250                 goto err_ret;
251             if (sdp_add_time(my_sess, 2854678930ULL, 2854679000ULL, &my_time)
252                        != 0)
253                 goto err_ret;
254             if (sdp_add_repeat(my_time, 604800ULL, 3600ULL, "0 90000") != 0)
255                 goto err_ret;
256             if (sdp_add_zone(my_sess, 2882844526ULL, "-1h") != 0)
257                 goto err_ret;
258             if (sdp_add_zone(my_sess, 2898848070ULL, "0h") != 0)
259                 goto err_ret;
260             if (sdp_add_attribute(&my_sess->s_attr, "sendrecv", NULL) != 0)
261                 goto err_ret;
262             if (sdp_add_media(my_sess, "audio", 49170, 1, "RTP/AVP",
263                               "0", &my_media) != 0)
264                 goto err_ret;
265             if (sdp_add_information(&my_media->m_info, "audio media") != 0)
266                 goto err_ret;
267             if (sdp_add_bandwidth(&my_media->m_bw, "CT", 1000) != 0)
268                 goto err_ret;
269             if (sdp_add_key(&my_media->m_key, "prompt", NULL) != 0)
270                 goto err_ret;
271             if (sdp_add_media(my_sess, "video", 51732, 1, "RTP/AVP",
272                         "99 90", &my_media) != 0)
273                 goto err_ret;
274             if (sdp_add_information(&my_media->m_info, "video media") != 0)
275                 goto err_ret;
276             if (sdp_add_attribute(&my_media->m_attr, "rtpmap",
277                       "99 h232-199/90000") != 0)
278                 goto err_ret;
279             if (sdp_add_attribute(&my_media->m_attr, "rtpmap",
280                       "90 h263-1998/90000") != 0)
281                 goto err_ret;
282             b_sdp = sdp_session_to_str(my_sess, &error);
283
284             /*
285              * b_sdp is the string representation of my_sess structure
286              */
287
288             free(b_sdp);
289             sdp_free_session(my_sess);
290             return (0);
291         err_ret:
292             free(b_sdp);
293             sdp_free_session(my_sess);
294             return (1);
295         }
296
297

ATTRIBUTES

299       See attributes(5) for descriptions of the following attributes:
300
301
302
303
304       ┌─────────────────────────────┬─────────────────────────────┐
305       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
306       ├─────────────────────────────┼─────────────────────────────┤
307       │Interface Stability          │Committed                    │
308       ├─────────────────────────────┼─────────────────────────────┤
309       │MT-Level                     │Safe                         │
310       └─────────────────────────────┴─────────────────────────────┘
311

SEE ALSO

313       libcommputil(3LIB), sdp_new_session(3COMMPUTIL), sdp_parse(3COMMPUTIL),
314       sdp_session_to_str(3COMMPUTIL), attributes(5)
315
316
317
318SunOS 5.11                        12 Oct 2007       sdp_add_origin(3COMMPUTIL)
Impressum