incude human readable text in some session-terminates

This commit is contained in:
Daniel Gultsch 2020-04-09 20:35:44 +02:00
parent 6a1df0538e
commit 39e3791345
3 changed files with 16 additions and 8 deletions

View File

@ -1064,7 +1064,7 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple
private void sendSessionTerminate(Reason reason) { private void sendSessionTerminate(Reason reason) {
final JinglePacket packet = bootstrapPacket(JinglePacket.Action.SESSION_TERMINATE); final JinglePacket packet = bootstrapPacket(JinglePacket.Action.SESSION_TERMINATE);
packet.setReason(reason); packet.setReason(reason, null);
this.sendJinglePacket(packet); this.sendJinglePacket(packet);
} }

View File

@ -246,10 +246,10 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
final SessionDescription sessionDescription; final SessionDescription sessionDescription;
try { try {
sessionDescription = SessionDescription.of(contentMap); sessionDescription = SessionDescription.of(contentMap);
} catch (IllegalArgumentException e) { } catch (final IllegalArgumentException e) {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": unable convert offer from session-accept to SDP", e); Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": unable convert offer from session-accept to SDP", e);
webRTCWrapper.close(); webRTCWrapper.close();
sendSessionTerminate(Reason.FAILED_APPLICATION); sendSessionTerminate(Reason.FAILED_APPLICATION, e.getMessage());
return; return;
} }
org.webrtc.SessionDescription answer = new org.webrtc.SessionDescription( org.webrtc.SessionDescription answer = new org.webrtc.SessionDescription(
@ -276,8 +276,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
} catch (final IllegalArgumentException e) { } catch (final IllegalArgumentException e) {
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": unable convert offer from session-initiate to SDP", e); Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": unable convert offer from session-initiate to SDP", e);
webRTCWrapper.close(); webRTCWrapper.close();
sendSessionTerminate(Reason.FAILED_APPLICATION); sendSessionTerminate(Reason.FAILED_APPLICATION, e.getMessage());
;
return; return;
} }
sendSessionAccept(offer); sendSessionAccept(offer);
@ -470,10 +469,14 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
} }
private void sendSessionTerminate(final Reason reason) { private void sendSessionTerminate(final Reason reason) {
sendSessionTerminate(reason, null);
}
private void sendSessionTerminate(final Reason reason, final String text) {
final State target = reasonToState(reason); final State target = reasonToState(reason);
transitionOrThrow(target); transitionOrThrow(target);
final JinglePacket jinglePacket = new JinglePacket(JinglePacket.Action.SESSION_TERMINATE, id.sessionId); final JinglePacket jinglePacket = new JinglePacket(JinglePacket.Action.SESSION_TERMINATE, id.sessionId);
jinglePacket.setReason(reason); jinglePacket.setReason(reason, text);
send(jinglePacket); send(jinglePacket);
Log.d(Config.LOGTAG, jinglePacket.toString()); Log.d(Config.LOGTAG, jinglePacket.toString());
jingleConnectionManager.finishConnection(this); jingleConnectionManager.finishConnection(this);

View File

@ -4,6 +4,7 @@ import android.support.annotation.NonNull;
import com.google.common.base.CaseFormat; import com.google.common.base.CaseFormat;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import java.util.Map; import java.util.Map;
@ -81,9 +82,13 @@ public class JinglePacket extends IqPacket {
return Reason.UNKNOWN; return Reason.UNKNOWN;
} }
public void setReason(final Reason reason) { public void setReason(final Reason reason, final String text) {
final Element jingle = findChild("jingle", Namespace.JINGLE); final Element jingle = findChild("jingle", Namespace.JINGLE);
jingle.addChild("reason").addChild(reason.toString()); final Element reasonElement = jingle.addChild("reason");
reasonElement.addChild(reason.toString());
if (!Strings.isNullOrEmpty(text)) {
reasonElement.addChild("text").setContent(text);
}
} }
//RECOMMENDED for session-initiate, NOT RECOMMENDED otherwise //RECOMMENDED for session-initiate, NOT RECOMMENDED otherwise