use of org.webrtc.SessionDescription in project webrtc-tutorials by dalkofjac.
the class SessionCallActivity method sendOffer.
private void sendOffer() {
Log.d(TAG, "sendOffer");
addTransceivers();
mPeerConnection.createOffer(new CustomSdpObserver() {
@Override
public void onCreateSuccess(SessionDescription sessionDescription) {
mPeerConnection.setLocalDescription(new CustomSdpObserver(), sessionDescription);
try {
LinkedTreeMap<String, Object> offer = new LinkedTreeMap<String, Object>();
offer.put("type", sessionDescription.type.canonicalForm());
offer.put("sdp", sessionDescription.description);
sendMessage(offer);
} catch (Exception e) {
Log.e(TAG, "sendOffer failed.", e);
}
}
}, new MediaConstraints());
}
use of org.webrtc.SessionDescription in project Signal-Android by WhisperSystems.
the class PeerConnectionWrapper method createOffer.
public SessionDescription createOffer(MediaConstraints mediaConstraints) throws PeerConnectionException {
final SettableFuture<SessionDescription> future = new SettableFuture<>();
peerConnection.createOffer(new SdpObserver() {
@Override
public void onCreateSuccess(SessionDescription sdp) {
future.set(sdp);
}
@Override
public void onCreateFailure(String error) {
future.setException(new PeerConnectionException(error));
}
@Override
public void onSetSuccess() {
throw new AssertionError();
}
@Override
public void onSetFailure(String error) {
throw new AssertionError();
}
}, mediaConstraints);
try {
return correctSessionDescription(future.get());
} catch (InterruptedException e) {
throw new AssertionError(e);
} catch (ExecutionException e) {
throw new PeerConnectionException(e);
}
}
use of org.webrtc.SessionDescription in project Signal-Android by WhisperSystems.
the class PeerConnectionWrapper method setRemoteDescription.
public void setRemoteDescription(SessionDescription sdp) throws PeerConnectionException {
final SettableFuture<Boolean> future = new SettableFuture<>();
peerConnection.setRemoteDescription(new SdpObserver() {
@Override
public void onCreateSuccess(SessionDescription sdp) {
}
@Override
public void onCreateFailure(String error) {
}
@Override
public void onSetSuccess() {
future.set(true);
}
@Override
public void onSetFailure(String error) {
future.setException(new PeerConnectionException(error));
}
}, sdp);
try {
future.get();
} catch (InterruptedException e) {
throw new AssertionError(e);
} catch (ExecutionException e) {
throw new PeerConnectionException(e);
}
}
use of org.webrtc.SessionDescription in project Signal-Android by WhisperSystems.
the class PeerConnectionWrapper method createAnswer.
public SessionDescription createAnswer(MediaConstraints mediaConstraints) throws PeerConnectionException {
final SettableFuture<SessionDescription> future = new SettableFuture<>();
peerConnection.createAnswer(new SdpObserver() {
@Override
public void onCreateSuccess(SessionDescription sdp) {
future.set(sdp);
}
@Override
public void onCreateFailure(String error) {
future.setException(new PeerConnectionException(error));
}
@Override
public void onSetSuccess() {
throw new AssertionError();
}
@Override
public void onSetFailure(String error) {
throw new AssertionError();
}
}, mediaConstraints);
try {
return correctSessionDescription(future.get());
} catch (InterruptedException e) {
throw new AssertionError(e);
} catch (ExecutionException e) {
throw new PeerConnectionException(e);
}
}
use of org.webrtc.SessionDescription in project Signal-Android by WhisperSystems.
the class WebRtcCallService method handleResponseMessage.
private void handleResponseMessage(Intent intent) {
try {
Log.w(TAG, "Got response: " + intent.getStringExtra(EXTRA_REMOTE_DESCRIPTION));
if (callState != CallState.STATE_DIALING || !getRemoteRecipient(intent).equals(recipient) || !Util.isEquals(this.callId, getCallId(intent))) {
Log.w(TAG, "Got answer for recipient and call id we're not currently dialing: " + getCallId(intent) + ", " + getRemoteRecipient(intent));
return;
}
if (peerConnection == null || pendingIceUpdates == null) {
throw new AssertionError("assert");
}
if (!pendingIceUpdates.isEmpty()) {
ListenableFutureTask<Boolean> listenableFutureTask = sendMessage(recipient, SignalServiceCallMessage.forIceUpdates(pendingIceUpdates));
listenableFutureTask.addListener(new FailureListener<Boolean>(callState, callId) {
@Override
public void onFailureContinue(Throwable error) {
Log.w(TAG, error);
sendMessage(WebRtcViewModel.State.NETWORK_FAILURE, recipient, localVideoEnabled, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled);
terminate();
}
});
}
this.peerConnection.setRemoteDescription(new SessionDescription(SessionDescription.Type.ANSWER, intent.getStringExtra(EXTRA_REMOTE_DESCRIPTION)));
this.pendingIceUpdates = null;
} catch (PeerConnectionException e) {
Log.w(TAG, e);
terminate();
}
}
Aggregations