本文整理汇总了Java中javax.sdp.Origin类的典型用法代码示例。如果您正苦于以下问题:Java Origin类的具体用法?Java Origin怎么用?Java Origin使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Origin类属于javax.sdp包,在下文中一共展示了Origin类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setOrigin
import javax.sdp.Origin; //导入依赖的package包/类
/**
* Sets information about the originator of the session. This corresponds to the o= field of the
* SDP data.
*
* @param origin origin - the originator data.
* @throws SdpException if the origin is null
*/
public void setOrigin(Origin origin) throws SdpException {
if (origin == null) throw new SdpException("The parameter is null");
if (origin instanceof OriginField) {
OriginField o = (OriginField) origin;
originImpl = o;
} else
throw new SdpException("The parameter must be an instance of OriginField");
}
示例2: generateHoldSdpDescription
import javax.sdp.Origin; //导入依赖的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);
}
}
示例3: getOrigin
import javax.sdp.Origin; //导入依赖的package包/类
/**
* Returns information about the originator of the session. This corresponds to the o= field of
* the SDP data.
*
* @return the originator data.
*/
public Origin getOrigin() {
return originImpl;
}