diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 8d40ac629..55e95a7fe 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -3961,13 +3961,21 @@ static PayloadType* find_payload_type_from_list(const char* type, int rate,const 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) { + if ((strcmp((char*)type, payload_type_get_mime(pt)) == 0) && (rate == -1 || rate==pt->clock_rate)) { return pt; } } return NULL; } +static void printCodecs(const MSList* from) { + const MSList *elem; + for(elem=from;elem!=NULL;elem=elem->next){ + PayloadType *pt=(PayloadType*)elem->data; + ms_message(payload_type_get_mime(pt)); + } +} + /** * Get payload type from mime type and clock rate * @ingroup media_parameters diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 077de5f3f..91021d8e1 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -509,6 +509,24 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv* env->ReleaseStringUTFChars(jmime, mime); return result; } +extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listVideoPayloadTypes(JNIEnv* env + ,jobject thiz + ,jlong lc) { + const MSList* codecs = linphone_core_get_video_codecs((LinphoneCore*)lc); + int codecsCount = ms_list_size(codecs); + jlongArray jCodecs = env->NewLongArray(codecsCount); + jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL); + + for (int i = 0; i < codecsCount; i++ ) { + jInternalArray[i] = (unsigned long) (codecs->data); + codecs = codecs->next; + } + + env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0); + + return jCodecs; +} + extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv* env ,jobject thiz ,jlong lc @@ -831,12 +849,9 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE; } -extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv* env - ,jobject thiz - ,jlong ptr) { - +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]" + char* value = ms_strdup_printf("[%s] clock [%i], bitrate [%i]" ,payload_type_get_mime(pt) ,payload_type_get_rate(pt) ,payload_type_get_bitrate(pt)); @@ -844,6 +859,16 @@ extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv* env ms_free(value); return jvalue; } +extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_getMime(JNIEnv* env,jobject thiz,jlong ptr) { + PayloadType* pt = (PayloadType*)ptr; + jstring jvalue =env->NewStringUTF(payload_type_get_mime(pt)); + return jvalue; +} +extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv* env,jobject thiz, jlong ptr) { + PayloadType* pt = (PayloadType*)ptr; + return payload_type_get_rate(pt); +} + //LinphoneCall extern "C" void Java_org_linphone_core_LinphoneCallImpl_ref(JNIEnv* env ,jobject thiz diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index cbf3bdd34..c3166faa8 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -485,4 +485,7 @@ public interface LinphoneCore { public void setPreferredVideoSize(VideoSize vSize); public VideoSize getPreferredVideoSize(); + + public PayloadType[] listVideoCodecs(); + } diff --git a/java/common/org/linphone/core/PayloadType.java b/java/common/org/linphone/core/PayloadType.java index 59a64699b..952da57d2 100644 --- a/java/common/org/linphone/core/PayloadType.java +++ b/java/common/org/linphone/core/PayloadType.java @@ -20,4 +20,5 @@ package org.linphone.core; public interface PayloadType { + String getMime(); }