devopvoid / webrtc-java

WebRTC for desktop platforms running Java
Apache License 2.0
248 stars 60 forks source link

my remoteVideo not display #75

Closed ChdDongyang closed 2 years ago

ChdDongyang commented 2 years ago

Hello, I have some questions to ask you. As shown in the following code, I don't know why my addsink method doesn't seem to execute. In addition, I want to know how to get video frames. If you could help me, I would be very grateful.

peerConnection = factory.createPeerConnection(config, new PeerConnectionObserver() {
            @Override
            public void onIceCandidate(RTCIceCandidate candidate) {
                peerConnection.addIceCandidate(candidate);
                String jsonStr = JSON.toJSONString(candidate);
                JSONObject object = JSON.parseObject(jsonStr);
                handleIceCandidate(object);
            }

            @Override
            public void onIceCandidateError(RTCPeerConnectionIceErrorEvent event) {
                PeerConnectionObserver.super.onIceCandidateError(event);
                System.out.println(event.getErrorCode()+event.getErrorText());
            }

            @Override
            public void onTrack(RTCRtpTransceiver transceiver) {
                PeerConnectionObserver.super.onTrack(transceiver);
                MediaStreamTrack mediaStreamTrack = transceiver.getReceiver().getTrack();

                if (mediaStreamTrack.getKind().equals(MediaStreamTrack.VIDEO_TRACK_KIND)) {
                    VideoTrack track = (VideoTrack) mediaStreamTrack;
                    VideoCallController controller = (VideoCallController) 
                    VideoCallController.controllers.get(VideoCallController.class.getSimpleName());
                    VideoView remoteMedia = controller.remoteMedia;
                    track.addSink(remoteMedia::setVideoFrame);
                    System.out.println(track.getState());
                }
            }
        });
kinsleykajiva commented 2 years ago

hi , whats the sdp situation ? also are you using a apprtc app or do you have a media server?

ChdDongyang commented 2 years ago

Sorry, my negligence caused the problem when setting answer, because JSON format is incorrect and SDP cannot be parsed. Sorry to disturb you again. Thank you for your excellent work.

ChdDongyang commented 2 years ago

Now that I have obtained the video frame, can you give me some suggestions on how to convert the videoframe into a picture?

kinsleykajiva commented 2 years ago

on making the picture what's the aim here is to save the frames as images or files locally all the time?

kinsleykajiva commented 2 years ago

I would suggest that you create a new issue here that states fully the intent as well so that you don't get to bundle issues under the wrong title!

ChdDongyang commented 2 years ago

OK,Thank you very much! I would close this issues.