Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Fixed the use of the right error constant #2595

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2424c99
Fixing implicit integer and wrong use of SRT_ERROR and SRT_INVALID_SO…
Dec 22, 2022
6ad1041
[MAINT] Fixed example buildbreaks. Added examples for message mode tr…
ethouris Dec 22, 2022
340f0b5
Updated
ethouris Dec 22, 2022
29e8c19
Fixed wrong assertion for drop snd buf sequence check
Dec 23, 2022
31b3a78
Updated
Dec 23, 2022
ce98b8a
[MAINT] Refax for CSndBuffer::readData to make the call form clearer
Dec 23, 2022
333eaf2
[MAINT] Removed reference fields from CPacket pinned to the SRT header
Dec 23, 2022
43c0883
Updated and fixed
Dec 23, 2022
6e2280d
Updated with the fixes
Dec 23, 2022
512e548
Merge branch 'master' into dev-fix-implicit-int
Jan 11, 2023
08d1e5c
Minor fixes
Jan 11, 2023
4888873
Merge branch 'master' into dev-refax-readdata-rexmit
Jan 11, 2023
dba39ef
Merge branch 'master' into dev-refax-readdata-rexmit
Jan 24, 2023
addefb3
Merge branch 'master' into dev-fix-implicit-int
Jan 25, 2023
03c19ac
Merge branch 'master' into dev-refax-readdata-rexmit
Feb 20, 2023
b0e681f
Updated and fixed
Feb 20, 2023
3781775
Merge branch 'master' into dev-refax-readdata-rexmit
May 4, 2023
d126e64
Merge branch 'master' into dev-refax-remove-cpacket-refs
May 8, 2023
380e12f
Updated to latest upstream through #2594
May 8, 2023
88b9f33
Fixed build break on Android
May 10, 2023
084c9c5
Merge branch 'master' into dev-refax-remove-cpacket-refs
Sep 14, 2023
185276c
Merged and fixed
Sep 14, 2023
200e3c5
Updated and fixed
Oct 9, 2023
1ffde27
Merge branch 'master' into dev-refax-readdata-rexmit
Oct 10, 2023
58fbf27
Updated and fixed
Oct 10, 2023
a0de6ff
Merge branch 'dev-refax-remove-cpacket-refs' into dev-fix-implicit-int
Oct 10, 2023
920969b
Synchronized and improved
Oct 10, 2023
7a4e00c
Fixed clang warnings (build break on some CI)
Oct 10, 2023
8c0102a
Updated and fixed
Feb 19, 2024
d28e3b2
Introduced SRTRUNSTATUS to cover all cases of srt_startup(). Fixed do…
Feb 19, 2024
be302ca
Removed srt::isgroup. Reused CUDT::isgroup where applicable. Added mi…
Feb 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ if (FORCE_CXX_STANDARD)
endif()

# add extra warning flags for gccish compilers
if (HAVE_COMPILER_GNU_COMPAT)
if ((HAVE_COMPILER_GNU_COMPAT) AND (NOT DEFINED SRT_GCC_WARN))
set (SRT_GCC_WARN "-Wall -Wextra")
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set (SRT_GCC_WARN "${SRT_GCC_WARN} -Wshadow=local")
Expand Down
14 changes: 9 additions & 5 deletions apps/socketoptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,27 @@ struct SocketOption
bool applyt(Object socket, std::string value) const;

template <Domain D, typename Object>
static int setso(Object socket, int protocol, int symbol, const void* data, size_t size);
static int setso(Object , int , int , const void* , size_t)
{
typename Object::wrong_version error;
return -1;
}

template<Type T>
bool extract(std::string value, OptionValue& val) const;
};

template<>
inline int SocketOption::setso<SocketOption::SRT, int>(int socket, int /*ignored*/, int sym, const void* data, size_t size)
inline int SocketOption::setso<SocketOption::SRT, SRTSOCKET>(SRTSOCKET socket, int /*ignored*/, int sym, const void* data, size_t size)
{
return srt_setsockopt(socket, 0, SRT_SOCKOPT(sym), data, (int) size);
return (int)srt_setsockflag(socket, SRT_SOCKOPT(sym), data, (int) size);
}

#if ENABLE_BONDING
template<>
inline int SocketOption::setso<SocketOption::SRT, SRT_SOCKOPT_CONFIG*>(SRT_SOCKOPT_CONFIG* obj, int /*ignored*/, int sym, const void* data, size_t size)
{
return srt_config_add(obj, SRT_SOCKOPT(sym), data, (int) size);
return (int)srt_config_add(obj, SRT_SOCKOPT(sym), data, (int) size);
}
#endif

Expand Down Expand Up @@ -184,7 +188,7 @@ inline bool SocketOption::applyt(Object socket, std::string value) const
int result = -1;
if (extract<T>(value, o))
result = setso<D>(socket, protocol, symbol, o.value, o.size);
return result != -1;
return result != int(SRT_ERROR);
}


Expand Down
14 changes: 7 additions & 7 deletions apps/srt-file-transmit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ bool DoUpload(UriParser& ut, string path, string filename,

int events = SRT_EPOLL_OUT | SRT_EPOLL_ERR;
if (srt_epoll_add_usock(pollid,
tar->GetSRTSocket(), &events))
tar->GetSRTSocket(), &events) == SRT_ERROR)
{
cerr << "Failed to add SRT destination to poll, "
<< tar->GetSRTSocket() << endl;
Expand Down Expand Up @@ -349,7 +349,7 @@ bool DoUpload(UriParser& ut, string path, string filename,

s = tar->GetSRTSocket();
int events = SRT_EPOLL_OUT | SRT_EPOLL_ERR;
if (srt_epoll_add_usock(pollid, s, &events))
if (srt_epoll_add_usock(pollid, s, &events) == SRT_ERROR)
{
cerr << "Failed to add SRT client to poll" << endl;
goto exit;
Expand Down Expand Up @@ -391,7 +391,7 @@ bool DoUpload(UriParser& ut, string path, string filename,
int st = tar->Write(buf.data() + shift, n, 0, out_stats);
Verb() << "Upload: " << n << " --> " << st
<< (!shift ? string() : "+" + Sprint(shift));
if (st == SRT_ERROR)
if (st == int(SRT_ERROR))
{
cerr << "Upload: SRT error: " << srt_getlasterror_str()
<< endl;
Expand Down Expand Up @@ -429,7 +429,7 @@ bool DoUpload(UriParser& ut, string path, string filename,
size_t bytes;
size_t blocks;
int st = srt_getsndbuffer(s, &blocks, &bytes);
if (st == SRT_ERROR)
if (st == int(SRT_ERROR))
{
cerr << "Error in srt_getsndbuffer: " << srt_getlasterror_str()
<< endl;
Expand Down Expand Up @@ -490,7 +490,7 @@ bool DoDownload(UriParser& us, string directory, string filename,

int events = SRT_EPOLL_IN | SRT_EPOLL_ERR;
if (srt_epoll_add_usock(pollid,
src->GetSRTSocket(), &events))
src->GetSRTSocket(), &events) == SRT_ERROR)
{
cerr << "Failed to add SRT source to poll, "
<< src->GetSRTSocket() << endl;
Expand Down Expand Up @@ -528,7 +528,7 @@ bool DoDownload(UriParser& us, string directory, string filename,

s = src->GetSRTSocket();
int events = SRT_EPOLL_IN | SRT_EPOLL_ERR;
if (srt_epoll_add_usock(pollid, s, &events))
if (srt_epoll_add_usock(pollid, s, &events) == SRT_ERROR)
{
cerr << "Failed to add SRT client to poll" << endl;
goto exit;
Expand Down Expand Up @@ -593,7 +593,7 @@ bool DoDownload(UriParser& us, string directory, string filename,
}

int n = src->Read(cfg.chunk_size, packet, out_stats);
if (n == SRT_ERROR)
if (n == int(SRT_ERROR))
{
cerr << "Download: SRT error: " << srt_getlasterror_str() << endl;
goto exit;
Expand Down
14 changes: 7 additions & 7 deletions apps/srt-live-transmit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ int main(int argc, char** argv)
{
case UriParser::SRT:
if (srt_epoll_add_usock(pollid,
src->GetSRTSocket(), &events))
src->GetSRTSocket(), &events) == SRT_ERROR)
{
cerr << "Failed to add SRT source to poll, "
<< src->GetSRTSocket() << endl;
Expand All @@ -528,7 +528,7 @@ int main(int argc, char** argv)
case UriParser::UDP:
case UriParser::RTP:
if (srt_epoll_add_ssock(pollid,
src->GetSysSocket(), &events))
src->GetSysSocket(), &events) == SRT_ERROR)
{
cerr << "Failed to add " << src->uri.proto()
<< " source to poll, " << src->GetSysSocket()
Expand All @@ -538,7 +538,7 @@ int main(int argc, char** argv)
break;
case UriParser::FILE:
if (srt_epoll_add_ssock(pollid,
src->GetSysSocket(), &events))
src->GetSysSocket(), &events) == SRT_ERROR)
{
cerr << "Failed to add FILE source to poll, "
<< src->GetSysSocket() << endl;
Expand Down Expand Up @@ -568,7 +568,7 @@ int main(int argc, char** argv)
{
case UriParser::SRT:
if (srt_epoll_add_usock(pollid,
tar->GetSRTSocket(), &events))
tar->GetSRTSocket(), &events) == SRT_ERROR)
{
cerr << "Failed to add SRT destination to poll, "
<< tar->GetSRTSocket() << endl;
Expand Down Expand Up @@ -641,7 +641,7 @@ int main(int argc, char** argv)
SRTSOCKET ns = (issource) ?
src->GetSRTSocket() : tar->GetSRTSocket();
int events = SRT_EPOLL_IN | SRT_EPOLL_ERR;
if (srt_epoll_add_usock(pollid, ns, &events))
if (srt_epoll_add_usock(pollid, ns, &events) == SRT_ERROR)
{
cerr << "Failed to add SRT client to poll, "
<< ns << endl;
Expand Down Expand Up @@ -739,7 +739,7 @@ int main(int argc, char** argv)
const int events = SRT_EPOLL_IN | SRT_EPOLL_ERR;
// Disable OUT event polling when connected
if (srt_epoll_update_usock(pollid,
tar->GetSRTSocket(), &events))
tar->GetSRTSocket(), &events) == SRT_ERROR)
{
cerr << "Failed to add SRT destination to poll, "
<< tar->GetSRTSocket() << endl;
Expand Down Expand Up @@ -783,7 +783,7 @@ int main(int argc, char** argv)
std::shared_ptr<MediaPacket> pkt(new MediaPacket(transmit_chunk_size));
const int res = src->Read(transmit_chunk_size, *pkt, out_stats);

if (res == SRT_ERROR && src->uri.type() == UriParser::SRT)
if (res == int(SRT_ERROR) && src->uri.type() == UriParser::SRT)
{
if (srt_getlasterror(NULL) == SRT_EASYNCRCV)
break;
Expand Down
22 changes: 11 additions & 11 deletions apps/srt-tunnel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ void Engine::Worker()

class SrtMedium: public Medium
{
SRTSOCKET m_socket = SRT_ERROR;
SRTSOCKET m_socket = SRT_INVALID_SOCK;
friend class Medium;
public:

Expand All @@ -440,10 +440,10 @@ class SrtMedium: public Medium
{
Verb() << "Closing SRT socket for " << uri();
lock_guard<std::mutex> lk(access);
if (m_socket == SRT_ERROR)
if (m_socket == SRT_INVALID_SOCK)
return;
srt_close(m_socket);
m_socket = SRT_ERROR;
m_socket = SRT_INVALID_SOCK;
}

// Forwarded in order to separate the implementation from
Expand Down Expand Up @@ -624,16 +624,16 @@ void SrtMedium::CreateListener()

sockaddr_any sa = CreateAddr(m_uri.host(), m_uri.portno());

int stat = srt_bind(m_socket, sa.get(), sizeof sa);
SRTSTATUS stat = srt_bind(m_socket, sa.get(), sizeof sa);

if ( stat == SRT_ERROR )
if (stat == SRT_ERROR)
{
srt_close(m_socket);
Error(UDT::getlasterror(), "srt_bind");
}

stat = srt_listen(m_socket, backlog);
if ( stat == SRT_ERROR )
if (stat == SRT_ERROR)
{
srt_close(m_socket);
Error(UDT::getlasterror(), "srt_listen");
Expand Down Expand Up @@ -674,7 +674,7 @@ unique_ptr<Medium> SrtMedium::Accept()
{
sockaddr_any sa;
SRTSOCKET s = srt_accept(m_socket, (sa.get()), (&sa.len));
if (s == SRT_ERROR)
if (s == SRT_INVALID_SOCK)
{
Error(UDT::getlasterror(), "srt_accept");
}
Expand Down Expand Up @@ -734,8 +734,8 @@ void SrtMedium::Connect()
{
sockaddr_any sa = CreateAddr(m_uri.host(), m_uri.portno());

int st = srt_connect(m_socket, sa.get(), sizeof sa);
if (st == SRT_ERROR)
SRTSOCKET st = srt_connect(m_socket, sa.get(), sizeof sa);
if (st == SRT_INVALID_SOCK)
Error(UDT::getlasterror(), "srt_connect");

ConfigurePost(m_socket);
Expand Down Expand Up @@ -766,7 +766,7 @@ int SrtMedium::ReadInternal(char* w_buffer, int size)
do
{
st = srt_recv(m_socket, (w_buffer), size);
if (st == SRT_ERROR)
if (st == int(SRT_ERROR))
{
int syserr;
if (srt_getlasterror(&syserr) == SRT_EASYNCRCV && !m_broken)
Expand Down Expand Up @@ -885,7 +885,7 @@ Medium::ReadStatus Medium::Read(bytevector& w_output)
void SrtMedium::Write(bytevector& w_buffer)
{
int st = srt_send(m_socket, w_buffer.data(), (int)w_buffer.size());
if (st == SRT_ERROR)
if (st == int(SRT_ERROR))
{
Error(UDT::getlasterror(), "srt_send");
}
Expand Down
6 changes: 3 additions & 3 deletions apps/statswriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class SrtStatsJson : public SrtStatsWriter
}

public:
string WriteStats(int sid, const CBytePerfMon& mon) override
string WriteStats(SRTSOCKET sid, const CBytePerfMon& mon) override
{
std::ostringstream output;

Expand Down Expand Up @@ -235,7 +235,7 @@ class SrtStatsCsv : public SrtStatsWriter
public:
SrtStatsCsv() : first_line_printed(false) {}

string WriteStats(int sid, const CBytePerfMon& mon) override
string WriteStats(SRTSOCKET sid, const CBytePerfMon& mon) override
{
std::ostringstream output;

Expand Down Expand Up @@ -286,7 +286,7 @@ class SrtStatsCsv : public SrtStatsWriter
class SrtStatsCols : public SrtStatsWriter
{
public:
string WriteStats(int sid, const CBytePerfMon& mon) override
string WriteStats(SRTSOCKET sid, const CBytePerfMon& mon) override
{
std::ostringstream output;
output << "======= SRT STATS: sid=" << sid << endl;
Expand Down
2 changes: 1 addition & 1 deletion apps/statswriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct SrtStatDataType: public SrtStatData
class SrtStatsWriter
{
public:
virtual std::string WriteStats(int sid, const CBytePerfMon& mon) = 0;
virtual std::string WriteStats(SRTSOCKET sid, const CBytePerfMon& mon) = 0;
virtual std::string WriteBandwidth(double mbpsBandwidth) = 0;
virtual ~SrtStatsWriter() {}

Expand Down
Loading
Loading