首页 > 其他分享 >linphone-PresenceNoteImpl文件对应的JNI层文件分析

linphone-PresenceNoteImpl文件对应的JNI层文件分析

时间:2023-05-29 14:36:33浏览次数:41  
标签:lang 文件 NULL presence note content JNI linphone


说明

这个很短, 自己看。

native函数

private native long newPresenceNoteImpl(String content, String lang);
    private native void unref(long nativePtr);
    private native String getContent(long nativePtr);
    private native int setContent(long nativePtr, String content);
    private native String getLang(long nativePtr);
    private native int setLang(long nativePtr, String lang);

具体的函数分析

newPresenceNoteImpl

/*
 * Class:     org_linphone_core_PresenceNoteImpl
 * Method:    newPresenceNoteImpl
 * Signature: (Ljava/lang/String;Ljava/lang/String;)J
 */
JNIEXPORT jlong JNICALL Java_org_linphone_core_PresenceNoteImpl_newPresenceNoteImpl(JNIEnv *env, jobject jobj, jstring content, jstring lang) {
    LinphonePresenceNote *note;
    const char *ccontent = content ? env->GetStringUTFChars(content, NULL) : NULL;
    const char *clang = lang ? env->GetStringUTFChars(lang, NULL) : NULL;
    note = linphone_presence_note_new(ccontent, clang);
    note = linphone_presence_note_ref(note);
    if (clang) env->ReleaseStringUTFChars(lang, clang);
    if (ccontent) env->ReleaseStringUTFChars(content, ccontent);
    return (jlong)note;
}

linphone_presence_note_new

LinphonePresenceNote * linphone_presence_note_new(const char *content, const char *lang) {
    LinphonePresenceNote *note;

    if (content == NULL) return NULL;
    note = ms_new0(LinphonePresenceNote, 1);
    note->refcnt = 1;
    note->content = ms_strdup(content);
    if (lang != NULL) {
        note->lang = ms_strdup(lang);
    }
    return note;
}

linphone_presence_note_ref

LinphonePresenceNote * linphone_presence_note_ref(LinphonePresenceNote *note) {
    note->refcnt++;
    return note;
}

unref

/*
 * Class:     org_linphone_core_PresenceNoteImpl
 * Method:    unref
 * Signature: (J)V
 */
JNIEXPORT void JNICALL Java_org_linphone_core_PresenceNoteImpl_unref(JNIEnv *env, jobject jobj, jlong ptr) {
    LinphonePresenceNote *note = (LinphonePresenceNote *)ptr;
    linphone_presence_note_unref(note);
}

linphone_presence_note_unref

LinphonePresenceNote * linphone_presence_note_unref(LinphonePresenceNote *note) {
    note->refcnt--;
    if (note->refcnt == 0) {
        presence_note_delete(note);
        return NULL;
    }
    return note;
}

presence_note_delete

static void presence_note_delete(LinphonePresenceNote *note) {
    ms_free(note->content);
    if (note->lang != NULL) {
        ms_free(note->lang);
    }
    ms_free(note);
}

getContent

/*
 * Class:     org_linphone_core_PresenceNoteImpl
 * Method:    getContent
 * Signature: (J)Ljava/lang/String;
 */
JNIEXPORT jstring JNICALL Java_org_linphone_core_PresenceNoteImpl_getContent(JNIEnv *env, jobject jobj, jlong ptr) {
    LinphonePresenceNote *note = (LinphonePresenceNote *)ptr;
    const char *ccontent = linphone_presence_note_get_content(note);
    return ccontent ? env->NewStringUTF(ccontent) : NULL;
}

linphone_presence_note_get_content

const char * linphone_presence_note_get_content(const LinphonePresenceNote *note) {
    if (note == NULL)
        return NULL;
    return note->content;
}

setContent

/*
 * Class:     org_linphone_core_PresenceNoteImpl
 * Method:    setContent
 * Signature: (JLjava/lang/String;)I
 */
JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceNoteImpl_setContent(JNIEnv *env, jobject jobj, jlong ptr, jstring content) {
    LinphonePresenceNote *note = (LinphonePresenceNote *)ptr;
    const char *ccontent = content ? env->GetStringUTFChars(content, NULL) : NULL;
    linphone_presence_note_set_content(note, ccontent);
    if (ccontent) env->ReleaseStringUTFChars(content, ccontent);
    return (jint)0;
}

linphone_presence_note_set_content

int linphone_presence_note_set_content(LinphonePresenceNote *note, const char *content) {
    if (content == NULL) return -1;
    if (note->content != NULL) {
        ms_free(note->content);
    }
    note->content = ms_strdup(content);
    return 0;
}

getLang

/*
 * Class:     org_linphone_core_PresenceNoteImpl
 * Method:    getLang
 * Signature: (J)Ljava/lang/String;
 */
JNIEXPORT jstring JNICALL Java_org_linphone_core_PresenceNoteImpl_getLang(JNIEnv *env, jobject jobj, jlong ptr) {
    LinphonePresenceNote *note = (LinphonePresenceNote *)ptr;
    const char *clang = linphone_presence_note_get_lang(note);
    return clang ? env->NewStringUTF(clang) : NULL;
}

linphone_presence_note_get_lang

const char * linphone_presence_note_get_lang(const LinphonePresenceNote *note) {
    if (note == NULL)
        return NULL;
    return note->lang;
}

setLang

/*
 * Class:     org_linphone_core_PresenceNoteImpl
 * Method:    setLang
 * Signature: (JLjava/lang/String;)I
 */
JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceNoteImpl_setLang(JNIEnv *env, jobject jobj, jlong ptr, jstring lang) {
    LinphonePresenceNote *note = (LinphonePresenceNote *)ptr;
    const char *clang = lang ? env->GetStringUTFChars(lang, NULL) : NULL;
    linphone_presence_note_set_lang(note, clang);
    if (clang) env->ReleaseStringUTFChars(lang, clang);
    return (jint)0;
}

linphone_presence_note_set_lang

int linphone_presence_note_set_lang(LinphonePresenceNote *note, const char *lang) {
    if (note->lang != NULL) {
        ms_free(note->lang);
        note->lang = NULL;
    }
    if (lang != NULL) {
        note->lang = ms_strdup(lang);
    }
    return 0;
}


标签:lang,文件,NULL,presence,note,content,JNI,linphone
From: https://blog.51cto.com/u_11797608/6370705

相关文章

  • linphone-TunnelConfigImpl文件对应的JNI层文件分析
    说明native函数privatenativeStringgetHost(longnativePtr);privatenativevoidsetHost(longnativePtr,Stringhost);privatenativeintgetPort(longnativePtr);privatenativevoidsetPort(longnativePtr,intport);privatenativeintgetRem......
  • linphone-LinphoneService.java文件分析
    说明主要是处理接听电话的逻辑,监听linphone拨打电话的状态逻辑。官方注释/****Linphoneservice,reactingtoIncomingcalls,...<br/>**Rolesinclude:<ul>*<li>InitializingLinphoneManager</li>*<li>StartingClibLinphonethroughLinphoneManage......
  • linphone-LinphoneCallParams.java文件分析
    说明专门作为Audio和Video的参数功能设置视频的带宽设置音频的带宽设置媒体的加密数据(encryption)设置是否允许低带宽设置RecordFile设置Sdp设置会话名称等是否允许多个rtp请求UML类图LinphoneCallParamsImpl.javapackageorg.linphone.core;importorg.linphone.core.LinphoneCor......
  • linphone-CallManager.java文件分析
    说明进行会话的管理,重新加入会话等功能创建会话重新进入Video重新设置参数更新会话UML类图CallManger.javapackageorg.linphone;importorg.linphone.core.LinphoneAddress;importorg.linphone.core.LinphoneCall;importorg.linphone.core.LinphoneCallParams;importorg.l......
  • 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......
  • JNI-记录一个内存泄露的问题
    android:channelisunrecoverablybrokenandwillbedisposed记录一个关于内存泄漏的问题:RT,在停止播放音乐时,每过一段时间就会报05-2510:52:21.125491-528/system_processE/InputDispatcher:channel'4a8b59f4activity.MainActivity(server)'~Channelisun......
  • linphone-NetworkManger.java文件分析
    功能InterceptnetworkstatechangesandupdatelinphonecorethroughLinphoneManger翻译拦截网络状态的变化,并通过LinphoneManger更新linphone核心内容。NetworkManager.java/**......
  • linphone-KeepAliveReceiver.java文件分析
    说明Purposeofthisreceiveristodisablekeepaliveswhenscreenisoff解释这个接收器的目的是屏幕关闭的时候进行保活。<—翻译的准确性,等更加深刻的分析源码时更正,或者读者自己在下面评论也可以。介绍此类为接收器,接收外部传来的广播。KeepAliveReceiver.java/**Purpos......