Sip Servlet获取SDP内容

时间:2015-08-19 10:11:05

标签: java sdp sip-servlet mobicents-sip-servlets

我需要从SIP应用程序中的SIP消息中推断SDP。 我试过做类似的事情:

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

但它并没有让我回归SDP。 有些建议可以解决这个问题吗?谢谢!

3 个答案:

答案 0 :(得分:3)

这通常取决于Content-Type标头,但鉴于这是一个INVITE,我假设Content-Type是application / sdp。如果是这种情况,您是否尝试过以下操作?

  

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

答案 1 :(得分:2)

  

但它并没有让我回归SDP。一些解决问题的建议?

尝试以下方法获取SDP,我在doInvite方法中使用它在session_progress中打包SDP:

@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);
    }
}

注意:代码不完整,当您使用Session_Progress回复时,还需要做其他事情

答案 2 :(得分:0)

我把json文本字符串作为sip消息内容。在我设置request.setContentType(" text / json")之后;在客户端和服务器代码中,我可以正确地获取内容json字符串。

相关问题