Temasys / AdapterJS

AdapterJS Javascript Polyfill and Tools for WebRTC - Skylink WebRTC
http://skylink.io/web
Other
432 stars 100 forks source link

On Safari Error calling method on NPObject #190

Open zaigham-mt opened 8 years ago

zaigham-mt commented 8 years ago

Error: Error calling method on NPObject. 348           function (sessionDescription) { Its occurring on following scripts

function answer(data) { var pc = peerDatabase[getPeerIndex(data)].pc;

    toggleLocalStream(pc,data.videoChatId);

    pc.createAnswer(
        function (sessionDescription) {

            pc.setLocalDescription(sessionDescription);

            send('answer', data, sessionDescription);

        },
        function (error) {
            console.log(error);
        },
        config.mediaConstraints
    );
}

Its working fine for firefox. But due to plugin load not working for Safari and IE.

GetMediaStream and attachMediaStream seems to be working fine. But issue is when generating answer.

Here is attachment.

screen shot 2016-04-08 at 7 15 47 am

Any help will be appreciated.

johache commented 8 years ago

Hi,

that all looks pretty good. Can you check that config.mediaConstraints is a dictionary ? Can you also check without constraints to see what happens ?

Finally, can you check that you are using the latest version of the plugin ? It should be 0.8.869.

Thanks, J-O

zaigham-mt commented 8 years ago

Here is the config file.

config = { peerConnectionConfig: { iceServers: [ {"url": "stun:23.21.150.121"}, {"url": "stun:stun.l.google.com:19302"} ] }, peerConnectionConstraints: { optional: [ {"DtlsSrtpKeyAgreement": true} // (browser === 'firefox') ] },

        mediaConstraints: {

            'mandatory': {

                'OfferToReceiveAudio': {

                    echoCancellation: true,
                    googEchoCancellation: true,
                    googAutoGainControl: true,
                    googAutoGainControl2: true,
                    googNoiseSuppression: true,
                    googHighpassFilter: true,
                    googTypingNoiseDetection: false,
                    googAudioMirroring: true // For some reason setting googAudioMirroring causes a navigator.getUserMedia error:  NavigatorUserMediaError

                },
                'OfferToReceiveAudio': audioConstraints,
                'OfferToReceiveVideo': true

            }
        }

    }

How would it work without constraints as there are few mandatory fields required.

I am using latest version of TemSys , its not showing version number.

screen shot 2016-04-11 at 1 10 52 am
johache commented 8 years ago

I find it weird that you have 2 OfferToReceiveAudio fields in mandatory. Can you fix that first and try again ?

zaigham-mt commented 8 years ago

I have used following now. Still same scenario.

        mediaConstraints: {

            'mandatory': {

                'OfferToReceiveAudio': {

                    echoCancellation: true,
                    googEchoCancellation: true,
                    googAutoGainControl: true,
                    googAutoGainControl2: true,
                    googNoiseSuppression: true,
                    googHighpassFilter: true,
                    googTypingNoiseDetection: false,
                    googAudioMirroring: true // For some reason setting googAudioMirroring causes a navigator.getUserMedia error:  NavigatorUserMediaError

                },

                'OfferToReceiveVideo': true

            }
        }

    }
zaigham-mt commented 8 years ago

@johache I have even tried to create following answer.

function answer(data) { var pc = peerDatabase[getPeerIndex(data)].pc;

    toggleLocalStream(pc,data.videoChatId);

    pc.createAnswer(
        function (sessionDescription) {
            pc.setLocalDescription(sessionDescription);
            send('answer', data, sessionDescription);
        },
        function (error) {
            console.log(error);
        }
    );
}

I go through adapter.debug.js file and its not using third parameter that is media constraints. So does not matter whatever the media constraints are.

window.RTCPeerConnection.prototype.createAnswer = function() { var self = this; var answerOptions; if (arguments.length === 1 && typeof arguments[0] !== 'function') { answerOptions = arguments[0]; } else if (arguments.length === 3) { answerOptions = arguments[2]; }

    var sdp = SDPUtils.writeSessionBoilerplate();
    this.transceivers.forEach(function(transceiver) {
      // Calculate intersection of capabilities.
      var commonCapabilities = self._getCommonCapabilities(
          transceiver.localCapabilities,
          transceiver.remoteCapabilities);

      sdp += SDPUtils.writeMediaSection(transceiver, commonCapabilities,
          'answer', self.localStreams[0]);
    });

    var desc = new RTCSessionDescription({
      type: 'answer',
      sdp: sdp
    });
    if (arguments.length && typeof arguments[0] === 'function') {
      window.setTimeout(arguments[0], 0, desc);
    }
    return Promise.resolve(desc);
  };
johache commented 8 years ago

It does, this is exactly what the first part of the function is doing. It split the cases where the options are provided as first argument and as third.

Do you have a live version of you app to test against ?

zaigham-mt commented 8 years ago

Ok Finally it worked using correct constraints parameters on offer packet.Its working fine for Safari now.

But when I am trying it for firefox , on IOS device I am getting video stream and also audio. But on browser there was no video on browser. I get adapter.js from somewhere else and combined and it worked. Change was attachmediastream and reattachmediastream functions.

One last thing is when I do have video call for 3-4 times on same page session IE crash due to plugin. Thanks for your cooperation.