❶ 如何打开slp文件
SLP是模拟的文件。用CIM自带的模拟软件打开吧。
不过此文件一般都是在编好以后直接看了,所以一般都把它删除,没什么用
❷ 怎样打开VOIP与SIP
打开SIP功能的方法,适用于JB2,JB3,JB5:
请在alps\mediatek\config\proct_nam\ProjectConfig.mk中,将MTK_SIP_SUPPORT置为yes即可
打开SIP功能的方法,适用于JB2之前的版本:
1. 在文件alps\mediatek\config\proct_name\android.software.sip.voip.xml中添加如下代码
<permissions>
<feature name="android.software.sip" />
<feature name="android.software.sip.voip" />
</permissions>
2. 在文件alps\mediatek\config\proct_name\android.software.sip.xml
<permissions>
<feature name="android.software.sip" />
</permissions>
允许SIP使用GPRS,仅针对GB, GB2,GB3:
在文件alps\frameworks\base\core\res\res\values\Config.xml中将
<bool name="config_sip_wifi_only">true</bool>
修改为
<bool name="config_sip_wifi_only">false</bool>
注:JB2,JB3,JB5版本中SIP call功能与OP02互斥,不可以同时开启。
原因是由于运营商的某些原因不允许开启Sip功能。
如希望同时使用,可以修改mk去除互斥条件:
/alps/mediatek/build/addon/core/android_dep_rule.mak中去掉以下内容
############################################################
ifneq ($(filter OP02%, $(OPTR_SPEC_SEG_DEF)),)
ifeq ($(strip $(MTK_SIP_SUPPORT)),yes)
$(call dep-err-common, Please do not set OPTR_SPEC_SEG_DEF as OP02* or set MTK_SIP_SUPPORT as no)
endif
endif
1、VOIP基于SIP协议,SDK2.3包含一个SIP协议栈和框架API
2、VOIP位于android.net.sip包中,最重要的为SipManager类,可开发基于SIP的VOIP应用。使用时要包含android.permission.INTERNET和android.permission.USE_SIP权限
3、如果在market中显示仅支持VOIP API幸好的手机的话,发布时需要在androidManifest.xml中加入<uses_feature android:name = "android.software.sip" android:required = "true">和<uses_feature android:name = "android.software.sip.voip">
4、要支持SIP API
(1)仅Android2.3或更高版本平台支持
(2)不是所有设备都提供SIP支持,确保你的APP只安装在支持SIP的装置上
5、根据GOOGLE官方DEMO项目来扩展的概念
二、类及方法描述
1、一个基本的VOIP项目至少需要三个类SIPSettings(对SIP的基本设置身份验证)、WalkieTalkieActivity(登录到SIP设备供应商,注册device去处理来电,拨打电话,在通话过程中用户界面管理)、IncomingCallReceiver(监听传入的SIP电话,然后传递这些SIP电话给WalkieTalkieActivity控制)
2、
WalkieTalkieActivity
A、SipManager.newInstance()-->此方法中首先判断context是否支持SIP API,若支持则new SipManager。SipManager构造函数中,实例化了一个ISIPService(运用的公式:
IBinder b =ServiceManager.getService(Context.SIP_SERVICE); //获取系统相应的服务
ISipService service = ISipService.Stub.asInterface(bIBinder);)
上面这两句代码其实是使用了AIDL,就以SipService为例,步骤如下
Service端
1、编写aidl文件:ISipService.aidl,并定义使用的接口(就等同于interface一样)
2、使用makefile生成与之同名的java文件,SipService.java,此类继承extends ISipService.Stub并实现接口定义的方法或者在SipService extends Service,并代码中加入
ISipService.stub sipImpl = new ISipService.stub(){
//实现其接口方法,在SipService.java中是实现了一个名为start()的方法,里面有句是ServiceManager.addService("sip",newSipService(context));表示SipService已经交给ServiceManager统一管理了
}
Client端
一(以SIPService为例)
1、而在需要用到SipService时,也就是我们构造SipManager的时候,就通过ServiceManager.getService(Context.SIP_SERVICE)获得SIP的服务(类型为IBinder)
2、并调用 ISipService.Stub.asInterface(IBinder);去获取一个SipService实例(前提是该Service一定是通过ServiceManager.addService的方式添加进去管理的,这样才能找到此Service)
二(以普通Activity为例)
1、利用Intent intent = new Intent(Activity.this,SipService.class);-->bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);来绑定SERVICE,在serviceConnection的onServiceConnected方法中,使用IService.stub.asIntentface(IBinder);来获取实例
B、SipManager创建好后,先从SharedPreference中获取username,domain及pwd,如果第一次进来没有设置这些的话则需要先创建账户,这里用EditTextPreference来保存用户信息,好处是当填写信息并返回后,EditTextPreference会自动将值放入SharedPreference中。我们假设username="woody";domain="192.168.12.30";pwd="910913"
C、这时,我们的SipManager以及用户信息已经设定好了,接下来使用了这句SipProfile.Builder builder = new
SipProfile.Builder(username, domain);我们去看看SipProfile.Builder中做了些什么:
SipURI mUri =mAddressFactory.createSipURI(username,serverDomain);
SipProfile mProfile.mDomain=serverDomain; //设置domain
(在mAddressFactory.createSipURl方法中,我选取了一些核心代码)
StringBuffer uriString=new StringBuffer("sip:");
uriString.append(user);
uriString.append("@");
//if host is an IPv6 string we should enclose it in sq brackets
if(host.indexOf(':') !=host.lastIndexOf(':')&&host.trim().charAt(0) !='[')
host='['+host+']';
uriString.append(host);
StringMsgParser smp=new StringMsgParser();
SipUrl sipUri=smp.parseSIPUrl(uriString.toString());
return sipUri;
从以上代码可以看出其实就是在Format SipURL罢了,里面多加了个if host为IPV6的判断(IPv4为为32位,十进制;IPv6为128位,16进制)。urlString最后为"sip:[email protected]",smp.parseSIPUrl()方法中,有关于是如何parse的就不做阐述了,总之最后返回了一个SipUri
D、接下来就是SipProfile sipProfile = SipProfile.Builder.build(); //返回一个SipProfile object
在SipProfile.Builder.build()中,设置了sipProfile的pwd值,删除了之前SipUrl对象里的
password(mUri.setUserPassword(null);)、将sipProfile的address属性设置为AddressImpl类型的对象值、调用AddressFactory.createURI返回一个SipUri,并sipProfile.mProxyAddress=sipUri.getHost();
E、创建PendingIntent对象:(Intent与PendingIntent区别在于Intent是及时启动,而PendingIntent是不立刻反应,在特定的情况或通知下才启动,适用于AlertClock等)
Intent i = new Intent();
i.setAction("android.SipDemo.INCOMING_CALL");
PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, Intent.FILL_IN_DATA);
F、
SipManager.open(sipProfile,PendingIntent,null); //(实际是SIPService在做操作)设置localSIPProfile的callingID-->建立SIP连接(算是注册至SIP Server)-->打开receiveCall
其中建立SIP连接,最后能追溯到是在SipSessionGroup.java的reset()方法中通过是注册服务器实现的,
注册服务器的步骤为:
(1)设置服务器的属性,例如服务器的地址(IP_ADDRESS_PROP)、栈名(javax.sip.STACK_NAME)、发出去的路径(localProfile中的javax.sip.OUTBOUND_PROXY)、线程池的大小(gov.nist.javax.sip.THREAD_POOL_SIZE)等,并且将这些属性加载到服务器中.
(2)通过SipFactory的静态方法取得一个实例,然后通过SipFactory实例sipfactory
(3)创建一个SipStack实例sipstack(这一步获得IP_ADDRESS_PROP,String address = Properties.getProperty("javax.sip.IP_ADDRESS");)
(4)用sipstack创建一个SipProvider实例sipProvider
(5)注册SipListener
G、A~F步骤都是在做准备工作,大致的步骤如下:new SIPService-->new SIPManager-->设定用户信息-->new SIPURI-->new SIPProfile-->new PendingIntent-->set sipProfile callingID-->(if profile.getAutoRegistation)open toReceiveCalls-->register SipService
现在是call someone~呼叫的工作是SipAudioCall类来完成(可用sipManager.makeAudioCall或takeAudioCall来实例化,SipAudioCall.startAudio时需要 RECORD_AUDIO, ACCESS_WIFI_STATE, and WAKE_LOCK permissions,
化,SipAudioCall.startAudio时需要 RECORD_AUDIO, ACCESS_WIFI_STATE, and WAKE_LOCK permissions,setSpeakerMode() 时需要MODIFY_AUDIO_SETTINGS permission)
【1】当需要呼叫时,使用sipManager.makeAudioCall(String localProfileURI, String peerProfileURI, SipAudioCall.listener,int timeout);来创建一个SipAudioCall,其中timeout以seconds为单位,过了timeout表示打电话超时。需要打给别人时使用makeAudioCall创建,接听电话用takeAudioCall来创建sipAudioCall
【2】SipAudioCall中有一个嵌套的class:SipAudioCall.Listener(此类主要用于监听SIP CALL,when[呼叫电话 or 接听电话])
SipAudioCall.Listener listener = new SipAudioCall.Listener() {
@Override
public void onCallEstablished(SipAudioCall call) { //呼叫建立
call.startAudio(); //启动音频
call.setSpeakerMode(true); //调整为可讲话模式
call.toggleMute(); //触发无声
updateStatus(call);
}
};
SipAudioCall call = manager.makeAudioCall(me.getUriString(), sipAddress, listener, 30);
(以上例子为makeAudioCall)
【3】我们看看makeAudioCall()方法(makeAudioCall requires 2 sipProfile):
SipAudioCall call =new SipAudioCall(mContext, localProfile);
call.setListener(listener); //这两句很简单就是创建一个local的sipAudioCall
SipSession s = createSipSession(localProfile, null); -->mSipService.createSession(localProfile, null);// sipService来创建session,并保存在SipSessionGroupExt中
call.makeCall(peerProfile,s,null); //这句就是呼叫,最后追溯到实际是SipSession.makecall
总结:在发起通话中
首先是创建SipAudioCall.listener,以便监听对话建立和对话结束,然后做相应的操作
然后是SipManager.makeAudioCall(localAdd,llistener,XXXX),在makeAudioCall方法中
A、创建一个sipAudioCall(localProfile)
B、创建SipSession以建立起会话
C、SipSession.makeCall(peerProfile,XXXX); //SipSession呼叫远程profile
【4】关于接电话道理都差不多,takeAudioCall
通过之前设置的callingID来查找mSipService.getPendingSession(callId);来获得SipSession。并创建SipAudioCall,然后attachCall就算接受电话了