Search in sources :

Example 6 with SdpInfo

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();
}
Also used : SdpInfo(com.sun.voip.SdpInfo) ParseException(java.text.ParseException)

Example 7 with SdpInfo

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();
    }
}
Also used : InetSocketAddress(java.net.InetSocketAddress) SdpInfo(com.sun.voip.SdpInfo) ParseException(java.text.ParseException)

Example 8 with SdpInfo

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;
    }
}
Also used : MediaInfo(com.sun.voip.MediaInfo) InetSocketAddress(java.net.InetSocketAddress) SdpInfo(com.sun.voip.SdpInfo) ParseException(java.text.ParseException) IOException(java.io.IOException) InvalidArgumentException(javax.sip.InvalidArgumentException) ParseException(java.text.ParseException)

Example 9 with SdpInfo

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);
}
Also used : CallParticipant(com.sun.voip.CallParticipant) InetSocketAddress(java.net.InetSocketAddress) SdpInfo(com.sun.voip.SdpInfo) ParseException(java.text.ParseException)

Example 10 with SdpInfo

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();
}
Also used : SdpInfo(com.sun.voip.SdpInfo) ParseException(java.text.ParseException)

Aggregations

SdpInfo (com.sun.voip.SdpInfo)11 ParseException (java.text.ParseException)10 InetSocketAddress (java.net.InetSocketAddress)6 MediaInfo (com.sun.voip.MediaInfo)4 CallParticipant (com.sun.voip.CallParticipant)1 IOException (java.io.IOException)1 InvalidArgumentException (javax.sip.InvalidArgumentException)1