diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index b1ac0dc4e..66c4f5bcb 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -32,6 +32,7 @@
+
{
- showState(state);
+ updateStateDisplay(state);
+ updateButtonConfiguration(state);
});
} else {
Log.d(Config.LOGTAG,"received update for other rtp session");
diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java
index 8ea923804..3d346dfd5 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java
@@ -317,6 +317,8 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
return RtpEndUserState.CONNECTED;
} else if (state == PeerConnection.PeerConnectionState.NEW || state == PeerConnection.PeerConnectionState.CONNECTING) {
return RtpEndUserState.CONNECTING;
+ } else if (state == PeerConnection.PeerConnectionState.CLOSED) {
+ return RtpEndUserState.ENDING_CALL;
} else {
return RtpEndUserState.FAILED;
}
@@ -342,6 +344,14 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
Log.d(Config.LOGTAG, "todo rejecting call");
}
+ public void endCall() {
+ if (isInState(State.SESSION_INITIALIZED, State.SESSION_ACCEPTED)) {
+ webRTCWrapper.close();
+ } else {
+ Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": called 'endCall' while in state " + this.state);
+ }
+ }
+
private void setupWebRTC() {
this.webRTCWrapper.setup(this.xmppConnectionService);
this.webRTCWrapper.initializePeerConnection();
@@ -392,6 +402,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
@Override
public void onConnectionChange(PeerConnection.PeerConnectionState newState) {
+ Log.d(Config.LOGTAG,id.account.getJid().asBareJid()+": PeerConnectionState changed to "+newState);
updateEndUserState();
}
diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/RtpEndUserState.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/RtpEndUserState.java
index bfae8e53b..30055a3d6 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/jingle/RtpEndUserState.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/RtpEndUserState.java
@@ -8,5 +8,6 @@ public enum RtpEndUserState {
RINGING, //'propose' has been sent out and it has been 184 acked
ACCEPTED_ON_OTHER_DEVICE, //received 'accept' from one of our own devices
ACCEPTING_CALL, //'proceed' message has been sent; but no session-initiate has been received
+ ENDING_CALL, //libwebrt says 'closed' but session-terminate hasnt gone through
FAILED //something went wrong. TODO needs more concrete error states
}
diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java
index 2fdd99003..f7d79771e 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java
@@ -81,8 +81,8 @@ public class WebRTCWrapper {
@Override
public void onAddStream(MediaStream mediaStream) {
Log.d(Config.LOGTAG, "onAddStream");
- for(AudioTrack audioTrack : mediaStream.audioTracks) {
- Log.d(Config.LOGTAG,"remote? - audioTrack enabled:"+audioTrack.enabled()+" state="+audioTrack.state());
+ for (AudioTrack audioTrack : mediaStream.audioTracks) {
+ Log.d(Config.LOGTAG, "remote? - audioTrack enabled:" + audioTrack.enabled() + " state=" + audioTrack.state());
}
final List videoTracks = mediaStream.videoTracks;
if (videoTracks.size() > 0) {
@@ -130,8 +130,8 @@ public class WebRTCWrapper {
CameraVideoCapturer capturer = null;
Camera1Enumerator camera1Enumerator = new Camera1Enumerator();
- for(String deviceName : camera1Enumerator.getDeviceNames()) {
- Log.d(Config.LOGTAG,"camera device name: "+deviceName);
+ for (String deviceName : camera1Enumerator.getDeviceNames()) {
+ Log.d(Config.LOGTAG, "camera device name: " + deviceName);
if (camera1Enumerator.isFrontFacing(deviceName)) {
capturer = camera1Enumerator.createCapturer(deviceName, new CameraVideoCapturer.CameraEventsHandler() {
@Override
@@ -151,12 +151,12 @@ public class WebRTCWrapper {
@Override
public void onCameraOpening(String s) {
- Log.d(Config.LOGTAG,"onCameraOpening");
+ Log.d(Config.LOGTAG, "onCameraOpening");
}
@Override
public void onFirstFrameAvailable() {
- Log.d(Config.LOGTAG,"onFirstFrameAvailable");
+ Log.d(Config.LOGTAG, "onFirstFrameAvailable");
}
@Override
@@ -179,7 +179,7 @@ public class WebRTCWrapper {
final AudioSource audioSource = peerConnectionFactory.createAudioSource(new MediaConstraints());
final AudioTrack audioTrack = peerConnectionFactory.createAudioTrack("my-audio-track", audioSource);
- Log.d(Config.LOGTAG,"audioTrack enabled:"+audioTrack.enabled()+" state="+audioTrack.state());
+ Log.d(Config.LOGTAG, "audioTrack enabled:" + audioTrack.enabled() + " state=" + audioTrack.state());
final MediaStream stream = peerConnectionFactory.createLocalMediaStream("my-media-stream");
stream.addTrack(audioTrack);
//stream.addTrack(videoTrack);
@@ -200,6 +200,9 @@ public class WebRTCWrapper {
this.peerConnection = peerConnection;
}
+ public void close() {
+ requirePeerConnection().close();
+ }
public ListenableFuture createOffer() {
@@ -287,15 +290,19 @@ public class WebRTCWrapper {
}
public void addIceCandidate(IceCandidate iceCandidate) {
+ requirePeerConnection().addIceCandidate(iceCandidate);
+ }
+
+ public PeerConnection.PeerConnectionState getState() {
+ return requirePeerConnection().connectionState();
+ }
+
+ private PeerConnection requirePeerConnection() {
final PeerConnection peerConnection = this.peerConnection;
if (peerConnection == null) {
throw new IllegalStateException("initialize PeerConnection first");
}
- peerConnection.addIceCandidate(iceCandidate);
- }
-
- public PeerConnection.PeerConnectionState getState() {
- return this.peerConnection.connectionState();
+ return peerConnection;
}
private static abstract class SetSdpObserver implements SdpObserver {
@@ -329,6 +336,7 @@ public class WebRTCWrapper {
public interface EventCallback {
void onIceCandidate(IceCandidate iceCandidate);
+
void onConnectionChange(PeerConnection.PeerConnectionState newState);
}
}
diff --git a/src/main/res/layout/activity_rtp_session.xml b/src/main/res/layout/activity_rtp_session.xml
index dc7dc4eec..28d954313 100644
--- a/src/main/res/layout/activity_rtp_session.xml
+++ b/src/main/res/layout/activity_rtp_session.xml
@@ -54,7 +54,22 @@
app:backgroundTint="@color/red700"
app:elevation="4dp"
app:fabCustomSize="72dp"
- app:maxImageSize="36dp" />
+ app:maxImageSize="36dp"
+ android:visibility="gone"
+ tools:visibility="visible"/>
+
+
+ app:maxImageSize="36dp"
+ android:visibility="gone"
+ tools:visibility="visible"/>
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index b7de99684..3d4c35661 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -889,6 +889,7 @@
Connecting
Connected
Accepting call
+ Ending call
- View %1$d Participant
- View %1$d Participants