この問題についてはすでに多くの質問がありますが、それらはすべて Javascript に関連しています。私は Android で試していますonIceCandidate()
が、 を呼び出したときに が呼び出されることはありませんsetLocalDescription
。
private PeerConnection initPeerConnection(boolean isLocal) {
MediaConstraints sdpConstraints = new MediaConstraints();
sdpConstraints.mandatory.add(new MediaConstraints.KeyValuePair("offerToReceiveAudio", "true"));
sdpConstraints.mandatory.add(new MediaConstraints.KeyValuePair("offerToReceiveVideo", "true"));
List<PeerConnection.IceServer> servers = new ArrayList<>();
return peerConnectionFactory.createPeerConnection(servers, new CustomPeerConnectionObserver() {
@Override
public void onIceCandidate(IceCandidate iceCandidate) {
super.onIceCandidate(iceCandidate);
if (isLocal)
onIceCandidateReceived(localPeerConnection, iceCandidate);
else
onIceCandidateReceived(remotePeerConnection, iceCandidate);
}
@Override
public void onAddStream(MediaStream mediaStream) {
super.onAddStream(mediaStream);
if (!isLocal)
gotRemoteStream(mediaStream);
}
});
}
接続の作成:
localPeerConnection = initPeerConnection(true);
remotePeerConnection = initPeerConnection(false);
オファーを作成します。これで onIceCandidate() がトリガーされます。
localPeerConnection.createOffer(new SimpleSdpObserver() {
@Override
public void onCreateSuccess(SessionDescription sessionDescription) {
Log.e("SDP", sessionDescription.description + sessionDescription.type.toString());
localPeerConnection.setLocalDescription(new SimpleSdpObserver(), sessionDescription);
sendOffer(sessionDescription);
}
}, sdpMediaConstraints);
しかし、残念ながらそれはそれを引き起こしません。なにが問題ですか?何を正しくする必要がありますか?
注: Android JavaScriptに固有の回答は大歓迎です。