multiplex: Distinguish received RTCP packets from RTP packets

This commit is contained in:
Heikki Tampio 2023-06-14 09:51:35 +03:00
parent d8a9863999
commit 8b6037fa62
4 changed files with 17 additions and 15 deletions

View File

@ -275,7 +275,7 @@ enum RTP_CTX_ENABLE_FLAGS {
/** Paces the sending of frame fragments within frame interval (default 1/30 s) */ /** Paces the sending of frame fragments within frame interval (default 1/30 s) */
RCE_PACE_FRAGMENT_SENDING = 1 << 20, RCE_PACE_FRAGMENT_SENDING = 1 << 20,
RCE_RTCP_MULTIPLEX = 1 << 21, RCE_RTCP_MUX = 1 << 21,
/// \cond DO_NOT_DOCUMENT /// \cond DO_NOT_DOCUMENT
RCE_LAST = 1 << 21 RCE_LAST = 1 << 21

View File

@ -87,7 +87,7 @@ uvgrtp::media_stream::~media_stream()
sfp_->clear_port(src_port_, socket_); sfp_->clear_port(src_port_, socket_);
} }
} }
if (rce_flags_ & RCE_RTCP_MULTIPLEX) { if (rce_flags_ & RCE_RTCP_MUX) {
reception_flow_->clear_rtcp_from_rec(remote_ssrc_); reception_flow_->clear_rtcp_from_rec(remote_ssrc_);
} }
@ -318,7 +318,7 @@ rtp_error_t uvgrtp::media_stream::init()
reception_flow_->map_handler_key(rtp_handler_key_, remote_ssrc_); reception_flow_->map_handler_key(rtp_handler_key_, remote_ssrc_);
reception_flow_->install_aux_handler(rtp_handler_key_, rtcp_.get(), rtcp_->recv_packet_handler, nullptr); reception_flow_->install_aux_handler(rtp_handler_key_, rtcp_.get(), rtcp_->recv_packet_handler, nullptr);
if (rce_flags_ & RCE_RTCP_MULTIPLEX) { if (rce_flags_ & RCE_RTCP_MUX) {
reception_flow_->map_rtcp_to_rec(remote_ssrc_, rtcp_); reception_flow_->map_rtcp_to_rec(remote_ssrc_, rtcp_);
rtcp_->set_socket(socket_); rtcp_->set_socket(socket_);
} }
@ -384,7 +384,7 @@ rtp_error_t uvgrtp::media_stream::init(std::shared_ptr<uvgrtp::zrtp> zrtp)
reception_flow_->install_aux_handler(rtp_handler_key_, srtp_.get(), srtp_->recv_packet_handler, nullptr); reception_flow_->install_aux_handler(rtp_handler_key_, srtp_.get(), srtp_->recv_packet_handler, nullptr);
reception_flow_->install_aux_handler(rtp_handler_key_, rtcp_.get(), rtcp_->recv_packet_handler, nullptr); reception_flow_->install_aux_handler(rtp_handler_key_, rtcp_.get(), rtcp_->recv_packet_handler, nullptr);
if (rce_flags_ & RCE_RTCP_MULTIPLEX) { if (rce_flags_ & RCE_RTCP_MUX) {
reception_flow_->map_rtcp_to_rec(remote_ssrc_, rtcp_); reception_flow_->map_rtcp_to_rec(remote_ssrc_, rtcp_);
rtcp_->set_socket(socket_); rtcp_->set_socket(socket_);
} }
@ -437,7 +437,7 @@ rtp_error_t uvgrtp::media_stream::add_srtp_ctx(uint8_t *key, uint8_t *salt)
reception_flow_->install_aux_handler(rtp_handler_key_, rtcp_.get(), rtcp_->recv_packet_handler, nullptr); reception_flow_->install_aux_handler(rtp_handler_key_, rtcp_.get(), rtcp_->recv_packet_handler, nullptr);
reception_flow_->install_aux_handler(rtp_handler_key_, srtp_.get(), srtp_->recv_packet_handler, nullptr); reception_flow_->install_aux_handler(rtp_handler_key_, srtp_.get(), srtp_->recv_packet_handler, nullptr);
if (rce_flags_ & RCE_RTCP_MULTIPLEX) { if (rce_flags_ & RCE_RTCP_MUX) {
reception_flow_->map_rtcp_to_rec(remote_ssrc_, rtcp_); reception_flow_->map_rtcp_to_rec(remote_ssrc_, rtcp_);
rtcp_->set_socket(socket_); rtcp_->set_socket(socket_);
} }
@ -463,7 +463,7 @@ rtp_error_t uvgrtp::media_stream::start_components()
} }
else else
{ {
if (!(rce_flags_ & RCE_RTCP_MULTIPLEX)) { if (!(rce_flags_ & RCE_RTCP_MUX)) {
rtcp_->set_network_addresses(local_address_, remote_address_, src_port_ + 1, dst_port_ + 1, ipv6_); rtcp_->set_network_addresses(local_address_, remote_address_, src_port_ + 1, dst_port_ + 1, ipv6_);
} }
else { else {
@ -473,12 +473,11 @@ rtp_error_t uvgrtp::media_stream::start_components()
bandwidth_ = get_default_bandwidth_kbps(fmt_); bandwidth_ = get_default_bandwidth_kbps(fmt_);
rtcp_->set_session_bandwidth(bandwidth_); rtcp_->set_session_bandwidth(bandwidth_);
uint16_t rtcp_port = src_port_ + 1; uint16_t rtcp_port = src_port_ + 1;
std::shared_ptr<uvgrtp::socket> rtcp_socket; std::shared_ptr<uvgrtp::socket> rtcp_socket;
std::shared_ptr<uvgrtp::rtcp_reader> rtcp_reader; std::shared_ptr<uvgrtp::rtcp_reader> rtcp_reader;
if (!(rce_flags_ & RCE_RTCP_MULTIPLEX)) { if (!(rce_flags_ & RCE_RTCP_MUX)) {
// If RTCP is not multiplexed with RTP, configure the socket for RTCP: // If RTCP is not multiplexed with RTP, configure the socket for RTCP:
// 1. If RTCP port is not in use -> create new socket // 1. If RTCP port is not in use -> create new socket

View File

@ -78,7 +78,7 @@ void uvgrtp::reception_flow::create_ring_buffer()
uint8_t* data = new uint8_t[payload_size_]; uint8_t* data = new uint8_t[payload_size_];
if (data) if (data)
{ {
ring_buffer_.push_back({data, 0}); ring_buffer_.push_back({ data, 0, {}, {} });
} }
else else
{ {
@ -639,11 +639,13 @@ void uvgrtp::reception_flow::process_packet(int rce_flags)
} }
frame = nullptr; frame = nullptr;
if (rce_flags & RCE_RTCP_MUX) {
// rtcp packet types 200 201 202 203 204 // rtcp packet types 200 201 202 203 204
uint8_t pt = (uint8_t)&ptr[1]; uint8_t pt = (uint8_t)ptr[1];
UVG_LOG_DEBUG("Received frame with pt %u", pt); //UVG_LOG_DEBUG("Received frame with pt %u", pt);
if (rce_flags & RCE_RTCP_MULTIPLEX) {
if ((uint8_t)&ptr[1] >= 200 && (uint8_t)&ptr[1] <= 204) { if (pt >= 200 && pt <= 204) {
rtcp_map_mutex_.lock(); rtcp_map_mutex_.lock();
for (auto& p : rtcps_map_) { for (auto& p : rtcps_map_) {
std::shared_ptr<uvgrtp::rtcp> rtcp_ptr = p.second; std::shared_ptr<uvgrtp::rtcp> rtcp_ptr = p.second;
@ -655,6 +657,7 @@ void uvgrtp::reception_flow::process_packet(int rce_flags)
} }
} }
rtcp_map_mutex_.unlock(); rtcp_map_mutex_.unlock();
break;
} }
} }

View File

@ -203,7 +203,7 @@ rtp_error_t uvgrtp::rtcp::start()
{ {
active_ = true; active_ = true;
ipv6_ = sfp_->get_ipv6(); ipv6_ = sfp_->get_ipv6();
if ((rce_flags_ & RCE_RTCP_MULTIPLEX)) { if ((rce_flags_ & RCE_RTCP_MUX)) {
if (ipv6_) { if (ipv6_) {
socket_address_ipv6_ = uvgrtp::socket::create_ip6_sockaddr(remote_addr_, dst_port_); socket_address_ipv6_ = uvgrtp::socket::create_ip6_sockaddr(remote_addr_, dst_port_);
} }