2

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

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

但它并没有返回我的 SDP。解决问题的一些建议?谢谢!

4

3 回答 3

3

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

字符串 sdp = new String(req.getContent())

于 2015-08-20T07:50:25.553 回答
2

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

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

@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 回复的时候还需要做其他的事情

于 2016-10-27T08:02:59.670 回答
0

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

于 2018-01-10T02:42:40.227 回答