use of com.sun.voip.MediaInfo in project Openfire by igniterealtime.
the class NSOutgoingCallAgent method setRemoteMediaInfo.
/*
* This is called for calls with an input treatment.
* There is really no endpoint
* and no data is ever sent to the call.
* The looks like any other call but is used only as a source of sound.
*/
public void setRemoteMediaInfo(TreatmentManager treatmentManager) throws ParseException {
if (getState() != CallState.INVITED) {
Logger.println("Call " + cp + ": NSOutgoingCallAgent: bad state " + getState());
return;
}
MediaInfo mediaInfo = mixerMediaPreference;
if (treatmentManager != null) {
int sampleRate = treatmentManager.getSampleRate();
int channels = treatmentManager.getChannels();
try {
mediaInfo = MediaInfo.findMediaInfo(RtpPacket.PCM_ENCODING, sampleRate, channels);
} catch (IOException e) {
Logger.println("Using conference media preference " + mediaInfo + ": " + e.getMessage());
}
}
InetSocketAddress isa = callHandler.getMember().getMemberReceiver().getReceiveAddress();
Logger.println("Call " + cp + ": NSOutgoingCallAgent: " + mediaInfo + " remote " + isa);
setEndpointAddress(isa, mediaInfo.getPayload(), mediaInfo.getPayload(), (byte) 0);
if (callAnswered) {
Logger.writeFile("Call " + cp + ": NSOutgoingCallAgent: done remote SDP");
return;
}
/*
* The CallParticipant has answered.
* If join confirmation is required, we remain in the
* INVITED state.
*/
callAnswered = true;
if (cp.getJoinConfirmationTimeout() == 0) {
setState(CallState.ANSWERED);
}
/*
* Start treatment if any and wait for it to finish.
* When the treatment finishes, notification will
* be delivered to our parent which will indicate
* we're ready for the conference.
*
* If there's no treatment to be played, we're ready now
* unless we're waiting for join confirmation..
*/
initializeCallAnsweredTreatment();
if (callAnsweredTreatment != null) {
startCallAnsweredTreatment();
} else {
if (cp.getJoinConfirmationTimeout() == 0) {
setState(CallState.ESTABLISHED);
}
}
}
use of com.sun.voip.MediaInfo in project Openfire by igniterealtime.
the class MemberReceiver method setRecordFromMember.
public void setRecordFromMember(boolean enabled, String recordingFile, String recordingType) throws IOException {
if (doNotRecord()) {
if (enabled) {
Logger.println("Call " + cp + " doesn't allow recording.");
enabled = false;
}
}
if (recorder != null) {
recorder.done();
recorder = null;
}
synchronized (recordingLock) {
if (enabled == false) {
cp.setFromRecordingFile(null);
return;
}
if (recordingType == null) {
recordingType = "Au";
}
recordRtp = false;
if (recordingType.equalsIgnoreCase("Rtp")) {
recordRtp = true;
}
synchronized (recordingLock) {
MediaInfo m;
try {
if (recordingType.equalsIgnoreCase("Rtp")) {
m = SdpManager.findMediaInfo(myMediaInfo.getEncoding(), myMediaInfo.getSampleRate(), myMediaInfo.getChannels());
} else {
m = SdpManager.findMediaInfo(RtpPacket.PCM_ENCODING, conferenceManager.getMediaInfo().getSampleRate(), conferenceManager.getMediaInfo().getChannels());
}
} catch (ParseException e) {
Logger.println("Can't record rtp to " + recordingFile + " " + e.getMessage());
throw new IOException(e.getMessage());
}
Logger.println("Recording media " + m);
recorder = new Recorder(cp.getRecordDirectory(), recordingFile, recordingType, m);
cp.setFromRecordingFile(recordingFile);
cp.setFromRecordingType(recordingType);
}
}
}
use of com.sun.voip.MediaInfo in project Openfire by igniterealtime.
the class ConferenceManager method getConferenceInfo.
private static String getConferenceInfo(int format) {
synchronized (conferenceList) {
if (conferenceList.size() == 0) {
if (format != 0) {
return ("\n\n\n\n");
}
return "";
}
String s = "";
for (int i = 0; i < conferenceList.size(); i++) {
ConferenceManager conferenceManager = (ConferenceManager) conferenceList.get(i);
String id = conferenceManager.getId();
String displayName = conferenceManager.getDisplayName();
if (format != 1) {
if (displayName != null) {
id += " '" + displayName + "'";
}
} else {
if (displayName == null) {
if (id.length() >= 14) {
id = id.substring(0, 13);
}
} else {
id = "'" + displayName + "'";
}
}
s += "Conference Id: " + id + " ";
s += conferenceManager.getMediaInfo().toString();
s += " Members=" + conferenceManager.getMemberList().size();
if (conferenceManager.isPermanent()) {
s += " persistent";
}
String recordingFile = conferenceManager.getWGManager().getRecordingFile();
if (recordingFile != null) {
s += " Recording to " + recordingFile;
}
s += "\n";
if (format == 0) {
continue;
}
/*
* Copy the member list so we can avoid unnecessary
* synchronization
*/
ArrayList memberList = (ArrayList) conferenceManager.getMemberList().clone();
for (int n = 0; n < memberList.size(); n++) {
ConferenceMember member = (ConferenceMember) memberList.get(n);
MemberSender memberSender = member.getMemberSender();
MemberReceiver memberReceiver = member.getMemberReceiver();
String info = " ";
MediaInfo transmitMediaInfo = memberSender.getMediaInfo();
if (transmitMediaInfo != null) {
info += transmitMediaInfo.toString();
}
MediaInfo receiveMediaInfo = memberReceiver.getMediaInfo();
if (receiveMediaInfo != null) {
if (transmitMediaInfo.getEncoding() != receiveMediaInfo.getEncoding() || transmitMediaInfo.getSampleRate() != receiveMediaInfo.getSampleRate() || transmitMediaInfo.getChannels() != receiveMediaInfo.getChannels()) {
/*
* The member is transmitting at a different
* media setting than it is receiving.
*/
info += " Transmit:" + memberReceiver.getMediaInfo();
}
}
CallParticipant cp = member.getCallParticipant();
if (cp.isMuted()) {
info += " MUTED";
}
if (cp.isConferenceMuted()) {
info += " CONFERENCE_MUTED";
}
if (cp.isConferenceSilenced()) {
info += " MAIN_CONFERENCE_SILENCED";
}
if (memberReceiver.doNotRecord() == true) {
info += " RECORDED NOT ALLOWED";
}
if (memberReceiver.getFromRecordingFile() != null) {
info += " Recording from member in " + memberReceiver.getFromRecordingFile();
}
if (cp.isRecorder()) {
String toRecordingFile = memberSender.getCallParticipant().getToRecordingFile();
if (toRecordingFile != null) {
info += " Recording to member in " + toRecordingFile;
} else {
info += " Recorder";
}
}
if (cp.speexEncode()) {
info += " SpeexEncode";
}
//
if (memberSender.getSendAddress() != null) {
String gateway = "";
String address = memberSender.getSendAddress().toString();
int ix = address.indexOf("/");
if (ix >= 0) {
address = address.substring(ix + 1);
if ((ix = address.indexOf(":")) >= 0) {
address = address.substring(0, ix);
}
}
if (address.equals("10.6.4.192")) {
gateway = " Menlo Park Gateway";
} else if (address.equals("129.148.75.22")) {
gateway = " Burlington Gateway";
} else if (address.equals("10.1.224.22")) {
gateway = " Broomfield Gateway";
}
info += gateway;
}
if (format == 2) {
info += conferenceManager.getWGManager().getWhisperGroupInfo(member);
}
cp = member.getCallParticipant();
id = cp.toString();
if (format == 1) {
id = cp.toConsiseString();
}
s += " " + id + info + "\n";
}
s += "\n";
}
return s + "\n";
}
}
use of com.sun.voip.MediaInfo in project Openfire by igniterealtime.
the class ConferenceManager method parseMediaPreference.
private MediaInfo parseMediaPreference(String mediaPreference) throws ParseException {
if (mediaPreference == null) {
if (mediaInfo != null) {
return mediaInfo;
}
return SdpManager.findMediaInfo(RtpPacket.PCMU_ENCODING, 8000, 1);
}
int ix;
int encoding = RtpPacket.PCMU_ENCODING;
int sampleRate = 8000;
int channels = 1;
try {
if (mediaPreference.indexOf("PCMU/") == 0) {
encoding = RtpPacket.PCMU_ENCODING;
mediaPreference = mediaPreference.substring(5);
} else if (mediaPreference.indexOf("PCM/") == 0) {
encoding = RtpPacket.PCM_ENCODING;
mediaPreference = mediaPreference.substring(4);
} else if (mediaPreference.indexOf("SPEEX/") == 0) {
encoding = RtpPacket.SPEEX_ENCODING;
mediaPreference = mediaPreference.substring(6);
} else if (mediaPreference.indexOf("PCM") == 0) {
// do nothing
} else {
Logger.println("Invalid media specification " + mediaPreference);
}
if ((ix = mediaPreference.indexOf("/")) < 0) {
Logger.println("Invalid media specification " + mediaPreference);
} else {
sampleRate = Integer.parseInt(mediaPreference.substring(0, ix));
channels = Integer.parseInt(mediaPreference.substring(ix + 1));
}
} catch (IndexOutOfBoundsException e) {
Logger.println("Invalid media specification " + mediaPreference);
} catch (NumberFormatException e) {
Logger.println("Invalid media specification " + mediaPreference);
}
if (sampleRate == 8000 && channels == 1 && encoding == RtpPacket.PCM_ENCODING) {
encoding = RtpPacket.PCMU_ENCODING;
}
MediaInfo mediaInfo = SdpManager.findMediaInfo(encoding, sampleRate, channels);
Logger.println("conference " + conferenceId + " using media settings " + mediaInfo);
conferenceStartTime = System.currentTimeMillis();
return mediaInfo;
}
use of com.sun.voip.MediaInfo in project Openfire by igniterealtime.
the class CallSetupAgent method cancelRequest.
/**
* Cancel a call
*/
public void cancelRequest(String s) {
if (reasonCallTerminated != null || getState() == CallState.ENDED) {
return;
}
reasonCallTerminated = s;
if (inviteTimeoutThread != null) {
inviteTimeoutThread.interrupt();
inviteTimeoutThread = null;
}
if (Logger.logLevel >= Logger.LOG_INFO) {
Logger.println("Call " + callHandler + ": cancelling call, " + s);
}
if (callAnsweredTreatment != null) {
callAnsweredTreatment.stopTreatment();
}
if (callEstablishedTreatment != null) {
callEstablishedTreatment.stopTreatment();
}
if (getState() == CallState.ESTABLISHED) {
String endTreatment = cp.getCallEndTreatment();
if (endTreatment != null && cp.isConferenceMuted() == false) {
try {
MediaInfo mediaInfo = callHandler.getConferenceManager().getMediaInfo();
TreatmentManager callEndTreatment = new TreatmentManager(endTreatment, 0, mediaInfo.getSampleRate(), mediaInfo.getChannels());
setState(CallState.ENDING, "Reason='" + s + "'");
if (Logger.logLevel >= Logger.LOG_MOREINFO) {
Logger.println("Call " + callHandler + " adding end treatment...");
}
callEndTreatment.addTreatmentDoneListener(this);
callHandler.addTreatment(callEndTreatment);
return;
} catch (IOException e) {
Logger.error("Call " + callHandler + " " + e.getMessage());
}
}
}
// do subclass specific work
terminateCall();
setState(CallState.ENDING, "Reason='" + s + "'");
done();
}
Aggregations