use of com.example.webrtcandroidapp.observers.CustomSdpObserver in project webrtc-tutorials by dalkofjac.
the class SessionCallActivity method sendAnswer.
private void sendAnswer() {
Log.d(TAG, "sendAnswer");
addTransceivers();
mPeerConnection.createAnswer(new CustomSdpObserver() {
@Override
public void onCreateSuccess(SessionDescription sessionDescription) {
mPeerConnection.setLocalDescription(new CustomSdpObserver(), sessionDescription);
try {
LinkedTreeMap<String, Object> answer = new LinkedTreeMap<String, Object>();
answer.put("type", sessionDescription.type.canonicalForm());
answer.put("sdp", sessionDescription.description);
sendMessage(answer);
} catch (Exception e) {
Log.e(TAG, "sendAnswer failed.", e);
}
}
}, new MediaConstraints());
}
use of com.example.webrtcandroidapp.observers.CustomSdpObserver 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 com.example.webrtcandroidapp.observers.CustomSdpObserver in project webrtc-tutorials by dalkofjac.
the class SessionCallActivity method defineSignaling.
private void defineSignaling() {
mSignalrService.define("log", log -> {
Log.i(TAG, "log [" + log + "]");
}, String.class);
mSignalrService.define("created", () -> {
mIsInitiator = true;
});
mSignalrService.define("joined", () -> {
mIsChannelReady = true;
});
mSignalrService.define("message", message -> {
Log.i(TAG, "message [" + message + "]");
if (message instanceof String) {
String data = (String) message;
if (data.equalsIgnoreCase("got user media")) {
initiateCall();
} else if (data.equalsIgnoreCase("bye")) {
handleRemoteHangup();
}
} else if (message instanceof LinkedTreeMap) {
Object type = ((LinkedTreeMap) message).get("type");
if (type != null) {
if (type.toString().equalsIgnoreCase("offer")) {
if (!mIsStarted) {
initiateCall();
}
mPeerConnection.setRemoteDescription(new CustomSdpObserver(), new SessionDescription(SessionDescription.Type.OFFER, ((LinkedTreeMap) message).get("sdp").toString()));
sendAnswer();
} else if (type.toString().equalsIgnoreCase("answer") && mIsStarted) {
mPeerConnection.setRemoteDescription(new CustomSdpObserver(), new SessionDescription(SessionDescription.Type.fromCanonicalForm(((LinkedTreeMap) message).get("type").toString()), ((LinkedTreeMap) message).get("sdp").toString()));
} else if (type.toString().equalsIgnoreCase("candidate") && mIsStarted) {
addIceCandidate((LinkedTreeMap) message);
}
}
}
}, Object.class);
}
Aggregations