The client is a web browser, so the consumer has REMB support, right?
I configured the simulcast bitrates in the rtp producer as follows:
'encodings': [
{'ssrc': 1000, 'active': True, 'maxBitrate': 2000000, 'scaleResolutionDownBy': 4, 'scalabilityMode': 'S1T1'},
{'ssrc': 1001, 'active': True, 'maxBitrate': 4000000, 'scaleResolutionDownBy': 2, 'scalabilityMode': 'S1T1'},
{'ssrc': 1002, 'active': True, 'maxBitrate': 8000000, 'scaleResolutionDownBy': 1, 'scalabilityMode': 'S1T1'}
]
CanSwitchToSpatialLayer returns true, here is a log of a simulcast consumer:
mediasoup:Channel[pid:52] request() [method:consumer.resume, id:12]
mediasoup:worker[pid:52] RTC::RembClient::CalculateProbationTargetBitrate() | probation enabled [bitrate:0, availableBitrate:600000, factor:0.000000, probationTargetBitrate:600000]
mediasoup:worker[pid:52] RTC::WebRtcTransport::DistributeAvailableOutgoingBitrate() | before iterations [availableBitrate:600000]
mediasoup:worker[pid:52] RTC::WebRtcTransport::DistributeAvailableOutgoingBitrate() | main bitrate for Consumer [priority:3, bitrate:600000, consumerId:4d1b5fb4-6ee9-40b6-a935-05f213f6cc18]
mediasoup:worker[pid:52] RTC::SimulcastConsumer::UseAvailableBitrate() | CanSwitchToSpatialLayer(0) returns true
mediasoup:worker[pid:52] RTC::SimulcastConsumer::UseAvailableBitrate() | choosing layers -1:-1 [bitrate:600000, virtualBitrate:648000, usedBitrate:0, consumerId:4d1b5fb4-6ee9-40b6-a935-05f213f6cc18]
mediasoup:worker[pid:52] RTC::WebRtcTransport::DistributeAvailableOutgoingBitrate() | after first main iteration [remainingBitrate:600000]
mediasoup:worker[pid:52] RTC::WebRtcTransport::DistributeAvailableOutgoingBitrate() | layer bitrate for Consumer [bitrate:600000, consumerId:4d1b5fb4-6ee9-40b6-a935-05f213f6cc18]
mediasoup:worker[pid:52] RTC::WebRtcTransport::DistributeAvailableOutgoingBitrate() | after layer-by-layer iteration [remainingBitrate:600000]
The consumer doesn’t receive anything after this point. I see that the lower level has a maxBItrate=2000000 > availableBitrate:600000
Changing these lines in https://github.com/versatica/mediasoup/blob/5c2208d5e70324ef28a91106afdeb67330ac70bd/worker/src/RTC/WebRtcTransport.cpp#L919 makes the consumer works:
uint32_t availableBitrate{ 1000000000 };
if (this->rembClient)
{
//availableBitrate = this->rembClient->GetAvailableBitrate();
// Resechedule next REMB event.
this->rembClient->ResecheduleNextEvent();
}
mediasoup:Channel[pid:52] request() [method:consumer.resume, id:27]
mediasoup:worker[pid:52] RTC::WebRtcTransport::DistributeAvailableOutgoingBitrate() | before iterations [availableBitrate:1000000000]
mediasoup:worker[pid:52] RTC::WebRtcTransport::DistributeAvailableOutgoingBitrate() | main bitrate for Consumer [priority:3, bitrate:1000000000, consumerId:f0d8fd8b-2e6c-4a4d-aa71-ad4a631d3634]
mediasoup:worker[pid:52] RTC::SimulcastConsumer::UseAvailableBitrate() | CanSwitchToSpatialLayer(0) returns true
mediasoup:worker[pid:52] RTC::SimulcastConsumer::UseAvailableBitrate() | CanSwitchToSpatialLayer(1) returns true
mediasoup:worker[pid:52] RTC::SimulcastConsumer::UseAvailableBitrate() | CanSwitchToSpatialLayer(2) returns true
mediasoup:worker[pid:52] RTC::SimulcastConsumer::UseAvailableBitrate() | choosing layers 2:0 [bitrate:1000000000, virtualBitrate:1080000000, usedBitrate:7997632, consumerId:f0d8fd8b-2e6c-4a4d-aa71-ad4a631d3634]
mediasoup:worker[pid:52] RTC::WebRtcTransport::DistributeAvailableOutgoingBitrate() | after first main iteration [remainingBitrate:992002368]
mediasoup:worker[pid:52] RTC::WebRtcTransport::DistributeAvailableOutgoingBitrate() | layer bitrate for Consumer [bitrate:992002368, consumerId:f0d8fd8b-2e6c-4a4d-aa71-ad4a631d3634]
mediasoup:worker[pid:52] RTC::WebRtcTransport::DistributeAvailableOutgoingBitrate() | after layer-by-layer iteration [remainingBitrate:992002368]
mediasoup:worker[pid:52] RTC::SimulcastConsumer::UpdateTargetLayers() | using spatialLayer:2 as RTP timestamp reference
mediasoup:worker[pid:52] RTC::SimulcastConsumer::UpdateTargetLayers() | target layers changed [spatial:2, temporal:0, consumerId:f0d8fd8b-2e6c-4a4d-aa71-ad4a631d3634]
mediasoup:worker[pid:52] RTC::RtpStreamRecv::RequestKeyFrame() | sending PLI [ssrc:1002]