sdp.docs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* -*- c -*- */
  2. /**@MODULEPAGE "sdp" - SDP Module
  3. @section sdp_meta Module Meta Information
  4. The @b sdp module provides a simple "C" parser interface for SDP [@RFC2327],
  5. <em>Session Description Protocol</em>. The parser also implements support
  6. for IPv6 addresses as per @RFC3266. The @RFC4566 should be supported, but we
  7. have not checked since draft-eitf-mmusic-sdp-new-17 or so.
  8. @CONTACT Pekka Pessi <Pekka.Pessi@nokia.com>
  9. @STATUS @SofiaSIP Core library
  10. @LICENSE LGPL
  11. Contributor(s):
  12. - Pekka Pessi <Pekka.Pessi@nokia.com>
  13. - Jari Selin <Jari.Selin@nokia.com>
  14. @section sdp_parser SDP Parser
  15. SDP parser parses an SDP message and converts it to internally used SDP
  16. structure #sdp_session_t.
  17. Typically, the SDP parser is used as follows:
  18. @code
  19. sdp_parser_t *parser = sdp_parse(home, message, len, 0);
  20. if (!sdp_session(parser)) {
  21. show(sdp_parsing_error(parser));
  22. } else {
  23. sdp_session_t *sdp = sdp_session(parser);
  24. @endcode
  25. Act upon session description, then free the parser:
  26. @code
  27. }
  28. sdp_parser_free(parser);
  29. @endcode
  30. There are various flags indicating what kind of SDP variants the sdp_parse()
  31. accepts. The sanity check run after parsing can be disabled by including
  32. flag #sdp_f_insane. The parser can be used to parse syntactically vague
  33. configuration files when using flag #sdp_f_config. The parser will then
  34. accept * for media, protocol and port, for instance.
  35. @section sdp_printer SDP Printer
  36. SDP printer converts internally used SDP structure #sdp_session_t to the
  37. standard SDP format.
  38. Typically, the SDP printer is used as follows:
  39. @code
  40. char buffer[512];
  41. sdp_printer_t *printer = sdp_print(home, session, buffer, sizeof(buffer), 0);
  42. if (sdp_message(printer)) {
  43. char const *msg = sdp_message(printer);
  44. size_t msgsize = sdp_message_size(printer);
  45. @endcode
  46. At this point, application can use the SDP message contents, e.g., it can
  47. send them to network, and then free the message:
  48. @code
  49. }
  50. else {
  51. show_critical_error(sdp_printing_error(printer));
  52. }
  53. sdp_printer_free(printer);
  54. @endcode
  55. @section sdp_example Example
  56. Examples on using SDP parser can be found from test_sdp.c and soa.c. Here is
  57. an simple example, which decodes an SDP text in @a original, increments the
  58. version number in the origin line, and encodes the SDP description again to
  59. @a buf.
  60. @code
  61. size_t increment_sdp_version(char buf[], size_t bsize,
  62. char const *original, size_t osize)
  63. {
  64. su_home_t home[1] = { SU_HOME_INIT(home) };
  65. sdp_parser_t *parser = sdp_parse(home, original, osize, 0);
  66. sdp_printer_t *printer;
  67. size_t retval = 0;
  68. if (sdp_session(parser)) {
  69. sdp_session_t *sdp = sdp_session(parser);
  70. sdp->sdp_origin->o_version++;
  71. printer = sdp_print(home, sdp, buf, bsize, 0);
  72. if (sdp_message(printer)) {
  73. retval = sdp_message_size(printer);
  74. }
  75. else {
  76. fprintf(stderr, "increment_sdp_version: %s\n",
  77. sdp_printing_error(printer));
  78. }
  79. sdp_printer_free(printer);
  80. }
  81. else {
  82. fprintf(stderr, "increment_sdp_version: %s\n",
  83. sdp_parsing_error(parser));
  84. }
  85. sdp_parser_free(parser);
  86. su_home_deinit(home);
  87. return retval;
  88. }
  89. @endcode
  90. */