`Worker`: Add `RTC::SharedInterface` and include on it utils to create timers and so on
Author: ibcCreated Apr 28, 2026Updated May 18, 2026
Context
- Followup of https://github.com/versatica/mediasoup/pull/1784 "Worker: Add interfaces for Timer classes".
- We need class interfaces to be able to run tests that involve C++ classes that require timers (among other things such as current time, random number/string generators, etc).
- Best place to do it is by creating a
RTC::SharedInterfaceabstract class. Currently eachWorkercreates aRTC::Sharedinterface that is passed down to all worker subclasses (not to all of them actually). We should add functions/utils into it. - This way, in C++ tests we could pass mock
RTC::Sharedclasses that create mock timer classes and so on.
Current RTC::Shared
Current RTC::Shared class looks as follows:
class Shared
{
public:
explicit Shared(
ChannelMessageRegistrator* channelMessageRegistrator,
Channel::ChannelNotifier* channelNotifier);
~Shared();
public:
ChannelMessageRegistrator* channelMessageRegistrator{ nullptr };
Channel::ChannelNotifier* channelNotifier{ nullptr };
};New RTC::SharedInterface
The new interface requires moving current members to also interfaces and new utils/functions. Presumably something like this (to be properly designed):
class SharedInterface
{
public:
explicit SharedInterface(
ChannelMessageRegistratorInterface* channelMessageRegistrator,
Channel::ChannelNotifierInterface* channelNotifier,
TimerHandleInterface* createTimer(),
BackoffTimerHandleInterface* createBackoffTimer(BackoffTimerHandleOptions& options),
/* etc */);
virtual ~SharedInterface() = default;
public:
ChannelMessageRegistratorInterface* channelMessageRegistrator{ nullptr };
Channel::ChannelNotifierInterface* channelNotifier{ nullptr };
};TODO
- Create
ChannelMessageRegistratorInterfaceandChannelNotifierInterfaceclasses. - Create
MockBackoffTimerHandleandMockTimerHandleclasses. - Remove class forward declaration hack in
TimerHandle.hppandBackoffTimerHandle.hpp.
Source: versatica/mediasoup