Skip to content

Commit

Permalink
MEDIA-1620: add 'deleteEmptyConferencesWithBarbells' to config, defau…
Browse files Browse the repository at this point in the history
…lt value is false.

If true, empty conferences with existing barbell connections will be automatically deleted despite ICE-only activity after
config.mixerInactivityTimeoutMs timeout.
  • Loading branch information
reddvl1980 committed Dec 13, 2023
1 parent e2d28b6 commit 6dc0469
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
14 changes: 11 additions & 3 deletions bridge/engine/EngineMixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ EngineMixer::EngineMixer(const std::string& id,
assert(videoSsrcs.size() <= SsrcRewrite::ssrcArraySize);

std::memset(_mixedData, 0, samplesPerFrame20ms * channelsPerFrame);
_iceReceived.test_and_set();
_iceReceivedOnRegularTransport.test_and_set();
_iceReceivedOnBarbellTransport.test_and_set();
}

EngineMixer::~EngineMixer() {}
Expand Down Expand Up @@ -1067,7 +1068,10 @@ void EngineMixer::processIncomingRtcpPackets(const uint64_t timestamp)

void EngineMixer::processIceActivity(const uint64_t timestamp)
{
if (!_iceReceived.test_and_set())
bool needToUpdate = !_iceReceivedOnBarbellTransport.test_and_set() && !_config.deleteEmptyConferencesWithBarbells;
needToUpdate |= !_iceReceivedOnRegularTransport.test_and_set();

if (needToUpdate)
{
// if it was cleared by any transport receiving ICE, we will now set the keep alive timestamp
_lastReceiveTime = timestamp;
Expand Down Expand Up @@ -1590,6 +1594,10 @@ bool EngineMixer::asyncHandleSctpControl(const size_t endpointIdHash, memory::Un

void EngineMixer::onIceReceived(transport::RtcTransport* transport, uint64_t timestamp)
{
_iceReceived.clear();
if (EngineBarbell::isFromBarbell(transport->getTag())) {
_iceReceivedOnBarbellTransport.clear();
} else {
_iceReceivedOnRegularTransport.clear();
}
}
} // namespace bridge
3 changes: 2 additions & 1 deletion bridge/engine/EngineMixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,8 @@ class EngineMixer : public transport::DataReceiver
memory::AudioPacketPoolAllocator& _audioAllocator;

uint64_t _lastReceiveTime;
std::atomic_flag _iceReceived = ATOMIC_FLAG_INIT;
std::atomic_flag _iceReceivedOnRegularTransport = ATOMIC_FLAG_INIT;
std::atomic_flag _iceReceivedOnBarbellTransport = ATOMIC_FLAG_INIT;
uint64_t _lastCounterCheck;

std::unique_ptr<EngineStreamDirector> _engineStreamDirector;
Expand Down
4 changes: 3 additions & 1 deletion config/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ class Config : public ConfigReader
CFG_PROP(std::string, logLevel, "INFO");
CFG_PROP(bool, enableSrtpNullCipher, false);

// If mixer does not receive any packets during this timeout, it's considered abandoned and is garbage collected.
// If mixer does not receive any packets during this timeout, it's considered abandoned and is garbage collected...
CFG_PROP(int, mixerInactivityTimeoutMs, 2 * 60 * 1000);
// ...unless it has barbell connections, and 'deleteEmptyConferencesWithBarbells' is false.
CFG_PROP(bool, deleteEmptyConferencesWithBarbells, false);
CFG_PROP(int, numWorkerTreads, 0);
CFG_PROP(std::string, logFile, "/tmp/smb.log");

Expand Down

0 comments on commit 6dc0469

Please sign in to comment.