From 62e6ec958343c3baa4291179066d59d0bbf53135 Mon Sep 17 00:00:00 2001 From: Maxim Sharabayko Date: Tue, 8 Oct 2024 10:31:06 +0200 Subject: [PATCH] Fixed printing StreamID of a connected socket. Was outputting all the trailing NUL characters of a buffer. --- xtransmit/srt_socket.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xtransmit/srt_socket.cpp b/xtransmit/srt_socket.cpp index bd50b59..dca7d15 100644 --- a/xtransmit/srt_socket.cpp +++ b/xtransmit/srt_socket.cpp @@ -381,15 +381,16 @@ std::string socket::srt::print_negotiated_config(SRTSOCKET sock) const string crypto_mode_str = ""; #endif #undef VAL_AND_STR - + // Template lambdas are only available since C++20, have to duplicate the code. std::string streamid(512, '\0'); - int streamid_len = (int) streamid.size(); + auto streamid_len = (int)streamid.size(); if (srt_getsockflag(sock, SRTO_STREAMID, (void*)streamid.data(), &streamid_len) != SRT_SUCCESS) { spdlog::error(LOG_SOCK_SRT "Failed to get sockopt SRTO_STREAMID."); streamid_len = 0; } + streamid.resize(streamid_len); return fmt::format("TSBPD {}. KM state {} (RCV {}, SND {}). PB key length: {}. Cryptomode {}. Stream ID: {}", latency_str,