Merge branch 'call_info'
This commit is contained in:
@ -18,7 +18,7 @@ rtcp_mux no
|
||||
jitter_buffer_type adaptive
|
||||
jitter_buffer_delay 5-10
|
||||
jitter_buffer_wish 6
|
||||
rtp_stats no
|
||||
rtp_stats yes
|
||||
dyn_dns yes
|
||||
module opus.so
|
||||
module amr.so
|
||||
|
||||
@ -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
|
||||
|
||||
@ -49,8 +49,13 @@ class Call(val callp: String, val ua: UserAgent, val peerUri: String, val dir: S
|
||||
call_notify_sipfrag(callp, code, reason)
|
||||
}
|
||||
|
||||
fun status(): String {
|
||||
return call_status(callp)
|
||||
fun duration(): Int {
|
||||
return call_duration(callp)
|
||||
}
|
||||
|
||||
|
||||
fun stats(stream: String): String {
|
||||
return call_stats(callp, stream)
|
||||
}
|
||||
|
||||
fun audioCodecs(): String {
|
||||
@ -69,7 +74,8 @@ class Call(val callp: String, val ua: UserAgent, val peerUri: String, val dir: S
|
||||
private external fun call_notify_sipfrag(callp: String, code: Int, reason: String)
|
||||
private external fun call_start_audio(callp: String)
|
||||
private external fun call_audio_codecs(callp: String): String
|
||||
private external fun call_status(callp: String): String
|
||||
private external fun call_duration(callp: String): Int
|
||||
private external fun call_stats(callp: String, stream: String): String
|
||||
private external fun call_has_video(callp: String): Boolean
|
||||
|
||||
companion object {
|
||||
|
||||
@ -17,6 +17,9 @@ object Config {
|
||||
|
||||
config = config.replace("webrtc_aec.so", "webrtc_aecm.so")
|
||||
|
||||
if (config.contains("rtp_stats no"))
|
||||
replaceVariable("rtp_stats", "yes")
|
||||
|
||||
if (!config.contains(Regex("ausrc_format s16"))) {
|
||||
config = "${config}ausrc_format s16\nauplay_format s16\nauenc_format s16\naudec_format s16\nmodule webrtc_aecm.so\n"
|
||||
}
|
||||
|
||||
@ -380,19 +380,24 @@ class MainActivity : AppCompatActivity() {
|
||||
val ua = UserAgent.uas()[aorSpinner.selectedItemPosition]
|
||||
val calls = Call.uaCalls(ua, "")
|
||||
if (calls.size > 0) {
|
||||
val status = calls[0].status()
|
||||
val codecs = calls[0].audioCodecs()
|
||||
if (status.contains('[') && status.contains(']') &&
|
||||
status.contains('=') && codecs.contains(',')) {
|
||||
val duration = status.split("[")[1].split("]")[0]
|
||||
val rate = status.split('=')[1]
|
||||
val call = calls[0]
|
||||
val stats = call.stats("audio")
|
||||
if (stats != "") {
|
||||
val parts = stats.split(",")
|
||||
val codecs = call.audioCodecs()
|
||||
val duration = call.duration()
|
||||
Log.d(TAG, "********** stats ${calls[0].stats("audio")}")
|
||||
val txCodec = codecs.split(',')[0].split("/")
|
||||
val rxCodec = codecs.split(',')[1].split("/")
|
||||
Utils.alertView(this, getString(R.string.call_info),
|
||||
"${getString(R.string.duration)}: $duration\n" +
|
||||
"${String.format(getString(R.string.duration), duration)}\n" +
|
||||
"${getString(R.string.codecs)}: ${txCodec[0]} ch ${txCodec[2]}/" +
|
||||
"${rxCodec[0]} ch ${rxCodec[2]}\n" +
|
||||
"${getString(R.string.rate)}: $rate")
|
||||
"${String.format(getString(R.string.rate), parts[0])}\n" +
|
||||
"${String.format(getString(R.string.average_rate), parts[1])}\n" +
|
||||
"${getString(R.string.packets)}: ${parts[2]}\n" +
|
||||
"${getString(R.string.lost)}: ${parts[3]}\n" +
|
||||
"${getString(R.string.jitter)}: ${parts[4]}")
|
||||
} else {
|
||||
Utils.alertView(this, getString(R.string.call_info),
|
||||
getString(R.string.call_info_not_available))
|
||||
|
||||
@ -438,9 +438,13 @@
|
||||
<string name="dtmf">DTMF</string>
|
||||
<string name="call_info">Puhelutiedot</string>
|
||||
<string name="call_info_not_available">Ei saatavilla</string>
|
||||
<string name="duration">Kesto</string>
|
||||
<string name="duration">Kesto: %1$s (sek)</string>
|
||||
<string name="codecs">Koodekit</string>
|
||||
<string name="rate">Nopeus</string>
|
||||
<string name="rate">Nykyinen nopeus: %1$s (Kbit/s)</string>
|
||||
<string name="average_rate">Keskinopeus: %1$s (Kbit/s)</string>
|
||||
<string name="packets">Paketit</string>
|
||||
<string name="lost">Hukkunu</string>
|
||||
<string name="jitter">Vaihtelur</string>
|
||||
<string name="voicemail">Puheposti</string>
|
||||
<string name="voicemail_messages">Puhepostiviestit</string>
|
||||
<string name="you_have">Sinulla on</string>
|
||||
|
||||
@ -399,9 +399,13 @@
|
||||
<string name="dtmf">DTMF</string>
|
||||
<string name="call_info">Call Info</string>
|
||||
<string name="call_info_not_available">No info available</string>
|
||||
<string name="duration">Duration</string>
|
||||
<string name="duration">Duration: %1$s (secs)</string>
|
||||
<string name="codecs">Codecs</string>
|
||||
<string name="rate">Rate</string>
|
||||
<string name="rate">Current Rate: %1$s (Kbits/s)</string>
|
||||
<string name="average_rate">Average Rate: %1$s (Kbits/s)</string>
|
||||
<string name="packets">Packets</string>
|
||||
<string name="lost">Lost</string>
|
||||
<string name="jitter">Jitter</string>
|
||||
<string name="voicemail">Voicemail</string>
|
||||
<string name="voicemail_messages">Voicemail Messages</string>
|
||||
<string name="you_have">You have</string>
|
||||
|
||||
Reference in New Issue
Block a user