onIceCandidate not fired

37 Views Asked by At

We have made a peer connection which receives offer , set it into remote description, create answer and set it into local description. But when we are firing peerconnection.onIceConnection , the event is not fired.

Also peerconnection.gerReceivers() and peerconnection.getSenders() are empty array , so we are not able to get any media streams. the other client is using gstreamer , and they get the stream through appsrc.Can anyone suggest any methods to solve this error.Out client code is:

    const data = await e.data.text();
    const message = JSON.parse(data);
     handleReceivedOffer(message);
    }

 handleReceivedOffer=(offer)=>{
    peerConnection.setRemoteDescription(offer)
    .then(()=>{
      return  peerConnection.createAnswer();    
        })
    .then((answer)=>{
      return peerConnection.setLocalDescription(answer);
    })
    .then(()=>{
            peerConnection.onicecandidate=async (event)=>{
            if (event.target.iceGatheringState==='complete') {
                console.log("ice gathering state",event.target.iceGatheringState);
                socket.send(JSON.stringify(event.target.localDescription));
             }
             else{
                console.log("ice gathering state",event.target.iceGatheringState);
             }
       }
    })
    .then(()=>{
        const streaminfo=peerConnection.getReceivers();
      console.log("Getting the remote Streams :",peerConnection.getRemoteStreams());
      const remoteVideoElement = document.getElementById('remote-video');
      const remoteStream = new MediaStream([streaminfo[0].track]);
      remoteVideoElement.srcObject = remoteStream;
    })
    .catch((error)=>console.error(error));
    }




We are getting streaminfo when we are using videotestsrc instead of appsrc, but with appsrc, peerconnection.onIceCandidate does not even trigger.

0

There are 0 best solutions below