基于linphone实现视频通话小结Word格式.docx
- 文档编号:21871125
- 上传时间:2023-02-01
- 格式:DOCX
- 页数:14
- 大小:322.97KB
基于linphone实现视频通话小结Word格式.docx
《基于linphone实现视频通话小结Word格式.docx》由会员分享,可在线阅读,更多相关《基于linphone实现视频通话小结Word格式.docx(14页珍藏版)》请在冰豆网上搜索。
linphoneManager开始实例化,设置电话铃音以及配置信息的保存路径,依据工程的环境变量以及配置信息初始化LinphoneCore,设置PlaybackGain,周期性地检测核对Sip数据,设置网络协议和相应的端口,根据CPU速度以及机型计算能为用户提供的编解码方式,计算能否回音校正,传递账户服务器信息到LInphoneCore中,得到网络连接操作对象和连接信息Info并告知LInphoneCore。
publicsynchronizedstaticfinalLinphoneManagercreateAndStart(
Contextc,LinphoneServiceListenerlistener){
if(instance!
=null)
thrownewRuntimeException("
LinphoneManagerisalreadyinitialized"
);
instance=newLinphoneManager(c);
instance.serviceListener=listener;
instance.startLibLinphone(c);
returninstance;
}//FromLinphoneManager
privatesynchronizedvoidstartLibLinphone(finalContextcontext){
try{
copyAssetsFromPackage(context);
mLc=LinphoneCoreFactory.instance().createLinphoneCore(
this,linphoneConfigFile,linphoneInitialConfigFile,null);
mLc.enableIpv6(mPref.getBoolean(getString(R.string.pref_ipv6_key),false));
mLc.setZrtpSecretsCache(basePath+"
/zrtp_secrets"
mLc.setPlaybackGain(3);
mLc.setRing(null);
mLc.setRootCA(linphoneRootCaFile);
initFromConf(context);
}catch(LinphoneExceptione){
Log.w("
noconfigreadyyet"
}
TimerTasklTask=newTimerTask(){
@Override
publicvoidrun(){
mLc.iterate();
};
mTimer.scheduleAtFixedRate(lTask,0,100);
IntentFilterlFilter=newIntentFilter(Intent.ACTION_SCREEN_ON);
lFilter.addAction(Intent.ACTION_SCREEN_OFF);
context.registerReceiver(mKeepAliveReceiver,lFilter);
catch(Exceptione){
Log.e(e,"
Cannotstartlinphone"
publicvoidinitFromConf(Contextcontext)throwsLinphoneConfigException{
//traces
booleanlIsDebug=mPref.getBoolean(getString(R.string.pref_debug_key),false);
LinphoneCoreFactory.instance().setDebugMode(lIsDebug);
if(initialTransports==null)
initialTransports=mLc.getSignalingTransportPorts();
setSignalingTransportsFromConfiguration(initialTransports);
//Configureaudiocodecs
//enableDisableAudioCodec("
speex"
32000,R.string.pref_codec_speex32_key);
enableDisableAudioCodec("
32000,false);
16000,R.string.pref_codec_speex16_key);
8000,R.string.pref_codec_speex8_key);
iLBC"
8000,R.string.pref_codec_ilbc_key);
GSM"
8000,R.string.pref_codec_gsm_key);
PCMU"
8000,R.string.pref_codec_pcmu_key);
PCMA"
8000,R.string.pref_codec_pcma_key);
AMR"
8000,R.string.pref_codec_amr_key);
//Configurevideocodecs
for(PayloadTypevideoCodec:
mLc.getVideoCodecs()){
enableDisableVideoCodecs(videoCodec);
mLc.enableEchoCancellation(mPref.getBoolean(getString(R.string.pref_echo_cancellation_key),false));
}catch(LinphoneCoreExceptione){
thrownewLinphoneConfigException(getString(R.string.wrong_settings),e);
booleanisVideoEnabled=isVideoEnabled();
mLc.enableVideo(isVideoEnabled,isVideoEnabled);
//1readproxyconfigfrompreferences
StringlUserName=mPref.getString(getString(R.string.pref_username_key),null);
if(lUserName==null||lUserName.length()==0){
thrownewLinphoneConfigException(getString(R.string.wrong_username));
StringlPasswd=mPref.getString(getString(R.string.pref_passwd_key),null);
if(lPasswd==null||lPasswd.length()==0){
thrownewLinphoneConfigException(getString(R.string.wrong_passwd));
StringlDomain=mPref.getString(getString(R.string.pref_domain_key),null);
if(lDomain==null||lDomain.length()==0){
thrownewLinphoneConfigException(getString(R.string.wrong_domain));
StringlStun=mPref.getString(getString(R.string.pref_stun_server_key),null);
//stunserver
mLc.setStunServer(lStun);
mLc.setFirewallPolicy((lStun!
=null&
&
lStun.length()>
0)?
FirewallPolicy.UseStun:
FirewallPolicy.NoFirewall);
//auth
mLc.clearAuthInfos();
LinphoneAuthInfolAuthInfo=LinphoneCoreFactory.instance().createAuthInfo(lUserName,lPasswd,null);
mLc.addAuthInfo(lAuthInfo);
//proxy
mLc.clearProxyConfigs();
StringlProxy=mPref.getString(getString(R.string.pref_proxy_key),null);
if(lProxy==null||lProxy.length()==0){
lProxy="
sip:
"
+lDomain;
if(!
lProxy.startsWith("
)){
+lProxy;
//getDefaultproxyifany
LinphoneProxyConfiglDefaultProxyConfig=mLc.getDefaultProxyConfig();
StringlIdentity="
+lUserName+"
@"
if(lDefaultProxyConfig==null){
lDefaultProxyConfig=LinphoneCoreFactory.instance().createProxyConfig(lIdentity,lProxy,null,true);
mLc.addProxyConfig(lDefaultProxyConfig);
mLc.setDefaultProxyConfig(lDefaultProxyConfig);
}else{
lDefaultProxyConfig.edit();
lDefaultProxyConfig.setIdentity(lIdentity);
lDefaultProxyConfig.setProxy(lProxy);
lDefaultProxyConfig.enableRegister(true);
lDefaultProxyConfig.done();
lDefaultProxyConfig=mLc.getDefaultProxyConfig();
if(lDefaultProxyConfig!
=null){
//prefix
StringlPrefix=mPref.getString(getString(R.string.pref_prefix_key),null);
if(lPrefix!
=null){
lDefaultProxyConfig.setDialPrefix(lPrefix);
//escape+
lDefaultProxyConfig.setDialEscapePlus(mPref.getBoolean(getString(R.string.pref_escape_plus_key),false));
//outboundproxy
if(mPref.getBoolean(getString(R.string.pref_enable_outbound_proxy_key),false)){
lDefaultProxyConfig.setRoute(lProxy);
lDefaultProxyConfig.setRoute(null);
//initnetworkstate
ConnectivityManagerlConnectivityManager=(ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfolInfo=lConnectivityManager.getActiveNetworkInfo();
mLc.setNetworkReachable(lInfo!
=null?
lConnectivityManager.getActiveNetworkInfo().getState()==NetworkInfo.State.CONNECTED:
false);
在DialerActivity中,设置了CallButton,当用户选择了拨号对象并点击Callbutton时,运行Linphone.Manger.NewOutgingCall并传入地址,这个函数解析地址为SIP地址,选择摄像头,计算电话被持方向。
当对方接听时,通话状态改变,相应的执行就交给电话状态监听器。
在Linphone中有4个非常重要的监听器,它们实现了打接电话以及电话过程的调整,都由LinphoneManager实现LinphoneCore的接口并重写,分别是:
OnDisplaySatus显示监听:
用于显示LinphoneCore内核欲显示的信息。
OnGlobalStateChanged全局变量改变监听:
当已经在打电话的时候若已经在通话则设置通话键不可见,挂机键可见;
如果在视频通话就设置相应的视频通话的控制按钮。
OnRegistrationStageChanged帐号状态监听:
若成功提示OK,并允许通话;
若失败提示失败。
OnCallStateChanged电话状态监听:
当有电话打来时,点亮10秒屏幕,开始响铃;
当接了电话,停止响铃,设置声音到听筒;
当状态为IncomingCallReceived运行LInphoneCore.callPending;
当状态为OutgoingInit运行EnterCallmode(解析并显示对方名称,开启距离感应器,设置静音,通话按钮);
当状态为Connected,告知LinphoneCore通话方向为来电,并EnterCallmode;
当状态为ERROR和CALLEND运行Exitcallmode。
publicvoidcallState(finalLinphoneCorelc,finalLinphoneCallcall,finalStatestate,finalStringmessage){
Log.i("
newstate["
state,"
]"
if(state==IncomingReceived&
!
call.equals(lc.getCurrentCall())){
if(call.getReplacedCall()==null){
//nomulticallsupport,justdecline
lc.terminateCall(call);
}//otherwiseitwillbeacceptedautomatically.
return;
if(state==IncomingReceived){
//Brightenscreenforatleast10seconds
WakeLockwl=mPowerManager.newWakeLock(
PowerManager.ACQUIRE_CAUSES_WAKEUP
|PowerManager.ON_AFTER_RELEASE
|PowerManager.SCREEN_BRIGHT_WAKE_LOCK,
"
incoming_call"
wl.acquire(10000);
startRinging();
if(mCurrentCallState==IncomingReceived){
//previousstatewasringing,sostopringing
stopRinging();
routeAudioToReceiver();
if(state==CallEnd||state==Error){
mAudioManager.setMode(MODE_NORMAL);
if(state==State.Connected){
if(Hacks.needSoftvolume()||LinphonePreferenceManager.getInstance().useSoftvolume()){
adjustSoftwareVolume(0);
//Synchronize
mCurrentCallState=state;
serviceListener.onCallStateChanged(call,state,message);
}//FromLinphoneManeger
publicvoidonCallStateChanged(finalLinphoneCallcall,finalStatestate,finalStringmessage){
if(state==LinphoneCall.State.IncomingReceived){
//wakeuplinphone
startActivity(newIntent()
.setClass(this,LinphoneActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}elseif(state==LinphoneCall.State.StreamsRunning){
if(Version.isVideoCapable()
&
getResources().getBoolean(R.bool.use_video_activity)
VideoCallActivity.launched&
LinphoneActivity.isInstanciated()
call.getCurrentParamsCopy().getVideoEnabled()){
//Donotcallifvideoactivityalreadylaunchedasitwouldcauseapause()ofthelaunchedone
//andaraceconditionwithcapturesurfaceviewleadingtoacrash
LinphoneActivity.instance().startVideoActivity();
mHandler.post(newRunnable(){
if(guiListener()!
guiListener().onCallStateChanged(call,state,message);
});
}//FromLinphoneService
publicvoidonCallStateChanged(LinphoneCallcall,Statestate,Stringmessage){
Linp
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 基于 linphone 实现 视频 通话 小结