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

linphone-LinphoneProxyConfig.java文件分析

时间:2023-05-29 14:35:14浏览次数:46  
标签:java String void long nativePtr return linphone LinphoneProxyConfig public


说明

这个是linphone的纯配置文件,可能需要保存到文件中,是长久的数据.如何保存c/c++分析.

功能

  1. 设置Identity
  2. 设置Address
  3. 设置Proxy
  4. 设置register
  5. 设置Domain
  6. 设置Dial
  7. 设置 Route
  8. 设置Route
  9. 设置Expires
  10. 设置AVPF
  11. 设置Realm
  12. 设置ContactParameters
  13. 设置PublichExpires

UML类图

linphone-LinphoneProxyConfig.java文件分析_sed

linphone-LinphoneProxyConfig.java文件分析_ide_02

LinphoneProxyConfig.java

package org.linphone.core;
/**
 * The LinphoneProxyConfig object represents a proxy configuration to be used by the LinphoneCore object. Its fields must not be used directly in favour of the accessors methods.
 * Once created and filled properly the LinphoneProxyConfig can be given to LinphoneCore with {@link LinphoneCore#addProxyConfig(LinphoneProxyConfig)}. This will automatically triggers the registration, if enabled.
 *<br>The proxy configuration are persistent to restarts because they are saved in the configuration file. As a consequence, after {@link LinphoneCoreFactory#createLinphoneCore(LinphoneCoreListener, String, String, Object)} there might already be a default proxy that can be examined with {@link LinphoneCore#getDefaultProxyConfig()} .
 *
 */
public interface LinphoneProxyConfig {

    /**
     *Starts editing a proxy configuration.
     *Because proxy configuration must be consistent, applications MUST call {@link #edit()} before doing any attempts to modify proxy configuration (such as identity, proxy address and so on).
     *Once the modifications are done, then the application must call {@link #done()} to commit the changes.
     */
    public LinphoneProxyConfig edit();
    /**
     * Commits modification made to the proxy configuration.
     */
    public void done();
    /**
     * Sets the user identity as a SIP address.
     * @param identity This identity is normally formed with display name, username and domain, such as: Alice <sip:[email protected]> The REGISTER messages will have from and to set to this identity.
     */
    public void setIdentity(String identity) throws LinphoneCoreException;
    /**
     *get  the SIP identity that belongs to this proxy configuration.
     *
     * @return The SIP identity is a SIP address (Display Name <sip:username> )
     */
    public String getIdentity();
    /**
     * Sets the address of the proxy configuration
     * @param address
     */
    public void setAddress(LinphoneAddress address) throws LinphoneCoreException;
    /**
     *get linphoneAddress that belongs to this proxy configuration.
     *
     * @return LinphoneAddress
     */
    public LinphoneAddress getAddress();
    /**
     *Sets the proxy address
     * Examples of valid sip proxy address are:
     *<li>IP address: sip:87.98.157.38
     *<li>IP address with port: sip:87.98.157.38:5062
     *<li>hostnames : sip:sip.example.net
     * @param proxyUri
     * @throws LinphoneCoreException
     */
    public void setProxy(String proxyUri) throws LinphoneCoreException;
    /**
     * get the proxy's SIP address.
     *
     */
    public String getProxy();
    /**
     * Enable register for this proxy config.
     * Register message is issued after call to {@link #done()}
     * @param value
     */
    public LinphoneProxyConfig enableRegister(boolean value);
    /**
     * @return true if registration to the proxy is enabled.
     */
    public boolean registerEnabled();

    /**
     * normalize a human readable phone number into a basic string. 888-444-222 becomes 888444222
     * @param number
     * @return
     */
    public String normalizePhoneNumber(String number);
    /**
     * Normalize a human readable sip uri into a fully qualified LinphoneAddress.
     * A sip address should look like DisplayName \<sip:username\@domain:port\> .
     * @param username the string to parse
     * @return NULL if invalid input, normalized sip address otherwise.
     */
    public LinphoneAddress normalizeSipUri(String username);
    /**
     * Useful function to automatically add international prefix to e164 phone numbers
     * @param prefix
     */
    public void setDialPrefix(String prefix);

    /**
     * Returns the automatically added international prefix to e164 phone numbers
     */
    public String getDialPrefix();

    /**
     * * Sets whether liblinphone should replace "+" by "00" in dialed numbers (passed to
     * {@link LinphoneCore#invite(String)}).
     * @param value default value is false
     */
    public void setDialEscapePlus(boolean value);

    /**
     * Whether liblinphone should replace "+" by "00" in dialed numbers (passed to
     * {@link LinphoneCore#invite(String)}).
     */
    public boolean getDialEscapePlus();

    /**
     * get domain host name or ip
     * @return may be null
     */
    public String getDomain();
    /**
     *
     * @return  a boolean indicating that the user is successfully registered on the proxy.
     */
    public boolean isRegistered();
    /**
     * Sets a SIP route. When a route is set, all outgoing calls will go to the route's destination if this proxy is the default one (see {@link LinphoneCore#getDefaultProxyConfig()} ).
     * @param routeUri ex sip:git.linphone.org
     * @throws LinphoneCoreException
     */
    public void setRoute(String routeUri) throws LinphoneCoreException;
    /**
     *
     * @return  the route set for this proxy configuration.
     */
    public String getRoute();
    /**
     * Indicates  either or not, PUBLISH must be issued for this #LinphoneProxyConfig .
     * <br> In case this #LinphoneProxyConfig has been added to #LinphoneCore, follows the linphone_proxy_config_edit() rule.
     * @param enable if true, publish will be engaged
     *
     */
    public void enablePublish(boolean enable);
    /**
     * returns publish state for this proxy config (see {@link #enablePublish(boolean)} )
     */
    public boolean publishEnabled();


    LinphoneCore.RegistrationState getState();

    /**
     * Sets the registration expiration time.
     * @param delay expiration time in seconds
     */
    void setExpires(int delay);

    /**
     * Gets the registration expiration time.
     * @return delay expiration time in seconds.
     */
    int getExpires();

    /**
     * Set the privacy for all calls or chat sessions using the identity exposed by this LinphoneProxyConfig
     * @param privacy_mask a or'd int of values defined in interface {@link org.linphone.core.Privacy}
     */
    void setPrivacy(int privacy_mask);

    /**
     * Get the privacy mask requested for this proxy config.
     * @return the privacy mask as defined in interface {@link org.linphone.core.Privacy}
     */
    int getPrivacy();

    /**
     * Indicates whether AVPF/SAVPF must be used for calls using this proxy config.
     * @param enable True to enable AVPF/SAVF, false to disable it.
     */
    void enableAvpf(boolean enable);

    /**
     * Whether AVPF is used for calls through this proxy.
     * @return
     */
    boolean avpfEnabled();

    /**
     * Set the interval between regular RTCP reports when using AVPF/SAVPF.
     * @param interval The interval in seconds (between 0 and 5 seconds).
     */
    void setAvpfRRInterval(int interval);

    /**
     * Get the interval between regular RTCP reports when using AVPF/SAVPF.
     * @return The interval in seconds.
     */
    int getAvpfRRInterval();

    /**
     * Indicates whether quality reporting must be used for calls using this proxy config.
     * @param enable True to enable quality reporting, false to disable it.
     */
    void enableQualityReporting(boolean enable);


    /**
     * Whether quality reporting is used for calls through this proxy.
     * @return
     */
    boolean qualityReportingEnabled();

    /**
     * Set the interval between quality interval reports during a call when using quality reporting.
     * @param interval The interval in seconds (should be greater than 120 seconds to avoid too much).
     */
    void setQualityReportingInterval(int interval);

    /**
     * Get the interval between quality interval reports during a call when using quality reporting.
     * @return The interval in seconds.
     */
    int getQualityReportingInterval();

    /**
     * Set the collector SIP URI to collect reports when using quality reporting.
     * @param collector The collector SIP URI which should be configured server side too.
     */
    void setQualityReportingCollector(String collector);

    /**
     * Get the collector SIP URI collecting reports when using quality reporting.
     * @return The SIP URI collector address.
     */
    String getQualityReportingCollector();

    /**
     * Set the outbound proxy realm. It is used in digest authentication to avoid
     * re-authentication if a previous token has already been provided.
     * @param realm The new outbound proxy realm.
     */
    void setRealm(String realm);

    /**
     * Get the outbound proxy realm.
     * @return The outbound proxy realm.
     */
    String getRealm();

    /**
     * Set optional contact parameters that will be added to the contact information sent in the registration.
     * @param contact_params a string containing the additional parameters in text form, like "myparam=something;myparam2=something_else"
     *
     * The main use case for this function is provide the proxy additional information regarding the user agent, like for example unique identifier or android push id.
     * As an example, the contact address in the SIP register sent will look like <sip:[email protected]:50421>;android-push-id=43143-DFE23F-2323-FA2232.
    **/
    public void setContactParameters(String contact_params);

    /**
     * Get the contact's parameters.
     * @return
     */
    public String getContactParameters();

    /**
     * Set optional contact parameters that will be added to the contact information sent in the registration, inside the URI.
     * @param params a string containing the additional parameters in text form, like "myparam=something;myparam2=something_else"
     *
     * The main use case for this function is provide the proxy additional information regarding the user agent, like for example unique identifier or apple push id.
     * As an example, the contact address in the SIP register sent will look like <sip:[email protected]:50421;apple-push-id=43143-DFE23F-2323-FA2232>.
    **/
    public void setContactUriParameters(String params);

    /**
     * Get the contact's URI parameters.
     * @return
     */
    public String getContactUriParameters();

    /**
     * Return the international prefix for the given country
     * @param iso code
     */
    public int lookupCCCFromIso(String iso);

    /**
     * Return the international prefix for the given country
     * @param e164 phone number
     */
    public int lookupCCCFromE164(String e164);

    /**
     * Return reason error code.
     * @return reason code.
     */
    public Reason getError();

    /**
     * Get full error information about last error occured on the proxy config.
     * @return an ErrorInfo.
     */
    public ErrorInfo getErrorInfo();

    /**
     * Set the publish expiration time in second.
     * @param expires in second
     */
    public void setPublishExpires(int expires);
    /**
     * @return the publish expiration time in second. Default value is the registration expiration value.
     */
    public int getPublishExpires();

    /**
     *  attached a user data to a proxy config
     **/
    void setUserData(Object obj);

    /**
     * Detect if the given input is a phone number or not.
     * @param username string to parse.
     * @return TRUE if input is a phone number, FALSE otherwise.
     **/
    boolean isPhoneNumber(String username);

    /**
     * Returns user data from a proxy config. return null if any
     * @return an Object.
     */
    Object getUserData();
}

LinphoneProxyCofnigImpl.java

package org.linphone.core;

import org.linphone.core.LinphoneCore.RegistrationState;

class LinphoneProxyConfigImpl implements LinphoneProxyConfig {

    protected final long nativePtr;
    protected LinphoneCoreImpl mCore;
    Object userData;

    private native void finalize(long ptr);
    private native int getState(long nativePtr);
    private native void setExpires(long nativePtr, int delay);
    private native int getExpires(long nativePtr);
    private native long createProxyConfig( long nativePtr);

    protected LinphoneProxyConfigImpl(LinphoneCoreImpl core,String identity,String proxy,String route, boolean enableRegister) throws LinphoneCoreException {
        mCore=core;
        nativePtr = createProxyConfig(core.nativePtr);
        setIdentity(identity);
        setProxy(proxy);
        setRoute(route);
        enableRegister(enableRegister);
    }

    protected LinphoneProxyConfigImpl(LinphoneCoreImpl core)  {
        mCore=core;
        nativePtr = createProxyConfig(core.nativePtr);
    }
    /*reserved for JNI */
    protected LinphoneProxyConfigImpl(LinphoneCoreImpl core, long aNativePtr)  {
        mCore=core;
        nativePtr = aNativePtr;
    }

    private void isValid() {
        if (nativePtr == 0) {
            throw new RuntimeException("proxy config removed");
        }
    }

    protected void finalize() throws Throwable {
        if (nativePtr != 0) {
            finalize(nativePtr);
        }
        super.finalize();
    }
    private native long newLinphoneProxyConfig();

    private native void edit(long ptr);
    private native void done(long ptr);

    private native void setIdentity(long ptr,String identity);
    private native String getIdentity(long ptr);
    private native void setAddress(long ptr, long address);
    private native long getAddress(long ptr);
    private native int setProxy(long ptr,String proxy);
    private native String getProxy(long ptr);


    private native void enableRegister(long ptr,boolean value);
    private native boolean isRegisterEnabled(long ptr);

    private native boolean isRegistered(long ptr);
    private native void setDialPrefix(long ptr, String prefix);
    private native String getDialPrefix(long ptr);

    private native String normalizePhoneNumber(long ptr,String number);
    private native long normalizeSipUri(long ptr,String username);

    private native String getDomain(long ptr);

    private native void setDialEscapePlus(long ptr, boolean value);
    private native boolean getDialEscapePlus(long ptr);

    private native String getRoute(long ptr);
    private native int setRoute(long ptr,String uri);
    private native void enablePublish(long ptr,boolean enable);
    private native boolean publishEnabled(long ptr);
    private native void setContactParameters(long ptr, String params);

    private native int lookupCCCFromIso(long nativePtr, String iso);
    private native int lookupCCCFromE164(long nativePtr, String e164);

    public LinphoneProxyConfig enableRegister(boolean value) {
        isValid();
        enableRegister(nativePtr,value);
        return this;
    }

    public void done() {
        isValid();
        Object mutex=mCore!=null ? mCore : this;
        synchronized(mutex){
            done(nativePtr);
        }
    }

    public LinphoneProxyConfig edit() {
        isValid();
        Object mutex=mCore!=null ? mCore : this;
        synchronized(mutex){
            edit(nativePtr);
        }
        return this;
    }

    public void setIdentity(String identity) throws LinphoneCoreException {
        isValid();
        setIdentity(nativePtr,identity);
    }

    public void setAddress(LinphoneAddress address) throws LinphoneCoreException {
        isValid();
        setAddress(nativePtr,((LinphoneAddressImpl)address).nativePtr);
    }

    public void setProxy(String proxyUri) throws LinphoneCoreException {
        isValid();
        if (setProxy(nativePtr,proxyUri)!=0) {
            throw new LinphoneCoreException("Bad proxy address ["+proxyUri+"]");
        }
    }
    public String normalizePhoneNumber(String number) {
        isValid();
        return normalizePhoneNumber(nativePtr,number);
    }
    public LinphoneAddress normalizeSipUri(String username) {
        isValid();
        long ptr = normalizeSipUri(nativePtr,username);
        if (ptr==0) {
            return null;
        } else {
            return new LinphoneAddressImpl(ptr,LinphoneAddressImpl.WrapMode.FromConst);
        }
    }
    public void setDialPrefix(String prefix) {
        isValid();
        setDialPrefix(nativePtr, prefix);
    }
    public String getDialPrefix() {
        isValid();
        return getDialPrefix(nativePtr);
    }
    public String getDomain() {
        isValid();
        return getDomain(nativePtr);
    }
    public void setDialEscapePlus(boolean value) {
        isValid();
        setDialEscapePlus(nativePtr,value);
    }
    public boolean getDialEscapePlus() {
        isValid();
        return getDialEscapePlus(nativePtr);
    }
    public String getIdentity() {
        isValid();
        return getIdentity(nativePtr);
    }
    public LinphoneAddress getAddress() {
        isValid();
        long ptr = getAddress(nativePtr);
        if (ptr==0) {
            return null;
        } else {
            return new LinphoneAddressImpl(ptr,LinphoneAddressImpl.WrapMode.FromConst);
        }
    }
    public String getProxy() {
        isValid();
        return getProxy(nativePtr);
    }
    public boolean isRegistered() {
        isValid();
        return isRegistered(nativePtr);
    }
    public boolean registerEnabled() {
        isValid();
        return isRegisterEnabled(nativePtr);
    }
    public String getRoute() {
        isValid();
        return getRoute(nativePtr);
    }
    public void setRoute(String routeUri) throws LinphoneCoreException {
        isValid();
        if (setRoute(nativePtr, routeUri) != 0) {
            throw new LinphoneCoreException("cannot set route ["+routeUri+"]");
        }
    }
    public void enablePublish(boolean enable) {
        isValid();
        enablePublish(nativePtr,enable);
    }
    public RegistrationState getState() {
        isValid();
        return RegistrationState.fromInt(getState(nativePtr));
    }

    public void setExpires(int delay) {
        isValid();
        setExpires(nativePtr, delay);
    }
    public int getExpires() {
        isValid();
        return getExpires(nativePtr);
    }
    public boolean publishEnabled() {
        isValid();
        return publishEnabled(nativePtr);
    }
    @Override
    public void setContactParameters(String params) {
        isValid();
        setContactParameters(nativePtr, params);
    }
    @Override
    public int lookupCCCFromIso(String iso) {
        isValid();
        return lookupCCCFromIso(nativePtr, iso);
    }
    @Override
    public int lookupCCCFromE164(String e164) {
        isValid();
        return lookupCCCFromE164(nativePtr, e164);
    }
    private native int getError(long nativeptr);
    @Override
    public Reason getError() {
        isValid();
        return Reason.fromInt(getError(nativePtr));
    }
    private native void setPrivacy(long nativePtr, int mask);
    @Override
    public void setPrivacy(int privacy_mask) {
        isValid();
        setPrivacy(nativePtr,privacy_mask);
    }

    private native int getPrivacy(long nativePtr);
    @Override
    public int getPrivacy() {
        isValid();
        return getPrivacy(nativePtr);
    }

    private native void enableAvpf(long nativePtr, boolean enable);
    @Override
    public void enableAvpf(boolean enable) {
        isValid();
        enableAvpf(nativePtr, enable);
    }

    private native boolean avpfEnabled(long nativePtr);
    @Override
    public boolean avpfEnabled() {
        isValid();
        return avpfEnabled(nativePtr);
    }

    private native void setAvpfRRInterval(long nativePtr, int interval);
    @Override
    public void setAvpfRRInterval(int interval) {
        isValid();
        setAvpfRRInterval(nativePtr, interval);
    }

    private native int getAvpfRRInterval(long nativePtr);
    @Override
    public int getAvpfRRInterval() {
        isValid();
        return getAvpfRRInterval(nativePtr);
    }

    private native String getContactParameters(long ptr);
    @Override
    public String getContactParameters() {
        isValid();
        return getContactParameters(nativePtr);
    }

    private native void setContactUriParameters(long ptr, String params);
    @Override
    public void setContactUriParameters(String params) {
        isValid();
        setContactUriParameters(nativePtr,params);
    }

    private native String getContactUriParameters(long ptr);
    @Override
    public String getContactUriParameters() {
        isValid();
        return getContactUriParameters(nativePtr);
    }

    private native long getErrorInfo(long nativePtr);

    @Override
    public ErrorInfo getErrorInfo() {
        return new ErrorInfoImpl(getErrorInfo(nativePtr));
    }

    private native void enableQualityReporting(long nativePtr, boolean enable);
    @Override
    public void enableQualityReporting(boolean enable) {
        isValid();
        enableQualityReporting(nativePtr, enable);
    }

    private native boolean qualityReportingEnabled(long nativePtr);
    @Override
    public boolean qualityReportingEnabled() {
        isValid();
        return avpfEnabled(nativePtr);
    }

    private native void setQualityReportingInterval(long nativePtr, int interval);
    @Override
    public void setQualityReportingInterval(int interval) {
        isValid();
        setQualityReportingInterval(nativePtr, interval);
    }
    private native int getQualityReportingInterval(long nativePtr);
    @Override
    public int getQualityReportingInterval() {
        isValid();
        return getQualityReportingInterval(nativePtr);
    }

    private native void setQualityReportingCollector(long nativePtr, String collector);
    @Override
    public void setQualityReportingCollector(String collector) {
        isValid();
        setQualityReportingCollector(nativePtr, collector);
    }
    private native String getQualityReportingCollector(long nativePtr);
    @Override
    public String getQualityReportingCollector() {

        isValid();
        return getQualityReportingCollector(nativePtr);
    }

    private native void setRealm(long nativePtr, String realm);
    @Override
    public void setRealm(String realm) {
        isValid();
        setRealm(nativePtr, realm);
    }
    private native String getRealm(long nativePtr);
    @Override
    public String getRealm() {

        isValid();
        return getRealm(nativePtr);
    }

    private native void setPublishExpires(long nativePtr, int expires);
    @Override
    public void setPublishExpires(int expires) {
        isValid();
        setPublishExpires(nativePtr, expires);
    }
    private native int getPublishExpires(long nativePtr);
    @Override
    public int getPublishExpires() {

        isValid();
        return getPublishExpires(nativePtr);
    }

    private native boolean isPhoneNumber(long nativePtr,String username);
    @Override
    public boolean isPhoneNumber(String username){
        return isPhoneNumber(nativePtr,username);
    }

    @Override
    public void setUserData(Object obj) {
        userData = obj;
    }
    @Override
    public Object getUserData() {
        return userData;
    }
}


标签:java,String,void,long,nativePtr,return,linphone,LinphoneProxyConfig,public
From: https://blog.51cto.com/u_11797608/6370717

相关文章

  • 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......
  • linphone-PresenceActivity.java文件分析
    说明此类的对象供PresenceModel使用UML类图PresenceActivityImpl.javapackageorg.linphone.core;publicclassPresenceActivityImplimplementsPresenceActivity{privatelongmNativePtr;protectedPresenceActivityImpl(longnativePtr){mNativePtr=......
  • 什么是 JavaScript 里的循环引用(circular references)
    JavaScript的循环引用(circularreferences)是指在对象之间存在相互引用的情况,形成一个闭环,导致对象无法被完全释放和垃圾回收。循环引用发生在当一个对象的属性或成员引用另一个对象,并且这个被引用的对象又直接或间接地引用回原始对象,从而形成一个循环。当存在循环引用时,JavaScrip......