mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-30 10:02:46 +00:00
RTP: replace use_ipv6 by force_ip_version
This commit is contained in:
@@ -649,9 +649,9 @@ int udp_addr_valid(const char *addr)
|
||||
* Returns: a pointer to a valid socket_udp structure on success, NULL otherwise.
|
||||
**/
|
||||
socket_udp *udp_init(const char *addr, uint16_t rx_port, uint16_t tx_port,
|
||||
int ttl, bool use_ipv6, bool multithreaded)
|
||||
int ttl, int force_ip_version, bool multithreaded)
|
||||
{
|
||||
return udp_init_if(addr, NULL, rx_port, tx_port, ttl, use_ipv6, multithreaded);
|
||||
return udp_init_if(addr, NULL, rx_port, tx_port, ttl, force_ip_version, multithreaded);
|
||||
}
|
||||
|
||||
ADD_TO_PARAM(udp_queue_len, "udp-queue-len",
|
||||
@@ -668,13 +668,13 @@ ADD_TO_PARAM(udp_queue_len, "udp-queue-len",
|
||||
* @param rx_port receive port.
|
||||
* @param tx_port transmit port.
|
||||
* @param ttl time-to-live value for transmitted packets.
|
||||
* @param use_ipv6 whether to use IPv6 for hostname
|
||||
* @param force_ip_version force specific IP version
|
||||
* @param multithreaded receiving in a separate thread than processing
|
||||
*
|
||||
* @returns a pointer to a socket_udp structure on success, NULL otherwise.
|
||||
**/
|
||||
socket_udp *udp_init_if(const char *addr, const char *iface, uint16_t rx_port,
|
||||
uint16_t tx_port, int ttl, bool use_ipv6, bool multithreaded)
|
||||
uint16_t tx_port, int ttl, int force_ip_version, bool multithreaded)
|
||||
{
|
||||
int ret;
|
||||
int reuse = 1;
|
||||
@@ -686,9 +686,8 @@ socket_udp *udp_init_if(const char *addr, const char *iface, uint16_t rx_port,
|
||||
s->local = new socket_udp_local();
|
||||
s->local->fd = INVALID_SOCKET;
|
||||
|
||||
if (use_ipv6) {
|
||||
s->local->mode = IPv6;
|
||||
}
|
||||
assert(force_ip_version == 0 || force_ip_version == 4 || force_ip_version == 6);
|
||||
s->local->mode = force_ip_version;
|
||||
|
||||
if ((ret = resolve_address(s, addr, tx_port)) != 0) {
|
||||
log_msg(LOG_LEVEL_ERROR, "Can't resolve IP address for %s: %s\n", addr,
|
||||
|
||||
@@ -53,8 +53,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
int udp_addr_valid(const char *addr);
|
||||
socket_udp *udp_init(const char *addr, uint16_t rx_port, uint16_t tx_port, int ttl, bool use_ipv6, bool multithreaded);
|
||||
socket_udp *udp_init_if(const char *addr, const char *iface, uint16_t rx_port, uint16_t tx_port, int ttl, bool use_ipv6, bool multithreaded);
|
||||
socket_udp *udp_init(const char *addr, uint16_t rx_port, uint16_t tx_port, int ttl, int force_ip_version, bool multithreaded);
|
||||
socket_udp *udp_init_if(const char *addr, const char *iface, uint16_t rx_port, uint16_t tx_port, int ttl, int force_ip_version, bool multithreaded);
|
||||
void udp_exit(socket_udp *s);
|
||||
|
||||
int udp_peek(socket_udp *s, char *buffer, int buflen);
|
||||
@@ -97,7 +97,7 @@ int udp_fd_isset_r(socket_udp *s, struct udp_fd_r *);
|
||||
|
||||
int udp_recv_data(socket_udp * s, char **buffer);
|
||||
bool udp_not_empty(socket_udp *s, struct timeval *timeout);
|
||||
bool udp_port_pair_is_free(const char *addr, bool use_ipv6, int even_port);
|
||||
bool udp_port_pair_is_free(const char *addr, int force_ip_version, int even_port);
|
||||
bool udp_is_ipv6(socket_udp *s);
|
||||
|
||||
void socket_error(const char *msg, ...);
|
||||
|
||||
@@ -1026,10 +1026,10 @@ struct rtp *rtp_init(const char *addr,
|
||||
uint16_t rx_port, uint16_t tx_port,
|
||||
int ttl, double rtcp_bw,
|
||||
int tfrc_on, rtp_callback callback, uint8_t * userdata,
|
||||
bool use_ipv6, bool multithreaded)
|
||||
int force_ip_version, bool multithreaded)
|
||||
{
|
||||
return rtp_init_if(addr, NULL, rx_port, tx_port, ttl, rtcp_bw, tfrc_on,
|
||||
callback, userdata, use_ipv6, multithreaded);
|
||||
callback, userdata, force_ip_version, multithreaded);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1049,7 +1049,7 @@ struct rtp *rtp_init(const char *addr,
|
||||
* @callback: See section on #rtp_callback.
|
||||
* @userdata: Opaque data associated with the session. See
|
||||
* rtp_get_userdata().
|
||||
* @use_ipv6 whether or not use IP version 6
|
||||
* @force_ip_version if IPv4 or IPv4 is requested, pass 4 or 6 respectively, otherwise 0
|
||||
* @multithreaded if set to true uses separate thread to receive data (performance optimization)
|
||||
*
|
||||
* Creates and initializes an RTP session.
|
||||
@@ -1061,15 +1061,19 @@ struct rtp *rtp_init_if(const char *addr, const char *iface,
|
||||
uint16_t rx_port, uint16_t tx_port,
|
||||
int ttl, double rtcp_bw,
|
||||
int tfrc_on, rtp_callback callback, uint8_t * userdata,
|
||||
bool use_ipv6, bool multithreaded)
|
||||
int force_ip_version, bool multithreaded)
|
||||
{
|
||||
struct rtp *session;
|
||||
int i, j;
|
||||
char *cname;
|
||||
char *hname;
|
||||
|
||||
if (force_ip_version != 0 && force_ip_version != 4 && force_ip_version != 6) {
|
||||
log_msg(LOG_LEVEL_ERROR, "IP version must be either 4 or 6 (or 0)\n");
|
||||
return NULL;
|
||||
}
|
||||
if (ttl < 0 || ttl > 255) {
|
||||
fprintf(stderr, "ttl must be in range [0..255]\n");
|
||||
log_msg(LOG_LEVEL_ERROR, "ttl must be in range [0..255]\n");
|
||||
return NULL;
|
||||
}
|
||||
if (rx_port % 2) {
|
||||
@@ -1091,7 +1095,7 @@ struct rtp *rtp_init_if(const char *addr, const char *iface,
|
||||
if (rx_port == 0) {
|
||||
for (int i = 1<<15; i < 1<<16; i += 2) {
|
||||
// this stuff is not atomic. but... it cannot be done in this way, either
|
||||
if (udp_port_pair_is_free(addr, use_ipv6, i)) {
|
||||
if (udp_port_pair_is_free(addr, force_ip_version, i)) {
|
||||
rx_port = i;
|
||||
break;
|
||||
}
|
||||
@@ -1105,11 +1109,11 @@ struct rtp *rtp_init_if(const char *addr, const char *iface,
|
||||
if (tx_port == 0) {
|
||||
tx_port = rx_port;
|
||||
}
|
||||
session->rtp_socket = udp_init_if(addr, iface, rx_port, tx_port, ttl, use_ipv6, multithreaded);
|
||||
session->rtp_socket = udp_init_if(addr, iface, rx_port, tx_port, ttl, force_ip_version, multithreaded);
|
||||
|
||||
session->rtcp_socket =
|
||||
udp_init_if(addr, iface, (uint16_t) (rx_port + (rx_port ? 1 : 0)),
|
||||
(uint16_t) (tx_port + (tx_port ? 1 : 0)), ttl, use_ipv6, false);
|
||||
(uint16_t) (tx_port + (tx_port ? 1 : 0)), ttl, force_ip_version, false);
|
||||
|
||||
init_opt(session);
|
||||
|
||||
|
||||
@@ -230,14 +230,14 @@ rtp_t rtp_init(const char *addr,
|
||||
int tfrc_on,
|
||||
rtp_callback callback,
|
||||
uint8_t *userdata,
|
||||
bool use_ipv6, bool multithreaded);
|
||||
int force_ip_version, bool multithreaded);
|
||||
rtp_t rtp_init_if(const char *addr, const char *iface,
|
||||
uint16_t rx_port, uint16_t tx_port,
|
||||
int ttl, double rtcp_bw,
|
||||
int tfrc_on,
|
||||
rtp_callback callback,
|
||||
uint8_t *userdata,
|
||||
bool use_ipv6, bool multithreaded);
|
||||
int force_ip_version, bool multithreaded);
|
||||
rtp_t rtp_init_with_udp_socket(struct socket_udp_local *l, struct sockaddr *sa, socklen_t len, rtp_callback callback);
|
||||
|
||||
void rtp_send_bye(struct rtp *session);
|
||||
|
||||
Reference in New Issue
Block a user