Communication Protocol Parser Utilities Library Functions
sdpaddorigin(3COMPUTIL)
NAME
sdpaddorigin, sdpaddname, sdpaddinformation,
sdpadduri, sdpaddemail, sdpaddphone,
sdpaddconnection, sdpaddbandwidth, sdpaddrepeat,
sdpaddtime, sdpaddzone, sdpaddkey, sdpaddattribute,
sdpaddmedia - add specific SDP fields to the SDP session
structure
SYNOPSIS
cc [ flag...] file... -lcommputil [ library...]
#include
int sdpaddorigin(sdpsessiont *session, const char *name,
uint64t id, uint64t ver, const char *nettype,
const char *addrtype, const char *address);
int sdpaddname(sdpsessiont *session, const char *name);
int sdpaddinformation(char **information, const char *value);
int sdpadduri(sdpsessiont *session, const char *uri);
int sdpaddemail(sdpsessiont *session, const char *email);
int sdpaddphone(sdpsessiont *session, const char *phone);
int sdpaddconnection(sdpconnt **conn, const char *nettype,
const char *addrtype, const char *address, uint8t ttl,
int addrcount);
int sdpaddbandwidth(sdpbandwidtht **bw, const char *type,
uint64t value);
int sdpaddrepeat(sdptimet *time, uint64t interval,
uint64t duration, const char *offset);
int sdpaddtime(sdpsessiont *session, uint64t starttime,
uint64t stoptime, sdptimet **time);
int sdpaddzone(sdpsessiont *session, uint64t time,
const char *offset);
SunOS 5.11 Last change: 12 Oct 2007 1
Communication Protocol Parser Utilities Library Functions
sdpaddorigin(3COMPUTIL)
int sdpaddkey(sdpkeyt **key, const char *method,
const char *enckey);
int sdpaddattribute(sdpattrt **attr, const char *name,
const char *value);
int sdpaddmedia(sdpsessiont *session, const char *name,
uintt port, int portcount, const char *protocol,
const char *format, sdpmediat **media);
DESCRIPTION
The caller has to first call sdpnewsession(3COMPUTIL) and
get pointer to a session structure. Then that pointer is
used as argument in the following functions and the session
structure is constructed. Once the structure is built the
caller converts it to a string representation using
sdpsessiontostr(3COMPUTIL).
The sdpaddorigin() function adds ORIGIN (o=) SDP field to
the session structure (sdpsessiont) using name, id, ver,
nettype, addrtype, and address.
The sdpaddname() function adds NAME (s=) SDP field to the
session structure (sdpsessiont) using name.
The sdpaddinformation() function adds INFO (i=) SDP field
to the session structure (sdpsessiont) or media structure
(sdpmediat) using value. Since this field can be either in
the media section or the session section of an SDP descrip-
tion the caller has to pass &session->sinfo or
&media->minfo as the first argument.
The sdpadduri() function adds URI (u=) SDP field to the
session structure (sdpsessiont) using uri.
The sdpaddemail() function adds EMAIL (e=) SDP field to
the session structure (sdpsessiont) using email.
The sdpaddphone() function adds PHONE (p=) SDP field to
the session structure (sdpsessiont) using phone.
SunOS 5.11 Last change: 12 Oct 2007 2
Communication Protocol Parser Utilities Library Functions
sdpaddorigin(3COMPUTIL)
The sdpaddconnection() function adds CONECTION (c=) SDP
field to the session structure (sdpsessiont) or the media
structure (sdpmediat) using nettype, addrtype, address,
ttl, and addrcount. While adding an IP4 or IP6 unicast
address the ttl and addrcount should be set to 0. For multi-
cast address the ttl should be set a reasonable value (0 -
255) and addrcount cannot be 0. Also since this field can be
either in the media section or the session section of an SDP
description, the caller has to pass &session->sconn or
&media->mconn as the first argument.
The sdpaddbandwidth() function adds BANDWIDTH (b=) SDP
field to the session structure (sdpsessiont) or the media
structure (sdpmediat) using type and value. Since this
field can be either in the media section or the session sec-
tion of an SDP description, the caller has to pass
&session->sbw or &media->mbw as the first argument.
The sdpaddtime() function adds the TIME (t=) SDP field to
the session structure using startime and stoptime. The
pointer to the newly created time structure is returned in
time. This pointer is then used in sdpaddrepeat() func-
tion.
The sdpaddrepeat() function adds the REPEAT (r=) SDP field
to the session structure using interval, duration and
offset. Here, offset is a string holding one or more offset
values, for example "60" or "60 1d 3h".
The sdpaddzone() function adds the ZONE (z=) SDP field to
the session structure using time and offset. To add multiple
time and offset values in a single zone field, call this
function once for each pair. See the example below.
The sdpaddkey() function adds the KEY (k=) SDP field to
the session structure (sdpsessiont) or media structure
(sdpmediat) using method and enckey. Since this field can
be either in the media section or the session section of an
SDP description, the caller has to pass &session->skey or
&media->mkey as the first argument.
The sdpaddattribute() function adds the ATRIBUTE (a=) SDP
field to the session structure (sdpsessiont) or media
structure (sdpmediat) using name and value. Since this
field can be either in the media section or the session
SunOS 5.11 Last change: 12 Oct 2007 3
Communication Protocol Parser Utilities Library Functions
sdpaddorigin(3COMPUTIL)
section of an SDP description, the caller has to pass
&session->sattr or &media->mattr as the first argument.
The sdpaddmedia() function adds the MEDIA (m=) SDP field
to the session structure (sdpsessiont) using name, port,
portcount, protocol, and format. Here, format is a string
holding possibly more than one value, for example, "0 31 32
97". The pointer to the newly created media structure is
returned in media. This pointer is then used to add SDP
fields specific to that media section.
RETURN VALUES
These functions return 0 on success and the appropriate
error value on failure. The value of errno is not changed by
these calls in the event of an error.
ERORS
These functions will fail if:
EINVAL Mandatory parameters are not provided (they are
null).
ENOMEM The allocation of memory failed.
EXAMPLES
Example 1 Build an SDP session structure
In the following example we see how to build an SDP session
structure using the functions described on this manual page.
We first get a pointer to sdpsessiont structure by calling
sdpnewsession(). Then to this newly created structure we
add various SDP fields. Once the structure is built we
obtain a string representation of the structure using
sdpsessiontostr() function. Since its caller responsibil-
ity to free the session we call sdpfreesession() towards
the end.
/* SDP Message we will be building
"v=0\r\n\
o=Alice 2890844526 2890842807 IN IP4 10.47.16.5\r\n\
s=-\r\n\
i=A Seminar on the session description protocol\r\n\
u=http:/www.example.com/seminars/sdp.pdf\r\n\
e=alice@example.com (Alice Smith)\r\n\
p=]1 911-345-1160\r\n\
c=IN IP4 10.47.16.5\r\n\
SunOS 5.11 Last change: 12 Oct 2007 4
Communication Protocol Parser Utilities Library Functions
sdpaddorigin(3COMPUTIL)
b=CT:1024\r\n\
t=2854678930 2854679000\r\n\
r=604800 3600 0 90000\r\n\
z=2882844526 -1h 2898848070 0h\r\n\
a=recvonly\r\n\
m=audio 49170 RTP/AVP 0\r\n\
i=audio media\r\n\
b=CT:1000\r\n\
k=prompt\r\n\
m=video 51372 RTP/AVP 99 90\r\n\
i=video media\r\n\
a=rtpmap:99 h232-199/90000\r\n\
a=rtpmap:90 h263-1998/90000\r\n"
*/
#include stdio.h>
#include string.h>
#include errno.h>
#include sdp.h>
int main ()
{
sdpsessiont *mysess;
sdpmediat *mymedia;
sdptimet *mytime;
char *bsdp;
mysess = sdpnewsession();
if (mysess == NUL) {
return (ENOMEM);
}
mysess->version = 0;
if (sdpaddname(mysess, "-") != 0)
goto errret;
if (sdpaddorigin(mysess, "Alice", 2890844526UL, 2890842807UL,
"IN", "IP4", "10.47.16.5") != 0)
goto errret;
if (sdpaddinformation(&mysess->sinfo, "A Seminar on the session"
"description protocol") != 0)
goto errret;
if (sdpadduri (mysess, "http:/www.example.com/seminars/sdp.pdf")
!= 0)
goto errret;
if (sdpaddemail(mysess, "alice@example.com (Alice smith)") != 0)
goto errret;
if (sdpaddphone(mysess, "]1 911-345-1160") != 0)
goto errret;
if (sdpaddconnection(&mysess->sconn, "IN", "IP4", "10.47.16.5",
0, 0) != 0)
goto errret;
if (sdpaddbandwidth(&mysess->sbw, "CT", 1024) != 0)
SunOS 5.11 Last change: 12 Oct 2007 5
Communication Protocol Parser Utilities Library Functions
sdpaddorigin(3COMPUTIL)
goto errret;
if (sdpaddtime(mysess, 2854678930UL, 2854679000UL, &mytime)
!= 0)
goto errret;
if (sdpaddrepeat(mytime, 604800UL, 3600UL, "0 90000") != 0)
goto errret;
if (sdpaddzone(mysess, 2882844526UL, "-1h") != 0)
goto errret;
if (sdpaddzone(mysess, 2898848070UL, "0h") != 0)
goto errret;
if (sdpaddattribute(&mysess->sattr, "sendrecv", NUL) != 0)
goto errret;
if (sdpaddmedia(mysess, "audio", 49170, 1, "RTP/AVP",
"0", &mymedia) != 0)
goto errret;
if (sdpaddinformation(&mymedia->minfo, "audio media") != 0)
goto errret;
if (sdpaddbandwidth(&mymedia->mbw, "CT", 1000) != 0)
goto errret;
if (sdpaddkey(&mymedia->mkey, "prompt", NUL) != 0)
goto errret;
if (sdpaddmedia(mysess, "video", 51732, 1, "RTP/AVP",
"99 90", &mymedia) != 0)
goto errret;
if (sdpaddinformation(&mymedia->minfo, "video media") != 0)
goto errret;
if (sdpaddattribute(&mymedia->mattr, "rtpmap",
"99 h232-199/90000") != 0)
goto errret;
if (sdpaddattribute(&mymedia->mattr, "rtpmap",
"90 h263-1998/90000") != 0)
goto errret;
bsdp = sdpsessiontostr(mysess, &error);
/*
* bsdp is the string representation of mysess structure
*/
free(bsdp);
sdpfreesession(mysess);
return (0);
errret:
free(bsdp);
sdpfreesession(mysess);
return (1);
}
ATRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
SunOS 5.11 Last change: 12 Oct 2007 6
Communication Protocol Parser Utilities Library Functions
sdpaddorigin(3COMPUTIL)
ATRIBUTE TYPE ATRIBUTE VALUE
Interface Stability Committed
MT-Level Safe
SEE ALSO
libcommputil(3LIB), sdpnewsession(3COMPUTIL),
sdpparse(3COMPUTIL), sdpsessiontostr(3COMPUTIL),
attributes(5)
SunOS 5.11 Last change: 12 Oct 2007 7
Communication Protocol Parser Utilities Library Functions
sdpaddorigin(3COMPUTIL)
SunOS 5.11 Last change: 12 Oct 2007 8
|