本文整理汇总了Java中javax.sdp.SessionDescription类的典型用法代码示例。如果您正苦于以下问题:Java SessionDescription类的具体用法?Java SessionDescription怎么用?Java SessionDescription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SessionDescription类属于javax.sdp包,在下文中一共展示了SessionDescription类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: startConversation
import javax.sdp.SessionDescription; //导入依赖的package包/类
void startConversation(Message response,
Transaction clientTransaction) throws SipException,
SdpParseException, SdpException, IOException,
NoDataSourceException, NoProcessorException, InterruptedException,
NotConfiguredError, NotRealizedError, NoDataSinkException,
InvalidSessionAddressException, UnknownHostException {
System.out.println("Starting conversation");
String sdpData = new String(response.getRawContent());
SdpFactory sdpFactory = new SdpFactory();
SessionDescription sessionDescription = sdpFactory
.createSessionDescription(sdpData);
Vector mediaDescriptions = sessionDescription
.getMediaDescriptions(true);
for (int mdNum = 0; mdNum < mediaDescriptions.size(); mdNum++) {
MediaDescription mediaDescription = (MediaDescription) mediaDescriptions
.elementAt(mdNum);
Media media = mediaDescription.getMedia();
String proto = media.getProtocol();
String type = media.getMediaType();
int port = media.getMediaPort();
Vector formats = media.getMediaFormats(true);
if (formats.size() < 1) {
BrokerFactory.getLoggingBroker().logWarn(
"In SIP outbound call: No audio formats");
}
int sdpFormat = SdpConstants.PCMU;
try {
sdpFormat = Integer.parseInt((String) formats.elementAt(0));
} catch (NumberFormatException nfExc) {
nfExc.printStackTrace();
}
startReceiver(localMediaPort);
transmitter = new RtpTransmitter(remoteHost, port, sdpFormat);
}
}
开发者ID:davidrudder23,项目名称:OpenNotification,代码行数:40,代码来源:SipInboundCall.java
示例2: handleAnswerRequest
import javax.sdp.SessionDescription; //导入依赖的package包/类
/**
* Handle a answer request
*/
public boolean handleAnswerRequest(Interlocutor interlocutor) {
// cancel call request if no Media Locator
if (PhoneManager.isUseStaticLocator() && PhoneManager.isUsingMediaLocator()) {
return false;
}
PhoneManager.setUsingMediaLocator(true);
SessionDescription sdpData = null;
try {
sdpData = mediaManager.generateSdpDescription();
interlocutor.getCall().setLocalSdpDescription(sdpData);
}
catch (MediaException ex) {
try {
sipManager.sendServerInternalError(interlocutor.getID());
}
catch (CommunicationsException ex1) {
Log.error("handleAnswerRequest", ex1);
}
return false;
}
try {
sipManager.answerCall(interlocutor.getID(), sdpData.toString());
}
catch (CommunicationsException exc) {
Log.error("handleAnswerRequest", exc);
return false;
}
return true;
}
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:36,代码来源:SoftPhoneManager.java
示例3: handleDialRequest
import javax.sdp.SessionDescription; //导入依赖的package包/类
/**
* Handle a dial request
*/
public void handleDialRequest(String phoneNumber) {
try {
System.err.println("Audio Static:" + PhoneManager.isUseStaticLocator() + " Using:" + PhoneManager.isUsingMediaLocator());
// cancel call request if no Media Locator
if (PhoneManager.isUseStaticLocator() && PhoneManager.isUsingMediaLocator()) {
return;
}
PhoneManager.setUsingMediaLocator(true);
SessionDescription sdpData = mediaManager.generateSdpDescription();
Call call = sipManager.establishCall(phoneNumber, sdpData.toString());
if (call == null) return;
call.setLocalSdpDescription(sdpData);
call.addStateChangeListener(this);
Interlocutor interlocutor = new Interlocutor();
interlocutor.setCall(call);
guiManager.addInterlocutor(interlocutor);
}
catch (Exception e) {
Log.error("handleDialRequest", e);
}
}
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:34,代码来源:SoftPhoneManager.java
示例4: handleOffer
import javax.sdp.SessionDescription; //导入依赖的package包/类
/**
*
* @param offer the received offer
* @return The answer to respond with.
*/
public Answer handleOffer(Offer offer) throws Exception {
String fingerPrint = CertUtil.getCertFingerPrint(
keyStoreInfo.getFilePath(),
keyStoreInfo.getAlias(),
keyStoreInfo.getPassword());
SessionDescription sdp = offer.getSdp();
sdp.setAttribute("fingerprint", fingerPrint);
MediaDescription med = (MediaDescription)sdp.getMediaDescriptions(true).get(0);
med.setAttribute("fingerprint", fingerPrint);
String pwd = med.getAttribute("ice-pwd");
String user = med.getAttribute("ice-ufrag");
String cand = med.getAttribute("candidate");
List<String> candData = Arrays.asList(cand.split(" "));
String ip = candData.get(4);
String port = candData.get(5);
this.setRemote(new UserData(user,pwd));
/**
* TODO The below should be defined outside PeerConnection
*
* This is a huge hack now. Should follow browser API
* and create datachannel from the outside.
*/
DataChannelImpl conn = new DataChannelImpl(this);
//Add handling of input
conn.onOpen(() -> {
logger.info("Running onOpen");
conn.send("I'M SO OPEN!!!");
});
conn.onMessage((i)->{
String in = new String(i.getData());
//logger.info("Running onMessage: " + in);
conn.send("ECHO: " + in);
});
conn.onError((i)->{
logger.info("Received error",i.getError());
});
new Thread(conn).start();
String localAddress = InetAddress.getLocalHost().getHostAddress();
String address = System.getProperty("com.bitbreeds.ip",localAddress);
logger.info("Adr: {}", address);
med.setAttribute("ice-pwd",local.getPassword());
med.setAttribute("ice-ufrag",local.getUserName());
med.setAttribute("candidate","1 1 UDP 2122252543 "+address+" "+conn.getPort()+" typ host");
return new Answer(sdp);
}
开发者ID:IIlllII,项目名称:bitbreeds-webrtc,代码行数:62,代码来源:PeerConnection.java
示例5: Offer
import javax.sdp.SessionDescription; //导入依赖的package包/类
public Offer(SessionDescription sdp) {
this.sdp = sdp;
}
开发者ID:IIlllII,项目名称:bitbreeds-webrtc,代码行数:4,代码来源:Offer.java
示例6: getSdp
import javax.sdp.SessionDescription; //导入依赖的package包/类
public SessionDescription getSdp() {
return sdp;
}
开发者ID:IIlllII,项目名称:bitbreeds-webrtc,代码行数:4,代码来源:Offer.java
示例7: Answer
import javax.sdp.SessionDescription; //导入依赖的package包/类
public Answer(SessionDescription sdp) {
this.sdp = sdp;
}
开发者ID:IIlllII,项目名称:bitbreeds-webrtc,代码行数:4,代码来源:Answer.java
示例8: getAudioData
import javax.sdp.SessionDescription; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public final ArrayList<AudioData> getAudioData()
{
if (getMessage().getRawContent() == null)
return null;
ArrayList<AudioData> list = new ArrayList<AudioData>();
String content = new String(getMessage().getRawContent());
logger.debug("content=<" + content + ">");
try {
SessionDescription sdp = sdpFactory.createSessionDescription(content);
String ipAddy = sdp.getConnection().getAddress();
Vector<MediaDescriptionImpl> descriptors = (Vector<MediaDescriptionImpl>)sdp.getMediaDescriptions(true);
Iterator<MediaDescriptionImpl> it = descriptors.iterator();
while (it.hasNext()) {
MediaDescriptionImpl mediaDescription = it.next();
MediaField field = mediaDescription.getMediaField();
if (field == null) {
logger.warn("Missing media field");
continue;
}
AudioData audio = new AudioData();
audio.ipAddy = ipAddy;
audio.rtpPort = field.getPort();
Vector formats = field.getFormats();
if (formats == null) {
list.add(audio);
continue;
}
if (formats.size() < 1) {
list.add(audio);
continue;
}
audio.payloadType = (String) field.getFormats().get(0);
Vector attributes = mediaDescription.getAttributeFields();
if (attributes == null) {
list.add(audio);
continue;
}
Iterator ait = attributes.iterator();
while (ait.hasNext()) {
Object objay = ait.next();
if (! (objay instanceof AttributeField))
continue;
AttributeField afield = (AttributeField)objay;
if (! "rtpmap".equals(afield.getName()))
continue;
String [] parsed = afield.getValue().split("[ /]");
if (parsed.length < 3)
continue;
if (! parsed[0].equals(audio.payloadType))
continue;
audio.payloadDescription = parsed[1];
audio.sampleRate = parsed[2];
}
list.add(audio);
logger.info(getCallId() + " audio=" + audio.toString());
}
return list;
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
开发者ID:lmangani,项目名称:Reaper,代码行数:65,代码来源:SipMessage.java
示例9: startConversation
import javax.sdp.SessionDescription; //导入依赖的package包/类
/**
* @param response
* @param clientTransaction
* @throws SipException
* @throws SdpParseException
* @throws SdpException
* @throws IOException
* @throws NoDataSourceException
* @throws NoProcessorException
* @throws InterruptedException
* @throws NotConfiguredError
* @throws NotRealizedError
* @throws NoDataSinkException
* @throws InvalidSessionAddressException
* @throws UnknownHostException
*/
void startConversation(Message response,
Transaction clientTransaction) throws SipException,
SdpParseException, SdpException, IOException,
NoDataSourceException, NoProcessorException, InterruptedException,
NotConfiguredError, NotRealizedError, NoDataSinkException,
InvalidSessionAddressException, UnknownHostException {
System.out.println("Starting conversation");
String sdpData = new String(response.getRawContent());
SdpFactory sdpFactory = new SdpFactory();
SessionDescription sessionDescription = sdpFactory
.createSessionDescription(sdpData);
Vector mediaDescriptions = sessionDescription
.getMediaDescriptions(true);
BrokerFactory.getLoggingBroker().logDebug("We have "+mediaDescriptions.size()+" media descriptions");
for (int mdNum = 0; mdNum < mediaDescriptions.size(); mdNum++) {
MediaDescription mediaDescription = (MediaDescription) mediaDescriptions
.elementAt(mdNum);
Media media = mediaDescription.getMedia();
String proto = media.getProtocol();
String type = media.getMediaType();
int port = media.getMediaPort();
Vector formats = media.getMediaFormats(true);
if (formats.size() < 1) {
BrokerFactory.getLoggingBroker().logWarn(
"In SIP outbound call: No audio formats");
}
int sdpFormat = SdpConstants.PCMU;
try {
sdpFormat = Integer.parseInt((String) formats.elementAt(0));
} catch (NumberFormatException nfExc) {
nfExc.printStackTrace();
}
transmitter = new RtpTransmitter(remoteHost, port, sdpFormat);
startReceiver(remoteHost, port);
BrokerFactory.getLoggingBroker().logDebug("Starting transmitter");
transmitter = new RtpTransmitter(remoteHost, port, sdpFormat);
BrokerFactory.getLoggingBroker().logDebug("transmitter="+transmitter);
}
}
开发者ID:davidrudder23,项目名称:OpenNotification,代码行数:61,代码来源:SipOutboundCall.java
示例10: generateHoldSdpDescription
import javax.sdp.SessionDescription; //导入依赖的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);
}
}
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:68,代码来源:JmfMediaManager.java
示例11: getLocalSdpDescription
import javax.sdp.SessionDescription; //导入依赖的package包/类
public SessionDescription getLocalSdpDescription() {
return localSdpDescription;
}
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:4,代码来源:Call.java
示例12: setLocalSdpDescription
import javax.sdp.SessionDescription; //导入依赖的package包/类
public void setLocalSdpDescription(SessionDescription localSdpDescription) {
this.localSdpDescription = localSdpDescription;
}
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:4,代码来源:Call.java
示例13: hold
import javax.sdp.SessionDescription; //导入依赖的package包/类
public void hold(int callID, SessionDescription sdp, boolean mic, boolean cam)
throws CommunicationsException {
callProcessing.hold(callID, sdp.toString());
callProcessing.callDispatcher.getCall(callID).onHoldMic(mic);
callProcessing.callDispatcher.getCall(callID).onHoldCam(cam);
}
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:7,代码来源:SipManager.java
示例14: setRemoteSdpDescription
import javax.sdp.SessionDescription; //导入依赖的package包/类
/**
* Set remote SDP Description of this call
*
* @param data the remoteSdpDescription to set.
*/
void setRemoteSdpDescription(SessionDescription data) {
this.remoteSdpDescription = data;
}
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:9,代码来源:Call.java
示例15: getRemoteSdpDescription
import javax.sdp.SessionDescription; //导入依赖的package包/类
/**
* Get remote SDP Description of this call
*
* @return Returns the remoteSdpDescription.
*/
public SessionDescription getRemoteSdpDescription() {
return remoteSdpDescription;
}
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:9,代码来源:Call.java
注:本文中的javax.sdp.SessionDescription类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论