From 67476189d253205b5d26525ca650f97e8bb17b5c Mon Sep 17 00:00:00 2001 From: Andrea Bondavalli Date: Sat, 1 Feb 2020 15:56:10 +0100 Subject: [PATCH] Fixes to add and update of source and sink --- daemon/session_manager.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/daemon/session_manager.cpp b/daemon/session_manager.cpp index 25a3df4..7fdad0a 100644 --- a/daemon/session_manager.cpp +++ b/daemon/session_manager.cpp @@ -495,12 +495,19 @@ std::error_code SessionManager::add_source(const StreamSource& source) { ret = driver_->add_rtp_stream(info.stream, info.handle); if (ret) { if (it != sources_.end()) { + /* update operation failed */ sources_.erase(source.id); + igmp_.leave(config_->get_ip_addr_str(), + ip::address_v4(info.stream.m_ui32DestIP).to_string()); } return ret; } - igmp_.join(config_->get_ip_addr_str(), - ip::address_v4(info.stream.m_ui32DestIP).to_string()); + + if (it == sources_.end()) { + /* if add join multicast */ + igmp_.join(config_->get_ip_addr_str(), + ip::address_v4(info.stream.m_ui32DestIP).to_string()); + } } // update source map @@ -713,12 +720,16 @@ std::error_code SessionManager::add_sink(const StreamSink& sink) { auto ret = driver_->add_rtp_stream(info.stream, info.handle); if (ret) { if (it != sinks_.end()) { + /* update operation failed */ sinks_.erase(sink.id); + igmp_.leave(config_->get_ip_addr_str(), + ip::address_v4(info.stream.m_ui32DestIP).to_string()); } return ret; } if (it == sinks_.end()) { + /* if add join multicast */ igmp_.join(config_->get_ip_addr_str(), ip::address_v4(info.stream.m_ui32DestIP).to_string()); }