So @ibc, I did a little bit of digging to see where exactly the failure happens, and it seems it’s happening when trying to consume the video. In this piece of code of mine
try {
const audioConsumer = await transport.consume({
id: audioConsumerId,
kind: 'audio',
producerId: audioProducerId,
rtpParameters: audioRtpParameters
});
mediaStream.addTrack(audioConsumer.track);
// Audio works, we are good till this point
const videoConsumer = await transport.consume({ // this call dies
id: videoConsumerId,
kind: 'video',
producerId: videoProducerId,
rtpParameters: videoRtpParameters
});
mediaStream.addTrack(videoConsumer.track);
} catch(error) {
console.error('failed to consume [error:%o]', error);
throw error;
}
The transport.consume
call calls this function in Firefox60.js
:
async receive({ id, kind, rtpParameters })
{
logger.debug('receive() [id:%s, kind:%s]', id, kind);
const localId = String(this._nextMid);
this._remoteSdp.receive(
{
mid : localId,
kind,
offerRtpParameters : rtpParameters,
streamId : rtpParameters.rtcp.cname,
trackId : id
});
const offer = { type: 'offer', sdp: this._remoteSdp.getSdp() };
logger.debug(
'receive() | calling pc.setRemoteDescription() [offer:%o]', offer);
await this._pc.setRemoteDescription(offer);
let answer = await this._pc.createAnswer();
const localSdpObject = sdpTransform.parse(answer.sdp);
const answerMediaObject = localSdpObject.media
.find((m) => String(m.mid) === localId);
// May need to modify codec parameters in the answer based on codec
// parameters in the offer.
sdpCommonUtils.applyCodecParameters(
{
offerRtpParameters : rtpParameters,
answerMediaObject
});
answer = { type: 'answer', sdp: sdpTransform.write(localSdpObject) };
if (!this._transportReady)
await this._setupTransport({ localDtlsRole: 'client', localSdpObject });
logger.debug(
'receive() | calling pc.setLocalDescription() [answer:%o]', answer);
await this._pc.setLocalDescription(answer);
const transceiver = this._pc.getTransceivers() // returns [
.find((t) => t.mid === localId);
if (!transceiver)
throw new Error('new transceiver not found');
Turns out the video tranceiver (RTCRtpTransceiver) has a null mid. MDN says “This field is null
if neither a local or remote description has been applied, or if its associated m-line is rejected by either a remote offer or any answer.”
Now the question is, why only Firefox60.js?