mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-21 06:40:15 +00:00
Added -T/--ttl parameter
This commit is contained in:
@@ -108,6 +108,7 @@ struct audio_network_parameters {
|
||||
struct pdb *participants = 0;
|
||||
int force_ip_version = 0;
|
||||
char *mcast_if = nullptr;
|
||||
int ttl = -1;
|
||||
};
|
||||
|
||||
struct state_audio {
|
||||
@@ -238,7 +239,8 @@ struct state_audio * audio_cfg_init(struct module *parent, const char *addrs, in
|
||||
char *audio_channel_map, const char *audio_scale,
|
||||
bool echo_cancellation, int force_ip_version, const char *mcast_if,
|
||||
const char *audio_codec_cfg,
|
||||
long long int bitrate, volatile int *audio_delay, const std::chrono::steady_clock::time_point *start_time, int mtu, struct exporter *exporter)
|
||||
long long int bitrate, volatile int *audio_delay, const std::chrono::steady_clock::time_point *start_time,
|
||||
int mtu, int ttl, struct exporter *exporter)
|
||||
{
|
||||
struct state_audio *s = NULL;
|
||||
char *tmp, *unused = NULL;
|
||||
@@ -313,6 +315,7 @@ struct state_audio * audio_cfg_init(struct module *parent, const char *addrs, in
|
||||
s->audio_network_parameters.force_ip_version = force_ip_version;
|
||||
s->audio_network_parameters.mcast_if = mcast_if
|
||||
? strdup(mcast_if) : NULL;
|
||||
s->audio_network_parameters.ttl = ttl;
|
||||
|
||||
if ((s->audio_network_device = initialize_audio_network(
|
||||
&s->audio_network_parameters))
|
||||
@@ -504,17 +507,8 @@ static struct rtp *initialize_audio_network(struct audio_network_parameters *par
|
||||
struct rtp *r;
|
||||
double rtcp_bw = 1024 * 512; // FIXME: something about 5% for rtcp is said in rfc
|
||||
|
||||
int ttl = 255;
|
||||
if (commandline_params.find("ttl") != commandline_params.end()) {
|
||||
ttl = stoi(commandline_params.at("ttl"));
|
||||
if (ttl < -1 || ttl > 255) {
|
||||
log_msg(LOG_LEVEL_ERROR, "TTL must be in range 0..255 or -1!");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
r = rtp_init_if(params->addr, params->mcast_if, params->recv_port,
|
||||
params->send_port, ttl, rtcp_bw,
|
||||
params->send_port, params->ttl, rtcp_bw,
|
||||
FALSE, rtp_recv_callback,
|
||||
(uint8_t *) params->participants,
|
||||
params->force_ip_version, false);
|
||||
|
||||
@@ -67,7 +67,8 @@ struct state_audio * audio_cfg_init(struct module *parent, const char *addrs, in
|
||||
const char *fec_cfg, const char *encryption,
|
||||
char *audio_channel_map, const char *audio_scale,
|
||||
bool echo_cancellation, int force_ip_version, const char *mcast_iface, const char *audio_codec_cfg,
|
||||
long long int bitrate, volatile int *audio_delay, const std::chrono::steady_clock::time_point *start_time, int mtu, struct exporter *exporter);
|
||||
long long int bitrate, volatile int *audio_delay, const std::chrono::steady_clock::time_point *start_time,
|
||||
int mtu, int ttl, struct exporter *exporter);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -651,8 +651,6 @@ ADD_TO_PARAM("audio-disable-adaptive-buffer", "* audio-disable-adaptive-buffer\n
|
||||
ADD_TO_PARAM("low-latency-audio", "* low-latency-audio[=ultra]\n"
|
||||
" Try to reduce audio latency at the expense of worse reliability\n"
|
||||
" Add ultra for even more aggressive setting.\n");
|
||||
ADD_TO_PARAM("ttl", "* ttl=<ttl>\n"
|
||||
" TTL to be used for transmission in range 0-255 or -1 to use default values.\n");
|
||||
ADD_TO_PARAM("window-title", "* window-title=<title>\n"
|
||||
" Use alternative window title (SDL/GL only)\n");
|
||||
|
||||
|
||||
17
src/main.cpp
17
src/main.cpp
@@ -380,8 +380,9 @@ static void usage(const char *exec_path, bool full = false)
|
||||
print_help_item("-m <mtu>", {"set path MTU assumption towards receiver"});
|
||||
print_help_item("-M <video_mode>", {"received video mode (eg tiled-4K, 3D,",
|
||||
"dual-link)"});
|
||||
print_help_item("-p <postprocess> | help", {"postprocess module"});
|
||||
print_help_item("-N|--nat-traverse"s, {"try to deploy NAT traversal techniques"s});
|
||||
print_help_item("-p <postprocess> | help", {"postprocess module"});
|
||||
print_help_item("-T/--ttl <num>", {"Use specified TTL for multicast/unicast (0..255, -1 for default)"});
|
||||
}
|
||||
print_help_item("-f [A:|V:]<settings>", {"FEC settings (audio or video) - use",
|
||||
"\"none\", \"mult:<nr>\",", "\"ldgm:<max_expected_loss>%%\" or", "\"ldgm:<k>:<m>:<c>\"",
|
||||
@@ -624,6 +625,7 @@ int main(int argc, char *argv[])
|
||||
char *audio_channel_map = NULL;
|
||||
const char *audio_scale = "mixauto";
|
||||
int port_base = PORT_BASE;
|
||||
int requested_ttl = 255;
|
||||
int video_rx_port = -1, video_tx_port = -1, audio_rx_port = -1, audio_tx_port = -1;
|
||||
|
||||
bool echo_cancellation = false;
|
||||
@@ -711,9 +713,10 @@ int main(int argc, char *argv[])
|
||||
{"pix-fmts", no_argument, 0, OPT_PIX_FMTS},
|
||||
{"video-codecs", no_argument, 0, OPT_VIDEO_CODECS},
|
||||
{"nat-traverse", optional_argument, nullptr, 'N'},
|
||||
{"ttl", required_argument, nullptr, 'T'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
const char *optstring = "d:t:m:r:s:v46c:hM:N::p:f:P:l:A:V";
|
||||
const char *optstring = "d:t:m:r:s:v46c:hM:N::p:f:P:l:A:VT:";
|
||||
|
||||
const char *audio_protocol = "ultragrid_rtp";
|
||||
const char *audio_protocol_opts = "";
|
||||
@@ -1076,6 +1079,13 @@ int main(int argc, char *argv[])
|
||||
case 'N':
|
||||
nat_traverse_config = optarg == nullptr ? "" : optarg;
|
||||
break;
|
||||
case 'T':
|
||||
requested_ttl = stoi(optarg);
|
||||
if (requested_ttl < -1 || requested_ttl >= 255) {
|
||||
LOG(LOG_LEVEL_ERROR) << "TTL must be in range [0..255] or -1!\n";
|
||||
EXIT(EXIT_FAIL_USAGE);
|
||||
}
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
usage(uv_argv[0]);
|
||||
@@ -1237,7 +1247,7 @@ int main(int argc, char *argv[])
|
||||
audio_channel_map,
|
||||
audio_scale, echo_cancellation, force_ip_version, requested_mcast_if,
|
||||
audio_codec, bitrate, &audio_offset, &start_time,
|
||||
requested_mtu, exporter);
|
||||
requested_mtu, requested_ttl, exporter);
|
||||
if(!uv.audio) {
|
||||
exit_uv(EXIT_FAIL_AUDIO);
|
||||
goto cleanup;
|
||||
@@ -1335,6 +1345,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
//RTP
|
||||
params["mtu"].i = requested_mtu;
|
||||
params["ttl"].i = requested_ttl;
|
||||
params["receiver"].str = requested_receiver;
|
||||
params["rx_port"].i = video_rx_port;
|
||||
params["tx_port"].i = video_tx_port;
|
||||
|
||||
@@ -149,7 +149,7 @@ static int vidcap_ug_input_init(struct vidcap_params *cap_params, void **state)
|
||||
"none", "embedded",
|
||||
"ultragrid_rtp", "",
|
||||
"none", NULL, NULL, audio_scale, false, 0, NULL, "PCM", RATE_UNLIMITED, NULL,
|
||||
&start_time, 1500, NULL);
|
||||
&start_time, 1500, -1, NULL);
|
||||
if (s->audio == nullptr) {
|
||||
delete s;
|
||||
return VIDCAP_INIT_FAIL;
|
||||
|
||||
@@ -88,7 +88,7 @@ struct response *rtp_video_rxtx::process_sender_message(struct msg_sender *msg,
|
||||
m_network_devices = initialize_network(m_requested_receiver.c_str(),
|
||||
m_recv_port_number,
|
||||
m_send_port_number, m_participants, m_force_ip_version,
|
||||
m_requested_mcast_if);
|
||||
m_requested_mcast_if, m_requested_ttl);
|
||||
if (!m_network_devices) {
|
||||
m_network_devices = old_devices;
|
||||
m_requested_receiver = old_receiver;
|
||||
@@ -115,7 +115,7 @@ struct response *rtp_video_rxtx::process_sender_message(struct msg_sender *msg,
|
||||
}
|
||||
m_network_devices = initialize_network(m_requested_receiver.c_str(), m_recv_port_number,
|
||||
m_send_port_number, m_participants, m_force_ip_version,
|
||||
m_requested_mcast_if);
|
||||
m_requested_mcast_if, m_requested_ttl);
|
||||
|
||||
if (!m_network_devices) {
|
||||
m_network_devices = old_devices;
|
||||
@@ -186,7 +186,7 @@ struct response *rtp_video_rxtx::process_sender_message(struct msg_sender *msg,
|
||||
m_network_devices = initialize_network(m_requested_receiver.c_str(),
|
||||
m_recv_port_number,
|
||||
m_send_port_number, m_participants, m_force_ip_version,
|
||||
m_requested_mcast_if);
|
||||
m_requested_mcast_if, m_requested_ttl);
|
||||
if (!m_network_devices) {
|
||||
m_network_devices = old_devices;
|
||||
log_msg(LOG_LEVEL_ERROR, "[control] Unable to change SSRC!\n");
|
||||
@@ -216,9 +216,10 @@ rtp_video_rxtx::rtp_video_rxtx(map<string, param_u> const ¶ms) :
|
||||
m_send_port_number = params.at("tx_port").i;
|
||||
m_force_ip_version = params.at("force_ip_version").i;
|
||||
m_requested_mcast_if = params.at("mcast_if").str;
|
||||
m_requested_ttl = params.find("ttl") != params.end() ? params.at("ttl").i : -1;
|
||||
|
||||
if ((m_network_devices = initialize_network(m_requested_receiver.c_str(), m_recv_port_number, m_send_port_number,
|
||||
m_participants, m_force_ip_version, m_requested_mcast_if))
|
||||
m_participants, m_force_ip_version, m_requested_mcast_if, m_requested_ttl))
|
||||
== NULL) {
|
||||
throw ug_runtime_error("Unable to open network", EXIT_FAIL_NETWORK);
|
||||
} else {
|
||||
@@ -287,11 +288,10 @@ void rtp_video_rxtx::display_buf_increase_warning(int size)
|
||||
|
||||
struct rtp **rtp_video_rxtx::initialize_network(const char *addrs, int recv_port_base,
|
||||
int send_port_base, struct pdb *participants, int force_ip_version,
|
||||
const char *mcast_if)
|
||||
const char *mcast_if, int ttl)
|
||||
{
|
||||
struct rtp **devices = NULL;
|
||||
double rtcp_bw = 5 * 1024 * 1024; /* FIXME */
|
||||
int ttl = 255;
|
||||
char *saveptr = NULL;
|
||||
char *addr;
|
||||
char *tmp;
|
||||
@@ -299,13 +299,6 @@ struct rtp **rtp_video_rxtx::initialize_network(const char *addrs, int recv_port
|
||||
int recv_port = recv_port_base;
|
||||
int send_port = send_port_base;
|
||||
|
||||
if (commandline_params.find("ttl") != commandline_params.end()) {
|
||||
ttl = stoi(commandline_params.at("ttl"));
|
||||
if (ttl < -1 || ttl > 255) {
|
||||
throw ug_runtime_error("TTL must be in range 0..255 or -1!");
|
||||
}
|
||||
}
|
||||
|
||||
tmp = strdup(addrs);
|
||||
if(strtok_r(tmp, ",", &saveptr) == NULL) {
|
||||
free(tmp);
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
|
||||
static struct rtp **initialize_network(const char *addrs, int recv_port_base,
|
||||
int send_port_base, struct pdb *participants, int force_ip_version,
|
||||
const char *mcast_if);
|
||||
const char *mcast_if, int ttl);
|
||||
void destroy_rtp_devices(struct rtp ** network_devices);
|
||||
static void display_buf_increase_warning(int size);
|
||||
|
||||
@@ -78,6 +78,7 @@ protected:
|
||||
int m_send_port_number;
|
||||
int m_force_ip_version;
|
||||
const char *m_requested_mcast_if;
|
||||
int m_requested_ttl;
|
||||
fec *m_fec_state;
|
||||
const std::chrono::steady_clock::time_point m_start_time;
|
||||
video_desc m_video_desc;
|
||||
|
||||
@@ -246,7 +246,7 @@ void ultragrid_rtp_video_rxtx::receiver_process_messages()
|
||||
m_network_devices = initialize_network(m_requested_receiver.c_str(),
|
||||
m_recv_port_number,
|
||||
m_send_port_number, m_participants, m_force_ip_version,
|
||||
m_requested_mcast_if);
|
||||
m_requested_mcast_if, m_requested_ttl);
|
||||
if (!m_network_devices) {
|
||||
log_msg(LOG_LEVEL_ERROR, "[control] Failed to change RX port to %d\n", msg->new_rx_port);
|
||||
r = new_response(RESPONSE_INT_SERV_ERR, "Changing RX port failed!");
|
||||
|
||||
Reference in New Issue
Block a user