use of com.sun.voip.SdpInfo in project Openfire by igniterealtime.
the class SipUtil method getUserNameFromSdp.
public static String getUserNameFromSdp(Request request) {
byte[] rawContent = request.getRawContent();
if (rawContent == null) {
return null;
}
String sdpBody = new String(rawContent);
SdpInfo sdpInfo;
try {
sdpInfo = SdpManager.parseSdp(sdpBody);
} catch (ParseException e) {
return null;
}
return sdpInfo.getUserName();
}
use of com.sun.voip.SdpInfo in project Openfire by igniterealtime.
the class SipIncomingCallAgent method answerCall.
public void answerCall(RequestEvent requestEvent) {
setState(CallState.INVITED);
Request request = requestEvent.getRequest();
FromHeader fromHeader = (FromHeader) request.getHeader(FromHeader.NAME);
ToHeader toHeader = (ToHeader) request.getHeader(ToHeader.NAME);
String from = fromHeader.getAddress().toString();
String to = toHeader.getAddress().toString();
Logger.println("SipIncomingCallAgent: Accept call " + from + " to " + to);
Logger.writeFile(request.toString());
try {
SdpInfo sdpInfo = processSdp(request);
st = requestEvent.getServerTransaction();
if (st == null) {
st = SipServer.getSipProvider().getNewServerTransaction(request);
}
InetSocketAddress isa = callHandler.getReceiveAddress();
if (isa == null) {
Logger.println("SipIncomingCallAgent: can't get receiver socket!");
terminateCall();
return;
}
setState(CallState.ANSWERED);
if (Logger.logLevel >= Logger.LOG_SIP) {
Logger.println("SipIncomingCallAgent: sending ok");
}
sipUtil.sendOkWithSdp(request, st, isa, sdpInfo);
} catch (Exception e) {
Logger.println("SipIncomingCallAgent: " + request);
e.printStackTrace();
terminateCall();
}
}
use of com.sun.voip.SdpInfo in project Openfire by igniterealtime.
the class SipTPCCallAgent method handleReInvite.
private void handleReInvite(Request request, ServerTransaction st) {
Logger.println("Call " + cp + " Re-INVITE\n" + request);
if (request.getRawContent() == null) {
Logger.error("Call " + cp + " no SDP in INVITE Request!");
return;
}
String sdpBody = new String(request.getRawContent());
SdpInfo sdpInfo;
try {
sdpInfo = sipUtil.getSdpInfo(sdpBody);
} catch (ParseException e) {
Logger.error("Call " + cp + " invalid SDP in re-INVITE Request! " + e.getMessage());
return;
}
MediaInfo mediaInfo = sdpInfo.getMediaInfo();
InetSocketAddress isa = new InetSocketAddress(sdpInfo.getRemoteHost(), sdpInfo.getRemotePort());
InetSocketAddress rtcpAddress = sdpInfo.getRtcpAddress();
setEndpointAddress(isa, mediaInfo.getPayload(), sdpInfo.getTransmitMediaInfo().getPayload(), sdpInfo.getTelephoneEventPayload(), rtcpAddress);
isa = callHandler.getReceiveAddress();
try {
sipUtil.sendOkWithSdp(request, st, isa, sdpInfo);
} catch (Exception e) {
Logger.println("Call " + cp + " Failed to send ok with sdp for re-invite " + e.getMessage());
return;
}
}
use of com.sun.voip.SdpInfo in project Openfire by igniterealtime.
the class NSIncomingCallAgent method initiateCall.
public void initiateCall() {
setState(CallState.INVITED);
CallParticipant cp = callHandler.getCallParticipant();
String remoteMediaInfo = cp.getRemoteMediaInfo();
if (Logger.logLevel >= Logger.LOG_MOREINFO) {
Logger.println("Call " + cp + ": NSIncomingCallAgent remoteMediaInfo " + remoteMediaInfo);
}
String[] tokens = remoteMediaInfo.split("\\+");
/*
* The remote media info is the SDP info but instead of
* new line as the separator, it has "+".
* Reformat the SDP with \r\n.
*/
String sdp = "";
for (int i = 0; i < tokens.length; i++) {
sdp += tokens[i] + "\r\n";
}
if (Logger.logLevel >= Logger.LOG_MOREINFO) {
Logger.println("Call " + cp + ": NSIncomingCallAgent Sdp\n" + sdp);
}
SdpInfo sdpInfo = null;
try {
sdpInfo = sipUtil.getSdpInfo(sdp, true);
String remoteHost = sdpInfo.getRemoteHost();
int remotePort = sdpInfo.getRemotePort();
Logger.println("Call " + cp + ": NSIncomingCallAgent: remote socket " + remoteHost + " " + remotePort + " mediaInfo " + sdpInfo.getMediaInfo());
InetSocketAddress isa = new InetSocketAddress(remoteHost, remotePort);
setEndpointAddress(isa, sdpInfo.getMediaInfo().getPayload(), sdpInfo.getTransmitMediaInfo().getPayload(), sdpInfo.getTelephoneEventPayload());
} catch (ParseException e) {
Logger.println("Call " + cp + ": NSIncomingCallAgent couldn't parse sdp");
cancelRequest("NSIncomingCallAgent couldn't parse sdp");
return;
}
setState(CallState.ANSWERED);
setState(CallState.ESTABLISHED);
}
use of com.sun.voip.SdpInfo in project Openfire by igniterealtime.
the class SipUtil method getCallIdFromSdp.
/*
* We add an attribute to the sdp data when we send a request
* to a sip phone number
*/
public static String getCallIdFromSdp(Request request) {
byte[] rawContent = request.getRawContent();
if (rawContent == null) {
return null;
}
String sdpBody = new String(rawContent);
SdpInfo sdpInfo;
try {
sdpInfo = SdpManager.parseSdp(sdpBody);
} catch (ParseException e) {
return null;
}
return sdpInfo.getCallId();
}
Aggregations