Skip to content

Worker: New Consumer class handling all possible producer stream modes.#1731

Draft
jmillan wants to merge 11 commits intov3from
new_consumer
Draft

Worker: New Consumer class handling all possible producer stream modes.#1731
jmillan wants to merge 11 commits intov3from
new_consumer

Conversation

@jmillan
Copy link
Member

@jmillan jmillan commented Feb 16, 2026

New ProducerStreamManager interface with the following implementations:

  • SimpleProducerStreamManager: handles a single stream with no spatial or temporal layers.
  • SimulcastProducerStreamManager: handles N streams with 1 spatial and N temporal layers.
  • SvcProducerStreamManager: handles 1 stream with N spatial and M temporal layers.

This new class handles the different flavours of producers streams making Consumer agnostic. This allows:

  • Cleaner implementation: Producer streams details are hidden in the corresponding implementation.
  • Reduced code size: No more duplicated full consumer implementation.
  • Will allow to use the same Consumer and switch the ProducerStreamManager that sources it.

Consumer + SimpleProducerStreamManager replaces SimpleConsumer.
Consumer + SimulcastProducerStreamManager replaces SimulcastConsumer.
Consumer + SvcProducerStreamManager replaces SvcConsumer.

NOTE1: Old consumer has been named OldConsumer for the time being. Old consumers are deprecated and just left in the repo for comparison purposes while this PR is ongoing.

NOTE2: PipeConsumer has not been touched as we are going to make Consumer pipe-able and we'll not need any specific consumer implementation for that. Hence pipe consumer tests in NODE are failing. That's OK.

NOTE3: This is a work in progress.

TODO:

  • [] Make consumer pipe-able.
  • [] Remove old consumers. They are just not used anymore.

New ProducerStreamManager interface with the following implementations:
- SimpleProducerStreamManager: handles a single stream with no spatial or temporal layers.
- SimulcastProducerStreamManager: handles N streams with 1 spatial and N temporal layers.
- SvcProducerStreamManager: handles 1 stream with N spatial and M temporal layers.

Consumer + SimpleProducerStreamManager replaces SimpleConsumer.
Consumer + SimulcastProducerStreamManager replaces SimulcastConsumer.
Consumer + SvcProducerStreamManager replaces SvcConsumer.
@jmillan jmillan requested a review from ibc February 16, 2026 10:43
@jmillan jmillan marked this pull request as draft February 16, 2026 10:44
Consumer::IsActive() checks:
- transportConnected
- paused
- producerPaused
- producerClosed

ProducerStreamManager::IsActive() checks:
- Consumer::IsActive()
- Whether producer streams are active
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

ibc
ibc previously requested changes Feb 18, 2026
@ibc ibc mentioned this pull request Feb 24, 2026
4 tasks
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

this->listener->IsActive() &&
std::any_of(
this->producerRtpStreams.begin(),
this->producerRtpStreams.end(),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use a ranges version of this algorithm [modernize-use-ranges]

worker/src/RTC/SimulcastProducerStreamManager.cpp:4:

- #include "Logger.hpp"
+ 
+ #include <algorithm>
+ #include "Logger.hpp"
Suggested change
this->producerRtpStreams.end(),
std::ranges::any_of(
this->producerRtpStreams,
,

temporalLayer = 0;

// Check bitrate of every temporal layer.
for (; temporalLayer < producerRtpStream->GetTemporalLayers(); ++temporalLayer)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]

worker/src/RTC/SimulcastProducerStreamManager.cpp:4:

- #include "Logger.hpp"
+ 
+ #include <utility>
+ #include "Logger.hpp"
Suggested change
for (; temporalLayer < producerRtpStream->GetTemporalLayers(); ++temporalLayer)
for (; std::cmp_less(temporalLayer , producerRtpStream->GetTemporalLayers()); ++temporalLayer)

if (this->keyFrameForTsOffsetRequested)
{
// Give up and use the theoretical offset.
if (tsExtraOffset > maxTsExtraOffset)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]

Suggested change
if (tsExtraOffset > maxTsExtraOffset)
if (std::cmp_greater(tsExtraOffset , maxTsExtraOffset))

tsExtraOffset = 1u;
}
}
else if (tsExtraOffset > maxTsExtraOffset)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]

Suggested change
else if (tsExtraOffset > maxTsExtraOffset)
else if (std::cmp_greater(tsExtraOffset , maxTsExtraOffset))

int16_t spatialLayer{ 0 };
int16_t temporalLayer{ 0 };

for (; spatialLayer < this->producerRtpStream->GetSpatialLayers(); ++spatialLayer)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]

worker/src/RTC/SvcProducerStreamManager.cpp:4:

- #include "Logger.hpp"
+ 
+ #include <utility>
+ #include "Logger.hpp"
Suggested change
for (; spatialLayer < this->producerRtpStream->GetSpatialLayers(); ++spatialLayer)
for (; std::cmp_less(spatialLayer , this->producerRtpStream->GetSpatialLayers()); ++spatialLayer)

temporalLayer = 0;

// Check bitrate of every temporal layer.
for (; temporalLayer < this->producerRtpStream->GetTemporalLayers(); ++temporalLayer)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]

Suggested change
for (; temporalLayer < this->producerRtpStream->GetTemporalLayers(); ++temporalLayer)
for (; std::cmp_less(temporalLayer , this->producerRtpStream->GetTemporalLayers()); ++temporalLayer)

goto done;
}

for (; spatialLayer < this->producerRtpStream->GetSpatialLayers(); ++spatialLayer)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]

Suggested change
for (; spatialLayer < this->producerRtpStream->GetSpatialLayers(); ++spatialLayer)
for (; std::cmp_less(spatialLayer , this->producerRtpStream->GetSpatialLayers()); ++spatialLayer)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants