首页 > 编程语言 >linphone-CallManager.java文件分析

linphone-CallManager.java文件分析

时间:2023-05-29 14:35:41浏览次数:45  
标签:java lc call CallManager return params lCall linphone


说明

进行会话的管理,重新加入会话等

功能

  1. 创建会话
  2. 重新进入Video
  3. 重新设置参数
  4. 更新会话

UML类图

linphone-CallManager.java文件分析_sed

CallManger.java

package org.linphone;

import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCallParams;
import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCoreException;
import org.linphone.mediastream.Log;


/**
 * Handle call updating, reinvites.
 * 
 * @author Guillaume Beraudo
 *
 */
public class CallManager {

    private static CallManager instance;

    private CallManager() {}
    public static final synchronized CallManager getInstance() {
    if (instance == null) instance = new CallManager();
    return instance;
    }

    private BandwidthManager bm() {
    return BandwidthManager.getInstance();
    }



    /**
     *
     * @params LinphoneAddress  linphone拨打电话的地址承载类
     * @params boolean          是否支持video
     * @params lowBandwidth     是否是lowBandwidth
     */
    public void inviteAddress(LinphoneAddress lAddress, boolean videoEnabled, boolean lowBandwidth) throws LinphoneCoreException {
    LinphoneCore lc = LinphoneManager.getLc();

    LinphoneCallParams params = lc.createCallParams(null);
    bm().updateWithProfileSettings(lc, params);

    if (videoEnabled && params.getVideoEnabled()) {
        params.setVideoEnabled(true);
    } else {
        params.setVideoEnabled(false);
    }

    if (lowBandwidth) {
        params.enableLowBandwidth(true);
        Log.d("Low bandwidth enabled in call params");
    }

    lc.inviteAddressWithParams(lAddress, params);
    }




    /**
     * Add video to a currently running voice only call.
     * No re-invite is sent if the current call is already video
     * or if the bandwidth settings are too low.
     * @return if updateCall called
     */
    boolean reinviteWithVideo() {
    LinphoneCore lc =  LinphoneManager.getLc();
    LinphoneCall lCall = lc.getCurrentCall();
    if (lCall == null) {
        Log.e("Trying to reinviteWithVideo while not in call: doing nothing");
        return false;
    }
    LinphoneCallParams params = lCall.getCurrentParamsCopy();

    if (params.getVideoEnabled()) return false;


    // Check if video possible regarding bandwidth limitations
    bm().updateWithProfileSettings(lc, params);

    // Abort if not enough bandwidth...
    if (!params.getVideoEnabled()) {
        return false;
    }

    // Not yet in video call: try to re-invite with video
    lc.updateCall(lCall, params);
    return true;
    }



    /**
     * Re-invite with parameters updated from profile.
     */
    void reinvite() {
    LinphoneCore lc = LinphoneManager.getLc();
    LinphoneCall lCall = lc.getCurrentCall();
    if (lCall == null) {
        Log.e("Trying to reinvite while not in call: doing nothing");
        return;
    }
    LinphoneCallParams params = lCall.getCurrentParamsCopy();
    bm().updateWithProfileSettings(lc, params);
    lc.updateCall(lCall, params);
    }

    /**
     * Change the preferred video size used by linphone core. (impact landscape/portrait buffer).
     * Update current call, without reinvite.
     * The camera will be restarted when mediastreamer chain is recreated and setParameters is called.
     */
    public void updateCall() {
    LinphoneCore lc = LinphoneManager.getLc();
    LinphoneCall lCall = lc.getCurrentCall();
    if (lCall == null) {
        Log.e("Trying to updateCall while not in call: doing nothing");
        return;
    }
    LinphoneCallParams params = lCall.getCurrentParamsCopy();
    bm().updateWithProfileSettings(lc, params);
    lc.updateCall(lCall, null);
    }

}


标签:java,lc,call,CallManager,return,params,lCall,linphone
From: https://blog.51cto.com/u_11797608/6370713

相关文章

  • linphone-PayloadType.java文件分析
    说明这个类主要是设置一些类型的参数,如MIME,RATE,FMTP等功能设置MIME设置RATE设置FMTUML类图PayloadType.javapackageorg.linphone.core;publicinterfacePayloadType{/***Obtaintheregisteredmime-type(actuallysubmime)ofthePayloadType.Forexample:......
  • linphone-LinphoneProxyConfig.java文件分析
    说明这个是linphone的纯配置文件,可能需要保存到文件中,是长久的数据.如何保存c/c++分析.功能设置Identity设置Address设置Proxy设置register设置Domain设置Dial设置Route设置Route设置Expires设置AVPF设置Realm设置ContactParameters设置PublichExpiresUML类图LinphoneProxyConfi......
  • linphone-LinphonePreferences.java文件分析
    说明这个文件比较长,主要是对于linphone的配置文件等设置。对于前面文章中文件的调用。其中大多数是对底层的调用设置。功能设置用户信息设置端口号设置显示名称设置密码设置代理设置编码设置编码速率设置DMTF等设置加密解密设置是否使用ipv6设置tunnel设置相机等UML类图LinphonePre......
  • linphone-NetworkManger.java文件分析
    功能InterceptnetworkstatechangesandupdatelinphonecorethroughLinphoneManger翻译拦截网络状态的变化,并通过LinphoneManger更新linphone核心内容。NetworkManager.java/**......
  • 使用 Java 代码调用 openAI 的 ChatGPT API
    前提:在https://beta.openai.com/account/api-keys注册一个自己的APIkey.要在JavaSpringFramework中使用OpenAIAPI,您需要使用一个能够处理HTTP请求的库。其中一个流行的库是SpringRestTemplate库。RestTemplate是一个强大而灵活的库,可以轻松地发送HTTP请求并处理响应。首......
  • linphone-KeepAliveReceiver.java文件分析
    说明Purposeofthisreceiveristodisablekeepaliveswhenscreenisoff解释这个接收器的目的是屏幕关闭的时候进行保活。<—翻译的准确性,等更加深刻的分析源码时更正,或者读者自己在下面评论也可以。介绍此类为接收器,接收外部传来的广播。KeepAliveReceiver.java/**Purpos......
  • linphone-BootReceiver.java文件分析
    说明这是个在android发送开机广播的时候调用的类功能主要就是为了在开机的时候启动LinphoneService开启后台服务。其中有一个.linphonerc的文件,这个文件应该是LpConfig的对应的配置文件。如果有错请更正。BootReceiver.javapublicclassBootReceiverextendsBroadcastReceiver{......
  • linphone-PresenceNote.java文件分析
    说明这个没什么好说的,一个普通的的类。UML类图PresenceNoteImpl.javapackageorg.linphone.core;publicclassPresenceNoteImplimplementsPresenceNote{privatelongmNativePtr;protectedPresenceNoteImpl(longnativePtr){mNativePtr=nativePtr;......
  • linphone-Tunnelconfig.java文件分析
    说明此类的主要作用主要是配置Host,port等。功能设置获取Host设置获取Port设置获取RemoteUdpMirrorPort获取设置maximumamountoftimeUML类图TunnelConfig.javapackageorg.linphone.core;publicclassTunnelConfigImplimplementsTunnelConfig{longmNativePtr;pr......
  • linphone-PresencePerson.java文件分析
    说明同上一张PresenceService和PresenceActivity的分析,但是不明白的是,为啥PresencePerson函数跟PresenceModel的函数很类似。唯一我现在能想到的原因是,每个Person主要存储。《—-放弃了,往后看吧。UML类图PresencePersonImpl.javapackageorg.linphone.core;publicclassPresenc......