Audio not coming both sides

26 views
Skip to first unread message

Utkarsh Singh

unread,
Jan 3, 2022, 5:04:30 AMJan 3
to JsSIP
This is my code 

var socket = new JsSIP.WebSocketInterface('ws://................./ws');
    socket.via_transport = "tcp";
    var configuration = {
      uri: 'sip:903@.........................:8088',
      authorization_user: "903",
      port: '8088',
      register: true,
      username: '903@.........................:8088',
      name: '903',
      id: '903',
      session_timers: false,
      password: '903',
      sockets: [socket],
      display_name: '903',
      debug: true
    };
    var remoteAudio = new window.Audio()
    remoteAudio.autoplay = true;

    const mediaSource = new MediaSource();

    JsSIP.debug.enable('JsSIP:*');
    const phone = new JsSIP.UA(configuration);
    phone.on('registrationFailed', function (ev) {
      alert('Registering on SIP server failed with error: ' + ev.cause);
      configuration.uri = null;
      configuration.password = null;
    });

    phone.on('newRTCSession', function (ev) {
      var newSession = ev.session;

      if (session) { // hangup any existing call
        session.terminate();
      }
      session = newSession;
      var completeSession = function () {
        session = null;
      };

      if (session.direction === 'outgoing') {
        console.log('stream outgoing  -------->');
        session.on('connecting', function () {
          console.log('CONNECT');
        });
        session.connection.addEventListener('addstream', function (e) {
          console.log(e, "^^^^^^^^^^^^")
          remoteAudio.srcObject = e.stream;
          remoteAudio.play();
          console.log(remoteAudio.srcObject, "$$$$$$$$$$$4")
          console.log("2acceptedo")
        });
       
        session.on('peerconnection', function (e) {
          console.log('1acceptedo');
          const peerconnection = e.peerconnection;
          peerconnection.onaddstream = function (e) {
            remoteAudio.srcObject = e.stream;
            remoteAudio.play();
          }
        });
        session.on('ended', completeSession);
        session.on('failed', completeSession);
        session.on('accepted', function (e) {
          console.log('accepted')
        });
        session.on('confirmed', function (e) {
          console.log('CONFIRM STREAM');
        });
      };

    phone.start();

    var session;

    function callAsterisk(numTels) {

      const eventHandlers = {
        'progress': function (e) {
          console.log('call is in progress');
        },
        'failed': function (e) {
          console.log('call failed with cause: ' + (e.data ? e.data.cause : 'no cause'), e);
        },
        'ended': function (e) {
          console.log('call ended with cause: ' + (e.data ? e.data.cause : 'no cause'), e);
        },
        'confirmed': function (e) {
          console.log('call confirmed');
        },
        'addstream': (e) => {
          console.log('Add stream (event handlers)')
          remoteAudio.srcObject = e.stream
          remoteAudio.play()
        }
      };

      var options = {
        'eventHandlers': eventHandlers,
        'mediaConstraints': { 'audio': true, 'video': false },
        'pcConfig': {'rtcpMuxPolicy': 'require'},
        'rtcOfferConstraints': {'offerToReceiveAudio': true,'offerToReceiveVideo': false},
        'rtcAnswerConstraints': {'offerToReceiveAudio': true,'offerToReceiveVideo': false}
      };

      phone.call(numTels, options)
    };

    callAsterisk('sip:901@..............')

and I am getting an error message and astrisk attached to this mail
and I am getting no audio packets and no streaming at all.

I am stuck so please help me thanks.

   
WhatsApp Image 2022-01-03 at 12.37.57 PM.jpeg

José Luis Millán

unread,
Jan 17, 2022, 4:14:11 AM (10 days ago) Jan 17
to js...@googlegroups.com
Hi,

Sorry, we cannot simply look at your Asterisk logs.

If you have a media issue check the chrome://webrtc-internals or the corresponding place in the affected browser.

Also, Asterisk community may be amore suitable place to evaluate Asterisk logs.

--
You received this message because you are subscribed to the Google Groups "JsSIP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jssip+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jssip/9d950273-474a-4456-b18c-df7ded083479n%40googlegroups.com.


--
José Luis Millán
Reply all
Reply to author
Forward
0 new messages