Commit cd009860 authored by jehan's avatar jehan

add codec management to java api

parent 8821090e
......@@ -71,7 +71,6 @@ LOCAL_C_INCLUDES += \
LOCAL_LDLIBS += -llog
LOCAL_STATIC_LIBRARIES := \
libmsandroidsnd \
libmediastreamer2 \
libortp \
libspeex \
......
......@@ -3777,3 +3777,27 @@ void linphone_core_destroy(LinphoneCore *lc){
ms_free(lc);
}
static PayloadType* find_payload_type_from_list(const char* type, int rate,const MSList* from) {
const MSList *elem;
for(elem=from;elem!=NULL;elem=elem->next){
PayloadType *pt=(PayloadType*)elem->data;
if ((strcmp((char*)type, payload_type_get_mime(pt)) == 0) && rate==pt->clock_rate) {
return pt;
}
}
return NULL;
}
PayloadType* linphone_core_find_payload_type(LinphoneCore* lc, const char* type, int rate) {
PayloadType* result = find_payload_type_from_list(type, rate, linphone_core_get_audio_codecs(lc));
if (result) {
return result;
} else {
result = find_payload_type_from_list(type, rate, linphone_core_get_video_codecs(lc));
if (result) {
return result;
}
}
//not found
return NULL;
}
......@@ -573,6 +573,14 @@ bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, PayloadType *pt);
int linphone_core_enable_payload_type(LinphoneCore *lc, PayloadType *pt, bool_t enable);
/*
* get payload type from mime type an clock rate
* @ingroup media_parameters
* iterates both audio an video
* return NULL if not found
*/
PayloadType* linphone_core_find_payload_type(LinphoneCore* lc, const char* type, int rate) ;
const char *linphone_core_get_payload_type_description(LinphoneCore *lc, PayloadType *pt);
bool_t linphone_core_check_payload_type_usability(LinphoneCore *lc, PayloadType *pt);
......
......@@ -337,6 +337,23 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMicMuted( JNIEnv*
,jlong lc) {
return linphone_core_is_mic_muted((LinphoneCore*)lc);
}
extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv* env
,jobject thiz
,jlong lc
,jstring jmime
,jint rate) {
const char* mime = env->GetStringUTFChars(jmime, NULL);
jlong result = (jlong)linphone_core_find_payload_type((LinphoneCore*)lc,mime,rate);
env->ReleaseStringUTFChars(jmime, mime);
return result;
}
extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv* env
,jobject thiz
,jlong lc
,jlong pt
,jboolean enable) {
return linphone_core_enable_payload_type((LinphoneCore*)lc,(PayloadType*)pt,enable);
}
......@@ -377,6 +394,20 @@ extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEn
return NULL;
}
}
extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) {
const char* route = env->GetStringUTFChars(jroute, NULL);
int err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route);
env->ReleaseStringUTFChars(jroute, route);
return err;
}
extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getRoute(JNIEnv* env,jobject thiz,jlong proxyCfg) {
const char* route = linphone_proxy_config_get_route((LinphoneProxyConfig*)proxyCfg);
if (route) {
return env->NewStringUTF(route);
} else {
return NULL;
}
}
extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enableRegister(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean enableRegister) {
linphone_proxy_config_enable_register((LinphoneProxyConfig*)proxyCfg,enableRegister);
......@@ -553,3 +584,17 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv
,jlong ptr) {
return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
}
extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv* env
,jobject thiz
,jlong ptr) {
PayloadType* pt = (PayloadType*)ptr;
char* value = ms_strdup_printf("[%s] clock [%s], bitrate [%s]"
,payload_type_get_mime(pt)
,payload_type_get_rate(pt)
,payload_type_get_bitrate(pt));
jstring jvalue =env->NewStringUTF(value);
ms_free(value);
return jvalue;
}
......@@ -185,4 +185,15 @@ public interface LinphoneCore {
*
*/
public void clearCallLogs();
/***
* get payload type from mime type an clock rate
*
* return null if not found
*/
public PayloadType findPayloadType(String mime,int clockRate);
public void enablePayloadType(PayloadType pt, boolean enable) throws LinphoneCoreException;
}
......@@ -72,4 +72,7 @@ public interface LinphoneProxyConfig {
public String getProxy();
public boolean registerEnabled();
public boolean isRegistered();
public void setRoute(String routeUri) throws LinphoneCoreException;
public String getRoute();
}
/*
PayloadType.java
Copyright (C) 2010 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.core;
public interface PayloadType {
}
mediastreamer2 @ 55d14a76
Subproject commit a6484a8463b62a60d03ef8358b2e305408f3b011
Subproject commit 55d14a76fa81b5941aec6cd272b3b69688e54e56
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment