Reads the remote SDP answer and sets up the proper media channels.

@param remoteAudio The description of the remote audio channel.

@throws IOException When binding the audio data channel or when failing to negotiate codecs.
491705
private void setupAudioChannelOutbound(MediaDescriptionField remoteAudio) throws IOException {
        // Negotiate audio codecs
        this.audioChannel.negotiateFormats(remoteAudio);
        if (!this.audioChannel.containsNegotiatedFormats()) {
            throw new IOException("Audio codecs were not supported");
        }

        // connect to remote peer - RTP
        String remoteRtpAddress = remoteAudio.getConnection().getAddress();
        int remoteRtpPort = remoteAudio.getPort();

        // only connect is calls are plain old SIP
        // For WebRTC cases, the ICE Agent must connect upon candidate selection
        boolean connectNow = !(this.outbound && audioChannel.isIceEnabled());
        if (connectNow) {
            this.audioChannel.connectRtp(remoteRtpAddress, remoteRtpPort);
            // connect to remote peer - RTCP
            boolean remoteRtcpMux = remoteAudio.isRtcpMux();
            if (remoteRtcpMux) {
                this.audioChannel.connectRtcp(remoteRtpAddress, remoteRtpPort);
            } else {
                RtcpAttribute remoteRtcp = remoteAudio.getRtcp();
                if (remoteRtcp == null) {
                    // No specific RTCP port, so default is RTP port + 1
                    this.audioChannel.connectRtcp(remoteRtpAddress, remoteRtpPort + 1);
                } else {
                    // Specific RTCP address and port contained in SDP
                    String remoteRtcpAddress = remoteRtcp.getAddress();
                    if (remoteRtcpAddress == null) {
                        // address is optional in rtcp attribute
                        // will match RTP address if not defined
                        remoteRtcpAddress = remoteRtpAddress;
                    }
                    int remoteRtcpPort = remoteRtcp.getPort();
                    this.audioChannel.connectRtcp(remoteRtcpAddress, remoteRtcpPort);
                }
            }
        }
    }
1340458
public void setAudioSelectors(java.util.Collection<AudioSelector> audioSelectors) {
        if (audioSelectors == null) {
            this.audioSelectors = null;
            return;
        }

        this.audioSelectors = new java.util.ArrayList<AudioSelector>(audioSelectors);
    }
1360369
protected Channel provideChannel() throws IOException {
        if (channel == null || !channel.isOpen()) {
            Connection connection = connectionFactory.newConnection();
            channel = connection.createChannel();
        }
        return channel;
    }
705050
private void connectCommon(Object _udpRequestContextObject) throws IOException {
        String localAddress = "*";
        int localPort = 0;
        Map<Object, Object> vcStateMap = getVirtualConnection().getStateMap();
        if (vcStateMap != null) {
            //
            // Size of the buffer the channel should use to read.
            //
            String value = (String) vcStateMap.get(UDPConfigConstants.CHANNEL_RCV_BUFF_SIZE);
            if (value != null) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, UDPConfigConstants.CHANNEL_RCV_BUFF_SIZE + " " + value);
                }
                cfg.setChannelReceiveBufferSize(Integer.parseInt(value));
            }
            //
            // Receive buffer size.
            //
            value = (String) vcStateMap.get(UDPConfigConstants.RCV_BUFF_SIZE);
            if (value != null) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, UDPConfigConstants.RCV_BUFF_SIZE + " " + value);
                }
                cfg.setReceiveBufferSize(Integer.parseInt(value));
            }
            //
            // Send buffer size
            //
            value = (String) vcStateMap.get(UDPConfigConstants.SEND_BUFF_SIZE);
            if (value != null) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, UDPConfigConstants.SEND_BUFF_SIZE + " " + value);
                }
                cfg.setSendBufferSize(Integer.parseInt(value));
            }
        }
        //
        // Allow for this to be null. If the requestContext is null, then just
        // allow The NetworkLayer to find the port to listen on.
        //
        if (_udpRequestContextObject != null) {
            final UDPRequestContext udpRequestContext = (UDPRequestContext) _udpRequestContextObject;
            final InetSocketAddress addr = udpRequestContext.getLocalAddress();
            localAddress = addr.getAddress().getHostAddress();
            localPort = addr.getPort();
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "connect with local address: " + localAddress + " local port: " + localPort);
            }
        }

        udpNetworkLayer = new UDPNetworkLayer(udpChannel, workQueueMgr, localAddress, localPort);
        udpNetworkLayer.initDatagramSocket(getVirtualConnection());
        udpNetworkLayer.setConnLink(this);
    }
837589
public void setUpdateChannelConfiguration(byte[] updateChannelConfigurationAsBytes) throws InvalidArgumentException {
        if (updateChannelConfigurationAsBytes == null) {
            throw new InvalidArgumentException("UpdateChannelConfiguration updateChannelConfigurationAsBytes must be non-null");
        }
        logger.trace("Creating setUpdateChannelConfiguration from bytes");
        configBytes = updateChannelConfigurationAsBytes;
    }
524891
@Override
	public void dispatchFromOutputChannel(Envelope envelope) throws IOException, InterruptedException {
		EnvelopeReceiverList receiverList = getReceiverListForEnvelope(envelope, true);

		Buffer srcBuffer = envelope.getBuffer();
		Buffer destBuffer = null;
		
		boolean success = false;
		
		try {
			if (receiverList.hasLocalReceiver()) {
				ChannelID receiver = receiverList.getLocalReceiver();
				Channel channel = this.channels.get(receiver);

				if (channel == null) {
					throw new LocalReceiverCancelledException(receiver);
				}

				if (!channel.isInputChannel()) {
					throw new IOException("Local receiver " + receiver + " is not an input channel.");
				}

				InputChannel<?> inputChannel = (InputChannel<?>) channel;
				
				// copy the buffer into the memory space of the receiver 
				if (srcBuffer != null) {
					try {
						destBuffer = inputChannel.requestBufferBlocking(srcBuffer.size());
					} catch (InterruptedException e) {
						throw new IOException(e.getMessage());
					}

					srcBuffer.copyToBuffer(destBuffer);
					envelope.setBuffer(destBuffer);
					srcBuffer.recycleBuffer();
				}
				
				inputChannel.queueEnvelope(envelope);
				success = true;
			}
			else if (receiverList.hasRemoteReceiver()) {
				RemoteReceiver remoteReceiver = receiverList.getRemoteReceiver();

				// Generate sender hint before sending the first envelope over the network
				if (envelope.getSequenceNumber() == 0) {
					generateSenderHint(envelope, remoteReceiver);
				}

				this.nettyConnectionManager.enqueue(envelope, remoteReceiver);
				success = true;
			}
		} finally {
			if (!success) {
				if (srcBuffer != null) {
					srcBuffer.recycleBuffer();
				}
				if (destBuffer != null) {
					destBuffer.recycleBuffer();
				}
			}
		}
	}
501291
@ObjectiveCName("sendAudioWithPeer:withName:withDuration:withDescriptor:")
    public void sendAudio(@NotNull Peer peer, @NotNull String fileName,
                          int duration, @NotNull String descriptor) {
        modules.getMessagesModule().sendAudio(peer, fileName, duration, descriptor);
    }
101996
private IQ receiveSessionInitiateAction(Jingle jingle, JingleDescription description) {
        IQ response = null;

        List<PayloadType> offeredPayloads = description.getAudioPayloadTypesList();
        bestCommonAudioPt = calculateBestCommonAudioPt(offeredPayloads);

        synchronized (remoteAudioPts) {
            remoteAudioPts.addAll(offeredPayloads);
        }

        // If there are suitable/matching payload types then accept this content.
        if (bestCommonAudioPt != null) {
            // Let the transport negotiators sort-out connectivity and content-accept instead.
            // response = createAudioPayloadTypesOffer();
            setNegotiatorState(JingleNegotiatorState.PENDING);
        } else {
            // Don't really know what to send here.  XEP-166 is not clear.
            setNegotiatorState(JingleNegotiatorState.FAILED);
        }

        return response;
    }
1356654
public T setAudioChannels(int channels) {
    checkArgument(channels > 0, "channels must be positive");
    this.audio_enabled = true;
    this.audio_channels = channels;
    return getThis();
  }
497432
@Trivial
    @Reference(name = "remoteIp",
               service = ChannelConfiguration.class,
               policy = ReferencePolicy.DYNAMIC,
               policyOption = ReferencePolicyOption.GREEDY,
               cardinality = ReferenceCardinality.MANDATORY)
    protected void setRemoteIp(ChannelConfiguration config) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
            Tr.event(this, tc, "set remote ip " + config.getProperty("id"), this);
        }
        this.remoteIpConfig = config;
        if (remoteIpConfig != null) {
            performAction(updateAction);
        }
    }
778516
public void setAudioDecoderConfiguration(IRTMPEvent decoderConfig) {
        if (decoderConfig instanceof IStreamData) {
            IoBuffer data = ((IStreamData<?>) decoderConfig).getData().asReadOnlyBuffer();
            audioConfigurationTag = ImmutableTag.build(decoderConfig.getDataType(), 0, data, 0);
        }
    }
1362284
@Override
    public AudioInputStream getAudioInputStream(URL url) throws UnsupportedAudioFileException, IOException {
        LOG.log(Level.FINE, "getAudioInputStream(URL url)");
        InputStream inputStream = url.openStream();
        try {
            return getAudioInputStream(inputStream);
        } catch (UnsupportedAudioFileException | IOException e) {
            if (inputStream != null) {
                inputStream.close();
            }
            throw e;
        }
    }
1032983
public void connectRtcp(SocketAddress remoteAddress) {
		this.rtcpChannel.setRemotePeer(remoteAddress);
		
		if(logger.isDebugEnabled()) {
			logger.debug(this.mediaType + " RTCP channel " + this.ssrc + " has connected to remote peer " + remoteAddress.toString());
		}
	}
1207161
@Override
    public void initialize() {

        String ip;
        String localIp;
        int localPort;
        int remotePort;

        if (this.getLocal().getSymmetric() != null) {
            ip = this.getLocal().getIp();
            localIp = this.getLocal().getLocalIp();
            localPort = getFreePort();
            remotePort = this.getLocal().getSymmetric().getPort();

            LOGGER.fine(this.getLocal().getConnection() + " " + ip + ": " + localPort + "->" + remotePort);

        }
        else {
            ip = this.getRemote().getIp();
            localIp = this.getLocal().getLocalIp();
            localPort = this.getLocal().getPort();
            remotePort = this.getRemote().getPort();
        }

        try {
            mediaSession = createSession(localIp, localPort, ip, remotePort, this, 2, false, true);
        }
        catch (NoProcessorException e) {
            LOGGER.log(Level.WARNING, "exception", e);
        }
        catch (UnsupportedFormatException e) {
            LOGGER.log(Level.WARNING, "exception", e);
        }
        catch (IOException e) {
            LOGGER.log(Level.WARNING, "exception", e);
        }
        catch (GeneralSecurityException e) {
            LOGGER.log(Level.WARNING, "exception", e);
        }
    }
169837
@Benchmark
	@BenchmarkMode(Mode.AverageTime)
	public void byteBufferFileChannel(final Configuration configuration) throws IOException {
		ByteBuffer buffer = ByteBuffer.allocate(BUFFER_CAPACITY);

		try (RandomAccessFile file = new RandomAccessFile(configuration.file, "rw")) {
			try (FileChannel channel = file.getChannel()) {
				for (long i = 0; i < LINES; ++i) {
					if (buffer.remaining() < DATA.length) {
						buffer.flip();
						channel.write(buffer);
						buffer.clear();
					}

					if (buffer.remaining() < DATA.length) {
						file.write(DATA);
					} else {
						buffer.put(DATA);
					}
				}

				if (buffer.position() > 0) {
					buffer.flip();
					channel.write(buffer);
				}
			}
		}
	}
791969
@Override
	public void addInputChannel(RemoteInputChannel listener) throws IOException {
		checkError();

		inputChannels.putIfAbsent(listener.getInputChannelId(), listener);
	}
331219
public void set(Object data, int iOpenMode) throws DBException, RemoteException
    {
        Record record = this.getMainRecord();
        int iOldOpenMode = record.getOpenMode();
        try   {
            Utility.getLogger().info("EJB Set");
            synchronized (this.getTask())
            {
                record.setOpenMode((iOldOpenMode & ~DBConstants.LOCK_TYPE_MASK) | (iOpenMode & DBConstants.LOCK_TYPE_MASK));  // Use client's lock data
                if (record.getEditMode() == Constants.EDIT_CURRENT)
                    record.edit();
                Record recordBase = record.getTable().getCurrentTable().getRecord();
                int iFieldTypes = this.getFieldTypes(recordBase);
                int iErrorCode = this.moveBufferToFields(data, iFieldTypes, recordBase);
                if (iErrorCode != DBConstants.NORMAL_RETURN)
                    ;   //?
                if (DBConstants.TRUE.equals(record.getTable().getProperty(DBParams.SUPRESSREMOTEDBMESSAGES)))
                    record.setSupressRemoteMessages(true);
                record.getTable().set(recordBase);
            }
        } catch (DBException ex)    {
            throw ex;
        } catch (Exception ex)  {
            ex.printStackTrace();
            throw new DBException(ex.getMessage());
        } finally   {
            record.setSupressRemoteMessages(false);
            this.getMainRecord().setOpenMode(iOldOpenMode);
        }
    }