Skip to content

ctxSip doesnt work on android phone , Iphone #52

@beatific-angel

Description

@beatific-angel

if I access via android, iphone, then I can see unssuported browser error message.
As my checking result, this is related with getUserMedia.

correctly the part is hasWebRTC : function() {} .

so I added some code in here.
navigator.mediaDevices.enumerateDevices().then(function(deviceInfos){
// deviceInfos will not have a populated lable unless to accept the permission
// during getUserMedia. This normally happens at startup/setup
// so from then on these devices will be with lables.
HasVideoDevice = false;
HasAudioDevice = false;
HasSpeakerDevice = false; // Safari and Firefox don't have these
AudioinputDevices = [];
VideoinputDevices = [];
SpeakerDevices = [];
var savedVideoDevice = 'default';
var videoDeviceFound = false;

                    var savedAudioDevice = 'default';
                    var audioDeviceFound = false;

                    var MicrophoneFound = false;
                    var SpeakerFound = false;
                    var VideoFound = false;
                    for (var i = 0; i < deviceInfos.length; ++i) {
                        if (deviceInfos[i].kind === "audioinput") {
                            MicrophoneFound = true;
                            HasAudioDevice = true;
                            AudioinputDevices.push(deviceInfos[i]);
                        }
                        else if (deviceInfos[i].kind === "audiooutput") {
                            SpeakerFound = true;
                            HasSpeakerDevice = true;
                            SpeakerDevices.push(deviceInfos[i]);
                        }
                        else if (deviceInfos[i].kind === "videoinput") {
                            HasVideoDevice = true;
                            VideoinputDevices.push(deviceInfos[i]);
                        }
                    }
                    console.log(AudioinputDevices, VideoinputDevices);

                    var contraints = {
                        audio: MicrophoneFound,
                        video: VideoFound
                    }

                    if(MicrophoneFound){
                        contraints.audio = { deviceId: "default" }
                        if(audioDeviceFound) contraints.audio.deviceId = { exact: savedAudioDevice }
                    }
                    if(VideoFound){
                        contraints.video = { deviceId: "default" }
                        if(videoDeviceFound) contraints.video.deviceId = { exact: savedVideoDevice }
                    }
                    // Additional

                    console.log("Get User Media", contraints);
                    // Get User Media
                    navigator.mediaDevices.getUserMedia(contraints).then(function(mediaStream){
                        // Handle Video
                        var videoTrack = (mediaStream.getVideoTracks().length >= 1)? mediaStream.getVideoTracks()[0] : null;
                        if(VideoFound && videoTrack != null){
                            localVideoStream.addTrack(videoTrack);
                            // Display Preview Video
                            localVideo.srcObject = localVideoStream;
                            localVideo.onloadedmetadata = function(e) {
                                localVideo.play();
                            }
                        }
                        else {
                            console.warn("No video / webcam devices found. Video Calling will not be possible.")
                        }

                        // Handle Audio
                        var audioTrack = (mediaStream.getAudioTracks().length >= 1)? mediaStream.getAudioTracks()[0] : null ;
                        if(MicrophoneFound && audioTrack != null){
                            localMicrophoneStream.addTrack(audioTrack);
                            // Display Micrphone Levels
                            window.SettingsMicrophoneStream = localMicrophoneStream;
                            window.SettingsMicrophoneSoundMeter = MeterSettingsOutput(localMicrophoneStream, "Settings_MicrophoneOutput", "width", 50);
                        }
                        else {
                            console.warn("No microphone devices found. Calling will not be possible.")
                        }

                        // Display Output Levels
                        $("#Settings_SpeakerOutput").css("width", "0%");
                        $("#Settings_RingerOutput").css("width", "0%");
                        if(!SpeakerFound){
                            console.log("No speaker devices found, make sure one is plugged in.")
                            $("#playbackSrc").hide();
                            $("#RingDeviceSection").hide();
                        }

                        // Return .then()
                        return navigator.mediaDevices.enumerateDevices();
                    }).catch(function(e){
                        console.error(e);
                        Alert(lang.alert_error_user_media, lang.error);
                    });
                }).catch(function(e){
                    console.error("Error enumerating devices", e);
                });

Then I can see detect audio and video media.
but when try call, I can see this error.

sip-0.10.0.js:807 Fri Jul 22 2022 06:19:10 GMT+0300 (Moscow Standard Time) | sip.invitecontext.sessionDescriptionHandler | unable to acquire streams
sip-0.10.0.js:807 DOMException: Requested device not found.

please check and help me this problem

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions