diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c
index 557ab9e6e3..d3c661d9d8 100644
--- a/libavformat/libsrt.c
+++ b/libavformat/libsrt.c
@@ -295,8 +295,8 @@ static int libsrt_set_options_post(URLContext *h, int fd)
 {
     SRTContext *s = h->priv_data;
 
-    if ((s->inputbw >= 0 && libsrt_setsockopt(h, fd, SRTO_INPUTBW, "SRTO_INPUTBW", &s->inputbw, sizeof(s->inputbw)) < 0) ||
-        (s->oheadbw >= 0 && libsrt_setsockopt(h, fd, SRTO_OHEADBW, "SRTO_OHEADBW", &s->oheadbw, sizeof(s->oheadbw)) < 0)) {
+    if ((s->inputbw >= 0 && LIBSRT_SETSOCKOPT(h, fd, SRTO_INPUTBW, &s->inputbw, sizeof(s->inputbw)) < 0) ||
+        (s->oheadbw >= 0 && LIBSRT_SETSOCKOPT(h, fd, SRTO_OHEADBW, &s->oheadbw, sizeof(s->oheadbw)) < 0)) {
         return AVERROR(EIO);
     }
     return 0;
@@ -314,44 +314,44 @@ static int libsrt_set_options_pre(URLContext *h, int fd)
     int peerlatency = s->peerlatency / 1000;
     int connect_timeout = s->connect_timeout;
 
-    if ((s->mode == SRT_MODE_RENDEZVOUS && libsrt_setsockopt(h, fd, SRTO_RENDEZVOUS, "SRTO_RENDEZVOUS", &yes, sizeof(yes)) < 0) ||
-        (s->transtype != SRTT_INVALID && libsrt_setsockopt(h, fd, SRTO_TRANSTYPE, "SRTO_TRANSTYPE", &s->transtype, sizeof(s->transtype)) < 0) ||
-        (s->maxbw >= 0 && libsrt_setsockopt(h, fd, SRTO_MAXBW, "SRTO_MAXBW", &s->maxbw, sizeof(s->maxbw)) < 0) ||
-        (s->pbkeylen >= 0 && libsrt_setsockopt(h, fd, SRTO_PBKEYLEN, "SRTO_PBKEYLEN", &s->pbkeylen, sizeof(s->pbkeylen)) < 0) ||
-        (s->passphrase && libsrt_setsockopt(h, fd, SRTO_PASSPHRASE, "SRTO_PASSPHRASE", s->passphrase, strlen(s->passphrase)) < 0) ||
+    if ((s->mode == SRT_MODE_RENDEZVOUS && LIBSRT_SETSOCKOPT(h, fd, SRTO_RENDEZVOUS, &yes, sizeof(yes)) < 0) ||
+        (s->transtype != SRTT_INVALID && LIBSRT_SETSOCKOPT(h, fd, SRTO_TRANSTYPE, &s->transtype, sizeof(s->transtype)) < 0) ||
+        (s->maxbw >= 0 && LIBSRT_SETSOCKOPT(h, fd, SRTO_MAXBW, &s->maxbw, sizeof(s->maxbw)) < 0) ||
+        (s->pbkeylen >= 0 && LIBSRT_SETSOCKOPT(h, fd, SRTO_PBKEYLEN, &s->pbkeylen, sizeof(s->pbkeylen)) < 0) ||
+        (s->passphrase && LIBSRT_SETSOCKOPT(h, fd, SRTO_PASSPHRASE, s->passphrase, strlen(s->passphrase)) < 0) ||
 #if SRT_VERSION_VALUE >= 0x010302
 #if SRT_VERSION_VALUE >= 0x010401
-        (s->enforced_encryption >= 0 && libsrt_setsockopt(h, fd, SRTO_ENFORCEDENCRYPTION, "SRTO_ENFORCEDENCRYPTION", &s->enforced_encryption, sizeof(s->enforced_encryption)) < 0) ||
+        (s->enforced_encryption >= 0 && LIBSRT_SETSOCKOPT(h, fd, SRTO_ENFORCEDENCRYPTION, &s->enforced_encryption, sizeof(s->enforced_encryption)) < 0) ||
 #else
         /* SRTO_STRICTENC == SRTO_ENFORCEDENCRYPTION (53), but for compatibility, we used SRTO_STRICTENC */
-        (s->enforced_encryption >= 0 && libsrt_setsockopt(h, fd, SRTO_STRICTENC, "SRTO_STRICTENC", &s->enforced_encryption, sizeof(s->enforced_encryption)) < 0) ||
+        (s->enforced_encryption >= 0 && LIBSRT_SETSOCKOPT(h, fd, SRTO_STRICTENC, &s->enforced_encryption, sizeof(s->enforced_encryption)) < 0) ||
 #endif
-        (s->kmrefreshrate >= 0 && libsrt_setsockopt(h, fd, SRTO_KMREFRESHRATE, "SRTO_KMREFRESHRATE", &s->kmrefreshrate, sizeof(s->kmrefreshrate)) < 0) ||
-        (s->kmpreannounce >= 0 && libsrt_setsockopt(h, fd, SRTO_KMPREANNOUNCE, "SRTO_KMPREANNOUNCE", &s->kmpreannounce, sizeof(s->kmpreannounce)) < 0) ||
+        (s->kmrefreshrate >= 0 && LIBSRT_SETSOCKOPT(h, fd, SRTO_KMREFRESHRATE, &s->kmrefreshrate, sizeof(s->kmrefreshrate)) < 0) ||
+        (s->kmpreannounce >= 0 && LIBSRT_SETSOCKOPT(h, fd, SRTO_KMPREANNOUNCE, &s->kmpreannounce, sizeof(s->kmpreannounce)) < 0) ||
 #endif
-        (s->mss >= 0 && libsrt_setsockopt(h, fd, SRTO_MSS, "SRTO_MSS", &s->mss, sizeof(s->mss)) < 0) ||
-        (s->ffs >= 0 && libsrt_setsockopt(h, fd, SRTO_FC, "SRTO_FC", &s->ffs, sizeof(s->ffs)) < 0) ||
-        (s->ipttl >= 0 && libsrt_setsockopt(h, fd, SRTO_IPTTL, "SRTO_IPTTL", &s->ipttl, sizeof(s->ipttl)) < 0) ||
-        (s->iptos >= 0 && libsrt_setsockopt(h, fd, SRTO_IPTOS, "SRTO_IPTOS", &s->iptos, sizeof(s->iptos)) < 0) ||
-        (s->latency >= 0 && libsrt_setsockopt(h, fd, SRTO_LATENCY, "SRTO_LATENCY", &latency, sizeof(latency)) < 0) ||
-        (s->rcvlatency >= 0 && libsrt_setsockopt(h, fd, SRTO_RCVLATENCY, "SRTO_RCVLATENCY", &rcvlatency, sizeof(rcvlatency)) < 0) ||
-        (s->peerlatency >= 0 && libsrt_setsockopt(h, fd, SRTO_PEERLATENCY, "SRTO_PEERLATENCY", &peerlatency, sizeof(peerlatency)) < 0) ||
-        (s->tlpktdrop >= 0 && libsrt_setsockopt(h, fd, SRTO_TLPKTDROP, "SRTO_TLPKDROP", &s->tlpktdrop, sizeof(s->tlpktdrop)) < 0) ||
-        (s->nakreport >= 0 && libsrt_setsockopt(h, fd, SRTO_NAKREPORT, "SRTO_NAKREPORT", &s->nakreport, sizeof(s->nakreport)) < 0) ||
-        (connect_timeout >= 0 && libsrt_setsockopt(h, fd, SRTO_CONNTIMEO, "SRTO_CONNTIMEO", &connect_timeout, sizeof(connect_timeout)) <0 ) ||
-        (s->sndbuf >= 0 && libsrt_setsockopt(h, fd, SRTO_SNDBUF, "SRTO_SNDBUF", &s->sndbuf, sizeof(s->sndbuf)) < 0) ||
-        (s->rcvbuf >= 0 && libsrt_setsockopt(h, fd, SRTO_RCVBUF, "SRTO_RCVBUF", &s->rcvbuf, sizeof(s->rcvbuf)) < 0) ||
-        (s->lossmaxttl >= 0 && libsrt_setsockopt(h, fd, SRTO_LOSSMAXTTL, "SRTO_LOSSMAXTTL", &s->lossmaxttl, sizeof(s->lossmaxttl)) < 0) ||
-        (s->minversion >= 0 && libsrt_setsockopt(h, fd, SRTO_MINVERSION, "SRTO_MINVERSION", &s->minversion, sizeof(s->minversion)) < 0) ||
-        (s->streamid && libsrt_setsockopt(h, fd, SRTO_STREAMID, "SRTO_STREAMID", s->streamid, strlen(s->streamid)) < 0) ||
+        (s->mss >= 0 && LIBSRT_SETSOCKOPT(h, fd, SRTO_MSS, &s->mss, sizeof(s->mss)) < 0) ||
+        (s->ffs >= 0 && LIBSRT_SETSOCKOPT(h, fd, SRTO_FC, &s->ffs, sizeof(s->ffs)) < 0) ||
+        (s->ipttl >= 0 && LIBSRT_SETSOCKOPT(h, fd, SRTO_IPTTL, &s->ipttl, sizeof(s->ipttl)) < 0) ||
+        (s->iptos >= 0 && LIBSRT_SETSOCKOPT(h, fd, SRTO_IPTOS, &s->iptos, sizeof(s->iptos)) < 0) ||
+        (s->latency >= 0 && LIBSRT_SETSOCKOPT(h, fd, SRTO_LATENCY, &latency, sizeof(latency)) < 0) ||
+        (s->rcvlatency >= 0 && LIBSRT_SETSOCKOPT(h, fd, SRTO_RCVLATENCY, &rcvlatency, sizeof(rcvlatency)) < 0) ||
+        (s->peerlatency >= 0 && LIBSRT_SETSOCKOPT(h, fd, SRTO_PEERLATENCY, &peerlatency, sizeof(peerlatency)) < 0) ||
+        (s->tlpktdrop >= 0 && LIBSRT_SETSOCKOPT(h, fd, SRTO_TLPKTDROP, &s->tlpktdrop, sizeof(s->tlpktdrop)) < 0) ||
+        (s->nakreport >= 0 && LIBSRT_SETSOCKOPT(h, fd, SRTO_NAKREPORT, &s->nakreport, sizeof(s->nakreport)) < 0) ||
+        (connect_timeout >= 0 && LIBSRT_SETSOCKOPT(h, fd, SRTO_CONNTIMEO, &connect_timeout, sizeof(connect_timeout)) <0 ) ||
+        (s->sndbuf >= 0 && LIBSRT_SETSOCKOPT(h, fd, SRTO_SNDBUF, &s->sndbuf, sizeof(s->sndbuf)) < 0) ||
+        (s->rcvbuf >= 0 && LIBSRT_SETSOCKOPT(h, fd, SRTO_RCVBUF, &s->rcvbuf, sizeof(s->rcvbuf)) < 0) ||
+        (s->lossmaxttl >= 0 && LIBSRT_SETSOCKOPT(h, fd, SRTO_LOSSMAXTTL, &s->lossmaxttl, sizeof(s->lossmaxttl)) < 0) ||
+        (s->minversion >= 0 && LIBSRT_SETSOCKOPT(h, fd, SRTO_MINVERSION, &s->minversion, sizeof(s->minversion)) < 0) ||
+        (s->streamid && LIBSRT_SETSOCKOPT(h, fd, SRTO_STREAMID, s->streamid, strlen(s->streamid)) < 0) ||
 #if SRT_VERSION_VALUE >= 0x010401
-        (s->smoother && libsrt_setsockopt(h, fd, SRTO_CONGESTION, "SRTO_CONGESTION", s->smoother, strlen(s->smoother)) < 0) ||
+        (s->smoother && LIBSRT_SETSOCKOPT(h, fd, SRTO_CONGESTION, s->smoother, strlen(s->smoother)) < 0) ||
 #else
-        (s->smoother && libsrt_setsockopt(h, fd, SRTO_SMOOTHER, "SRTO_SMOOTHER", s->smoother, strlen(s->smoother)) < 0) ||
+        (s->smoother && LIBSRT_SETSOCKOPT(h, fd, SRTO_SMOOTHER, s->smoother, strlen(s->smoother)) < 0) ||
 #endif
-        (s->messageapi >= 0 && libsrt_setsockopt(h, fd, SRTO_MESSAGEAPI, "SRTO_MESSAGEAPI", &s->messageapi, sizeof(s->messageapi)) < 0) ||
-        (s->payload_size >= 0 && libsrt_setsockopt(h, fd, SRTO_PAYLOADSIZE, "SRTO_PAYLOADSIZE", &s->payload_size, sizeof(s->payload_size)) < 0) ||
-        ((h->flags & AVIO_FLAG_WRITE) && libsrt_setsockopt(h, fd, SRTO_SENDER, "SRTO_SENDER", &yes, sizeof(yes)) < 0)) {
+        (s->messageapi >= 0 && LIBSRT_SETSOCKOPT(h, fd, SRTO_MESSAGEAPI, &s->messageapi, sizeof(s->messageapi)) < 0) ||
+        (s->payload_size >= 0 && LIBSRT_SETSOCKOPT(h, fd, SRTO_PAYLOADSIZE, &s->payload_size, sizeof(s->payload_size)) < 0) ||
+        ((h->flags & AVIO_FLAG_WRITE) && LIBSRT_SETSOCKOPT(h, fd, SRTO_SENDER, &yes, sizeof(yes)) < 0)) {
         return AVERROR(EIO);
     }
 
@@ -359,7 +359,7 @@ static int libsrt_set_options_pre(URLContext *h, int fd)
         struct linger lin;
         lin.l_linger = s->linger;
         lin.l_onoff  = lin.l_linger > 0 ? 1 : 0;
-        if (libsrt_setsockopt(h, fd, SRTO_LINGER, "SRTO_LINGER", &lin, sizeof(lin)) < 0)
+        if (LIBSRT_SETSOCKOPT(h, fd, SRTO_LINGER, &lin, sizeof(lin)) < 0)
             return AVERROR(EIO);
     }
     return 0;
@@ -470,7 +470,7 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags)
     if (flags & AVIO_FLAG_WRITE) {
         int packet_size = 0;
         int optlen = sizeof(packet_size);
-        ret = libsrt_getsockopt(h, fd, SRTO_PAYLOADSIZE, "SRTO_PAYLOADSIZE", &packet_size, &optlen);
+        ret = LIBSRT_GETSOCKOPT(h, fd, SRTO_PAYLOADSIZE, &packet_size, &optlen);
         if (ret < 0)
             goto fail1;
         if (packet_size > 0)
