From 8d454dade2d60dbaefa809eb8190e32d38497af6 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Wed, 11 Nov 2020 13:29:51 +0100 Subject: [PATCH] SDP: Set correct IP version + some documentation --- src/main.cpp | 2 +- src/utils/sdp.c | 6 +++--- src/video_rxtx/h264_sdp.cpp | 8 +++++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 01414b2e4..4d5f9a59a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1114,7 +1114,7 @@ int main(int argc, char *argv[]) audio_codec = "OPUS:sample_rate=48000"; } if (requested_compression == nullptr) { - requested_compression = "none"; // will be set later + requested_compression = "none"; // will be set later by h264_sdp_video_rxtx::send_frame() } if (force_ip_version == 0 && strcasecmp(video_protocol, "rtsp") == 0) { force_ip_version = 4; diff --git a/src/utils/sdp.c b/src/utils/sdp.c index 7416f1841..6e95e2d8b 100644 --- a/src/utils/sdp.c +++ b/src/utils/sdp.c @@ -106,7 +106,7 @@ struct sdp { }; struct sdp *new_sdp(int ip_version, const char *receiver) { - assert(ip_version == 0 || ip_version == 4 || ip_version == 6); + assert(ip_version == 4 || ip_version == 6); struct sdp *sdp; sdp = calloc(1, sizeof(struct sdp)); assert(sdp != NULL); @@ -137,9 +137,9 @@ struct sdp *new_sdp(int ip_version, const char *receiver) { connection_address = receiver; } strncpy(sdp->version, "v=0\n", STR_LENGTH - 1); - snprintf(sdp->origin, STR_LENGTH, "o=- 0 0 IN IP%d %s\n", ip_version == 0 ? 4 : 6, origin_address); + snprintf(sdp->origin, STR_LENGTH, "o=- 0 0 IN IP%d %s\n", ip_version, origin_address); strncpy(sdp->session_name, "s=Ultragrid streams\n", STR_LENGTH - 1); - snprintf(sdp->connection, STR_LENGTH, "c=IN IP%d %s\n", ip_version == 0 ? 4 : 6, connection_address); + snprintf(sdp->connection, STR_LENGTH, "c=IN IP%d %s\n", ip_version, connection_address); strncpy(sdp->times, "t=0 0\n", STR_LENGTH - 1); return sdp; diff --git a/src/video_rxtx/h264_sdp.cpp b/src/video_rxtx/h264_sdp.cpp index 4714d64c6..c0c93a58b 100644 --- a/src/video_rxtx/h264_sdp.cpp +++ b/src/video_rxtx/h264_sdp.cpp @@ -82,7 +82,7 @@ h264_sdp_video_rxtx::h264_sdp_video_rxtx(std::map const &p } LOG(LOG_LEVEL_WARNING) << "Warning: SDP support is experimental only. Things may be broken - feel free to report them but the support may be limited.\n"; - m_sdp = new_sdp(params.at("force_ip_version").i, m_requested_receiver.c_str()); + m_sdp = new_sdp(rtp_is_ipv6(m_network_devices[0]) ? 6 : 4 , m_requested_receiver.c_str()); m_saved_addr = m_requested_receiver; if (m_sdp == nullptr) { throw string("[SDP] SDP creation failed\n"); @@ -162,6 +162,12 @@ void h264_sdp_video_rxtx::sdp_add_video(codec_t codec) #endif } +/** + * @note + * This function sets compression just after first frame is received. The delayed initialization is to allow devices + * producing H.264/JPEG natively (eg. v4l2) to be passed untouched to transport. Fallback H.264 is applied when uncompressed + * stream is detected. + */ void h264_sdp_video_rxtx::send_frame(shared_ptr tx_frame) { if (!is_codec_opaque(tx_frame->color_spec)) {