通过 SIP 连接的 J2ME 音频流

发布于 2024-12-22 15:23:44 字数 2563 浏览 3 评论 0 原文

我正在创建一个带有 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(用户名、密码、领域);

I am creating a J2ME real time streaming audio player with RTP and through SIP connection. Also I am new for these things. I want to take look deeply those things. If any one know a good working sample code demonstrating an audio player streaming with RTP (That means how to send a REGISTER message to the server through SIP to get registered and send an INVITE message and get the response & play). Please let me know, highly appreciated.

Also I looked here

if

My server port is 6060
ip 111.111.111.1
id is myid password 123

Have I used the code correctly? If I am wrong, please make me correct.

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
  }
 }

I got a respond with 180 Rigging message. Also let me know what is realm here. scc.setCredentials(username, password, realm);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

別甾虛僞 2024-12-29 15:23:44

如您所见 此处 - 您会意识到,当您创建向服务器发出新鲜请求,当服务器需要身份验证时,它首先发送 401。通过看到此消息,客户端可以搜索密码或询问用户。当服务器发送 401 响应代码时,它指定哪个安全域适用于给定的请求。这已经是您在代码中得到的内容:

realm = sh.getParameter("realm"); 

一旦失败,您需要使用此处的凭据再次 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 :

realm = sh.getParameter("realm"); 

Once, failed, you need to send() the request again with credentials here. I guess the setCredentials() function is only setting these parameters inside the scc object and they will be applied when send() 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)

宣告ˉ结束 2024-12-29 15:23:44

有许多功能和更多东西可用,并且可以在此处找到广泛的答案还有诺基亚 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文