transport_udp.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  3. * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #ifndef __PJMEDIA_TRANSPORT_UDP_H__
  20. #define __PJMEDIA_TRANSPORT_UDP_H__
  21. /**
  22. * @file transport_udp.h
  23. * @brief Stream transport with UDP.
  24. */
  25. #include <pjmedia/stream.h>
  26. /**
  27. * @defgroup PJMEDIA_TRANSPORT_UDP UDP Media Transport
  28. * @ingroup PJMEDIA_TRANSPORT
  29. * @brief Implementation of media transport with UDP sockets.
  30. * @{
  31. *
  32. * The UDP media transport is the standard based media transport
  33. * as described by RFC 3550/3551. It can be used to facilitate RTP/RTCP
  34. * unicast or multicast communication.
  35. */
  36. PJ_BEGIN_DECL
  37. /**
  38. * Options that can be specified when creating UDP transport.
  39. */
  40. enum pjmedia_transport_udp_options
  41. {
  42. /**
  43. * Normally the UDP transport will continuously check the source address
  44. * of incoming packets to see if it is different than the configured
  45. * remote address, and switch the remote address to the source address
  46. * of the packet if they are different after several packets are
  47. * received.
  48. * Specifying this option will disable this feature.
  49. */
  50. PJMEDIA_UDP_NO_SRC_ADDR_CHECKING = 1
  51. };
  52. /**
  53. * Create an RTP and RTCP sockets and bind the sockets to the specified
  54. * port to create media transport.
  55. *
  56. * @param endpt The media endpoint instance.
  57. * @param name Optional name to be assigned to the transport.
  58. * @param port UDP port number for the RTP socket. The RTCP port number
  59. * will be set to one above RTP port.
  60. * @param options Options, bitmask of #pjmedia_transport_udp_options.
  61. * @param p_tp Pointer to receive the transport instance.
  62. *
  63. * @return PJ_SUCCESS on success.
  64. */
  65. PJ_DECL(pj_status_t) pjmedia_transport_udp_create(pjmedia_endpt *endpt,
  66. const char *name,
  67. int port,
  68. unsigned options,
  69. pjmedia_transport **p_tp);
  70. /**
  71. * Create an RTP and RTCP sockets and bind the sockets to the specified
  72. * address and port to create media transport.
  73. *
  74. * @param endpt The media endpoint instance.
  75. * @param name Optional name to be assigned to the transport.
  76. * @param addr Optional local address to bind the sockets to. If this
  77. * argument is NULL or empty, the sockets will be bound
  78. * to all interface.
  79. * @param port UDP port number for the RTP socket. The RTCP port number
  80. * will be set to one above RTP port.
  81. * @param options Options, bitmask of #pjmedia_transport_udp_options.
  82. * @param p_tp Pointer to receive the transport instance.
  83. *
  84. * @return PJ_SUCCESS on success.
  85. */
  86. PJ_DECL(pj_status_t) pjmedia_transport_udp_create2(pjmedia_endpt *endpt,
  87. const char *name,
  88. const pj_str_t *addr,
  89. int port,
  90. unsigned options,
  91. pjmedia_transport **p_tp);
  92. /**
  93. * Another variant of #pjmedia_transport_udp_create() which allows
  94. * the creation of IPv6 transport.
  95. *
  96. * @param endpt The media endpoint instance.
  97. * @param af Address family, which can be pj_AF_INET() for IPv4 or
  98. * pj_AF_INET6() for IPv6.
  99. * @param name Optional name to be assigned to the transport.
  100. * @param addr Optional local address to bind the sockets to. If this
  101. * argument is NULL or empty, the sockets will be bound
  102. * to all interface.
  103. * @param port UDP port number for the RTP socket. The RTCP port number
  104. * will be set to one above RTP port.
  105. * @param options Options, bitmask of #pjmedia_transport_udp_options.
  106. * @param p_tp Pointer to receive the transport instance.
  107. *
  108. * @return PJ_SUCCESS on success.
  109. */
  110. PJ_DECL(pj_status_t) pjmedia_transport_udp_create3(pjmedia_endpt *endpt,
  111. int af,
  112. const char *name,
  113. const pj_str_t *addr,
  114. int port,
  115. unsigned options,
  116. pjmedia_transport **p_tp);
  117. /**
  118. * Create UDP stream transport from existing sockets. Use this function when
  119. * the sockets have previously been created.
  120. *
  121. * @param endpt The media endpoint instance.
  122. * @param name Optional name to be assigned to the transport.
  123. * @param si Media socket info containing the RTP and RTCP sockets.
  124. * @param options Options, bitmask of #pjmedia_transport_udp_options.
  125. * @param p_tp Pointer to receive the transport instance.
  126. *
  127. * @return PJ_SUCCESS on success.
  128. */
  129. PJ_DECL(pj_status_t) pjmedia_transport_udp_attach(pjmedia_endpt *endpt,
  130. const char *name,
  131. const pjmedia_sock_info *si,
  132. unsigned options,
  133. pjmedia_transport **p_tp);
  134. PJ_END_DECL
  135. /**
  136. * @}
  137. */
  138. #endif /* __PJMEDIA_TRANSPORT_UDP_H__ */