2 .\" Copyright (c) 2007, Sun Microsystems Inc. All Rights Reserved.
3 .\" Portions Copyright (c) The Internet Society (2006) All Rights Reserved.
4 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
5 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
6 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
7 .TH SDP_ADD_ORIGIN 3COMMPUTIL "Oct 12, 2007"
9 sdp_add_origin, sdp_add_name, sdp_add_information, sdp_add_uri, sdp_add_email,
10 sdp_add_phone, sdp_add_connection, sdp_add_bandwidth, sdp_add_repeat,
11 sdp_add_time, sdp_add_zone, sdp_add_key, sdp_add_attribute, sdp_add_media \-
12 add specific SDP fields to the SDP session structure
16 \fBcc\fR [ \fIflag\fR...] \fIfile\fR... -\fBlcommputil\fR [ \fIlibrary\fR...]
19 \fBint\fR \fBsdp_add_origin\fR(\fBsdp_session_t *\fR\fIsession\fR, \fBconst char *\fR\fIname\fR,
20 \fBuint64_t\fR \fIid\fR, \fBuint64_t\fR \fIver\fR, \fBconst char *\fR\fInettype\fR,
21 \fBconst char *\fR\fIaddrtype\fR, \fBconst char *\fR\fIaddress\fR);
26 \fBint\fR sdp_add_name(\fBsdp_session_t *\fR\fIsession\fR, \fBconst char *\fR\fIname\fR);
31 \fBint\fR \fBsdp_add_information\fR(\fBchar **\fR\fIinformation\fR, \fBconst char *\fR\fIvalue\fR);
36 \fBint\fR \fBsdp_add_uri\fR(\fBsdp_session_t *\fR\fIsession\fR, \fBconst char *\fR\fIuri\fR);
41 \fBint\fR \fBsdp_add_email\fR(\fBsdp_session_t *\fR\fIsession\fR, \fBconst char *\fR\fIemail\fR);
46 \fBint\fR \fBsdp_add_phone\fR(\fBsdp_session_t *\fR\fIsession\fR, \fBconst char *\fR\fIphone\fR);
51 \fBint\fR \fBsdp_add_connection\fR(\fBsdp_conn_t **\fR\fIconn\fR, \fBconst char *\fR\fInettype\fR,
52 \fBconst char *\fR\fIaddrtype\fR, \fBconst char *\fR\fIaddress\fR, \fBuint8_t\fR \fIttl\fR,
53 \fBint\fR \fIaddrcount\fR);
58 \fBint\fR \fBsdp_add_bandwidth\fR(\fBsdp_bandwidth_t **\fR\fIbw\fR, \fBconst char *\fR\fItype\fR,
59 \fBuint64_t\fR \fIvalue\fR);
64 \fBint\fR \fBsdp_add_repeat\fR(\fBsdp_time_t *\fR\fItime\fR, \fBuint64_t\fR \fIinterval\fR,
65 \fBuint64_t\fR \fIduration\fR, \fBconst char *\fR\fIoffset\fR);
70 \fBint\fR \fBsdp_add_time\fR(\fBsdp_session_t *\fR\fIsession\fR, \fBuint64_t\fR \fIstarttime\fR,
71 \fBuint64_t\fR \fIstoptime\fR, \fBsdp_time_t **\fR\fItime\fR);
76 \fBint\fR \fBsdp_add_zone\fR(\fBsdp_session_t *\fR\fIsession\fR, \fBuint64_t\fR \fItime\fR,
77 \fBconst char *\fR\fIoffset\fR);
82 \fBint\fR \fBsdp_add_key\fR(\fBsdp_key_t **\fR\fIkey\fR, \fBconst char *\fR\fImethod\fR,
83 \fBconst char *\fR\fIenckey\fR);
88 \fBint\fR \fBsdp_add_attribute\fR(\fBsdp_attr_t **\fR\fIattr\fR, \fBconst char *\fR\fIname\fR,
89 \fBconst char *\fR\fIvalue\fR);
94 \fBint\fR \fBsdp_add_media\fR(\fBsdp_session_t *\fR\fIsession\fR, \fBconst char *\fR\fIname\fR,
95 \fBuint_t\fR \fIport\fR, \fBint\fR \fIportcount\fR, \fBconst char *\fR\fIprotocol\fR,
96 \fBconst char *\fR\fIformat\fR, \fBsdp_media_t **\fR\fImedia\fR);
102 The caller has to first call \fBsdp_new_session\fR(3COMMPUTIL) and get pointer
103 to a session structure. Then that pointer is used as argument in the following
104 functions and the session structure is constructed. Once the structure is built
105 the caller converts it to a string representation using
106 \fBsdp_session_to_str\fR(3COMMPUTIL).
109 The \fBsdp_add_origin()\fR function adds ORIGIN (o=) SDP field to the session
110 structure (\fBsdp_session_t\fR) using \fIname\fR, \fIid\fR, \fIver\fR,
111 \fInettype\fR, \fIaddrtype\fR, and \fIaddress\fR.
114 The \fBsdp_add_name()\fR function adds NAME (s=) SDP field to the session
115 structure (\fBsdp_session_t\fR) using \fIname\fR.
118 The \fBsdp_add_information()\fR function adds INFO (i=) SDP field to the
119 session structure (sdp_session_t) or media structure (\fBsdp_media_t\fR) using
120 value. Since this field can be either in the media section or the session
121 section of an SDP description the caller has to pass
122 &\fIsession\fR\(->\fBs_info\fR or &\fImedia\fR\(->\fBm_info\fR as the first
126 The \fBsdp_add_uri()\fR function adds URI (u=) SDP field to the session
127 structure (\fBsdp_session_t\fR) using \fIuri\fR.
130 The \fBsdp_add_email()\fR function adds EMAIL (e=) SDP field to the session
131 structure (\fBsdp_session_t\fR) using \fIemail\fR.
134 The \fBsdp_add_phone()\fR function adds PHONE (p=) SDP field to the session
135 structure (\fBsdp_session_t\fR) using \fIphone\fR.
138 The \fBsdp_add_connection()\fR function adds CONNECTION (c=) SDP field to the
139 session structure (\fBsdp_session_t\fR) or the media structure
140 (\fBsdp_media_t\fR) using \fInettype\fR, \fIaddrtype\fR, \fIaddress\fR,
141 \fIttl\fR, and \fIaddrcount\fR. While adding an IP4 or IP6 unicast address the
142 \fIttl\fR and \fIaddrcount\fR should be set to 0. For multicast address the
143 \fIttl\fR should be set a reasonable value (0 - 255) and \fIaddrcount\fR cannot
144 be 0. Also since this field can be either in the media section or the session
145 section of an SDP description, the caller has to pass
146 &\fIsession\fR\(->\fBs_conn\fR or &\fImedia\fR\(->\fBm_conn\fR as the first
150 The \fBsdp_add_bandwidth()\fR function adds BANDWIDTH (b=) SDP field to the
151 session structure (\fBsdp_session_t\fR) or the media structure
152 (\fBsdp_media_t\fR) using \fItype\fR and \fIvalue\fR. Since this field can be
153 either in the media section or the session section of an SDP description, the
154 caller has to pass &\fBsession\fR\(->\fBs_bw\fR or &\fBmedia\fR\(->\fBm_bw\fR
155 as the first argument.
158 The \fBsdp_add_time()\fR function adds the TIME (t=) SDP field to the session
159 structure using \fIstartime\fR and \fIstoptime\fR. The pointer to the newly
160 created time structure is returned in \fItime\fR. This pointer is then used in
161 \fBsdp_add_repeat()\fR function.
164 The \fBsdp_add_repeat()\fR function adds the REPEAT (r=) SDP field to the
165 session structure using interval, duration and offset. Here, offset is a string
166 holding one or more offset values, for example "60" or "60 1d 3h".
169 The \fBsdp_add_zone()\fR function adds the ZONE (z=) SDP field to the session
170 structure using \fItime\fR and \fIoffset\fR. To add multiple time and offset
171 values in a single zone field, call this function once for each pair. See the
175 The \fBsdp_add_key()\fR function adds the KEY (k=) SDP field to the session
176 structure (\fBsdp_session_t\fR) or media structure (\fBsdp_media_t\fR) using
177 \fImethod\fR and \fIenckey\fR. Since this field can be either in the media
178 section or the session section of an SDP description, the caller has to pass
179 &\fIsession\fR\(->\fBs_key\fR or &\fImedia\fR\(->\fBm_key\fR as the first
183 The \fBsdp_add_attribute()\fR function adds the ATTRIBUTE (a=) SDP field to the
184 session structure (\fBsdp_session_t\fR) or media structure (\fBsdp_media_t\fR)
185 using \fIname\fR and \fIvalue\fR. Since this field can be either in the media
186 section or the session section of an SDP description, the caller has to pass
187 &\fIsession\fR\(->\fBs_attr\fR or &\fImedia\fR\(->\fBm_attr\fR as the first
191 The \fBsdp_add_media()\fR function adds the MEDIA (m=) SDP field to the session
192 structure (\fBsdp_session_t\fR) using \fIname\fR, \fIport\fR, \fIportcount\fR,
193 \fIprotocol\fR, and \fIformat\fR. Here, \fIformat\fR is a string holding
194 possibly more than one value, for example, "0 31 32 97". The pointer to the
195 newly created media structure is returned in \fImedia\fR. This pointer is then
196 used to add SDP fields specific to that media section.
200 These functions return 0 on success and the appropriate error value on failure.
201 The value of \fBerrno\fR is not changed by these calls in the event of an
206 These functions will fail if:
213 Mandatory parameters are not provided (they are null).
222 The allocation of memory failed.
227 \fBExample 1 \fRBuild an SDP session structure
230 In the following example we see how to build an SDP session structure using the
231 functions described on this manual page. We first get a pointer to
232 \fBsdp_session_t\fR structure by calling \fBsdp_new_session()\fR. Then to this
233 newly created structure we add various SDP fields. Once the structure is built
234 we obtain a string representation of the structure using
235 \fBsdp_session_to_str()\fR function. Since its caller responsibility to free
236 the session we call \fBsdp_free_session()\fR towards the end.
241 /* SDP Message we will be building
243 o=Alice 2890844526 2890842807 IN IP4 10.47.16.5\er\en\e
245 i=A Seminar on the session description protocol\er\en\e
246 u=http://www.example.com/seminars/sdp.pdf\er\en\e
247 e=alice@example.com (Alice Smith)\er\en\e
248 p=+1 911-345-1160\er\en\e
249 c=IN IP4 10.47.16.5\er\en\e
251 t=2854678930 2854679000\er\en\e
252 r=604800 3600 0 90000\er\en\e
253 z=2882844526 -1h 2898848070 0h\er\en\e
255 m=audio 49170 RTP/AVP 0\er\en\e
256 i=audio media\er\en\e
259 m=video 51372 RTP/AVP 99 90\er\en\e
260 i=video media\er\en\e
261 a=rtpmap:99 h232-199/90000\er\en\e
262 a=rtpmap:90 h263-1998/90000\er\en"
272 sdp_session_t *my_sess;
273 sdp_media_t *my_media;
277 my_sess = sdp_new_session();
278 if (my_sess == NULL) {
281 my_sess->version = 0;
282 if (sdp_add_name(my_sess, "-") != 0)
284 if (sdp_add_origin(my_sess, "Alice", 2890844526ULL, 2890842807ULL,
285 "IN", "IP4", "10.47.16.5") != 0)
287 if (sdp_add_information(&my_sess->s_info, "A Seminar on the session"
288 "description protocol") != 0)
290 if (sdp_add_uri (my_sess, "http://www.example.com/seminars/sdp.pdf")
293 if (sdp_add_email(my_sess, "alice@example.com (Alice smith)") != 0)
295 if (sdp_add_phone(my_sess, "+1 911-345-1160") != 0)
297 if (sdp_add_connection(&my_sess->s_conn, "IN", "IP4", "10.47.16.5",
300 if (sdp_add_bandwidth(&my_sess->s_bw, "CT", 1024) != 0)
302 if (sdp_add_time(my_sess, 2854678930ULL, 2854679000ULL, &my_time)
305 if (sdp_add_repeat(my_time, 604800ULL, 3600ULL, "0 90000") != 0)
307 if (sdp_add_zone(my_sess, 2882844526ULL, "-1h") != 0)
309 if (sdp_add_zone(my_sess, 2898848070ULL, "0h") != 0)
311 if (sdp_add_attribute(&my_sess->s_attr, "sendrecv", NULL) != 0)
313 if (sdp_add_media(my_sess, "audio", 49170, 1, "RTP/AVP",
314 "0", &my_media) != 0)
316 if (sdp_add_information(&my_media->m_info, "audio media") != 0)
318 if (sdp_add_bandwidth(&my_media->m_bw, "CT", 1000) != 0)
320 if (sdp_add_key(&my_media->m_key, "prompt", NULL) != 0)
322 if (sdp_add_media(my_sess, "video", 51732, 1, "RTP/AVP",
323 "99 90", &my_media) != 0)
325 if (sdp_add_information(&my_media->m_info, "video media") != 0)
327 if (sdp_add_attribute(&my_media->m_attr, "rtpmap",
328 "99 h232-199/90000") != 0)
330 if (sdp_add_attribute(&my_media->m_attr, "rtpmap",
331 "90 h263-1998/90000") != 0)
333 b_sdp = sdp_session_to_str(my_sess, &error);
336 * b_sdp is the string representation of my_sess structure
340 sdp_free_session(my_sess);
344 sdp_free_session(my_sess);
353 See \fBattributes\fR(5) for descriptions of the following attributes:
361 ATTRIBUTE TYPE ATTRIBUTE VALUE
363 Interface Stability Committed
371 \fBlibcommputil\fR(3LIB), \fBsdp_new_session\fR(3COMMPUTIL),
372 \fBsdp_parse\fR(3COMMPUTIL), \fBsdp_session_to_str\fR(3COMMPUTIL),