use of javax.media.rtp.InvalidSessionAddressException in project Smack by igniterealtime.
the class AudioChannel method createTransmitter.
/**
* Use the RTPManager API to create sessions for each jmf
* track of the processor.
*
* @return description TODO javadoc me please
*/
private String createTransmitter() {
// Cheated. Should have checked the type.
PushBufferDataSource pbds = (PushBufferDataSource) dataOutput;
PushBufferStream[] pbss = pbds.getStreams();
rtpMgrs = new RTPManager[pbss.length];
SessionAddress localAddr, destAddr;
InetAddress ipAddr;
SendStream sendStream;
audioReceiver = new AudioReceiver(this, jingleMediaSession);
int port;
for (int i = 0; i < pbss.length; i++) {
try {
rtpMgrs[i] = RTPManager.newInstance();
port = portBase + 2 * i;
ipAddr = InetAddress.getByName(remoteIpAddress);
localAddr = new SessionAddress(InetAddress.getByName(this.localIpAddress), localPort);
destAddr = new SessionAddress(ipAddr, port);
rtpMgrs[i].addReceiveStreamListener(audioReceiver);
rtpMgrs[i].addSessionListener(audioReceiver);
BufferControl bc = (BufferControl) rtpMgrs[i].getControl("javax.media.control.BufferControl");
if (bc != null) {
int bl = 160;
bc.setBufferLength(bl);
}
try {
rtpMgrs[i].initialize(localAddr);
} catch (InvalidSessionAddressException e) {
// In case the local address is not allowed to read, we user another local address
SessionAddress sessAddr = new SessionAddress();
localAddr = new SessionAddress(sessAddr.getDataAddress(), localPort);
rtpMgrs[i].initialize(localAddr);
}
rtpMgrs[i].addTarget(destAddr);
LOGGER.severe("Created RTP session at " + localPort + " to: " + remoteIpAddress + " " + port);
sendStream = rtpMgrs[i].createSendStream(dataOutput, i);
sendStreams.add(sendStream);
sendStream.start();
} catch (Exception e) {
LOGGER.log(Level.WARNING, "exception", e);
return e.getMessage();
}
}
return null;
}
Aggregations