Been having an issue with DataConsumers with libmediasoup. My issue is that if dataconsumers are created with the wrong streamId by libmediasoup then everything goes bananas.
I don’t follow. Obviously this works according to the documented API. I don’t know how to answer to “Is there a reason why sctpParamaters aren’t passed in?”, that’s not the point.
In Transport.cpp no sctp Parameters are provided from the application. Instead ReceiveDataChannel constructs sctp parameters using an internal counter for the streamId.
In the application if each data consumer provides sctp parameters. If you do not process those messages in order of when they’re received (i.e. 1,2,3,4,5,6) and instead they get processed (1,2,4,3,5,6). Then when the datachannel in Transport.cpp it will have the wrong streamId because the internal streamId counter will map users incorrectly resulting in messages sent by user 3 showing up as user 4.
Is there a reason why sctp parameters are not passed into Transport.cpp and are instead created by the library?
@jmillan actually there is a big difference in how we receive a DataChannel in mediasoup-client and in libmediasoupclient. The latter seems indeed wrong. Look:
Handler::DataChannel RecvHandler::ReceiveDataChannel(
const std::string& label, webrtc::DataChannelInit dataChannelInit)
{
MSC_TRACE();
uint16_t streamId = this->nextSendSctpStreamId;
dataChannelInit.negotiated = true;
dataChannelInit.id = streamId;
/* clang-format off */
nlohmann::json sctpStreamParameters =
{
{ "streamId", streamId },
{ "ordered", dataChannelInit.ordered }
};
/* clang-format on */
// This will fill sctpStreamParameters's missing fields with default values.
ortc::validateSctpStreamParameters(sctpStreamParameters);
rtc::scoped_refptr<webrtc::DataChannelInterface> webrtcDataChannel =
this->pc->CreateDataChannel(label, &dataChannelInit);
// Increase next id.
this->nextSendSctpStreamId = (this->nextSendSctpStreamId + 1) % SctpNumStreamsMis;
In mediasoup-client we read streamId from the given sctpStreamParameters (as it should be). However, in libmediasoupclient we assume streamId is incremental based on a local count. It doesn’t make any sense.