Build an SDP description for a media channel.

@param channel
The channel to read information from
@return The SDP media description
505621
public static MediaDescriptionField buildMediaDescription(MediaChannel channel, boolean offer) {
		MediaDescriptionField md = new MediaDescriptionField();
		
		md.setMedia(channel.getMediaType());
		md.setPort(channel.getRtpPort());
		MediaProfile profile = channel.isDtlsEnabled() ? MediaProfile.RTP_SAVPF : MediaProfile.RTP_AVP;
		md.setProtocol(profile.getProfile());
        final String externalAddress = channel.getExternalAddress() == null || channel.getExternalAddress().isEmpty() ? null : channel.getExternalAddress();
        md.setConnection(new ConnectionField("IN", "IP4", externalAddress != null ? externalAddress : channel.getRtpAddress()));
		md.setPtime(new PacketTimeAttribute(20));
        md.setRtcp(new RtcpAttribute(channel.getRtcpPort(), "IN", "IP4", externalAddress != null ? externalAddress : channel.getRtcpAddress()));
		if (channel.isRtcpMux()) {
			md.setRtcpMux(new RtcpMuxAttribute());
		}
		
		// ICE attributes
		if (channel.isIceEnabled()) {
			md.setIceUfrag(new IceUfragAttribute(channel.getIceUfrag()));
			md.setIcePwd(new IcePwdAttribute(channel.getIcePwd()));
			
			// Fix connection address based on default (only) candidate
            md.getConnection().setAddress(externalAddress != null ? externalAddress : channel.getRtpAddress());
			md.setPort(channel.getRtpPort());
			
			// Fix RTCP if rtcp-mux is used
			if(channel.isRtcpMux()) {
                md.getRtcp().setAddress(externalAddress != null ? externalAddress : channel.getRtpAddress());
			    md.getRtcp().setPort(channel.getRtpPort());
			}
			
			// Add HOST candidate
			md.addCandidate(processHostCandidate(channel, IceComponent.RTP_ID));
			if(!channel.isRtcpMux()) {
			    md.addCandidate(processHostCandidate(channel, IceComponent.RTCP_ID));
			}
			
			if(channel.getExternalAddress() != null && !channel.getExternalAddress().isEmpty()) {
			    // Add SRFLX candidate
			    md.addCandidate(processSrflxCandidate(channel, IceComponent.RTP_ID));
			    if(!channel.isRtcpMux()) {
			        md.addCandidate(processSrflxCandidate(channel, IceComponent.RTCP_ID));
			    }
			}
			
//			List<LocalCandidateWrapper> rtpCandidates = channel.getRtpCandidates();
//			if(!rtpCandidates.isEmpty()) {
//				// Fix connection address based on default candidate
//				IceCandidate defaultCandidate = channel.getDefaultRtpCandidate().getCandidate();
//				md.getConnection().setAddress(defaultCandidate.getHostString());
//				md.setPort(defaultCandidate.getPort());
//				
//				// Fix RTCP if rtcp-mux is used
//				if(channel.isRtcpMux()) {
//					md.getRtcp().setAddress(defaultCandidate.getHostString());
//					md.getRtcp().setPort(defaultCandidate.getPort());
//				}
//				
//				// Add candidates list for ICE negotiation
//				for (LocalCandidateWrapper candidate : rtpCandidates) {
//					md.addCandidate(processCandidate(candidate.getCandidate()));
//				}
//			}
			
//			if (!channel.isRtcpMux()) {
//				List<LocalCandidateWrapper> rtcpCandidates = channel.getRtcpCandidates();
//				
//				if(!rtcpCandidates.isEmpty()) {
//					// Fix RTCP based on default RTCP candidate
//					IceCandidate defaultCandidate = channel.getDefaultRtcpCandidate().getCandidate();
//					md.getRtcp().setAddress(defaultCandidate.getHostString());
//					md.getRtcp().setPort(defaultCandidate.getPort());
//					
//					// Add candidates list for ICE negotiation
//					for (LocalCandidateWrapper candidate : rtcpCandidates) {
//						md.addCandidate(processCandidate(candidate.getCandidate()));
//					}
//				}
//			}
		}

		// Media formats
		RTPFormat[] negotiatedFormats = channel.getFormats().toArray();
		for (int index = 0; index < negotiatedFormats.length; index++) {
			RTPFormat f = negotiatedFormats[index];
			// Fixes #61 - MMS SDP offer should offer only 101 telephone-event
			if(offer && AVProfile.isDtmf(f) && !AVProfile.isDefaultDtmf(f)) {
			    continue;
			}
			RtpMapAttribute rtpMap = new RtpMapAttribute();
			rtpMap.setPayloadType(f.getID());
			rtpMap.setCodec(f.getFormat().getName().toString());
			rtpMap.setClockRate(f.getClockRate());
			
			switch (channel.getMediaType()) {
			case AudioChannel.MEDIA_TYPE:
				AudioFormat audioFormat = (AudioFormat) f.getFormat();

				if (audioFormat.getChannels() > 1) {
					rtpMap.setCodecParams(audioFormat.getChannels());
				}
				
				if (audioFormat.getOptions() != null) {
					rtpMap.setParameters(new FormatParameterAttribute(f.getID(), audioFormat.getOptions().toString()));
				}
				break;

			default:
				throw new IllegalArgumentException("Media type " + channel.getMediaType() + " not supported.");
			}
			
			md.addPayloadType(String.valueOf(f.getID()));
			md.addFormat(rtpMap);
		}

		// DTLS attributes
		if (channel.isDtlsEnabled()) {
			md.setSetup(new SetupAttribute(offer ? SetupAttribute.ACTPASS : SetupAttribute.PASSIVE));
			String fingerprint = channel.getDtlsFingerprint();
			int whitespace = fingerprint.indexOf(" ");
			String fingerprintHash = fingerprint.substring(0, whitespace);
			String fingerprintValue = fingerprint.substring(whitespace + 1);
			md.setFingerprint(new FingerprintAttribute(fingerprintHash, fingerprintValue));
		}
		
		md.setConnectionMode(new ConnectionModeAttribute(ConnectionModeAttribute.SENDRECV));
		SsrcAttribute ssrcAttribute = new SsrcAttribute(Long.toString(channel.getSsrc()));
		ssrcAttribute.addAttribute("cname", channel.getCname());
		md.setSsrc(ssrcAttribute);
		
		return md;
	}
425047
public static String getDescription(String symbol)
    {
        CharInfo info = (CharInfo) fSymbolMap.get(symbol);
        return (info != null) ? info.fDescription : null;
    }
954782
public ChannelSftp getSftpChannel() throws SftpException {

    try {
      ChannelSftp channelSftp = (ChannelSftp) this.session.openChannel("sftp");
      channelSftp.connect();
      return channelSftp;
    } catch (JSchException e) {
      throw new SftpException(0, "Cannot open a channel to SFTP server", e);
    }
  }
206420
public ServerUpdater setVoiceChannel(User user, ServerVoiceChannel channel) {
        delegate.setVoiceChannel(user, channel);
        return this;
    }
477683
public void init(ChannelSftp channel, Charset charset) {
		this.charset = charset;
		try {
			channel.setFilenameEncoding(charset.toString());
		} catch (SftpException e) {
			throw new JschRuntimeException(e);
		}
		this.channel = channel;
	}
1236107
public synchronized Channel findOrCreateChannel(ChannelData channelData) throws ChannelException {
        String channelName = channelData.getName();
        Channel ret = this.existingChannels.get(channelName);
        if (ret == null) {
            // Create the new channel with the input configuration
            ret = new JFapChannelInbound(_channelFactoryData, channelData);
            this.existingChannels.put(channelName, ret);
        }
        return ret;
    }
146860
public RTPFormats negotiateAudio(SessionDescription sdp, RTPFormats formats) {
    	this.audio.clean();
    	MediaDescriptorField descriptor = sdp.getAudioDescriptor();
    	descriptor.getFormats().intersection(formats, this.audio);
    	return this.audio;
    }
1369499
@Process(actionType = ReadConfig.class)
    public void readConfig(final ReadConfig action, final Dispatcher.Channel channel) {
        readConfig(action.getAddressTemplate(), channel);
    }
1039375
public static ChannelFramework getFramework() {
        final CHFWBundle chfw = getCHFWBundle();
        if (null == chfw) {
            return ChannelFrameworkFactory.getChannelFramework();
        }
        return chfw.getFramework();
    }
1121045
public static channel[] get(nitro_service service) throws Exception{
		channel obj = new channel();
		channel[] response = (channel[])obj.get_resources(service);
		return response;
	}
1199730
public static FastByteArrayOutputStream read(ReadableByteChannel channel) throws IORuntimeException {
		final FastByteArrayOutputStream out = new FastByteArrayOutputStream();
		copy(channel, Channels.newChannel(out));
		return out;
	}
1183073
public void addChannel(WebSocketChannel channel) {
        Objects.requireNonNull(channel, Required.CHANNEL.toString());

        final String url = RequestUtils.getWebSocketURL(channel);
        Set<WebSocketChannel> channels = getChannels(url);
        if (channels == null) {
            channels = new HashSet<>();
            channels.add(channel);
        } else {
            channels.add(channel);
        }
        setChannels(url, channels);
    }
829993
public GrpcChannelBuilder setChannelType(Class<? extends io.netty.channel.Channel> channelType) {
    mChannelKey.setChannelType(channelType);
    return this;
  }
680997
protected Object decode(ChannelHandlerContext channelHandlerContext, Channel channel, ChannelBuffer channelBuffer) throws Exception {
        // Wait until the length prefix is available.
        if (channelBuffer.readableBytes() < 4) {
            // If null is returned, it means there is not enough data yet.
            // FrameDecoder will call again when there is a sufficient amount of data available.
            return null;
        }

        //marking the current reading position
        channelBuffer.markReaderIndex();

        //get the fragment size and wait until the entire fragment is available.
        long fragSize = channelBuffer.readUnsignedInt();
        boolean lastFragment = RecordMarkingUtil.isLastFragment(fragSize);
        fragSize = RecordMarkingUtil.maskFragmentSize(fragSize);
        if (channelBuffer.readableBytes() < fragSize) {
            channelBuffer.resetReaderIndex();
            return null;
        }

        //seek to the beginning of the next fragment
        channelBuffer.skipBytes((int) fragSize);

        _recordLength += 4 + (int) fragSize;

        //check the last fragment
        if (!lastFragment) {
            //not the last fragment, the data is put in an internally maintained cumulative buffer
            return null;
        }

        byte[] rpcResponse = new byte[_recordLength];
        channelBuffer.readerIndex(channelBuffer.readerIndex() - _recordLength);
        channelBuffer.readBytes(rpcResponse, 0, _recordLength);

        _recordLength = 0;
        return rpcResponse;
    }
627104
public Channel getChannel(int channelId) {
        Channel channel = channels.putIfAbsent(channelId, new Channel(this, channelId));
        if (channel == null) {
            channel = channels.get(channelId);
        }
        return channel;
    }
1144055
@NotNull
    @ObjectiveCName("createChannelWithTitle:withAvatar:")
    public Promise<Integer> createChannel(String title, String avatarDescriptor) {
        return modules.getGroupsModule().createChannel(title, avatarDescriptor);
    }
1081120
protected Channel createChannel() throws IOException {
        LOGGER.debug("Creating channel");
        Connection connection = connectionFactory.newConnection();
        Channel channel = connection.createChannel();
        LOGGER.debug("Created channel");
        return channel;
    }