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