Skip to content

Commit 6ed417d

Browse files
committed
merge Issue-2274 with origin/master
2 parents f429cc7 + 54bb452 commit 6ed417d

7 files changed

Lines changed: 439 additions & 67 deletions

File tree

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

18621867
// If action is present redirect to the action URI.
18631868
String action = null;
@@ -1943,11 +1948,11 @@ public void execute(final Object message) throws Exception {
19431948
if (CallStateChanged.class.equals(klass) ) {
19441949
if (action == null || action.isEmpty()) {
19451950
source.tell(new StopInterpreter(), source);
1951+
} else {
1952+
// Ask the parser for the next action to take.
1953+
final GetNextVerb next = new GetNextVerb();
1954+
parser.tell(next, source);
19461955
}
1947-
} else {
1948-
// Ask the parser for the next action to take.
1949-
final GetNextVerb next = new GetNextVerb();
1950-
parser.tell(next, source);
19511956
}
19521957
// A little clean up.
19531958
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
@@ -733,6 +733,10 @@ private void onParserFailed(Object message) throws TransitionFailedException, Tr
733733

734734
private void onStopInterpreter(Object message) throws TransitionFailedException, TransitionNotFoundException, TransitionRollbackException {
735735
this.liveCallModification = ((StopInterpreter) message).isLiveCallModification();
736+
if (logger.isInfoEnabled()) {
737+
String msg = String.format("Got StopInterpreter, liveCallModification %s, CallState %s", liveCallModification, callState);
738+
logger.info(msg);
739+
}
736740
if (CallStateChanged.State.IN_PROGRESS.equals(callState) && !liveCallModification) {
737741
fsm.transition(message, hangingUp);
738742
} else {
@@ -834,10 +838,18 @@ else if (is(gathering) || (is(finishGathering) && !super.dtmfReceived)) {
834838
private void onEndMessage(Object message) throws TransitionFailedException, TransitionNotFoundException, TransitionRollbackException {
835839
//Because of RMS issue https://github.com/RestComm/mediaserver/issues/158 we cannot have List<URI> for waitUrl
836840
if (playWaitUrlPending && conferenceWaitUris != null && conferenceWaitUris.size() > 0) {
841+
if (logger.isInfoEnabled()) {
842+
String msg = String.format("End tag received, playWaitUrlPending is %s, conferenceWaitUris.size() %d",playWaitUrlPending, conferenceWaitUris.size());
843+
logger.info(msg);
844+
}
837845
fsm.transition(conferenceWaitUris, conferencing);
838846
return;
839847
}
840848
if (callState.equals(CallStateChanged.State.COMPLETED) || callState.equals(CallStateChanged.State.CANCELED)) {
849+
if(logger.isInfoEnabled()) {
850+
String msg = String.format("End tag received, Call state %s , VI state %s will move to finished state",callState, fsm.state());
851+
logger.info(msg);
852+
}
841853
fsm.transition(message, finished);
842854
} else {
843855
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
@@ -454,10 +454,10 @@ protected void notificationResponse(final Object message, final ActorRef sender)
454454
final int transaction = rqnt.getTransactionHandle();
455455
response.setTransactionHandle(transaction);
456456
try {
457-
Thread.sleep(sleepTime);
457+
Thread.sleep(sleepTime*10);
458458
} catch (InterruptedException e) {
459459
}
460-
System.out.println(response.toString());
460+
logger.info("About to send MockMediaGateway response: "+response.toString());
461461
sender.tell(response, self);
462462
}
463463

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
@@ -374,6 +374,7 @@ public Call(final SipFactory factory, final MediaServerControllerFactory mediaSe
374374
transitions.add(new Transition(this.inProgress, this.leaving));
375375
transitions.add(new Transition(this.inProgress, this.failed));
376376
transitions.add(new Transition(this.inProgress, this.inDialogRequest));
377+
transitions.add(new Transition(this.inProgress, this.completed));
377378
transitions.add(new Transition(this.joining, this.inProgress));
378379
transitions.add(new Transition(this.joining, this.stopping));
379380
transitions.add(new Transition(this.joining, this.failed));
@@ -1722,6 +1723,11 @@ public Stopping(final ActorRef source) {
17221723
public void execute(Object message) throws Exception {
17231724
// Stops media operations and closes media session
17241725
msController.tell(new CloseMediaSession(), source);
1726+
if (fail) {
1727+
fsm.transition(message, failed);
1728+
} else {
1729+
fsm.transition(message, completed);
1730+
}
17251731
}
17261732
}
17271733

@@ -1810,6 +1816,10 @@ private void onStopMediaGroup(StopMediaGroup message, ActorRef self, ActorRef se
18101816
liveCallModification = true;
18111817
self().tell(new Leave(true), self());
18121818
}
1819+
} else {
1820+
if (logger.isDebugEnabled()) {
1821+
logger.debug("Got StopMediaGroup but Call is already in state: "+fsm.state());
1822+
}
18131823
}
18141824
}
18151825

@@ -2191,6 +2201,13 @@ private void onHangup(Hangup message, ActorRef self, ActorRef sender) throws Exc
21912201
logger.debug("Got Hangup: "+message+" for Call, from: "+from+" to: "+to+" state: "+fsm.state()+" conferencing: "+conferencing +" conference: "+conference);
21922202
}
21932203

2204+
if (is(completed)) {
2205+
if (logger.isDebugEnabled()) {
2206+
logger.debug("Got Hangup but already in completed state");
2207+
}
2208+
return;
2209+
}
2210+
21942211
// Stop recording if necessary
21952212
if (recording) {
21962213
recording = false;
@@ -2458,11 +2475,15 @@ private void onMediaServerControllerStateChanged(MediaServerControllerStateChang
24582475

24592476
case INACTIVE:
24602477
if (is(stopping)) {
2461-
if (fail) {
2462-
fsm.transition(message, failed);
2463-
} else {
2464-
fsm.transition(message, completed);
2478+
if (logger.isDebugEnabled()) {
2479+
String msg = String.format("On MediaServerContollerStateChanged, message: INACTIVE, Call state: %s, Fail: %s", fsm.state(), fail);
2480+
logger.debug(msg);
24652481
}
2482+
// if (fail) {
2483+
// fsm.transition(message, failed);
2484+
// } else {
2485+
// fsm.transition(message, completed);
2486+
// }
24662487
} else if (is(canceling)) {
24672488
fsm.transition(message, canceled);
24682489
} else if (is(failingBusy)) {

0 commit comments

Comments
 (0)