| 1 |
/* |
| 2 |
* SRT - Secure, Reliable, Transport |
| 3 |
* Copyright (c) 2018 Haivision Systems Inc. |
| 4 |
* |
| 5 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 6 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 7 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 8 |
* |
| 9 |
*/ |
| 10 |
|
| 11 |
/***************************************************************************** |
| 12 |
written by |
| 13 |
Haivision Systems Inc. |
| 14 |
*****************************************************************************/ |
| 15 |
|
| 16 |
#include "platform_sys.h" |
| 17 |
|
| 18 |
#include <iterator> |
| 19 |
#include <fstream> |
| 20 |
#include "srt.h" |
| 21 |
#include "common.h" |
| 22 |
#include "packet.h" |
| 23 |
#include "core.h" |
| 24 |
#include "utilities.h" |
| 25 |
|
| 26 |
using namespace std; |
| 27 |
using namespace srt; |
| 28 |
|
| 29 |
namespace srt |
| 30 |
{ |
| 31 |
// This is provided in strerror_defs.cpp, which doesn't have |
| 32 |
// its header file. |
| 33 |
// XXX Consider adding some static function to CUDTException. |
| 34 |
const char* strerror_get_message(size_t major, size_t minor); |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
extern "C" { |
| 39 |
|
| 40 |
int srt_startup() { return CUDT::startup(); } |
| 41 |
int srt_cleanup() { return CUDT::cleanup(); } |
| 42 |
|
| 43 |
// Socket creation. |
| 44 |
SRTSOCKET srt_socket(int , int , int ) { return CUDT::socket(); } |
| 45 |
SRTSOCKET srt_create_socket() { return CUDT::socket(); } |
| 46 |
|
| 47 |
#if ENABLE_BONDING |
| 48 |
// Group management. |
| 49 |
SRTSOCKET srt_create_group(SRT_GROUP_TYPE gt) { return CUDT::createGroup(gt); } |
| 50 |
SRTSOCKET srt_groupof(SRTSOCKET socket) { return CUDT::getGroupOfSocket(socket); } |
| 51 |
int srt_group_data(SRTSOCKET socketgroup, SRT_SOCKGROUPDATA* output, size_t* inoutlen) |
| 52 |
{ |
| 53 |
return CUDT::getGroupData(socketgroup, output, inoutlen); |
| 54 |
} |
| 55 |
|
| 56 |
SRT_SOCKOPT_CONFIG* srt_create_config() |
| 57 |
{ |
| 58 |
return new SRT_SocketOptionObject; |
| 59 |
} |
| 60 |
|
| 61 |
int srt_config_add(SRT_SOCKOPT_CONFIG* config, SRT_SOCKOPT option, const void* contents, int len) |
| 62 |
{ |
| 63 |
if (!config) |
| 64 |
return -1; |
| 65 |
|
| 66 |
if (!config->add(option, contents, len)) |
| 67 |
return -1; |
| 68 |
|
| 69 |
return 0; |
| 70 |
} |
| 71 |
|
| 72 |
int srt_connect_group(SRTSOCKET group, |
| 73 |
SRT_SOCKGROUPCONFIG name[], int arraysize) |
| 74 |
{ |
| 75 |
return CUDT::connectLinks(group, name, arraysize); |
| 76 |
} |
| 77 |
|
| 78 |
#else |
| 79 |
|
| 80 |
SRTSOCKET srt_create_group(SRT_GROUP_TYPE) { return SRT_INVALID_SOCK; } |
| 81 |
SRTSOCKET srt_groupof(SRTSOCKET) { return SRT_INVALID_SOCK; } |
| 82 |
int srt_group_data(SRTSOCKET, SRT_SOCKGROUPDATA*, size_t*) { return srt::CUDT::APIError(MJ_NOTSUP, MN_INVAL, 0); } |
| 83 |
SRT_SOCKOPT_CONFIG* srt_create_config() { return NULL; } |
| 84 |
int srt_config_add(SRT_SOCKOPT_CONFIG*, SRT_SOCKOPT, const void*, int) { return srt::CUDT::APIError(MJ_NOTSUP, MN_INVAL, 0); } |
| 85 |
|
| 86 |
int srt_connect_group(SRTSOCKET, SRT_SOCKGROUPCONFIG[], int) { return srt::CUDT::APIError(MJ_NOTSUP, MN_INVAL, 0); } |
| 87 |
|
| 88 |
#endif |
| 89 |
|
| 90 |
SRT_SOCKGROUPCONFIG srt_prepare_endpoint(const struct sockaddr* src, const struct sockaddr* dst, int namelen) |
| 91 |
{ |
| 92 |
SRT_SOCKGROUPCONFIG data; |
| 93 |
#if ENABLE_BONDING |
| 94 |
data.errorcode = SRT_SUCCESS; |
| 95 |
#else |
| 96 |
data.errorcode = SRT_EINVOP; |
| 97 |
#endif |
| 98 |
data.id = -1; |
| 99 |
data.token = -1; |
| 100 |
data.weight = 0; |
| 101 |
data.config = NULL; |
| 102 |
if (src) |
| 103 |
memcpy(&data.srcaddr, src, namelen); |
| 104 |
else |
| 105 |
{ |
| 106 |
memset(&data.srcaddr, 0, sizeof data.srcaddr); |
| 107 |
// Still set the family according to the target address |
| 108 |
data.srcaddr.ss_family = dst->sa_family; |
| 109 |
} |
| 110 |
memcpy(&data.peeraddr, dst, namelen); |
| 111 |
return data; |
| 112 |
} |
| 113 |
|
| 114 |
void srt_delete_config(SRT_SOCKOPT_CONFIG* in) |
| 115 |
{ |
| 116 |
delete in; |
| 117 |
} |
| 118 |
|
| 119 |
// Binding and connection management |
| 120 |
int srt_bind(SRTSOCKET u, const struct sockaddr * name, int namelen) { return CUDT::bind(u, name, namelen); } |
| 121 |
int srt_bind_acquire(SRTSOCKET u, UDPSOCKET udpsock) { return CUDT::bind(u, udpsock); } |
| 122 |
int srt_listen(SRTSOCKET u, int backlog) { return CUDT::listen(u, backlog); } |
| 123 |
SRTSOCKET srt_accept(SRTSOCKET u, struct sockaddr * addr, int * addrlen) { return CUDT::accept(u, addr, addrlen); } |
| 124 |
SRTSOCKET srt_accept_bond(const SRTSOCKET lsns[], int lsize, int64_t msTimeOut) { return CUDT::accept_bond(lsns, lsize, msTimeOut); } |
| 125 |
int srt_connect(SRTSOCKET u, const struct sockaddr * name, int namelen) { return CUDT::connect(u, name, namelen, SRT_SEQNO_NONE); } |
| 126 |
int srt_connect_debug(SRTSOCKET u, const struct sockaddr * name, int namelen, int forced_isn) { return CUDT::connect(u, name, namelen, forced_isn); } |
| 127 |
int srt_connect_bind(SRTSOCKET u, |
| 128 |
const struct sockaddr* source, |
| 129 |
const struct sockaddr* target, int target_len) |
| 130 |
{ |
| 131 |
return CUDT::connect(u, source, target, target_len); |
| 132 |
} |
| 133 |
|
| 134 |
int srt_rendezvous(SRTSOCKET u, const struct sockaddr* local_name, int local_namelen, |
| 135 |
const struct sockaddr* remote_name, int remote_namelen) |
| 136 |
{ |
| 137 |
bool yes = 1; |
| 138 |
CUDT::setsockopt(u, 0, SRTO_RENDEZVOUS, &yes, sizeof yes); |
| 139 |
|
| 140 |
// Note: PORT is 16-bit and at the same location in both sockaddr_in and sockaddr_in6. |
| 141 |
// Just as a safety precaution, check the structs. |
| 142 |
if ( (local_name->sa_family != AF_INET && local_name->sa_family != AF_INET6) |
| 143 |
|| local_name->sa_family != remote_name->sa_family) |
| 144 |
return CUDT::APIError(MJ_NOTSUP, MN_INVAL, 0); |
| 145 |
|
| 146 |
const int st = srt_bind(u, local_name, local_namelen); |
| 147 |
if (st != 0) |
| 148 |
return st; |
| 149 |
|
| 150 |
return srt_connect(u, remote_name, remote_namelen); |
| 151 |
} |
| 152 |
|
| 153 |
int srt_close(SRTSOCKET u) |
| 154 |
{ |
| 155 |
SRT_SOCKSTATUS st = srt_getsockstate(u); |
| 156 |
|
| 157 |
if ((st == SRTS_NONEXIST) || |
| 158 |
(st == SRTS_CLOSED) || |
| 159 |
(st == SRTS_CLOSING) ) |
| 160 |
{ |
| 161 |
// It's closed already. Do nothing. |
| 162 |
return 0; |
| 163 |
} |
| 164 |
|
| 165 |
return CUDT::close(u); |
| 166 |
} |
| 167 |
|
| 168 |
int srt_getpeername(SRTSOCKET u, struct sockaddr * name, int * namelen) { return CUDT::getpeername(u, name, namelen); } |
| 169 |
int srt_getsockname(SRTSOCKET u, struct sockaddr * name, int * namelen) { return CUDT::getsockname(u, name, namelen); } |
| 170 |
int srt_getsockopt(SRTSOCKET u, int level, SRT_SOCKOPT optname, void * optval, int * optlen) |
| 171 |
{ return CUDT::getsockopt(u, level, optname, optval, optlen); } |
| 172 |
int srt_setsockopt(SRTSOCKET u, int level, SRT_SOCKOPT optname, const void * optval, int optlen) |
| 173 |
{ return CUDT::setsockopt(u, level, optname, optval, optlen); } |
| 174 |
|
| 175 |
int srt_getsockflag(SRTSOCKET u, SRT_SOCKOPT opt, void* optval, int* optlen) |
| 176 |
{ return CUDT::getsockopt(u, 0, opt, optval, optlen); } |
| 177 |
int srt_setsockflag(SRTSOCKET u, SRT_SOCKOPT opt, const void* optval, int optlen) |
| 178 |
{ return CUDT::setsockopt(u, 0, opt, optval, optlen); } |
| 179 |
|
| 180 |
int srt_send(SRTSOCKET u, const char * buf, int len) { return CUDT::send(u, buf, len, 0); } |
| 181 |
int srt_recv(SRTSOCKET u, char * buf, int len) { return CUDT::recv(u, buf, len, 0); } |
| 182 |
int srt_sendmsg(SRTSOCKET u, const char * buf, int len, int ttl, int inorder) { return CUDT::sendmsg(u, buf, len, ttl, 0!= inorder); } |
| 183 |
int srt_recvmsg(SRTSOCKET u, char * buf, int len) { int64_t ign_srctime; return CUDT::recvmsg(u, buf, len, ign_srctime); } |
| 184 |
int64_t srt_sendfile(SRTSOCKET u, const char* path, int64_t* offset, int64_t size, int block) |
| 185 |
{ |
| 186 |
if (!path || !offset ) |
| 187 |
{ |
| 188 |
return CUDT::APIError(MJ_NOTSUP, MN_INVAL, 0); |
| 189 |
} |
| 190 |
fstream ifs(path, ios::binary | ios::in); |
| 191 |
if (!ifs) |
| 192 |
{ |
| 193 |
return CUDT::APIError(MJ_FILESYSTEM, MN_READFAIL, 0); |
| 194 |
} |
| 195 |
int64_t ret = CUDT::sendfile(u, ifs, *offset, size, block); |
| 196 |
ifs.close(); |
| 197 |
return ret; |
| 198 |
} |
| 199 |
|
| 200 |
int64_t srt_recvfile(SRTSOCKET u, const char* path, int64_t* offset, int64_t size, int block) |
| 201 |
{ |
| 202 |
if (!path || !offset ) |
| 203 |
{ |
| 204 |
return CUDT::APIError(MJ_NOTSUP, MN_INVAL, 0); |
| 205 |
} |
| 206 |
fstream ofs(path, ios::binary | ios::out); |
| 207 |
if (!ofs) |
| 208 |
{ |
| 209 |
return CUDT::APIError(MJ_FILESYSTEM, MN_WRAVAIL, 0); |
| 210 |
} |
| 211 |
int64_t ret = CUDT::recvfile(u, ofs, *offset, size, block); |
| 212 |
ofs.close(); |
| 213 |
return ret; |
| 214 |
} |
| 215 |
|
| 216 |
extern const SRT_MSGCTRL srt_msgctrl_default = { |
| 217 |
0, // no flags set |
| 218 |
SRT_MSGTTL_INF, |
| 219 |
false, // not in order (matters for msg mode only) |
| 220 |
PB_SUBSEQUENT, |
| 221 |
0, // srctime: take "now" time |
| 222 |
SRT_SEQNO_NONE, |
| 223 |
SRT_MSGNO_NONE, |
| 224 |
NULL, // grpdata not supplied |
| 225 |
0 // idem |
| 226 |
}; |
| 227 |
|
| 228 |
void srt_msgctrl_init(SRT_MSGCTRL* mctrl) |
| 229 |
{ |
| 230 |
*mctrl = srt_msgctrl_default; |
| 231 |
} |
| 232 |
|
| 233 |
int srt_sendmsg2(SRTSOCKET u, const char * buf, int len, SRT_MSGCTRL *mctrl) |
| 234 |
{ |
| 235 |
// Allow NULL mctrl in the API, but not internally. |
| 236 |
if (mctrl) |
| 237 |
return CUDT::sendmsg2(u, buf, len, (*mctrl)); |
| 238 |
SRT_MSGCTRL mignore = srt_msgctrl_default; |
| 239 |
return CUDT::sendmsg2(u, buf, len, (mignore)); |
| 240 |
} |
| 241 |
|
| 242 |
int srt_recvmsg2(SRTSOCKET u, char * buf, int len, SRT_MSGCTRL *mctrl) |
| 243 |
{ |
| 244 |
if (mctrl) |
| 245 |
return CUDT::recvmsg2(u, buf, len, (*mctrl)); |
| 246 |
SRT_MSGCTRL mignore = srt_msgctrl_default; |
| 247 |
return CUDT::recvmsg2(u, buf, len, (mignore)); |
| 248 |
} |
| 249 |
|
| 250 |
const char* srt_getlasterror_str() { return UDT::getlasterror().getErrorMessage(); } |
| 251 |
|
| 252 |
int srt_getlasterror(int* loc_errno) |
| 253 |
{ |
| 254 |
if ( loc_errno ) |
| 255 |
*loc_errno = UDT::getlasterror().getErrno(); |
| 256 |
return CUDT::getlasterror().getErrorCode(); |
| 257 |
} |
| 258 |
|
| 259 |
const char* srt_strerror(int code, int /*err ignored*/) |
| 260 |
{ |
| 261 |
return strerror_get_message(CodeMajor(code/1000), CodeMinor(code%1000)); |
| 262 |
} |
| 263 |
|
| 264 |
|
| 265 |
void srt_clearlasterror() |
| 266 |
{ |
| 267 |
UDT::getlasterror().clear(); |
| 268 |
} |
| 269 |
|
| 270 |
int srt_bstats(SRTSOCKET u, SRT_TRACEBSTATS * perf, int clear) { return CUDT::bstats(u, perf, 0!= clear); } |
| 271 |
int srt_bistats(SRTSOCKET u, SRT_TRACEBSTATS * perf, int clear, int instantaneous) { return CUDT::bstats(u, perf, 0!= clear, 0!= instantaneous); } |
| 272 |
|
| 273 |
SRT_SOCKSTATUS srt_getsockstate(SRTSOCKET u) { return SRT_SOCKSTATUS((int)CUDT::getsockstate(u)); } |
| 274 |
|
| 275 |
// event mechanism |
| 276 |
int srt_epoll_create() { return CUDT::epoll_create(); } |
| 277 |
|
| 278 |
int srt_epoll_clear_usocks(int eit) { return CUDT::epoll_clear_usocks(eit); } |
| 279 |
|
| 280 |
// You can use either SRT_EPOLL_* flags or EPOLL* flags from <sys/epoll.h>, both are the same. IN/OUT/ERR only. |
| 281 |
// events == NULL accepted, in which case all flags are set. |
| 282 |
int srt_epoll_add_usock(int eid, SRTSOCKET u, const int * events) { return CUDT::epoll_add_usock(eid, u, events); } |
| 283 |
|
| 284 |
int srt_epoll_add_ssock(int eid, SYSSOCKET s, const int * events) |
| 285 |
{ |
| 286 |
int flag = 0; |
| 287 |
|
| 288 |
if (events) { |
| 289 |
flag = *events; |
| 290 |
} else { |
| 291 |
flag = SRT_EPOLL_IN | SRT_EPOLL_OUT | SRT_EPOLL_ERR; |
| 292 |
} |
| 293 |
|
| 294 |
// call UDT native function |
| 295 |
return CUDT::epoll_add_ssock(eid, s, &flag); |
| 296 |
} |
| 297 |
|
| 298 |
int srt_epoll_remove_usock(int eid, SRTSOCKET u) { return CUDT::epoll_remove_usock(eid, u); } |
| 299 |
int srt_epoll_remove_ssock(int eid, SYSSOCKET s) { return CUDT::epoll_remove_ssock(eid, s); } |
| 300 |
|
| 301 |
int srt_epoll_update_usock(int eid, SRTSOCKET u, const int * events) |
| 302 |
{ |
| 303 |
return CUDT::epoll_update_usock(eid, u, events); |
| 304 |
} |
| 305 |
|
| 306 |
int srt_epoll_update_ssock(int eid, SYSSOCKET s, const int * events) |
| 307 |
{ |
| 308 |
int flag = 0; |
| 309 |
|
| 310 |
if (events) { |
| 311 |
flag = *events; |
| 312 |
} else { |
| 313 |
flag = SRT_EPOLL_IN | SRT_EPOLL_OUT | SRT_EPOLL_ERR; |
| 314 |
} |
| 315 |
|
| 316 |
// call UDT native function |
| 317 |
return CUDT::epoll_update_ssock(eid, s, &flag); |
| 318 |
} |
| 319 |
|
| 320 |
int srt_epoll_wait( |
| 321 |
int eid, |
| 322 |
SRTSOCKET* readfds, int* rnum, SRTSOCKET* writefds, int* wnum, |
| 323 |
int64_t msTimeOut, |
| 324 |
SYSSOCKET* lrfds, int* lrnum, SYSSOCKET* lwfds, int* lwnum) |
| 325 |
{ |
| 326 |
return UDT::epoll_wait2( |
| 327 |
eid, |
| 328 |
readfds, rnum, writefds, wnum, |
| 329 |
msTimeOut, |
| 330 |
lrfds, lrnum, lwfds, lwnum); |
| 331 |
} |
| 332 |
|
| 333 |
int srt_epoll_uwait(int eid, SRT_EPOLL_EVENT* fdsSet, int fdsSize, int64_t msTimeOut) |
| 334 |
{ |
| 335 |
return UDT::epoll_uwait( |
| 336 |
eid, |
| 337 |
fdsSet, |
| 338 |
fdsSize, |
| 339 |
msTimeOut); |
| 340 |
} |
| 341 |
|
| 342 |
// use this function to set flags. Default flags are always "everything unset". |
| 343 |
// Pass 0 here to clear everything, or nonzero to set a desired flag. |
| 344 |
// Pass -1 to not change anything (but still get the current flag value). |
| 345 |
int32_t srt_epoll_set(int eid, int32_t flags) { return CUDT::epoll_set(eid, flags); } |
| 346 |
|
| 347 |
int srt_epoll_release(int eid) { return CUDT::epoll_release(eid); } |
| 348 |
|
| 349 |
void srt_setloglevel(int ll) |
| 350 |
{ |
| 351 |
UDT::setloglevel(srt_logging::LogLevel::type(ll)); |
| 352 |
} |
| 353 |
|
| 354 |
void srt_addlogfa(int fa) |
| 355 |
{ |
| 356 |
UDT::addlogfa(srt_logging::LogFA(fa)); |
| 357 |
} |
| 358 |
|
| 359 |
void srt_dellogfa(int fa) |
| 360 |
{ |
| 361 |
UDT::dellogfa(srt_logging::LogFA(fa)); |
| 362 |
} |
| 363 |
|
| 364 |
void srt_resetlogfa(const int* fara, size_t fara_size) |
| 365 |
{ |
| 366 |
UDT::resetlogfa(fara, fara_size); |
| 367 |
} |
| 368 |
|
| 369 |
void srt_setloghandler(void* opaque, SRT_LOG_HANDLER_FN* handler) |
| 370 |
{ |
| 371 |
UDT::setloghandler(opaque, handler); |
| 372 |
} |
| 373 |
|
| 374 |
void srt_setlogflags(int flags) |
| 375 |
{ |
| 376 |
UDT::setlogflags(flags); |
| 377 |
} |
| 378 |
|
| 379 |
int srt_getsndbuffer(SRTSOCKET sock, size_t* blocks, size_t* bytes) |
| 380 |
{ |
| 381 |
return CUDT::getsndbuffer(sock, blocks, bytes); |
| 382 |
} |
| 383 |
|
| 384 |
int srt_getrejectreason(SRTSOCKET sock) |
| 385 |
{ |
| 386 |
return CUDT::rejectReason(sock); |
| 387 |
} |
| 388 |
|
| 389 |
int srt_setrejectreason(SRTSOCKET sock, int value) |
| 390 |
{ |
| 391 |
return CUDT::rejectReason(sock, value); |
| 392 |
} |
| 393 |
|
| 394 |
int srt_listen_callback(SRTSOCKET lsn, srt_listen_callback_fn* hook, void* opaq) |
| 395 |
{ |
| 396 |
return CUDT::installAcceptHook(lsn, hook, opaq); |
| 397 |
} |
| 398 |
|
| 399 |
int srt_connect_callback(SRTSOCKET lsn, srt_connect_callback_fn* hook, void* opaq) |
| 400 |
{ |
| 401 |
return CUDT::installConnectHook(lsn, hook, opaq); |
| 402 |
} |
| 403 |
|
| 404 |
uint32_t srt_getversion() |
| 405 |
{ |
| 406 |
return SrtVersion(SRT_VERSION_MAJOR, SRT_VERSION_MINOR, SRT_VERSION_PATCH); |
| 407 |
} |
| 408 |
|
| 409 |
int64_t srt_time_now() |
| 410 |
{ |
| 411 |
return srt::sync::count_microseconds(srt::sync::steady_clock::now().time_since_epoch()); |
| 412 |
} |
| 413 |
|
| 414 |
int64_t srt_connection_time(SRTSOCKET sock) |
| 415 |
{ |
| 416 |
return CUDT::socketStartTime(sock); |
| 417 |
} |
| 418 |
|
| 419 |
int srt_clock_type() |
| 420 |
{ |
| 421 |
return SRT_SYNC_CLOCK; |
| 422 |
} |
| 423 |
|
| 424 |
const char* const srt_rejection_reason_msg [] = { |
| 425 |
"Unknown or erroneous", |
| 426 |
"Error in system calls", |
| 427 |
"Peer rejected connection", |
| 428 |
"Resource allocation failure", |
| 429 |
"Rogue peer or incorrect parameters", |
| 430 |
"Listener's backlog exceeded", |
| 431 |
"Internal Program Error", |
| 432 |
"Socket is being closed", |
| 433 |
"Peer version too old", |
| 434 |
"Rendezvous-mode cookie collision", |
| 435 |
"Incorrect passphrase", |
| 436 |
"Password required or unexpected", |
| 437 |
"MessageAPI/StreamAPI collision", |
| 438 |
"Congestion controller type collision", |
| 439 |
"Packet Filter settings error", |
| 440 |
"Group settings collision", |
| 441 |
"Connection timeout" |
| 442 |
#ifdef ENABLE_AEAD_API_PREVIEW |
| 443 |
,"Crypto mode" |
| 444 |
#endif |
| 445 |
}; |
| 446 |
|
| 447 |
// Deprecated, available in SRT API. |
| 448 |
extern const char* const srt_rejectreason_msg[] = { |
| 449 |
srt_rejection_reason_msg[0], |
| 450 |
srt_rejection_reason_msg[1], |
| 451 |
srt_rejection_reason_msg[2], |
| 452 |
srt_rejection_reason_msg[3], |
| 453 |
srt_rejection_reason_msg[4], |
| 454 |
srt_rejection_reason_msg[5], |
| 455 |
srt_rejection_reason_msg[6], |
| 456 |
srt_rejection_reason_msg[7], |
| 457 |
srt_rejection_reason_msg[8], |
| 458 |
srt_rejection_reason_msg[9], |
| 459 |
srt_rejection_reason_msg[10], |
| 460 |
srt_rejection_reason_msg[11], |
| 461 |
srt_rejection_reason_msg[12], |
| 462 |
srt_rejection_reason_msg[13], |
| 463 |
srt_rejection_reason_msg[14], |
| 464 |
srt_rejection_reason_msg[15], |
| 465 |
srt_rejection_reason_msg[16] |
| 466 |
#ifdef ENABLE_AEAD_API_PREVIEW |
| 467 |
, srt_rejection_reason_msg[17] |
| 468 |
#endif |
| 469 |
}; |
| 470 |
|
| 471 |
const char* srt_rejectreason_str(int id) |
| 472 |
{ |
| 473 |
if (id >= SRT_REJC_PREDEFINED) |
| 474 |
{ |
| 475 |
return "Application-defined rejection reason"; |
| 476 |
} |
| 477 |
|
| 478 |
static const size_t ra_size = Size(srt_rejection_reason_msg); |
| 479 |
if (size_t(id) >= ra_size) |
| 480 |
return srt_rejection_reason_msg[0]; |
| 481 |
return srt_rejection_reason_msg[id]; |
| 482 |
} |
| 483 |
|
| 484 |
} |