From 0a554938d0af4f72857d68578e9f7fd620fc91a7 Mon Sep 17 00:00:00 2001 From: Heikki Tampio Date: Wed, 19 Apr 2023 12:47:36 +0300 Subject: [PATCH] multiplex: Add option to manually set remote SSRC of media stream --- include/uvgrtp/media_stream.hh | 1 + include/uvgrtp/util.hh | 12 +++++++++--- src/media_stream.cc | 10 +++++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/include/uvgrtp/media_stream.hh b/include/uvgrtp/media_stream.hh index c11bfc1..49242e1 100644 --- a/include/uvgrtp/media_stream.hh +++ b/include/uvgrtp/media_stream.hh @@ -422,6 +422,7 @@ namespace uvgrtp { ssize_t fps_denominator_ = 1; uint32_t bandwidth_ = 0; std::shared_ptr> ssrc_; + std::shared_ptr> remote_ssrc_; }; } diff --git a/include/uvgrtp/util.hh b/include/uvgrtp/util.hh index 8c11ce4..36122bf 100644 --- a/include/uvgrtp/util.hh +++ b/include/uvgrtp/util.hh @@ -363,12 +363,18 @@ enum RTP_CTX_CONFIGURATION_FLAGS { */ RCC_FPS_DENOMINATOR = 9, - /** Set the SSRC of the stream manually + /** Set the local SSRC of the stream manually * - * By default SSRC is generated randomly + * By default local SSRC is generated randomly */ RCC_SSRC = 10, + /** Set the remote SSRC of the stream manually + * + * By default remote SSRC is generated randomly + */ + RCC_REMOTE_SSRC = 11, + /** Set bandwidth for the session * * uvgRTP chooses this automatically depending on the format of the data being transferred. @@ -381,7 +387,7 @@ enum RTP_CTX_CONFIGURATION_FLAGS { * Larger bandwidth values result in shorter RTCP intervals, and vice versa. * See RFC 3550 Appendix A.7 for further information on RTCP interval */ - RCC_SESSION_BANDWIDTH = 11, + RCC_SESSION_BANDWIDTH = 12, /// \cond DO_NOT_DOCUMENT RCC_LAST diff --git a/src/media_stream.cc b/src/media_stream.cc index bbe5210..818d764 100644 --- a/src/media_stream.cc +++ b/src/media_stream.cc @@ -58,7 +58,8 @@ uvgrtp::media_stream::media_stream(std::string cname, std::string remote_addr, cname_(cname), fps_numerator_(30), fps_denominator_(1), - ssrc_(std::make_shared>(uvgrtp::random::generate_32())) + ssrc_(std::make_shared>(uvgrtp::random::generate_32())), + remote_ssrc_(std::make_shared>(uvgrtp::random::generate_32())) { //socket_ = sfp_->create_new_socket(); //holepuncher_ = std::unique_ptr(new uvgrtp::holepuncher(socket_)); @@ -768,6 +769,13 @@ rtp_error_t uvgrtp::media_stream::configure_ctx(int rcc_flag, ssize_t value) *ssrc_ = (uint32_t)value; break; } + case RCC_REMOTE_SSRC: { + if (value <= 0 || value > (ssize_t)UINT32_MAX) + return RTP_INVALID_VALUE; + + *remote_ssrc_ = (uint32_t)value; + break; + } default: return RTP_INVALID_VALUE; }