Merge branch 'call_info'

This commit is contained in:
Juha Heinanen
2021-12-19 12:11:29 +02:00
7 changed files with 77 additions and 26 deletions

View File

@ -1403,18 +1403,47 @@ Java_com_tutpro_baresip_Call_call_1audio_1codecs(JNIEnv *env, jobject thiz, jstr
return (*env)->NewStringUTF(env, codec_buf);
}
JNIEXPORT jstring JNICALL
Java_com_tutpro_baresip_Call_call_1status(JNIEnv *env, jobject thiz, jstring javaCall) {
const char *native_call = (*env)->GetStringUTFChars(env, javaCall, 0);
JNIEXPORT jint JNICALL
Java_com_tutpro_baresip_Call_call_1duration(JNIEnv *env, jobject thiz, jstring jCall) {
const char *native_call = (*env)->GetStringUTFChars(env, jCall, 0);
struct call *call = (struct call *)strtoul(native_call, NULL, 10);
char status_buf[256];
int len = re_snprintf(&(status_buf[0]), 255, "%H", call_status, call);
if (len == -1) {
LOGE("failed to get status of call %s\n", native_call);
status_buf[0] = '\0';
int duration = call_duration(call);
(*env)->ReleaseStringUTFChars(env, jCall, native_call);
return duration;
}
JNIEXPORT jstring JNICALL
Java_com_tutpro_baresip_Call_call_1stats(JNIEnv *env, jobject thiz, jstring jCall, jstring jStream) {
const char *native_call = (*env)->GetStringUTFChars(env, jCall, 0);
struct call *call = (struct call *)strtoul(native_call, NULL, 10);
const char *native_stream = (*env)->GetStringUTFChars(env, jStream, 0);
const struct stream *s;
if (strcmp(native_stream, "audio") == 0)
s = audio_strm(call_audio(call));
else
s = video_strm(call_video(call));
const struct rtcp_stats *stats = stream_rtcp_stats(s);
char stats_buf[256];
int len;
if (stats) {
const double tx_rate = 1.0 * stream_metric_get_tx_bitrate(s) / 1000.0;
const double rx_rate = 1.0 * stream_metric_get_rx_bitrate(s) / 1000.0;
const double tx_avg_rate = 1.0 * stream_metric_get_tx_avg_bitrate(s) / 1000.0;
const double rx_avg_rate = 1.0 * stream_metric_get_rx_avg_bitrate(s) / 1000.0;
len = re_snprintf(&(stats_buf[0]), 256, "%.1f/%.1f,%.1f/%.1f,%u/%u,%d/%d,%.1f/%.1f\n",
tx_rate, rx_rate,
tx_avg_rate, rx_avg_rate,
stats->tx.sent, stats->rx.sent,
stats->tx.lost, stats->rx.lost,
1.0 * stats->tx.jit / 1000, 1.0 * stats->rx.jit / 1000);
if (len == -1) {
LOGE("failed to get stats of call %s %s stream\n", native_call, native_stream);
stats_buf[0] = '\0';
}
}
(*env)->ReleaseStringUTFChars(env, javaCall, native_call);
return (*env)->NewStringUTF(env, status_buf);
(*env)->ReleaseStringUTFChars(env, jCall, native_call);
(*env)->ReleaseStringUTFChars(env, jStream, native_stream);
return (*env)->NewStringUTF(env, stats_buf);
}
JNIEXPORT jboolean JNICALL