Module Meta Information
The sdp module provides a simple "C" parser interface for SDP [RFC 2327], Session Description Protocol. The parser also implements support for IPv6 addresses as per RFC 3266. The RFC 4566 should be supported, but we have not checked since draft-eitf-mmusic-sdp-new-17 or so.
- Contact:\n Pekka Pessi <Pekka.Pessi@nokia-email.address.hidden>
- Status:\n Sofia SIP Core library
- License:\n LGPL
Contributor(s):
SDP Parser
SDP parser parses an SDP message and converts it to internally used SDP structure sdp_session_t.
Typically, the SDP parser is used as follows:
} else {
char const * sdp_parsing_error(sdp_parser_t *p)
Get a parsing error message.
Definition: sdp_parse.c:237
sdp_parser_t * sdp_parse(su_home_t *, char const msg[], issize_t msgsize, int flags)
Parse an SDP message.
Definition: sdp_parse.c:148
sdp_session_t * sdp_session(sdp_parser_t *p)
Retrieve an SDP session structure.
Definition: sdp_parse.c:221
struct sdp_parser_s sdp_parser_t
SDP parser handle.
Definition: sdp.h:538
Session description.
Definition: sdp.h:82
Act upon session description, then free the parser:
}
void sdp_parser_free(sdp_parser_t *p)
Free an SDP parser.
Definition: sdp_parse.c:249
There are various flags indicating what kind of SDP variants the sdp_parse() accepts. The sanity check run after parsing can be disabled by including flag sdp_f_insane. The parser can be used to parse syntactically vague configuration files when using flag sdp_f_config. The parser will then accept * for media, protocol and port, for instance.
SDP Printer
SDP printer converts internally used SDP structure sdp_session_t to the standard SDP format.
Typically, the SDP printer is used as follows:
char buffer[512];
sdp_printer_t * sdp_print(su_home_t *, sdp_session_t const *, char msgbuf[], isize_t maxmsgsize, int flags)
Print a SDP description.
Definition: sdp_print.c:129
struct sdp_printer_s sdp_printer_t
SDP printer handle.
Definition: sdp.h:555
isize_t sdp_message_size(sdp_printer_t *p)
Get size of encoded SDP message.
Definition: sdp_print.c:218
char const * sdp_message(sdp_printer_t *p)
Get encoded SDP message.
Definition: sdp_print.c:201
At this point, application can use the SDP message contents, e.g., it can send them to network, and then free the message:
}
else {
}
void sdp_printer_free(sdp_printer_t *p)
Free a SDP printer.
Definition: sdp_print.c:233
char const * sdp_printing_error(sdp_printer_t *p)
Get encoding error.
Definition: sdp_print.c:180
Example
Examples on using SDP parser can be found from test_sdp.c and soa.c. Here is an simple example, which decodes an SDP text in original, increments the version number in the origin line, and encodes the SDP description again to buf.
size_t increment_sdp_version(char buf[], size_t bsize,
char const *original, size_t osize)
{
size_t retval = 0;
printer =
sdp_print(home, sdp, buf, bsize, 0);
}
else {
fprintf(stderr, "increment_sdp_version: %s\n",
}
}
else {
fprintf(stderr, "increment_sdp_version: %s\n",
}
return retval;
}
uint64_t o_version
Version of session description.
Definition: sdp.h:107
sdp_origin_t * sdp_origin
Owner/creator and session ID.
Definition: sdp.h:86
void su_home_deinit(su_home_t *h)