parse candidates from session-init and session-accept
This commit is contained in:
parent
54ca3fb020
commit
a49d69c878
|
@ -49,14 +49,12 @@ import rocks.xmpp.addr.Jid;
|
||||||
|
|
||||||
public class JingleRtpConnection extends AbstractJingleConnection implements WebRTCWrapper.EventCallback {
|
public class JingleRtpConnection extends AbstractJingleConnection implements WebRTCWrapper.EventCallback {
|
||||||
|
|
||||||
private static final long BUSY_TIME_OUT = 30;
|
|
||||||
|
|
||||||
public static final List<State> STATES_SHOWING_ONGOING_CALL = Arrays.asList(
|
public static final List<State> STATES_SHOWING_ONGOING_CALL = Arrays.asList(
|
||||||
State.PROCEED,
|
State.PROCEED,
|
||||||
State.SESSION_INITIALIZED_PRE_APPROVED,
|
State.SESSION_INITIALIZED_PRE_APPROVED,
|
||||||
State.SESSION_ACCEPTED
|
State.SESSION_ACCEPTED
|
||||||
);
|
);
|
||||||
|
private static final long BUSY_TIME_OUT = 30;
|
||||||
private static final List<State> TERMINATED = Arrays.asList(
|
private static final List<State> TERMINATED = Arrays.asList(
|
||||||
State.TERMINATED_SUCCESS,
|
State.TERMINATED_SUCCESS,
|
||||||
State.TERMINATED_DECLINED_OR_BUSY,
|
State.TERMINATED_DECLINED_OR_BUSY,
|
||||||
|
@ -236,31 +234,40 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
|
||||||
if (identificationTags.size() == 0) {
|
if (identificationTags.size() == 0) {
|
||||||
Log.w(Config.LOGTAG, id.account.getJid().asBareJid() + ": no identification tags found in initial offer. we won't be able to calculate mLineIndices");
|
Log.w(Config.LOGTAG, id.account.getJid().asBareJid() + ": no identification tags found in initial offer. we won't be able to calculate mLineIndices");
|
||||||
}
|
}
|
||||||
for (final Map.Entry<String, RtpContentMap.DescriptionTransport> content : contentMap.contents.entrySet()) {
|
receiveCandidates(identificationTags, contentMap.contents.entrySet());
|
||||||
final String ufrag = content.getValue().transport.getAttribute("ufrag");
|
} else {
|
||||||
for (final IceUdpTransportInfo.Candidate candidate : content.getValue().transport.getCandidates()) {
|
if (isTerminated()) {
|
||||||
final String sdp;
|
respondOk(jinglePacket);
|
||||||
try {
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": ignoring out-of-order transport info; we where already terminated");
|
||||||
sdp = candidate.toSdpAttribute(ufrag);
|
} else {
|
||||||
} catch (IllegalArgumentException e) {
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": received transport info while in state=" + this.state);
|
||||||
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": ignoring invalid ICE candidate " + e.getMessage());
|
terminateWithOutOfOrder(jinglePacket);
|
||||||
continue;
|
}
|
||||||
}
|
}
|
||||||
final String sdpMid = content.getKey();
|
}
|
||||||
final int mLineIndex = identificationTags.indexOf(sdpMid);
|
|
||||||
final IceCandidate iceCandidate = new IceCandidate(sdpMid, mLineIndex, sdp);
|
private void receiveCandidates(final List<String> identificationTags, final Set<Map.Entry<String, RtpContentMap.DescriptionTransport>> contents) {
|
||||||
if (isInState(State.SESSION_ACCEPTED)) {
|
for (final Map.Entry<String, RtpContentMap.DescriptionTransport> content : contents) {
|
||||||
Log.d(Config.LOGTAG, "received candidate: " + iceCandidate);
|
final String ufrag = content.getValue().transport.getAttribute("ufrag");
|
||||||
this.webRTCWrapper.addIceCandidate(iceCandidate);
|
for (final IceUdpTransportInfo.Candidate candidate : content.getValue().transport.getCandidates()) {
|
||||||
} else {
|
final String sdp;
|
||||||
this.pendingIceCandidates.offer(iceCandidate);
|
try {
|
||||||
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": put ICE candidate on backlog");
|
sdp = candidate.toSdpAttribute(ufrag);
|
||||||
}
|
} catch (IllegalArgumentException e) {
|
||||||
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": ignoring invalid ICE candidate " + e.getMessage());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final String sdpMid = content.getKey();
|
||||||
|
final int mLineIndex = identificationTags.indexOf(sdpMid);
|
||||||
|
final IceCandidate iceCandidate = new IceCandidate(sdpMid, mLineIndex, sdp);
|
||||||
|
if (isInState(State.SESSION_ACCEPTED)) {
|
||||||
|
Log.d(Config.LOGTAG, "received candidate: " + iceCandidate);
|
||||||
|
this.webRTCWrapper.addIceCandidate(iceCandidate);
|
||||||
|
} else {
|
||||||
|
this.pendingIceCandidates.offer(iceCandidate);
|
||||||
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": put ICE candidate on backlog");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": received transport info while in state=" + this.state);
|
|
||||||
terminateWithOutOfOrder(jinglePacket);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,6 +309,8 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
|
||||||
}
|
}
|
||||||
if (transition(target, () -> this.initiatorRtpContentMap = contentMap)) {
|
if (transition(target, () -> this.initiatorRtpContentMap = contentMap)) {
|
||||||
respondOk(jinglePacket);
|
respondOk(jinglePacket);
|
||||||
|
final List<String> identificationTags = contentMap.group == null ? Collections.emptyList() : contentMap.group.getIdentificationTags();
|
||||||
|
receiveCandidates(identificationTags, contentMap.contents.entrySet());
|
||||||
if (target == State.SESSION_INITIALIZED_PRE_APPROVED) {
|
if (target == State.SESSION_INITIALIZED_PRE_APPROVED) {
|
||||||
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": automatically accepting session-initiate");
|
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": automatically accepting session-initiate");
|
||||||
sendSessionAccept();
|
sendSessionAccept();
|
||||||
|
@ -346,6 +355,8 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
|
||||||
if (transition(State.SESSION_ACCEPTED)) {
|
if (transition(State.SESSION_ACCEPTED)) {
|
||||||
respondOk(jinglePacket);
|
respondOk(jinglePacket);
|
||||||
receiveSessionAccept(contentMap);
|
receiveSessionAccept(contentMap);
|
||||||
|
final List<String> identificationTags = contentMap.group == null ? Collections.emptyList() : contentMap.group.getIdentificationTags();
|
||||||
|
receiveCandidates(identificationTags, contentMap.contents.entrySet());
|
||||||
} else {
|
} else {
|
||||||
Log.d(Config.LOGTAG, String.format("%s: received session-accept while in state %s", id.account.getJid().asBareJid(), state));
|
Log.d(Config.LOGTAG, String.format("%s: received session-accept while in state %s", id.account.getJid().asBareJid(), state));
|
||||||
respondOk(jinglePacket);
|
respondOk(jinglePacket);
|
||||||
|
|
Loading…
Reference in New Issue