As stated in the forum, the RecvHandler::ReceiveDataChannel() implementation of libmediasoupclient is wrong. It does not read streamId from given sctpStreamParameters (there are no given sctpStreamParameters) but increments it locally.
- In mediasoup-client
Chrome74.ts handler:
async receiveDataChannel(
{ sctpStreamParameters, label, protocol }: HandlerReceiveDataChannelOptions
): Promise<HandlerReceiveDataChannelResult>
{
this._assertRecvDirection();
const {
streamId,
ordered,
maxPacketLifeTime,
maxRetransmits
}: SctpStreamParameters = sctpStreamParameters;
const options =
{
negotiated : true,
id : streamId,
ordered,
maxPacketLifeTime,
maxRetransmits,
protocol
};
logger.debug('receiveDataChannel() [options:%o]', options);
const dataChannel = this._pc.createDataChannel(label, options);
- In libmediasoupclient
Handler.cpp:
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.
As stated in the forum, the
RecvHandler::ReceiveDataChannel()implementation of libmediasoupclient is wrong. It does not readstreamIdfrom givensctpStreamParameters(there are no givensctpStreamParameters) but increments it locally.Chrome74.tshandler:Handler.cpp:In mediasoup-client we read
streamIdfrom the givensctpStreamParameters(as it should be). However, in libmediasoupclient we assumestreamIdis incremental based on a local count. It doesn't make any sense.