本文整理汇总了Java中javax.sdp.Connection类的典型用法代码示例。如果您正苦于以下问题:Java Connection类的具体用法?Java Connection怎么用?Java Connection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Connection类属于javax.sdp包,在下文中一共展示了Connection类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setConnection
import javax.sdp.Connection; //导入依赖的package包/类
/**
* Set the connection data for this entity.
*
* @param conn to set
* @throws SdpException if the parameter is null
*/
public void setConnection(Connection conn) throws SdpException {
if (conn == null) throw new SdpException("The parameter is null");
if (conn instanceof ConnectionField) {
ConnectionField c = (ConnectionField) conn;
connectionImpl = c;
} else
throw new SdpException("Bad implementation class ConnectionField");
}
示例2: setConnection
import javax.sdp.Connection; //导入依赖的package包/类
/**
* Set the connection data for this entity
*
* @param conn to set
* @throws SdpException if the connexion is null
*/
public void setConnection(Connection conn) throws SdpException {
if (conn == null) throw new SdpException("The conn is null");
if (conn instanceof ConnectionField) {
connectionField = (ConnectionField) conn;
} else
throw new SdpException("bad implementation");
}
示例3: generateHoldSdpDescription
import javax.sdp.Connection; //导入依赖的package包/类
/**
* Generates the Hold Description for a Call.
*
* @param setAudio set hold on Audio.
* @param setVideo set hold on Video.
* @param call the call that you want to hold.
* @return SessionDescription of a call.
* @throws MediaException
*/
public SessionDescription generateHoldSdpDescription(boolean setAudio, boolean setVideo, Call call)
throws MediaException {
try {
SessionDescription sessDescr = sdpFactory
.createSessionDescription();
Version v = sdpFactory.createVersion(0);
InetSocketAddress publicAudioAddress = NetworkAddressManager
.getPublicAddressFor(((MediaDescription) (call.getLocalSdpDescription().getMediaDescriptions(true).get(0))).getMedia().getMediaPort());
InetAddress publicIpAddress = publicAudioAddress.getAddress();
String addrType = publicIpAddress instanceof Inet6Address ? "IP6"
: "IP4";
Origin o = sdpFactory.createOrigin(SIPConfig.getUserName()
.replace(' ', '_'), 20109217, 2, "IN", addrType,
publicIpAddress.getHostAddress());
SessionName s = sdpFactory.createSessionName("<SparkPhone>");
Connection c = sdpFactory.createConnection("IN", addrType,
publicIpAddress.getHostAddress());
TimeDescription t = sdpFactory.createTimeDescription();
Vector<TimeDescription> timeDescs = new Vector<TimeDescription>();
timeDescs.add(t);
String[] formats = new String[getAudioFormats().size()];
int i = 0;
for (AudioFormat audioFormat : getAudioFormats()) {
formats[i++] = AudioFormatUtils.findCorrespondingSdpFormat(audioFormat.getEncoding());
}
MediaDescription am = sdpFactory.createMediaDescription(
"audio", publicAudioAddress.getPort(), 1, "RTP/AVP",
formats);
am.setAttribute(setAudio ? "sendonly" : "sendrecv", null);
am.setAttribute("rtmap:101", "telephone-event/"
+ publicAudioAddress.getPort());
Vector<MediaDescription> mediaDescs = new Vector<MediaDescription>();
mediaDescs.add(am);
sessDescr.setVersion(v);
sessDescr.setOrigin(o);
sessDescr.setConnection(c);
sessDescr.setSessionName(s);
sessDescr.setTimeDescriptions(timeDescs);
if (mediaDescs.size() > 0)
sessDescr.setMediaDescriptions(mediaDescs);
return sessDescr;
}
catch (SdpException exc) {
throw new MediaException(
"An SDP exception occurred while generating local sdp description",
exc);
}
}
示例4: getConnection
import javax.sdp.Connection; //导入依赖的package包/类
/**
* Returns the connection information associated with this object. This may be null for
* SessionDescriptions if all Media objects have a connection object and may be null for Media
* objects if the corresponding session connection is non-null.
*
* @return connection
*/
public Connection getConnection() {
return connectionImpl;
}
示例5: getConnection
import javax.sdp.Connection; //导入依赖的package包/类
/**
* Returns the connection information associated with this object. This may be null for
* SessionDescriptions if all Media objects have a connection object and may be null for Media
* objects if the corresponding session connection is non-null.
*
* @return connection
*/
public Connection getConnection() {
return connectionField;
}