Skip to content

Commit 54bb452

Browse files
committed
`Merge branch 'issue2313'
2 parents 94fd38f + b42e3e2 commit 54bb452

8 files changed

Lines changed: 440 additions & 68 deletions

File tree

restcomm/restcomm.commons/src/main/java/org/restcomm/connect/commons/faulttolerance/RestcommSupervisorStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class RestcommSupervisorStrategy implements SupervisorStrategyConfigurato
2222

2323
final SupervisorStrategy.Directive strategy = resume();
2424

25-
RestcommFaultToleranceStrategy defaultStrategy = new RestcommFaultToleranceStrategy(10, Duration.create("1 minute"),
25+
RestcommFaultToleranceStrategy defaultStrategy = new RestcommFaultToleranceStrategy(10, Duration.create("1 minute"),
2626
new RestcommFaultToleranceDecider());
2727

2828
@Override

restcomm/restcomm.interpreter/src/main/java/org/restcomm/connect/interpreter/BaseVoiceInterpreter.java

Lines changed: 63 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,67 +1800,72 @@ public void execute(final Object message) throws Exception {
18001800
final Recording recording = builder.build();
18011801
final RecordingsDao recordings = storage.getRecordingsDao();
18021802
recordings.addRecording(recording);
1803-
// Start transcription.
1804-
URI transcribeCallback = null;
1805-
Attribute attribute = verb.attribute("transcribeCallback");
1806-
if (attribute != null) {
1807-
final String value = attribute.value();
1808-
if (value != null && !value.isEmpty()) {
1809-
try {
1810-
transcribeCallback = URI.create(value);
1811-
} catch (final Exception exception) {
1812-
final Notification notification = notification(ERROR_NOTIFICATION, 11100, transcribeCallback
1813-
+ " is an invalid URI.");
1814-
notifications.addNotification(notification);
1815-
sendMail(notification);
1816-
final StopInterpreter stop = new StopInterpreter();
1817-
source.tell(stop, source);
1818-
return;
1819-
}
1820-
}
1821-
}
1822-
boolean transcribe = false;
1823-
if (transcribeCallback != null) {
1824-
transcribe = true;
1825-
} else {
1826-
attribute = verb.attribute("transcribe");
1803+
1804+
Attribute attribute = null;
1805+
1806+
if (checkAsrService()) {
1807+
// ASR service is enabled. Start transcription.
1808+
URI transcribeCallback = null;
1809+
attribute = verb.attribute("transcribeCallback");
18271810
if (attribute != null) {
18281811
final String value = attribute.value();
18291812
if (value != null && !value.isEmpty()) {
1830-
transcribe = Boolean.parseBoolean(value);
1813+
try {
1814+
transcribeCallback = URI.create(value);
1815+
} catch (final Exception exception) {
1816+
final Notification notification = notification(ERROR_NOTIFICATION, 11100, transcribeCallback
1817+
+ " is an invalid URI.");
1818+
notifications.addNotification(notification);
1819+
sendMail(notification);
1820+
final StopInterpreter stop = new StopInterpreter();
1821+
source.tell(stop, source);
1822+
return;
1823+
}
18311824
}
18321825
}
1833-
}
1834-
if (transcribe && checkAsrService()) {
1835-
final Sid sid = Sid.generate(Sid.Type.TRANSCRIPTION);
1836-
final Transcription.Builder otherBuilder = Transcription.builder();
1837-
otherBuilder.setSid(sid);
1838-
otherBuilder.setAccountSid(accountId);
1839-
otherBuilder.setStatus(Transcription.Status.IN_PROGRESS);
1840-
otherBuilder.setRecordingSid(recordingSid);
1841-
otherBuilder.setTranscriptionText("Transcription Text not available");
1842-
otherBuilder.setDuration(duration);
1843-
otherBuilder.setPrice(new BigDecimal("0.00"));
1844-
buffer = new StringBuilder();
1845-
buffer.append("/").append(version).append("/Accounts/").append(accountId.toString());
1846-
buffer.append("/Transcriptions/").append(sid.toString());
1847-
final URI uri = URI.create(buffer.toString());
1848-
otherBuilder.setUri(uri);
1849-
final Transcription transcription = otherBuilder.build();
1850-
final TranscriptionsDao transcriptions = storage.getTranscriptionsDao();
1851-
transcriptions.addTranscription(transcription);
1852-
try {
1853-
final Map<String, Object> attributes = new HashMap<String, Object>();
1854-
attributes.put("callback", transcribeCallback);
1855-
attributes.put("transcription", transcription);
1856-
getAsrService().tell(new AsrRequest(new File(recordingUri), "en", attributes), source);
1857-
outstandingAsrRequests++;
1858-
} catch (final Exception exception) {
1859-
logger.error(exception.getMessage(), exception);
1826+
boolean transcribe = false;
1827+
if (transcribeCallback != null) {
1828+
transcribe = true;
1829+
} else {
1830+
attribute = verb.attribute("transcribe");
1831+
if (attribute != null) {
1832+
final String value = attribute.value();
1833+
if (value != null && !value.isEmpty()) {
1834+
transcribe = Boolean.parseBoolean(value);
1835+
}
1836+
}
1837+
}
1838+
if (transcribe && checkAsrService()) {
1839+
final Sid sid = Sid.generate(Sid.Type.TRANSCRIPTION);
1840+
final Transcription.Builder otherBuilder = Transcription.builder();
1841+
otherBuilder.setSid(sid);
1842+
otherBuilder.setAccountSid(accountId);
1843+
otherBuilder.setStatus(Transcription.Status.IN_PROGRESS);
1844+
otherBuilder.setRecordingSid(recordingSid);
1845+
otherBuilder.setTranscriptionText("Transcription Text not available");
1846+
otherBuilder.setDuration(duration);
1847+
otherBuilder.setPrice(new BigDecimal("0.00"));
1848+
buffer = new StringBuilder();
1849+
buffer.append("/").append(version).append("/Accounts/").append(accountId.toString());
1850+
buffer.append("/Transcriptions/").append(sid.toString());
1851+
final URI uri = URI.create(buffer.toString());
1852+
otherBuilder.setUri(uri);
1853+
final Transcription transcription = otherBuilder.build();
1854+
final TranscriptionsDao transcriptions = storage.getTranscriptionsDao();
1855+
transcriptions.addTranscription(transcription);
1856+
try {
1857+
final Map<String, Object> attributes = new HashMap<String, Object>();
1858+
attributes.put("callback", transcribeCallback);
1859+
attributes.put("transcription", transcription);
1860+
getAsrService().tell(new AsrRequest(new File(recordingUri), "en", attributes), source);
1861+
outstandingAsrRequests++;
1862+
} catch (final Exception exception) {
1863+
logger.error(exception.getMessage(), exception);
1864+
}
18601865
}
18611866
} else if(logger.isInfoEnabled()){
1862-
logger.info("AsrService activated but not properly configured. Please set api-key for AsrService");
1863-
}
1867+
logger.info("AsrService is not enabled");
1868+
}
18641869

18651870
// If action is present redirect to the action URI.
18661871
String action = null;
@@ -1946,11 +1951,11 @@ public void execute(final Object message) throws Exception {
19461951
if (CallStateChanged.class.equals(klass) ) {
19471952
if (action == null || action.isEmpty()) {
19481953
source.tell(new StopInterpreter(), source);
1954+
} else {
1955+
// Ask the parser for the next action to take.
1956+
final GetNextVerb next = new GetNextVerb();
1957+
parser.tell(next, source);
19491958
}
1950-
} else {
1951-
// Ask the parser for the next action to take.
1952-
final GetNextVerb next = new GetNextVerb();
1953-
parser.tell(next, source);
19541959
}
19551960
// A little clean up.
19561961
recordingSid = null;

restcomm/restcomm.interpreter/src/main/java/org/restcomm/connect/interpreter/VoiceInterpreter.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,10 @@ private void onParserFailed(Object message) throws TransitionFailedException, Tr
730730

731731
private void onStopInterpreter(Object message) throws TransitionFailedException, TransitionNotFoundException, TransitionRollbackException {
732732
this.liveCallModification = ((StopInterpreter) message).isLiveCallModification();
733+
if (logger.isInfoEnabled()) {
734+
String msg = String.format("Got StopInterpreter, liveCallModification %s, CallState %s", liveCallModification, callState);
735+
logger.info(msg);
736+
}
733737
if (CallStateChanged.State.IN_PROGRESS.equals(callState) && !liveCallModification) {
734738
fsm.transition(message, hangingUp);
735739
} else {
@@ -831,10 +835,18 @@ else if (is(gathering) || (is(finishGathering) && !super.dtmfReceived)) {
831835
private void onEndMessage(Object message) throws TransitionFailedException, TransitionNotFoundException, TransitionRollbackException {
832836
//Because of RMS issue https://github.com/RestComm/mediaserver/issues/158 we cannot have List<URI> for waitUrl
833837
if (playWaitUrlPending && conferenceWaitUris != null && conferenceWaitUris.size() > 0) {
838+
if (logger.isInfoEnabled()) {
839+
String msg = String.format("End tag received, playWaitUrlPending is %s, conferenceWaitUris.size() %d",playWaitUrlPending, conferenceWaitUris.size());
840+
logger.info(msg);
841+
}
834842
fsm.transition(conferenceWaitUris, conferencing);
835843
return;
836844
}
837845
if (callState.equals(CallStateChanged.State.COMPLETED) || callState.equals(CallStateChanged.State.CANCELED)) {
846+
if(logger.isInfoEnabled()) {
847+
String msg = String.format("End tag received, Call state %s , VI state %s will move to finished state",callState, fsm.state());
848+
logger.info(msg);
849+
}
838850
fsm.transition(message, finished);
839851
} else {
840852
if (!isParserFailed) {

restcomm/restcomm.mgcp/src/main/java/org/restcomm/connect/mgcp/MockMediaGateway.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,10 +453,10 @@ protected void notificationResponse(final Object message, final ActorRef sender)
453453
final int transaction = rqnt.getTransactionHandle();
454454
response.setTransactionHandle(transaction);
455455
try {
456-
Thread.sleep(sleepTime);
456+
Thread.sleep(sleepTime*10);
457457
} catch (InterruptedException e) {
458458
}
459-
System.out.println(response.toString());
459+
logger.info("About to send MockMediaGateway response: "+response.toString());
460460
sender.tell(response, self);
461461
}
462462

restcomm/restcomm.telephony/src/main/java/org/restcomm/connect/telephony/Call.java

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ public Call(final SipFactory factory, final ActorRef mediaSessionController, fin
378378
transitions.add(new Transition(this.inProgress, this.leaving));
379379
transitions.add(new Transition(this.inProgress, this.failed));
380380
transitions.add(new Transition(this.inProgress, this.inDialogRequest));
381+
transitions.add(new Transition(this.inProgress, this.completed));
381382
transitions.add(new Transition(this.joining, this.inProgress));
382383
transitions.add(new Transition(this.joining, this.stopping));
383384
transitions.add(new Transition(this.joining, this.failed));
@@ -1726,6 +1727,11 @@ public Stopping(final ActorRef source) {
17261727
public void execute(Object message) throws Exception {
17271728
// Stops media operations and closes media session
17281729
msController.tell(new CloseMediaSession(), source);
1730+
if (fail) {
1731+
fsm.transition(message, failed);
1732+
} else {
1733+
fsm.transition(message, completed);
1734+
}
17291735
}
17301736
}
17311737

@@ -1814,6 +1820,10 @@ private void onStopMediaGroup(StopMediaGroup message, ActorRef self, ActorRef se
18141820
liveCallModification = true;
18151821
self().tell(new Leave(true), self());
18161822
}
1823+
} else {
1824+
if (logger.isDebugEnabled()) {
1825+
logger.debug("Got StopMediaGroup but Call is already in state: "+fsm.state());
1826+
}
18171827
}
18181828
}
18191829

@@ -2195,6 +2205,13 @@ private void onHangup(Hangup message, ActorRef self, ActorRef sender) throws Exc
21952205
logger.debug("Got Hangup: "+message+" for Call, from: "+from+" to: "+to+" state: "+fsm.state()+" conferencing: "+conferencing +" conference: "+conference);
21962206
}
21972207

2208+
if (is(completed)) {
2209+
if (logger.isDebugEnabled()) {
2210+
logger.debug("Got Hangup but already in completed state");
2211+
}
2212+
return;
2213+
}
2214+
21982215
// Stop recording if necessary
21992216
if (recording) {
22002217
recording = false;
@@ -2462,11 +2479,15 @@ private void onMediaServerControllerStateChanged(MediaServerControllerStateChang
24622479

24632480
case INACTIVE:
24642481
if (is(stopping)) {
2465-
if (fail) {
2466-
fsm.transition(message, failed);
2467-
} else {
2468-
fsm.transition(message, completed);
2482+
if (logger.isDebugEnabled()) {
2483+
String msg = String.format("On MediaServerContollerStateChanged, message: INACTIVE, Call state: %s, Fail: %s", fsm.state(), fail);
2484+
logger.debug(msg);
24692485
}
2486+
// if (fail) {
2487+
// fsm.transition(message, failed);
2488+
// } else {
2489+
// fsm.transition(message, completed);
2490+
// }
24702491
} else if (is(canceling)) {
24712492
fsm.transition(message, canceled);
24722493
} else if (is(failingBusy)) {

0 commit comments

Comments
 (0)