Reputation: 4096
My requirement is to do a SIP registration using java servlet and then make an audio call. In android i have found simple way to do Android Supporting SIP however i am not able use same android code in java since SIP manager class is present in android.net packages. What should i use for my users to do SIP registration in java servlet.
below is android code
if (sipManager == null) {
sipManager = SipManager.newInstance(this);
}
SipProfile.Builder builder = null;
try {
builder = new SipProfile.Builder("7001", "XXX.XXX.X.XXX");
builder.setPassword("XXX");
sipProfile = builder.build();
Intent i = new Intent();
i.setAction("android.SipDemo.INCOMING_CALL");
PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, Intent.FILL_IN_DATA);
sipManager.open(sipProfile, pi, null);
sipManager.setRegistrationListener(sipProfile.getUriString(), new SipRegistrationListener() {
public void onRegistering(String localProfileUri) {
}
public void onRegistrationDone(String localProfileUri, long expiryTime) {
}
public void onRegistrationFailed(String localProfileUri, int errorCode,
String errorMessage) {
}
});
} catch (ParseException pe) {
pe.printStackTrace();
} catch (SipException se) {
se.printStackTrace();
}
Upvotes: 0
Views: 421
Reputation: 22128
It is not clear from your question how do you envisage this to work. Servlets are server side, so if SIP messages are initiated from the server but I suspect what you really want is to initiate a SIP session, followed by an Audio stream established with some real-time streaming protocol from the client.
There are Java APIs for SIP, and Sun / Oracle had a standard API for integrating with telecoms networks using SIP and IMS: https://www.oracle.com/technetwork/java/introduction-jain-sip-090386.html Not sure if they are still maintained.
However, I suspect that this is not what you really need. Maybe you should look at this client based WebRTC and SIP client:
http://www.doubango.org/sipml5/
Your JSP would serve this Javascript, which allows the user to initiate a SIP session and establish the Audio call.
From their documentation, it seems to be straightforward:
SIPml.init(
function(e){
var stack = new SIPml.Stack({realm: 'example.org', impi: 'bob', impu: 'sip:[email protected]', password: 'mysecret',
events_listener: { events: 'started', listener: function(e){
var callSession = stack.newSession('call-audiovideo', {
video_local: document.getElementById('video-local'),
video_remote: document.getElementById('video-remote'),
audio_remote: document.getElementById('audio-remote')
});
callSession.call('alice');
}
}
});
stack.start();
}
);
Upvotes: 1