use of com.sun.voip.SdpInfo in project Openfire by igniterealtime.
the class SipIncomingCallAgent method processSdp.
private SdpInfo processSdp(Request request) throws ParseException {
byte[] rawSdp = request.getRawContent();
if (rawSdp == null) {
return null;
}
String sdpBody = new String(rawSdp);
SdpInfo sdpInfo = sipUtil.getSdpInfo(sdpBody);
String remoteHost = sdpInfo.getRemoteHost();
int remotePort = sdpInfo.getRemotePort();
Logger.println("SipIncomingCallAgent: remote socket " + remoteHost + " " + remotePort);
try {
InetSocketAddress isa = new InetSocketAddress(remoteHost, remotePort);
setEndpointAddress(isa, sdpInfo.getMediaInfo().getPayload(), sdpInfo.getTransmitMediaInfo().getPayload(), sdpInfo.getTelephoneEventPayload());
} catch (Exception e) {
Logger.println("SipIncomingCallAgent: can't create isa");
throw new ParseException("SipIncomingCallAgent: can't create isa", 0);
}
return sdpInfo;
}
use of com.sun.voip.SdpInfo in project Openfire by igniterealtime.
the class SipTPCCallAgent method handleCallParticipantInvited.
/**
* handles the INVITED state.
* @param response the response
* @param clientTransaction the client transaction
* @throws SipException SIP stack related error
*/
private void handleCallParticipantInvited(Response response, ClientTransaction clientTransaction) throws ParseException, SipException, InvalidArgumentException {
FromHeader fromHeader = (FromHeader) response.getHeader(FromHeader.NAME);
String displayName = fromHeader.getAddress().getDisplayName();
int statusCode = response.getStatusCode();
Logger.println("handleCallParticipantInvited " + cp + " status " + statusCode + " " + response.getReasonPhrase());
Logger.println("handleCallParticipantInvited , displayname " + displayName);
CallIdHeader callIdHeader = (CallIdHeader) response.getHeader(CallIdHeader.NAME);
if (sipCallId.equals(callIdHeader.getCallId()) && displayName.equals(cp.getDisplayName()) && (statusCode == Response.OK || statusCode == Response.SESSION_PROGRESS) && ((CSeqHeader) response.getHeader(CSeqHeader.NAME)).getMethod().equals(Request.INVITE)) {
if (statusCode == Response.SESSION_PROGRESS) {
if (cp.getHandleSessionProgress() == false) {
Logger.writeFile("Call " + cp + " Ignoring SESSION_PROGRESS");
return;
}
Logger.writeFile("Call " + cp + " Treating SESSION_PROGRESS as OK");
}
if (response.getRawContent() == null) {
Logger.error("Call " + cp + " no SDP in OK Response!");
cancelRequest("SIP error! no SDP in OK Response!");
return;
}
this.clientTransaction = clientTransaction;
if (statusCode == Response.OK) {
gotOk = true;
Logger.writeFile("Call " + cp + " Got OK, call answered\n" + response);
}
ToHeader toHeader = (ToHeader) response.getHeader(ToHeader.NAME);
if (statusCode == Response.OK) {
sipUtil.sendAck(clientTransaction);
ackSent = true;
}
if (callAnswered) {
Logger.writeFile("Call " + cp + " done processing OK");
return;
}
/*
* Remember the IP and port of where to send data to
* the CallParticipant.
*/
sdpBody = new String(response.getRawContent());
SdpInfo sdpInfo;
try {
sdpInfo = sipUtil.getSdpInfo(sdpBody, false);
} catch (ParseException e) {
Logger.error("Call " + cp + " Invalid SDP in OK Response! " + e.getMessage());
cancelRequest("SIP error! Invalid SDP in OK Response!");
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);
/*
* The CallParticipant has answered.
* If join confirmation is required, we remain in the
* INVITED state. We set the callAnswered flag so that
* if the join confirmation times out we know to
* send a BYE rather than a CANCEL.
*/
callAnswered = true;
if (cp.getJoinConfirmationTimeout() == 0) {
setState(CallState.ANSWERED);
}
/*
* Start treatment if any and wait for it to finish.
* When the treatment finishes, notification will
* be delivered to our parent which will indicate
* we're ready for the conference.
*
* If there's no treatment to be played, we're ready now
* unless we're waiting for join confirmation..
*/
initializeCallAnsweredTreatment();
if (callAnsweredTreatment != null) {
startCallAnsweredTreatment();
} else {
if (cp.getJoinConfirmationTimeout() == 0) {
setState(CallState.ESTABLISHED);
}
}
} else {
Logger.writeFile("Call " + cp + " Ignoring response: " + response.getReasonPhrase());
if (Logger.logLevel >= Logger.LOG_SIP) {
Logger.println("Call " + cp + " Response: " + response);
}
}
}
use of com.sun.voip.SdpInfo in project Openfire by igniterealtime.
the class SipUtil method getSdpInfo.
public SdpInfo getSdpInfo(String sdpBody, boolean isRequest) throws ParseException {
SdpInfo remoteSdpInfo = sdpManager.parseSdp(sdpBody);
MediaInfo myPreferredMediaInfo = sdpManager.getPreferredMediaInfo();
byte payload;
Logger.writeFile("My preferred media " + myPreferredMediaInfo);
/*
* If this is a remote SIP REQUEST and the remote side supports our
* preferred mediaInfo, we will reply selecting our preferred media.
* Otherwise, we reply using the remote's media choice, which is
* either the remote's preferred or the "best" choice.
*/
if (isRequest && remoteSdpInfo.isSupported(myPreferredMediaInfo)) {
payload = myPreferredMediaInfo.getPayload();
remoteSdpInfo.setMediaInfo(myPreferredMediaInfo);
Logger.println("My preferred payload being used " + payload);
} else {
if (isRequest) {
Logger.writeFile("My preferred media " + myPreferredMediaInfo + " not supported...");
}
try {
payload = remoteSdpInfo.getMediaInfo().getPayload();
remoteSdpInfo.setMediaInfo(sdpManager.findMediaInfo(payload));
Logger.writeFile("media setting is " + remoteSdpInfo.getMediaInfo());
} catch (ParseException e) {
remoteSdpInfo.setMediaInfo(new MediaInfo((byte) 0, RtpPacket.PCMU_ENCODING, 8000, 1, false));
}
}
return remoteSdpInfo;
}
use of com.sun.voip.SdpInfo in project Openfire by igniterealtime.
the class SipUtil method getDistributedBridgeFromSdp.
public static boolean getDistributedBridgeFromSdp(Request request) {
byte[] rawContent = request.getRawContent();
if (rawContent == null) {
return false;
}
String sdpBody = new String(rawContent);
SdpInfo sdpInfo;
try {
sdpInfo = SdpManager.parseSdp(sdpBody);
} catch (ParseException e) {
return false;
}
return sdpInfo.isDistributedBridge();
}
use of com.sun.voip.SdpInfo in project Openfire by igniterealtime.
the class NSOutgoingCallAgent method setRemoteMediaInfo.
public void setRemoteMediaInfo(String sdp) throws ParseException {
if (getState() != CallState.INVITED) {
Logger.println("Call " + cp + ": NSOutgoingCallAgent: bad state " + getState());
return;
}
sdp = sdp.replaceAll("\\+", "\r\n");
Logger.println("Call " + cp + ": NSOutgoingCallAgent: remote SDP: " + sdp);
SdpInfo sdpInfo = sipUtil.getSdpInfo(sdp, false);
MediaInfo mediaInfo = sdpInfo.getMediaInfo();
InetSocketAddress isa = new InetSocketAddress(sdpInfo.getRemoteHost(), sdpInfo.getRemotePort());
Logger.println("Call " + cp + ": NSOutgoingCallAgent: " + mediaInfo + " remote " + isa);
setEndpointAddress(isa, mediaInfo.getPayload(), sdpInfo.getTransmitMediaInfo().getPayload(), sdpInfo.getTelephoneEventPayload());
if (callAnswered) {
Logger.writeFile("Call " + cp + ": NSOutgoingCallAgent: done remote SDP");
return;
}
/*
* The CallParticipant has answered.
* If join confirmation is required, we remain in the
* INVITED state.
*/
callAnswered = true;
if (cp.getJoinConfirmationTimeout() == 0) {
setState(CallState.ANSWERED);
}
/*
* Start treatment if any and wait for it to finish.
* When the treatment finishes, notification will
* be delivered to our parent which will indicate
* we're ready for the conference.
*
* If there's no treatment to be played, we're ready now
* unless we're waiting for join confirmation..
*/
initializeCallAnsweredTreatment();
if (callAnsweredTreatment != null) {
startCallAnsweredTreatment();
} else {
if (cp.getJoinConfirmationTimeout() == 0) {
setState(CallState.ESTABLISHED);
}
}
}
Aggregations