It's useful for test client which pass streamid to ffmpeg/ffplay.
For example, use ffmpeg to test streamid support in VLC:
./ffmpeg -v info -re -i foo.mp4 -c copy -f mpegts -mode listener 
srt://127.0.0.1:9000
./vlc srt://127.0.0.1:9000?streamid=foobar
---
 libavformat/libsrt.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c
index c1e96f700e..6ea6c35c53 100644
--- a/libavformat/libsrt.c
+++ b/libavformat/libsrt.c
@@ -143,6 +143,8 @@ static const AVOption libsrt_options[] = {
     { NULL }
 };
 
+static int libsrt_getsockopt(URLContext *h, int fd, SRT_SOCKOPT optname, const 
char * optnamestr, void * optval, int * optlen);
+
 static int libsrt_neterrno(URLContext *h)
 {
     int os_errno;
@@ -224,6 +226,8 @@ static int libsrt_listen(int eid, int fd, const struct 
sockaddr *addr, socklen_t
 {
     int ret;
     int reuse = 1;
+    char streamid[512] = {};
+    int streamid_len = sizeof(streamid);
     if (srt_setsockopt(fd, SOL_SOCKET, SRTO_REUSEADDR, &reuse, sizeof(reuse))) 
{
         av_log(h, AV_LOG_WARNING, "setsockopt(SRTO_REUSEADDR) failed\n");
     }
@@ -242,6 +246,8 @@ static int libsrt_listen(int eid, int fd, const struct 
sockaddr *addr, socklen_t
         return libsrt_neterrno(h);
     if (libsrt_socket_nonblock(ret, 1) < 0)
         av_log(h, AV_LOG_DEBUG, "libsrt_socket_nonblock failed\n");
+    if (!libsrt_getsockopt(h, ret, SRTO_STREAMID, "SRTO_STREAMID", streamid, 
&streamid_len))
+        av_log(h, AV_LOG_INFO, "accept streamid [%s], length %d\n", streamid, 
streamid_len);
 
     return ret;
 }
-- 
2.29.2

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to