5

I'm implementing webrtc in android. I could not load the remote video stream after setting the remoteDescription in peerConnection object. I'm getting the remote audio,video track , When onAddStream() involked(org.webrtc.VideoTrack@37471a54). But could not load that in Videorenderer.

@Override
        public void onAddStream(final MediaStream stream) {
            Log.d("checklog","onaddstream"+stream.audioTracks.get(0)+stream.videoTracks.get(0));
            executor.execute(new Runnable() {
                @Override
                public void run() {
                    if (peerConnection == null ) {
                        return;
                    }
                    if (stream.audioTracks.size() > 1 || stream.videoTracks.size() > 1) {
                        Log.d("onAddstreamerror","Weird-looking stream: " + stream);
                        return;
                    }
                    if (stream.videoTracks.size() == 1) {
                        remoteVideoTrack = stream.videoTracks.get(0);
                        remoteVideoTrack.setEnabled(true);
                        remoteVideoTrack.addRenderer(new VideoRenderer(remoteRender));
                    }
                }
            });
        }
SaravInfern
  • 3,338
  • 1
  • 20
  • 44
Ayyappan
  • 1,275
  • 1
  • 11
  • 25
  • Do you get any errors? Is the video just not displayed? Does your local stream render ok? – Benjamin Trent Aug 12 '15 at 13:31
  • Local stream is rendering perfectly.remote video just not displayed. But i'm getting the video track onAddStream()(org.webrtc.VideoTrack@37471a54). – Ayyappan Aug 13 '15 at 07:27
  • I fixed the problem. I didn't set the ice candidate properly in peerconnection object. Now it is working fine. – Ayyappan Sep 14 '15 at 12:42
  • 2
    @Ayyappan could you please post the code? I'm facing exactly the same problem. I can't display the remote video. I think it'd be very useful. Thanks in advance. – leki arnold Jan 10 '16 at 20:23
  • Actually I missed the below part in my code `public void setRemoteIceCandidate() { 
 for (IceCandidate ice : remoteIceCandidate) {
 peerConnection.addIceCandidate(ice);
 }
 remoteIceCandidate = new ArrayList();
} ` After adding the ice candidate it is working fine now. – Ayyappan Jan 11 '16 at 12:26
  • I don't get it! Are you receiving the IceCandidates through signalling or embedded in remote SDP? If it is embedded in remote SDP then you don't need to set the IceCandidates separately. – Neernay Mar 18 '16 at 09:07
  • 1
    Also check if you are using `PeerConnection.ContinualGatheringPolicy.GATHER_CONTINUALLY` in your `PeerConnection.RTCConfiguration`. When I used `GATHER_ONCE` instead, my code actually worked, but ICE took very long time. I saw first frame of remote VideoTrack only after four minutes or so. – Ivan Mikhnovich Jun 22 '20 at 13:53
  • the problem is not about candidate, it's base on sdp return from server when subcrisber attach to room, " m=audio.." -> no videoTrack – famfamfam Aug 28 '20 at 04:24

0 Answers0