Hello, my .produce event listener is firing up only on video and not on audio even though I am passing audio and video for the .produce function.
async function loadDevice(routerRtpCapabilities) {
try {
device = new mediasoup.Device();
} catch (error) {
if (error.name === "UnsupportedError") {
console.error("browser not supported");
}
}
await device.load({ routerRtpCapabilities });
}
async function publish(e) {
const data = await socket.request("createProducerTransport", {
forceTcp: false,
rtpCapabilities: device.rtpCapabilities,
});
const transport = device.createSendTransport(data);
transport.on("connect", async ({ dtlsParameters }, callback, errback) => {
socket
.request("connectProducerTransport", { dtlsParameters })
.then(callback)
.catch(errback);
});
transport.on(
"produce",
async ({ kind, rtpParameters }, callback, errback) => {
try {
console.log("Kind:", kind);
} catch (err) {
errback(err);
}
}
);
let stream;
try {
stream = await getUserMedia(transport, isWebcam);
console.log("getusermedia stream:");
console.log(stream);
const track = stream.getVideoTracks()[0];
const track2 = stream.getAudioTracks()[0]; //audio
const params = { track };
const params2 = { track2 };
console.log("tracks:");
console.log(track); //outputs correctly
console.log(track2); //outputs correctly
producer = await transport.produce(params); //gets a callback
producer2 = await transport.produce(params2); //doesnt get a callback
} catch (err) {
}
}