Skip to content

Commit

Permalink
Merge pull request #658 from andrey-utkin/back-to-tcp-by-default
Browse files Browse the repository at this point in the history
Prefer TCP again
  • Loading branch information
curtishall authored Feb 13, 2024
2 parents b50817c + 7b7657d commit fce49bc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
18 changes: 4 additions & 14 deletions lib/lavf_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ void lavf_device::stop()
int lavf_device::start()
{
if (ctx) return 0;
bool using_tcp = false;

AVDictionary *avopt_open_input = NULL;
AVInputFormat *input_fmt = NULL;
Expand All @@ -88,11 +87,10 @@ int lavf_device::start()

if (!strncmp(url, "rtsp://", 7))
{
if (rtp_protocol == RTP_PROTOCOL_TCP || tcp_fallback)
{
av_dict_set(&avopt_open_input, "rtsp_flags", "+prefer_tcp", 0);
tcp_fallback = false;
using_tcp = true;
switch (rtp_protocol) {
case RTP_PROTOCOL_TCP: av_dict_set(&avopt_open_input, "rtsp_transport", "tcp", 0); break;
case RTP_PROTOCOL_UDP: av_dict_set(&avopt_open_input, "rtsp_transport", "+udp+udp_multicast", 0); break;
case RTP_PROTOCOL_AUTO: av_dict_set(&avopt_open_input, "rtsp_flags", "+prefer_tcp", 0); break;
}
}

Expand All @@ -118,14 +116,6 @@ int lavf_device::start()
av_strerror(re, error_message, sizeof(error_message));
bc_log(Error, "Failed to open stream. Error: %d (%s)", re, error_message);
ctx = NULL;

if (rtp_protocol == RTP_PROTOCOL_AUTO && !using_tcp)
{
bc_log(Info, "Falling back to TCP connection");
tcp_fallback = true;
return start();
}

return -1;
}

Expand Down
1 change: 0 additions & 1 deletion lib/lavf_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class lavf_device : public input_device
private:
char url[1024];
int rtp_protocol = RTP_PROTOCOL_AUTO;
bool tcp_fallback = false;
char error_message[512];

AVFormatContext *ctx;
Expand Down

0 comments on commit fce49bc

Please sign in to comment.