Skip to content

Commit 3b9f444

Browse files
committed
respect the selected port if sending over loopback
`uv -t testcard -d gl -P 5004` didn't select the port 5004 until now
1 parent d0bbce5 commit 3b9f444

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/main.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ struct ug_options {
560560

561561
const char *display_cfg = "";
562562
const char *requested_video_fec = "none";
563-
int port_base = PORT_BASE;
563+
int port_base = -1;
564564
int requested_ttl = -1;
565565
int video_rx_port = -1, video_tx_port = -1;
566566

@@ -1216,16 +1216,19 @@ static int adjust_params(struct ug_options *opt) {
12161216
opt->video_rxtx_mode |= MODE_SENDER;
12171217
}
12181218

1219-
// use dyn ports if sending only to ourselves or neither sending nor receiving
1219+
// use dyn ports if unset, sending only to ourselves or neither sending nor receiving
12201220
const unsigned mode_both = MODE_RECEIVER | MODE_SENDER;
12211221
if (is_host_loopback(opt->requested_receiver) && ((opt->video_rxtx_mode & mode_both) == mode_both || (opt->video_rxtx_mode & mode_both) == 0)
1222-
&& (opt->video_rx_port == -1 && opt->video_tx_port == -1)) {
1222+
&& (opt->video_rx_port == -1 && opt->video_tx_port == -1 && opt->port_base == -1)) {
12231223
opt->video_rx_port = opt->video_tx_port = 0;
12241224
}
12251225
if (is_host_loopback(opt->requested_receiver) && ((audio_rxtx_mode & mode_both) == mode_both || (audio_rxtx_mode & mode_both) == 0)
1226-
&& (opt->audio.recv_port == -1 && opt->audio.send_port == -1)) {
1226+
&& (opt->audio.recv_port == -1 && opt->audio.send_port == -1 && opt->port_base == -1)) {
12271227
opt->audio.recv_port = opt->audio.send_port = 0;
12281228
}
1229+
if (opt->port_base == -1) {
1230+
opt->port_base = PORT_BASE;
1231+
};
12291232

12301233
if (opt->video_rx_port == -1) {
12311234
if ((opt->video_rxtx_mode & MODE_RECEIVER) == 0U) {

0 commit comments

Comments
 (0)