use of com.sun.voip.SpeexEncoder in project Openfire by igniterealtime.
the class MemberSender method initialize.
/**
* Initialize this member. The call has been established and
* we now know the port at which the member (CallParticipant)
* listens for data.
*/
public void initialize(ConferenceManager conferenceManager, CallHandler callHandler, InetSocketAddress memberAddress, byte mediaPayload, byte telephoneEventPayload) {
this.conferenceManager = conferenceManager;
this.memberAddress = memberAddress;
this.telephoneEventPayload = telephoneEventPayload;
this.callHandler = callHandler;
Logger.writeFile("Call " + cp + " MemberSender initialization started ..." + cp.getProtocol());
conferenceMediaInfo = conferenceManager.getMediaInfo();
outSampleRate = conferenceMediaInfo.getSampleRate();
outChannels = conferenceMediaInfo.getChannels();
try {
myMediaInfo = SdpManager.findMediaInfo(mediaPayload);
} catch (ParseException e) {
Logger.println("Call " + cp + " Invalid mediaPayload " + mediaPayload);
callHandler.cancelRequest("Invalid mediaPayload " + mediaPayload);
return;
}
int inSampleRate = myMediaInfo.getSampleRate();
int inChannels = myMediaInfo.getChannels();
/*
* No data is ever sent to an input treatment unless it's a recorder
*/
if (cp.getInputTreatment() == null || cp.isRecorder() == true) {
if (inSampleRate != outSampleRate || inChannels != outChannels) {
Logger.println("Call " + cp + " resample data to send from " + inSampleRate + "/" + inChannels + " to " + outSampleRate + "/" + outChannels);
try {
outSampleRateConverter = new SampleRateConverter(this.toString(), outSampleRate, outChannels, inSampleRate, inChannels);
} catch (IOException e) {
callHandler.cancelRequest(e.getMessage());
return;
}
}
}
senderPacket = new RtpSenderPacket(myMediaInfo.getEncoding(), inSampleRate, inChannels);
if (myMediaInfo.getEncoding() == RtpPacket.SPEEX_ENCODING) {
try {
speexEncoder = new SpeexEncoder(inSampleRate, inChannels);
Logger.println("Call " + cp + " created SpeexEncoder");
} catch (SpeexException e) {
Logger.println("Call " + cp + " Speex initialization for encoding failed: " + e.getMessage());
callHandler.cancelRequest(e.getMessage());
return;
}
}
if (myMediaInfo.getEncoding() == RtpPacket.PCM_ENCODING) {
try {
opusEncoder = Opus.encoder_create(opusSampleRate, opusChannels);
if (opusEncoder == 0) {
Logger.println("Call " + cp + " OPUS encoder creation error ");
callHandler.cancelRequest("OPUS encoder creation error ");
return;
}
} catch (Exception e) {
e.printStackTrace();
}
}
initializationDone = true;
Logger.writeFile("Call " + cp + " MemberSender initialization done...");
}
use of com.sun.voip.SpeexEncoder in project Openfire by igniterealtime.
the class MemberSender method speexEncode.
public void speexEncode(int[] intData, byte[] byteData) throws SpeexException {
if (speexEncoder == null) {
speexEncoder = new SpeexEncoder(myMediaInfo.getSampleRate(), myMediaInfo.getChannels());
Logger.println("Call " + cp + " created SpeexEncoder");
}
speexEncoder.encode(intData, byteData, RtpPacket.HEADER_SIZE);
}
Aggregations