Skip to content

Commit

Permalink
jira-2165 RC does not send BYE to XMS when stop recording.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoan HL committed May 25, 2018
1 parent 8b72604 commit 2102555
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.restcomm.connect.mscontrol.api.messages;

import org.restcomm.connect.commons.annotations.concurrency.Immutable;

/**
* @author Hoan Luu (hoan.h.luu@telestax.com)
*/

@Immutable
public class RecordStoped {
public RecordStoped() {
super();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import org.restcomm.connect.mscontrol.api.messages.StopRecording;
import org.restcomm.connect.mscontrol.api.messages.Unmute;
import org.restcomm.connect.mscontrol.api.messages.UpdateMediaSession;
import org.restcomm.connect.mscontrol.api.messages.RecordStoped;

import javax.media.mscontrol.EventType;
import javax.media.mscontrol.MediaEvent;
Expand Down Expand Up @@ -830,6 +831,7 @@ private void onStop(Stop message, ActorRef self, ActorRef sender) {
this.mediaGroup.getSignalDetector().stop();
this.collecting = Boolean.FALSE;
}
call.tell(new RecordStoped(), self);
} catch (MsControlException e) {
call.tell(new MediaServerControllerError(e), self);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
import org.restcomm.connect.mscontrol.api.messages.StopRecording;
import org.restcomm.connect.mscontrol.api.messages.Unmute;
import org.restcomm.connect.mscontrol.api.messages.UpdateMediaSession;
import org.restcomm.connect.mscontrol.api.messages.RecordStoped;
import org.restcomm.connect.telephony.api.Answer;
import org.restcomm.connect.telephony.api.BridgeStateChanged;
import org.restcomm.connect.telephony.api.CallFail;
Expand Down Expand Up @@ -231,6 +232,7 @@ public final class Call extends RestcommUntypedActor implements TransitionEndLis
private boolean muted;
private boolean webrtc;
private boolean initialInviteOkSent;
private boolean isStoppingRecord = false;

// Conferencing
private ActorRef conference;
Expand Down Expand Up @@ -278,6 +280,8 @@ public final class Call extends RestcommUntypedActor implements TransitionEndLis
private DateTime recordingStart;
private long recordingDuration;

private String msCompatibilityMode;

private HttpRequestDescriptor requestCallback;
ActorRef downloader = null;
private URI statusCallback;
Expand Down Expand Up @@ -441,6 +445,7 @@ public Call(final Sid accountSid, final SipFactory factory, final MediaServerCon
final Configuration runtime = this.configuration.subset("runtime-settings");
this.disableSdpPatchingOnUpdatingMediaSession = runtime.getBoolean("disable-sdp-patching-on-updating-mediasession", false);
this.enable200OkDelay = runtime.getBoolean("enable-200-ok-delay",false);
this.msCompatibilityMode = this.configuration.subset("mscontrol").getString("compatibility", "rms");
if(!runtime.subset("ims-authentication").isEmpty()){
final Configuration imsAuthentication = runtime.subset("ims-authentication");
this.actAsImsUa = imsAuthentication.getBoolean("act-as-ims-ua");
Expand Down Expand Up @@ -766,6 +771,8 @@ public void onReceive(Object message) throws Exception {
onCallHoldStateChange((CallHoldStateChange)message, sender);
} else if (StopWaiting.class.equals(klass)) {
onStopWaiting((StopWaiting)message, sender);
} else if (RecordStoped.class.equals(klass)) {
onRecordStoped((RecordStoped) message, sender);
}
}

Expand Down Expand Up @@ -813,6 +820,14 @@ private void onCallHoldStateChange(CallHoldStateChange message, ActorRef sender)
}
}

private void onRecordStoped (RecordStoped message, ActorRef sender) {
if (is(stopping)) {
isStoppingRecord = false;
msController.tell(new CloseMediaSession(), self());
context().setReceiveTimeout(Duration.create(2000, TimeUnit.MILLISECONDS));
}
}

private void addCustomHeaders(SipServletMessage message) {
if (apiVersion != null)
message.addHeader("X-RestComm-ApiVersion", apiVersion);
Expand Down Expand Up @@ -1781,11 +1796,14 @@ public void execute(Object message) throws Exception {
}
}

msController.tell(new CloseMediaSession(), source);
// If working with XMS and RC is trying to stop Recording, Should not send CloseMediaSession otherwise this signal will be Ignore by RC.
if (!isStoppingRecord || !msCompatibilityMode.equalsIgnoreCase("xms")) {
msController.tell(new CloseMediaSession(), source);

//Github issue 2261 - https://github.com/RestComm/Restcomm-Connect/issues/2261
//Set a ReceivedTimeout duration to make sure call doesn't block waiting for the response from MmsCallController
context().setReceiveTimeout(Duration.create(2000, TimeUnit.MILLISECONDS));
//Github issue 2261 - https://github.com/RestComm/Restcomm-Connect/issues/2261
//Set a ReceivedTimeout duration to make sure call doesn't block waiting for the response from MmsCallController
context().setReceiveTimeout(Duration.create(2000, TimeUnit.MILLISECONDS));
}
}
}

Expand Down Expand Up @@ -2096,6 +2114,7 @@ else if(isCallOffHoldSdp(answer)){
if (!direction.contains("outbound")) {
// Initial Call sent BYE
recording = false;
isStoppingRecord = true;
if(logger.isInfoEnabled()) {
logger.info("Call Direction: " + direction);
logger.info("Initial Call - Will stop recording now");
Expand Down

0 comments on commit 2102555

Please sign in to comment.