SDP消息构造?
我想知道有人能给我指点一个关于如何构建 SDP 消息的好教程吗?
我已经阅读了基础知识,可以构建和理解参数,但我似乎无法让它工作。
我要么在这里收到不可接受的回复,要么根本没有回复,这是在我收到 100 尝试和 180 回铃之后。
所以我的 SIP 可以工作,但它不喜欢 SDP 数据。
它目前的构造是这样的:
String sdpData = "v=0\r\n"
+ "o=- 019078020 0"
+ " IN IP4 sip.ciceronetworks.com\r\n" + "s=MySession\r\n"
+ "c=IN IP4 sip.ciceronetworks.com\r\n"
+ "t=0 0\r\n" + "m=audio 6002 RTP/AVP 0\r\n"
+ "a=sendrecv\r\n" + "a=rtpmap:0 PCMU/8000\r\n" + "a=ptime:20\r\n"+ "a=fmtp:97 mode=20\r\n";
byte[] contents = sdpData.getBytes();
request.setContent(contents, contentTypeHeader);
虽然我尝试了 100 次,然后响了 180 次,但是当我接受另一端的呼叫时,我什么也没得到,它似乎只是崩溃了,我还得到了“音频设备错误”我尝试响铃的电脑客户端。
有人有什么想法吗?
I was wondering can anyone point me to a good tutorial on how to construct a SDP message.
I have read the basics and can construct and understand the parameters but I just can't seem to get it to work.
I either get a not acceptable here reply or no reply at all, this is after I get 100 Trying and 180 ringing back.
So my SIP works but it doesn't like the SDP Data.
Its currently constructed like this:
String sdpData = "v=0\r\n"
+ "o=- 019078020 0"
+ " IN IP4 sip.ciceronetworks.com\r\n" + "s=MySession\r\n"
+ "c=IN IP4 sip.ciceronetworks.com\r\n"
+ "t=0 0\r\n" + "m=audio 6002 RTP/AVP 0\r\n"
+ "a=sendrecv\r\n" + "a=rtpmap:0 PCMU/8000\r\n" + "a=ptime:20\r\n"+ "a=fmtp:97 mode=20\r\n";
byte[] contents = sdpData.getBytes();
request.setContent(contents, contentTypeHeader);
And while like that I get 100 trying then 180 ringing but when I accept the call on the other end I get nothing back at all, it seems to just crash, I also get "Audio device Error" on the pc client that I try ringing.
Anyone any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
问题可能非常简单:您似乎忘记了“a=sendrecv”后面的换行符。 :-)
无论如何,这里有一个建议:
出于测试目的,您可能最好使用工具,而不是直接跳入并编写协议的部分内容。您可以使用 sipp 来实现此目的,它是测试 SIP 网络的绝佳工具。除此之外,您当然可以嗅探两个工作 SIP 设备之间的网络流量,看看它与您的流量有何不同。
编辑:
我之前错过了这个:
您应该省略
a=fmtp:97 mode=20
,因为会话描述在这种情况下无效:您只能对媒体行中提到的编解码器使用格式参数属性。编解码器通过有效负载类型号进行标识(0=PCMU、8=PCMA、18=G723,...)。某些编解码器没有正式分配的编号,因此应使用动态范围 96-127:用户代理可以通过 rtpmap 属性自由分配此范围内的编号。因此,除非您指定 97 所指的编解码器,否则其他用户代理无法知道格式参数应应用于哪个编解码器。The issue could be really simple: you seem to forgot the newline after "a=sendrecv". :-)
Anyway, here's an advice:
For testing purposes you are probably better off using a tool rather than jumping right in and writing parts of the protocol. You can use sipp for this purpose, it makes a great tool for testing SIP networks. Other than that you could of course just sniff the network traffic between two working SIP devices and see how it differs from your traffic.
EDIT:
I missed this one before:
You should omit
a=fmtp:97 mode=20
, as the session description is invalid this way: You may only use the format parameter attribute for codecs that are mentioned in the media line. Codecs are identified via the payload type number (0=PCMU, 8=PCMA, 18=G723, ...). Some codecs don't have officially assigned numbers, for these the dynamic range 96-127 should be used: user agents are free to assign a number in this range via anrtpmap
attribute. So, unless you specify which codec you mean by 97, there is no way for the other user agent to know which codec the format parameters should be applied to.Paprika 是对的:a=fmtp:97 mode=20 完全是错误的(看起来它是 iLBC 编解码器产品的一部分)。您没有提供编解码器 97,而是提供了编解码器 0 (PCMU)。
请注意,a=fmtp:97 不会伤害您,它只是虚假的。
最可能的问题是您不是 sip.ciceronetworks.com - 即您的 c= 线路(和 m= 线路)说“将我的媒体发送到 sip.ciceronetworks.com 的端口 6002”。我怀疑您的 PC 的 IP 地址与 sip.ciceronetworks.com 不同,和/或您和另一端之间存在防火墙/NAT。
这可能不是你的问题,但根据规范, o= 行是错误的
来自 RFC 4566:
让 VoIP 正常工作并不像 RFC 或说明书解释那么简单就意味着……
Paprika is right: the a=fmtp:97 mode=20 is simply wrong (and looks like it's part of an iLBC codec offer). You didn't offer codec 97, you offered codec 0 (PCMU).
Note that the a=fmtp:97 shouldn't hurt you, it's just spurious.
The most likely problem is that you are not sip.ciceronetworks.com - i.e. your c= line (and m= line) said "send my media to port 6002 at sip.ciceronetworks.com". I suspect your PC's IP address is not the same as sip.ciceronetworks.com, and/or there's a firewall/NAT between you and the other end.
It probably isn't your problem, but the o= line is wrong per the spec
From RFC 4566:
Getting VoIP to work is not as simple as the RFCs or cookbook explanations would imply....
我发现一篇关于 SDP(会话描述协议)的好文章。它还与称为 Ozeki VoIP SIP SDK 的 SDK 相关。例如,如果将这些东西结合起来,您将能够创建一个软件电话。
还有关于 SDP 的总体简要介绍。
对于那些希望开发自己的软件电话或网络电话应用程序或您想要的应用程序的人来说,在 VoIP SIP 呼叫中使用 SDP 是一个有趣的主题。
SDP 描述多媒体通信会话,用于会话公告、会话邀请和参数协商。
使用SDK可以减轻很多负担,但保证了灵活性和高兼容性。
有关 SDP 与 SDK 结合以构建自己的应用程序的更多信息,如果您通过 Google 搜索,可以查看上述文章:“在 VoIP SIP 呼叫中使用 SDP”
I found a good article which deals with SDP (Session Description Protocol). It is also in relationship with an SDK which is called Ozeki VoIP SIP SDK. If you combine these things you will be able to create a softphone for instance.
There is also a brief overall about SDP.
Working with SDP in VoIP SIP calls is an interesting topic for those who wish to develop their own softphone or webphone application or what you desire.
SDP describes multimedia communication session for the purposes of session announcement, session invitation, and parameter negotiation.
The usage of an SDK can take a lot of burden from one's shoulder bucasue flexibility and high compatibility is assured.
For more information regarding SDP in connection with an SDK to build own applications you can have a look at the mentioned article if you Google for: "Working with SDP in VoIP SIP calls"