- Improved implementation of account_audio_codec() API function.
This commit is contained in:
@@ -775,8 +775,8 @@ Java_com_tutpro_baresip_AccountKt_account_1set_1outbound(JNIEnv *env, jobject th
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jstring JNICALL
|
JNIEXPORT jstring JNICALL
|
||||||
Java_com_tutpro_baresip_AccountKt_account_1audio_1codec(JNIEnv *env, jobject thiz, jstring javaAcc,
|
Java_com_tutpro_baresip_AccountKt_account_1audio_1codec(JNIEnv *env, jobject thiz,
|
||||||
jint ix) {
|
jstring javaAcc, jint ix) {
|
||||||
const char *native_acc = (*env)->GetStringUTFChars(env, javaAcc, 0);
|
const char *native_acc = (*env)->GetStringUTFChars(env, javaAcc, 0);
|
||||||
struct account *acc = (struct account *)strtoul(native_acc, NULL, 10);
|
struct account *acc = (struct account *)strtoul(native_acc, NULL, 10);
|
||||||
(*env)->ReleaseStringUTFChars(env, javaAcc, native_acc);
|
(*env)->ReleaseStringUTFChars(env, javaAcc, native_acc);
|
||||||
@@ -784,13 +784,13 @@ Java_com_tutpro_baresip_AccountKt_account_1audio_1codec(JNIEnv *env, jobject thi
|
|||||||
char codec_buf[32];
|
char codec_buf[32];
|
||||||
int len;
|
int len;
|
||||||
struct le *le;
|
struct le *le;
|
||||||
|
codec_buf[0] = '\0';
|
||||||
if (acc) {
|
if (acc) {
|
||||||
codecl = account_aucodecl(acc);
|
codecl = account_aucodecl(acc);
|
||||||
if (!list_isempty(codecl)) {
|
if (!list_isempty(codecl)) {
|
||||||
int i = -1;
|
int i = -1;
|
||||||
for (le = list_head(codecl); le != NULL; le = le->next) {
|
for (le = list_head(codecl); le != NULL; le = le->next) {
|
||||||
i++;
|
i++;
|
||||||
if (i > ix) break;
|
|
||||||
if (i == ix) {
|
if (i == ix) {
|
||||||
const struct aucodec *ac = le->data;
|
const struct aucodec *ac = le->data;
|
||||||
len = re_snprintf(codec_buf, sizeof codec_buf, "%s/%u/%u", ac->name, ac->srate, ac->ch);
|
len = re_snprintf(codec_buf, sizeof codec_buf, "%s/%u/%u", ac->name, ac->srate, ac->ch);
|
||||||
@@ -801,13 +801,10 @@ Java_com_tutpro_baresip_AccountKt_account_1audio_1codec(JNIEnv *env, jobject thi
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i == ix) {
|
}
|
||||||
|
}
|
||||||
return (*env)->NewStringUTF(env, codec_buf);
|
return (*env)->NewStringUTF(env, codec_buf);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return (*env)->NewStringUTF(env, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL
|
JNIEXPORT jint JNICALL
|
||||||
Java_com_tutpro_baresip_AccountKt_account_1set_1audio_1codecs(JNIEnv *env, jobject thiz,
|
Java_com_tutpro_baresip_AccountKt_account_1set_1audio_1codecs(JNIEnv *env, jobject thiz,
|
||||||
@@ -816,7 +813,6 @@ Java_com_tutpro_baresip_AccountKt_account_1set_1audio_1codecs(JNIEnv *env, jobje
|
|||||||
struct account *acc = (struct account *) strtoul(native_acc, NULL, 10);
|
struct account *acc = (struct account *) strtoul(native_acc, NULL, 10);
|
||||||
(*env)->ReleaseStringUTFChars(env, javaAcc, native_acc);
|
(*env)->ReleaseStringUTFChars(env, javaAcc, native_acc);
|
||||||
const char *codecs = (*env)->GetStringUTFChars(env, javaCodecs, 0);
|
const char *codecs = (*env)->GetStringUTFChars(env, javaCodecs, 0);
|
||||||
LOGD("setting audio codecs '%s'\n", codecs);
|
|
||||||
int res = account_set_audio_codecs(acc, codecs);
|
int res = account_set_audio_codecs(acc, codecs);
|
||||||
(*env)->ReleaseStringUTFChars(env, javaCodecs, codecs);
|
(*env)->ReleaseStringUTFChars(env, javaCodecs, codecs);
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
Reference in New Issue
Block a user