pjsip-android
pjsip-android copied to clipboard
Sample application based on this SIPService. How to use this ?
I have downloaded this and built, but it isn't running and I am facing difficulty understanding the code. So please somebody help me out how to make an application based on this. I need to develop just a simple application that could send/receive messages and calls. Please help me out somebody.
Hi zackbugti I am also looking for any supporting information “how to start” or simple demo app. Cheers.
Any update for this thread anyone??
Any sample app??
SipAccountData sipAccount = new SipAccountData();
SipServiceCommand.setEncryption(appContext, true, "alias");
// identifer of current call
int callId;
// identifer of current account
String accountId;
BroadcastEventReceiver event = new BroadcastEventReceiver(){
@Override
public void onStackStatus(boolean started) {
if( ! started) {
// something went wrong
}
}
@Override
public void onRegistration(String accountID, pjsip_status_code registrationStateCode) {
if (registrationStateCode == pjsip_status_code.PJSIP_SC_OK) {
Uri sipUri = Uri.parse(String.format("sip:%d@%s:%d", sipPayload.getCallId(), sipAccount.getHost(), sipAccount.getPort()));
SipServiceCommand.makeCall(appContext, accountId, sipUri.toString());
}
}
@Override
public void onCallState(String accountID, int callID, pjsip_inv_state callStateCode, pjsip_status_code callStatusCode,
long connectTimestamp, boolean isLocalHold, boolean isLocalMute, boolean isLocalVideoMute) {
if(callStateCode == pjsip_inv_state.PJSIP_INV_STATE_CALLING){
// current outgoing call
callId = callID;
}
if(callStateCode == pjsip_inv_state.PJSIP_INV_STATE_DISCONNECTED){
// end of call
}
}
});
// register events
event.register(appContext);
// init account
sipAccount.setHost(sipPayload.getHost())
.setPort(sipPayload.getPort())
.setTcpTransport(true)
.setUsername(sipPayload.getUser())
.setPassword(sipPayload.getPassword())
.setRealm(sipPayload.getHost())
.setContactUriParams("")
;
// add account to the service
accountId = SipServiceCommand.setAccount(appContext, sipAccount);
...
// after end, unregister event
event.unregister(appContext);
what is the format to dial a number or to make a call? I was using sip:#####@server_address But this is not working
I have asterisk sip server with user context client, so dialplan for this user looks like that:
[client]
; ${EXTEN} here is a sipPayload.getCallId() from sip:1000@server:port
exten => _X.,1,SomeWorkWith(${EXTEN})
exten => _X.,2,MeetMe(${ROOM})
If you want to dial some phone number you should configure that on your sip server. Asterisk dialplan should be looks like that:
[client_context]
exten => _X.,1,SomeCheckExten(${EXTEN})
exten => _X.,2,Dial(SIP/CHANNEL_THROUGH/EXTEN)
; or dial some sip user
; exten => _X.,2,Dial(SIP/USER/USER)
A simple sample project can see Here. Just replace the sip configuration with your own. Hope it helps you!
Thank you very much!