Fixes to add and update of source and sink

This commit is contained in:
Andrea Bondavalli 2020-02-01 15:56:10 +01:00
parent ed392d2719
commit 67476189d2

View File

@ -495,12 +495,19 @@ std::error_code SessionManager::add_source(const StreamSource& source) {
ret = driver_->add_rtp_stream(info.stream, info.handle); ret = driver_->add_rtp_stream(info.stream, info.handle);
if (ret) { if (ret) {
if (it != sources_.end()) { if (it != sources_.end()) {
/* update operation failed */
sources_.erase(source.id); sources_.erase(source.id);
igmp_.leave(config_->get_ip_addr_str(),
ip::address_v4(info.stream.m_ui32DestIP).to_string());
} }
return ret; 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 // 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); auto ret = driver_->add_rtp_stream(info.stream, info.handle);
if (ret) { if (ret) {
if (it != sinks_.end()) { if (it != sinks_.end()) {
/* update operation failed */
sinks_.erase(sink.id); sinks_.erase(sink.id);
igmp_.leave(config_->get_ip_addr_str(),
ip::address_v4(info.stream.m_ui32DestIP).to_string());
} }
return ret; return ret;
} }
if (it == sinks_.end()) { if (it == sinks_.end()) {
/* if add join multicast */
igmp_.join(config_->get_ip_addr_str(), igmp_.join(config_->get_ip_addr_str(),
ip::address_v4(info.stream.m_ui32DestIP).to_string()); ip::address_v4(info.stream.m_ui32DestIP).to_string());
} }