linphone-CallManager.java文件分析

来源:互联网 发布:oracle导入txt数据 编辑:程序博客网 时间:2024/06/07 00:21

说明

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

功能

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

UML类图

CallManager

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);    }}
0 0
原创粉丝点击