#1786·mediasoup

`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::SharedInterface abstract class. Currently each Worker creates a RTC::Shared interface 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::Shared classes that create mock timer classes and so on.

Current RTC::Shared

Current RTC::Shared class looks as follows:

cpp
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):

cpp
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 ChannelMessageRegistratorInterface and ChannelNotifierInterface classes.
  • Create MockBackoffTimerHandle and MockTimerHandle classes.
  • Remove class forward declaration hack in TimerHandle.hpp and BackoffTimerHandle.hpp.