I am able to createOffer in local and send sdp to server.Also, got server answer and got sdp.
Now, How Can I send my local video stream to server? I don't want server video.
private void startStreamingVideo() {
//creating local mediastream
MediaStream mediaStream = factory.createLocalMediaStream("ARDAMS");
mediaStream.addTrack(localAudioTrack);
mediaStream.addTrack(localVideoTrack);
localPeerConnection.addStream(mediaStream);
MediaConstraints sdpMediaConstraints = new MediaConstraints();
sdpMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair("OfferToReceiveAudio", "false"));
sdpMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair("OfferToReceiveVideo", "false"));
localPeerConnection.createOffer(new SimpleSdpObserver() {
@Override
public void onCreateSuccess(SessionDescription sessionDescription) {
Log.d(TAG, "onCreateSuccess: ");
localPeerConnection.setLocalDescription(new SimpleSdpObserver(), sessionDescription);
//remotePeerConnection.setRemoteDescription(new SimpleSdpObserver(), sessionDescription);
callApiOffer(new Example(sessionDescription.description,sessionDescription.type.name().toLowerCase()));
}
}, sdpMediaConstraints);
}
private void callApiOffer(Example example){
Utils.getInstance().getRetrofitInstance1().postRequest(example).enqueue(new Callback<ResponseExample>() {
@Override
public void onResponse(Call<ResponseExample> call, Response<ResponseExample> response) {
ResponseExample body = response.body();
if (body != null) {
Log.e(TAG, body.getType());
Log.e(TAG, body.getSdp());
// Here, I got server sdp and type="answer"
SessionDescription sessionDescription = new SessionDescription(Type.ANSWER, body.getSdp());
localPeerConnection.setRemoteDescription(new SimpleSdpObserver(), sessionDescription);
//doAnswer();
}
}
@Override
public void onFailure(Call<ResponseExample> call, Throwable t) {
t.printStackTrace();
}
});
}
Backend server is in Python aiortc
I am getting "onIceConnectionChange: FAILED" Need I add to -> addIceCandidate ??
You have to add peerconnection observer and in onIceCandidate method to send icecandidate. On receiving side you can add icecandidate.