Skip to content

Commit

Permalink
[core] Move srt_rejectreason_str implementation to srt_c_api
Browse files Browse the repository at this point in the history
  • Loading branch information
quink-black authored and maxsharabayko committed Apr 11, 2022
1 parent badf401 commit 4c08c3d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
33 changes: 0 additions & 33 deletions srtcore/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,39 +449,6 @@ std::string TransmissionEventStr(ETransmissionEvent ev)
return vals[ev];
}

extern const char* const srt_rejectreason_msg [] = {
"Unknown or erroneous",
"Error in system calls",
"Peer rejected connection",
"Resource allocation failure",
"Rogue peer or incorrect parameters",
"Listener's backlog exceeded",
"Internal Program Error",
"Socket is being closed",
"Peer version too old",
"Rendezvous-mode cookie collision",
"Incorrect passphrase",
"Password required or unexpected",
"MessageAPI/StreamAPI collision",
"Congestion controller type collision",
"Packet Filter settings error",
"Group settings collision",
"Connection timeout"
};

const char* srt_rejectreason_str(int id)
{
if (id >= SRT_REJC_PREDEFINED)
{
return "Application-defined rejection reason";
}

static const size_t ra_size = Size(srt_rejectreason_msg);
if (size_t(id) >= ra_size)
return srt_rejectreason_msg[0];
return srt_rejectreason_msg[id];
}

bool SrtParseConfig(string s, SrtConfig& w_config)
{
using namespace std;
Expand Down
33 changes: 33 additions & 0 deletions srtcore/srt_c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,4 +416,37 @@ int srt_clock_type()
return SRT_SYNC_CLOCK;
}

extern const char* const srt_rejectreason_msg [] = {
"Unknown or erroneous",
"Error in system calls",
"Peer rejected connection",
"Resource allocation failure",
"Rogue peer or incorrect parameters",
"Listener's backlog exceeded",
"Internal Program Error",
"Socket is being closed",
"Peer version too old",
"Rendezvous-mode cookie collision",
"Incorrect passphrase",
"Password required or unexpected",
"MessageAPI/StreamAPI collision",
"Congestion controller type collision",
"Packet Filter settings error",
"Group settings collision",
"Connection timeout"
};

const char* srt_rejectreason_str(int id)
{
if (id >= SRT_REJC_PREDEFINED)
{
return "Application-defined rejection reason";
}

static const size_t ra_size = Size(srt_rejectreason_msg);
if (size_t(id) >= ra_size)
return srt_rejectreason_msg[0];
return srt_rejectreason_msg[id];
}

}

0 comments on commit 4c08c3d

Please sign in to comment.