J2ME streaming audio over a SIP connection

I am creating a J2ME streaming audio player with RTP support and through SIP . I am also new to this. I want to deeply study these things. If someone knows a good working code example demonstrating the streaming of an audio player with RTP (this means sending a REGISTER message to the server via SIP to register and send an INVITE message and get a response and playback). Please let me know highly appreciated.

I also looked here

if

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

Did I use the code correctly? If I am wrong, make me right.

 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: 123@111.111.111.1 "); 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 response with 180 Rigging . Also let me know that there is a kingdom . scc.setCredentials(username, password, realm);

+4
source share
2 answers

Many features are available and much more, and a wide answer can be found here. Also in the Nokia JSR180 API there are also code examples.

0
source

As you see in example 1 here, you understand that when you make a new Reqeust on the server, where, when the server expects authentication, it first sends 401. Seeing this, the client can then either look for the password or ask the user. When the server sends a 401 response code, it indicates which security domain is applicable to these requests. This is what you got in your code:

 realm = sh.getParameter("realm"); 

Once, failed, you need to send() request again with the credentials here. I believe that the setCredentials() function sets only these parameters inside the scc object, and they will be applied when send() is called again.

Some links that may be of interest are: http://www.developer.nokia.com/Community/Discussion/showthread.php?126760-SIP-registration-401-Unauthorized- .. (here people had problems with the number port, which I'm not sure if this bothers you)

+2
source

Source: https://habr.com/ru/post/1387839/


All Articles