depulicate 'propose's when doing mam catchup

This commit is contained in:
Daniel Gultsch 2020-04-14 09:06:07 +02:00
parent e16e0d895e
commit 172d2c693f
3 changed files with 59 additions and 51 deletions

View File

@ -92,8 +92,8 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 28 targetSdkVersion 28
versionCode 368 versionCode 369
versionName "2.8.0-alpha.2" versionName "2.8.0-alpha.3"
archivesBaseName += "-$versionName" archivesBaseName += "-$versionName"
applicationId "eu.siacs.conversations" applicationId "eu.siacs.conversations"
resValue "string", "applicationId", applicationId resValue "string", "applicationId", applicationId

View File

@ -854,6 +854,12 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
final String namespace = description == null ? null : description.getNamespace(); final String namespace = description == null ? null : description.getNamespace();
if (Namespace.JINGLE_APPS_RTP.equals(namespace)) { if (Namespace.JINGLE_APPS_RTP.equals(namespace)) {
final Conversation c = mXmppConnectionService.findOrCreateConversation(account, counterpart.asBareJid(), false, false); final Conversation c = mXmppConnectionService.findOrCreateConversation(account, counterpart.asBareJid(), false, false);
final Message preExistingMessage = c.findRtpSession(sessionId, status);
if (preExistingMessage != null) {
preExistingMessage.setServerMsgId(serverMsgId);
mXmppConnectionService.updateMessage(preExistingMessage);
break;
}
final Message message = new Message( final Message message = new Message(
c, c,
status, status,

View File

@ -349,31 +349,33 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
sendSessionAccept(offer); sendSessionAccept(offer);
} }
private void sendSessionAccept(SessionDescription offer) { private void sendSessionAccept(final SessionDescription offer) {
discoverIceServers(iceServers -> { discoverIceServers(iceServers -> sendSessionAccept(offer,iceServers));
try { }
setupWebRTC(iceServers);
} catch (WebRTCWrapper.InitializationException e) {
sendSessionTerminate(Reason.FAILED_APPLICATION);
return;
}
final org.webrtc.SessionDescription sdp = new org.webrtc.SessionDescription(
org.webrtc.SessionDescription.Type.OFFER,
offer.toString()
);
try {
this.webRTCWrapper.setRemoteDescription(sdp).get();
addIceCandidatesFromBlackLog();
org.webrtc.SessionDescription webRTCSessionDescription = this.webRTCWrapper.createAnswer().get();
final SessionDescription sessionDescription = SessionDescription.parse(webRTCSessionDescription.description);
final RtpContentMap respondingRtpContentMap = RtpContentMap.of(sessionDescription);
sendSessionAccept(respondingRtpContentMap);
this.webRTCWrapper.setLocalDescription(webRTCSessionDescription);
} catch (Exception e) {
Log.d(Config.LOGTAG, "unable to send session accept", e);
} private void sendSessionAccept(final SessionDescription offer, final List<PeerConnection.IceServer> iceServers) {
}); try {
setupWebRTC(iceServers);
} catch (WebRTCWrapper.InitializationException e) {
sendSessionTerminate(Reason.FAILED_APPLICATION);
return;
}
final org.webrtc.SessionDescription sdp = new org.webrtc.SessionDescription(
org.webrtc.SessionDescription.Type.OFFER,
offer.toString()
);
try {
this.webRTCWrapper.setRemoteDescription(sdp).get();
addIceCandidatesFromBlackLog();
org.webrtc.SessionDescription webRTCSessionDescription = this.webRTCWrapper.createAnswer().get();
final SessionDescription sessionDescription = SessionDescription.parse(webRTCSessionDescription.description);
final RtpContentMap respondingRtpContentMap = RtpContentMap.of(sessionDescription);
sendSessionAccept(respondingRtpContentMap);
this.webRTCWrapper.setLocalDescription(webRTCSessionDescription);
} catch (Exception e) {
Log.d(Config.LOGTAG, "unable to send session accept", e);
}
} }
private void addIceCandidatesFromBlackLog() { private void addIceCandidatesFromBlackLog() {
@ -532,38 +534,39 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
private void sendSessionInitiate(final State targetState) { private void sendSessionInitiate(final State targetState) {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": prepare session-initiate"); Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": prepare session-initiate");
discoverIceServers(iceServers -> { discoverIceServers(iceServers -> sendSessionInitiate(targetState, iceServers));
try { }
setupWebRTC(iceServers);
} catch (WebRTCWrapper.InitializationException e) { private void sendSessionInitiate(final State targetState, final List<PeerConnection.IceServer> iceServers) {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": unable to initialize webrtc"); try {
setupWebRTC(iceServers);
} catch (WebRTCWrapper.InitializationException e) {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": unable to initialize webrtc");
transitionOrThrow(State.TERMINATED_APPLICATION_FAILURE);
return;
}
try {
org.webrtc.SessionDescription webRTCSessionDescription = this.webRTCWrapper.createOffer().get();
final SessionDescription sessionDescription = SessionDescription.parse(webRTCSessionDescription.description);
Log.d(Config.LOGTAG, "description: " + webRTCSessionDescription.description);
final RtpContentMap rtpContentMap = RtpContentMap.of(sessionDescription);
sendSessionInitiate(rtpContentMap, targetState);
this.webRTCWrapper.setLocalDescription(webRTCSessionDescription).get();
} catch (final Exception e) {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": unable to sendSessionInitiate", e);
webRTCWrapper.close();
if (isInState(targetState)) {
sendSessionTerminate(Reason.FAILED_APPLICATION);
} else {
transitionOrThrow(State.TERMINATED_APPLICATION_FAILURE); transitionOrThrow(State.TERMINATED_APPLICATION_FAILURE);
return;
} }
try { }
org.webrtc.SessionDescription webRTCSessionDescription = this.webRTCWrapper.createOffer().get();
final SessionDescription sessionDescription = SessionDescription.parse(webRTCSessionDescription.description);
Log.d(Config.LOGTAG, "description: " + webRTCSessionDescription.description);
final RtpContentMap rtpContentMap = RtpContentMap.of(sessionDescription);
sendSessionInitiate(rtpContentMap, targetState);
this.webRTCWrapper.setLocalDescription(webRTCSessionDescription).get();
} catch (final Exception e) {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": unable to sendSessionInitiate", e);
webRTCWrapper.close();
if (isInState(targetState)) {
sendSessionTerminate(Reason.FAILED_APPLICATION);
} else {
transitionOrThrow(State.TERMINATED_APPLICATION_FAILURE);
}
}
});
} }
private void sendSessionInitiate(RtpContentMap rtpContentMap, final State targetState) { private void sendSessionInitiate(RtpContentMap rtpContentMap, final State targetState) {
this.initiatorRtpContentMap = rtpContentMap; this.initiatorRtpContentMap = rtpContentMap;
this.transitionOrThrow(targetState); this.transitionOrThrow(targetState);
final JinglePacket sessionInitiate = rtpContentMap.toJinglePacket(JinglePacket.Action.SESSION_INITIATE, id.sessionId); final JinglePacket sessionInitiate = rtpContentMap.toJinglePacket(JinglePacket.Action.SESSION_INITIATE, id.sessionId);
Log.d(Config.LOGTAG, sessionInitiate.toString());
send(sessionInitiate); send(sessionInitiate);
} }
@ -591,7 +594,6 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
return; return;
} }
final JinglePacket jinglePacket = transportInfo.toJinglePacket(JinglePacket.Action.TRANSPORT_INFO, id.sessionId); final JinglePacket jinglePacket = transportInfo.toJinglePacket(JinglePacket.Action.TRANSPORT_INFO, id.sessionId);
Log.d(Config.LOGTAG, jinglePacket.toString());
send(jinglePacket); send(jinglePacket);
} }