通过 SIP 连接的 J2ME 音频流
我正在创建一个带有 RTP 和通过 SIP 连接的 J2ME 实时流音频播放器。我对这些事情也是新手。我想深入研究那些事情。如果有人知道一个很好的工作示例代码,演示了使用 RTP 进行流式传输的音频播放器(这意味着如何通过 SIP 向服务器发送 REGISTER
消息以进行注册并发送INVITE
消息并获取响应并播放)。请告诉我,非常感谢。
我还查看了此处
如果
我的服务器端口是6060
ip 111.111.111.1
id是myid密码123
我是否正确使用了代码?如果我错了,请纠正我。
public void doRegister(String username, String password, String realm) {
SipClientConnection scc = null;
SipConnectionNotifier scn = null;
String contact = null;
try {
scn = (SipConnectionNotifier) Connector.open("sip:5080");
contact = new String("sip:myid:123@"+scn.getLocalAddress()+":"+scn.getLocalPort());
scc = (SipClientConnection) Connector.open("sip:111.111.111.1+"transport=tcp") ;
scc.initRequest("REGISTER", scn);
scc.setHeader("From", "sip:myid:123@"+scn.getLocalAddress()+":5080");
scc.setHeader("To", "sip:myid:[email protected]");
scc.setHeader("Contact", contact);
scc.send();
boolean handled = false;
int scode = 0;
while(!handled) {
SipHeader sh;
scc.receive(30000);
scode = scc.getStatusCode();
switch(scode){
case 401:
sh = new SipHeader("WWW-Authenticate",
scc.getHeader("WWW-Authenticate"));
realm = sh.getParameter("realm");
scc.setCredentials(username, password, realm);
break;
case 407:
sh = new SipHeader("Proxy-Authenticate",
scc.getHeader("Proxy-Authenticate"));
realm = sh.getParameter("realm");
scc.setCredentials(username, password, realm);
break;
case 200:
handled = true;
break;
default:
handled = true;
}
}
scc.close();
} catch(Exception ex) {
// handle Exceptions
}
}
我收到了 180 Rigging
消息的回复。另外让我知道这里的领域是什么。 scc.setCredentials(用户名、密码、领域);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如您所见 此处 - 您会意识到,当您创建向服务器发出新鲜请求,当服务器需要身份验证时,它首先发送 401。通过看到此消息,客户端可以搜索密码或询问用户。当服务器发送 401 响应代码时,它指定哪个安全域适用于给定的请求。这已经是您在代码中得到的内容:
一旦失败,您需要使用此处的凭据再次
send()
请求。我猜setCredentials()
函数只是在scc
对象内设置这些参数,并且当再次调用send()
时它们将被应用。一些可能感兴趣的参考:http://www.developer.nokia.com/Community/Discussion/showthread.php?126760-SIP-registration-401-Unauthorized-..
(这里人们遇到了与端口号相关的问题,我不确定这是否困扰着您)
As you see here in example 1 - you realize that when you make a fresh Reqeust to server, where as server expects authentication it first sends 401. By seeing this the client can then either search for a password or ask the user. When server sends the 401 response code, it specifies which security domain is applicable for the given requests. This is already what you have got in your code :
Once, failed, you need to
send()
the request again with credentials here. I guess thesetCredentials()
function is only setting these parameters inside thescc
object and they will be applied whensend()
is called again.Some references that might be of interest: http://www.developer.nokia.com/Community/Discussion/showthread.php?126760-SIP-registration-401-Unauthorized-..
(here people had issues related port number, which i am not sure if this is bothering you)
有许多功能和更多东西可用,并且可以在此处找到广泛的答案还有诺基亚 JSR180 API还有示例代码
Many functions and more things are available and wide answer can be found here Also Nokia JSR180 API has sample codes as well