SIPML5 - Problem changing audio input device

64 views Asked by At

I have huge problem and I really need some help with it. I have searched through the internet for solution to this, but so far I have found nothing.

I am using library called SIPML5 to establish SIP connection through WebRTC. We are creating system that can be used to call to people. One of the requirements to this system is to make it possible to change audio devices. So far I have managed to create feature that allows user to change output device, but the problem begins when I try to change input device. Here is my code:

const setInputDevice = async e => {
    const deviceId = e.target.value;
    navigator.getUserMedia(
    {
            audio: {
                deviceId: {exact: deviceId},
            },
    },
    stream => {
        window.__o_jsep_stream_audio = stream;
        console.log(stream);
    },
    err => {
        console.error(err);
    },
);

I know that this code is deprecated, but I also tried to do it with new way to write it using navigator.mediaDevices.getUserMedia

const setInputDevice = async e => {
    const deviceId = e.target.value;
    const test = await navigator.mediaDevices.getUserMedia({
        audio: {
            deviceId: {exact: deviceId},
        },
    });
    console.log('---ALKUPERĂ„INEN---', window.__o_jsep_stream_audio);
    window.__o_jsep_stream_audio = test;
    console.log('---UUSI---', window.__o_jsep_stream_audio);
};

I am trying to set new MediaStream to window property called "__o_jsep_stream_audio" as it is the only property on window that has MediaStream set by SIPml5. However replacing it with new MediaStream does not really change anything. I have checked and deviceId is correctly set. I really do not know what to do at this point.

I am aware that I need to use this MediaStream somehow, but I just do not know how to use it properly. I have also tried to find original RTCPeerConnection and use method called "addTrack", but so far I haven't found any way to find the original RTCPeerConnection that is created in SIPML5.

Thank you in advance if you try to help me out on this one.

0

There are 0 answers