Sip Servlet get SDP content

4.5k views Asked by At

I need to extrapolate the SDP from a SIP message in a SIP application. I've tried to do something like:

protected void doInvite(SipServletRequest req) throws ServletException, IOException {
String = req.getContent().toString();
}

But it doesn't return me the SDP. Some advices to solve the problem? Thank you!

3

There are 3 answers

4
jeand On BEST ANSWER

This usually depends on the Content-Type header but given this is an INVITE I'm assuming the Content-Type is application/sdp. If that's the case, did you try the following ?

String sdp = new String(req.getContent())

0
Jue Wang On

I put json text string as sip message content. After I set the request.setContentType("text/json"); in both client and server code, I can get the content json string right.

0
shabby On

But it doesn't return me the SDP. Some advices to solve the problem?

Try the following to get SDP, I am using it to pack SDP in session_progress, in the doInvite method:

@Override
protected void doInvite(SipServletRequest request) throws ServletException, IOException {
    byte[] sdpOffer = request.getRawContent();

    try {
        SipServletResponse response = request.createResponse(SipServletResponse.SC_SESSION_PROGRESS);
        response.setContent(sdpOffer, "application/sdp");
        response.send();
        logger.info("SESSION_PROGRESS sent");
    } catch (Exception exp) {
        logger.error("exception in sending SP", exp);
    }
}

Note: the code is not complete, you need to do other things as well when you are replying with Session_Progress