Search in sources :

Example 1 with InvalidSessionAddressException

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;
}
Also used : PushBufferStream(javax.media.protocol.PushBufferStream) InvalidSessionAddressException(javax.media.rtp.InvalidSessionAddressException) SendStream(javax.media.rtp.SendStream) PushBufferDataSource(javax.media.protocol.PushBufferDataSource) InetAddress(java.net.InetAddress) BufferControl(javax.media.control.BufferControl) SessionAddress(javax.media.rtp.SessionAddress) NoProcessorException(javax.media.NoProcessorException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) InvalidSessionAddressException(javax.media.rtp.InvalidSessionAddressException) UnsupportedPlugInException(javax.media.UnsupportedPlugInException)

Aggregations

IOException (java.io.IOException)1 InetAddress (java.net.InetAddress)1 UnknownHostException (java.net.UnknownHostException)1 NoProcessorException (javax.media.NoProcessorException)1 UnsupportedPlugInException (javax.media.UnsupportedPlugInException)1 BufferControl (javax.media.control.BufferControl)1 PushBufferDataSource (javax.media.protocol.PushBufferDataSource)1 PushBufferStream (javax.media.protocol.PushBufferStream)1 InvalidSessionAddressException (javax.media.rtp.InvalidSessionAddressException)1 SendStream (javax.media.rtp.SendStream)1 SessionAddress (javax.media.rtp.SessionAddress)1