My approach is to
// modify your function makeCall(target)
function makeCall(target) {
outgoingSession = userAgent.call(target, callOptions);
setupMedia(outgoingSession);
}
and then implement
session.connection.addEventListener('track', ({ track, streams: [stream] }) => {
// logic identical to your peerConnection.addEventListener("track", (event) => {});
});
within setupMedia.
The specific reason, I suspect, is that addEventListener only captures newly added tracks. In your method, during outgoing calls, the audio may not be considered newly added?