use of com.sun.voip.CallEvent in project Openfire by igniterealtime.
the class CallSetupAgent method run.
/*
* INVITE timeout thread, handle call not answered
*/
public void run() {
int timeout = cp.getCallAnswerTimeout();
if (timeout == 0) {
timeout = defaultCallAnswerTimeout;
}
try {
Thread.sleep(timeout * 1000);
} catch (InterruptedException e) {
}
inviteTimeoutThread = null;
if (reasonCallTerminated == null && getState() < CallState.ANSWERED) {
Logger.println("Call answer time out " + cp);
sendCallEventNotification(new CallEvent(CallEvent.CALL_ANSWER_TIMEOUT));
cancelRequest("No answer");
}
}
use of com.sun.voip.CallEvent in project Openfire by igniterealtime.
the class ConferenceMember method treatmentDoneNotification.
public void treatmentDoneNotification(TreatmentManager treatmentManager) {
synchronized (conferenceManager) {
synchronized (memberTreatments) {
memberTreatments.remove(treatmentManager);
synchronized (mixManager) {
mixManager.removeMix(treatmentManager);
}
if (Logger.logLevel >= Logger.LOG_MOREINFO) {
Logger.println("Treatment done " + treatmentManager.getId());
Logger.println("treatments left " + memberTreatments.size());
}
CallEvent callEvent = new CallEvent(CallEvent.TREATMENT_DONE);
callEvent.setTreatmentId(treatmentManager.getId());
callHandler.sendCallEventNotification(callEvent);
startNextTreatment();
}
}
}
use of com.sun.voip.CallEvent in project Openfire by igniterealtime.
the class OutgoingCallHandler method run.
public void run() {
/*
* Join an existing conference or create a new one.
*/
synchronized (ConferenceManager.getConferenceList()) {
conferenceManager = ConferenceManager.getConference(cp);
if (conferenceManager == null) {
Logger.error("Couldn't start conference " + cp.getConferenceId());
sendCallEventNotification(new CallEvent(CallEvent.CANT_START_CONFERENCE));
return;
}
try {
member = conferenceManager.joinConference(cp);
memberSender = member.getMemberSender();
memberReceiver = member.getMemberReceiver();
} catch (IOException e) {
CallEvent callEvent = new CallEvent(CallEvent.CANT_CREATE_MEMBER);
callEvent.setInfo(e.getMessage());
sendCallEventNotification(callEvent);
removeCallEventListener(this);
return;
}
}
// add to list of active calls
addCall(this);
lastGateway = false;
onlyOneGateway = false;
/*
* Start the call (INVITE) and wait for it to end (BYE).
*/
ArrayList voIPGateways = SipServer.getVoIPGateways();
String gateway = cp.getVoIPGateway();
if (gateway != null) {
/*
* User specified a specific gateway. Use that one only.
*/
Logger.println("Call " + this + ": Using gateway specified for the call: " + gateway);
lastGateway = true;
onlyOneGateway = true;
placeCall();
} else if (voIPGateways.size() > 0) {
if (voIPGateways.size() == 1) {
onlyOneGateway = true;
}
lastGateway = true;
placeCall();
} else if (cp.getPhoneNumber() != null && cp.getPhoneNumber().indexOf("sip:") == 0) {
// no gateway involved, direct SIP call
placeCall();
} else if (cp.getProtocol() != null && ("Speaker".equals(cp.getProtocol()) || "WebRtc".equals(cp.getProtocol()) || "Rtmfp".equals(cp.getProtocol()))) {
// WebRtc call
placeCall();
} else {
Logger.error("Couldn't place call " + cp);
sendCallEventNotification(new CallEvent(CallEvent.CANT_START_CONFERENCE));
}
// Remove member from conference.
conferenceManager.leave(member);
// remove call from active call list
removeCall(this);
removeCallEventListener(this);
done = true;
}
use of com.sun.voip.CallEvent in project Openfire by igniterealtime.
the class OutgoingCallHandler method callEventNotification.
/*
* This method is called where there is new status information.
* Status can be a state change, dtmf key pressed,
* or speaking not speaking notification.
*/
public void callEventNotification(CallEvent callEvent) {
if (Logger.logLevel >= Logger.LOG_INFO) {
Logger.println("Notification: " + callEvent);
}
if (callEvent.equals(CallEvent.STATE_CHANGED)) {
if (callEvent.getCallState().equals(CallState.ANSWERED)) {
/*
* For two party calls
*/
synchronized (waitCallAnswerLock) {
waitCallAnswerLock.notify();
}
} else if (callEvent.getCallState().equals(CallState.ESTABLISHED)) {
/*
* For migrating calls
*/
synchronized (waitCallEstablishedLock) {
waitCallEstablishedLock.notify();
}
} else if (callEvent.getCallState().equals(CallState.ENDING)) {
CallHandler callHandler = CallHandler.findMigratingCall(cp.getCallId());
if (callHandler == this) {
/*
* If it's a gateway error and it's not the last gateway,
* don't end the call. It will be retried with the
* alternate gateway.
*/
if (callEvent.getInfo().indexOf("gateway error") >= 0 && lastGateway == false) {
return;
}
callEvent = new CallEvent(CallEvent.MIGRATION_FAILED);
callEvent.setInfo("Migration failed: " + getReasonCallEnded());
sendCallEventNotification(callEvent);
}
} else if (callEvent.getCallState().equals(CallState.ENDED)) {
reasonCallEnded = callEvent.getInfo();
synchronized (waitCallAnswerLock) {
waitCallAnswerLock.notify();
}
if (reasonCallEnded.indexOf("gateway error") >= 0 && lastGateway == false) {
CallHandler callHandler = CallHandler.findMigratingCall(cp.getCallId());
if (callHandler == this) {
synchronized (stateChangeLock) {
/*
* Let the outgoing call handler know so
* it can try another gateway.
*/
stateChangeLock.notify();
}
// don't tell the migrator yet
return;
}
}
synchronized (waitCallEstablishedLock) {
waitCallEstablishedLock.notify();
}
synchronized (stateChangeLock) {
// the call has ended
stateChangeLock.notify();
}
/*
* If it's a gateway error and not the last gateway,
* don't end the call. It will be retried with the
* alternate gateway.
*/
if (reasonCallEnded.indexOf("gateway error") >= 0 && lastGateway == false) {
return;
}
cancelRequest(reasonCallEnded);
}
}
if (suppressEvent(cp, callEvent) == false) {
Application.outgoingCallNotification(callEvent);
if (csl != null)
csl.callEventNotification(callEvent);
}
}
use of com.sun.voip.CallEvent in project Openfire by igniterealtime.
the class CallHandler method dtmfKeys.
/**
* Send indication when a dtmf key is pressed
*/
public void dtmfKeys(String dtmfKeys) {
//if (Logger.logLevel >= Logger.LOG_MOREINFO) {
Logger.println(cp + " got dtmf keys " + dtmfKeys + " " + cp.dtmfDetection());
if (isCallEstablished()) {
if (cp.dtmfDetection()) {
member.stopTreatment(null);
CallEvent callEvent = new CallEvent(CallEvent.DTMF_KEY);
callEvent.setDtmfKey(dtmfKeys);
sendCallEventNotification(callEvent);
}
if (otherCall != null) {
Logger.println("Call " + cp + " forwarding dtmf key " + dtmfKeys + " to " + otherCall);
otherCall.getMemberSender().setDtmfKeyToSend(dtmfKeys);
} else {
getMemberSender().setDtmfKeyToSend(dtmfKeys);
}
} else {
if (Logger.logLevel >= Logger.LOG_MOREINFO) {
Logger.println(cp + " Call not established, ignoring dtmf");
}
stopCallAnsweredTreatment();
}
}
Aggregations