Added FEC in-call stats

This commit is contained in:
Sylvain Berfini 2024-07-12 14:04:46 +02:00
parent 25be5e1814
commit 1cd79b5086
7 changed files with 171 additions and 34 deletions

View file

@ -39,6 +39,11 @@ class CallStatsModel @WorkerThread constructor() {
val videoResolution = MutableLiveData<String>()
val videoFps = MutableLiveData<String>()
val fecEnabled = MutableLiveData<Boolean>()
val lostPackets = MutableLiveData<String>()
val repairedPackets = MutableLiveData<String>()
val fecBandwidth = MutableLiveData<String>()
@WorkerThread
fun update(call: Call, stats: CallStats?) {
stats ?: return
@ -51,6 +56,9 @@ class CallStatsModel @WorkerThread constructor() {
val showVideoStats = videoEnabled && (remoteSendsVideo || localSendsVideo)
isVideoEnabled.postValue(showVideoStats)
val isFecEnabled = call.core.isFecEnabled // TODO FIXME: use real value from call
fecEnabled.postValue(showVideoStats && isFecEnabled)
when (stats.type) {
StreamType.Audio -> {
val payloadType = call.currentParams.usedAudioPayloadType
@ -101,6 +109,30 @@ class CallStatsModel @WorkerThread constructor() {
"$sentFps$receivedFps"
)
videoFps.postValue(fpsLabel)
if (isFecEnabled) {
val lostPacketsValue = stats.fecCumulativeLostPacketsNumber
val lostPacketsLabel = AppUtils.getFormattedString(
R.string.call_stats_fec_lost_packets_label,
lostPacketsValue
)
lostPackets.postValue(lostPacketsLabel)
val repairedPacketsValue = stats.fecRepairedPacketsNumber
val repairedPacketsLabel = AppUtils.getFormattedString(
R.string.call_stats_fec_repaired_packets_label,
repairedPacketsValue
)
repairedPackets.postValue(repairedPacketsLabel)
val fecUploadBandwidth = stats.fecUploadBandwidth.roundToInt()
val fecDownloadBandwidth = stats.fecDownloadBandwidth.roundToInt()
val fecBandwidthLabel = AppUtils.getFormattedString(
R.string.call_stats_fec_lost_bandwidth_label,
"$fecUploadBandwidth kbits/s ↓ $fecDownloadBandwidth kbits/s"
)
fecBandwidth.postValue(fecBandwidthLabel)
}
}
else -> {}
}

View file

@ -959,7 +959,7 @@ class ConversationFragment : SlidingPaneChildFragment() {
popupView.setUnmuteClickListener {
Log.i("$TAG Un-muting conversation")
viewModel.unmute()
viewModel.unMute()
popupWindow.dismiss()
}

View file

@ -432,7 +432,7 @@ class ConversationViewModel @UiThread constructor() : AbstractConversationViewMo
}
@UiThread
fun unmute() {
fun unMute() {
coreContext.postOnCoreThread {
chatRoom.muted = false
isMuted.postValue(chatRoom.muted)

View file

@ -36,13 +36,13 @@
android:id="@+id/audio_stats"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="20dp"
android:background="@drawable/shape_squircle_gray_600_background"
app:layout_constraintVertical_bias="0"
app:layout_constraintWidth_percent="0.45"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintTop_toBottomOf="@id/handle"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/video_stats"
@ -64,8 +64,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="@{model.audioCodec, default=@string/call_stats_codec_label}"
android:textColor="@color/white"
android:maxLines="1"
@ -77,8 +75,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="10dp"
android:text="@{model.audioBandwidth, default=@string/call_stats_bandwidth_label}"
android:textColor="@color/white"
@ -92,16 +88,15 @@
android:id="@+id/video_stats"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="20dp"
android:background="@drawable/shape_squircle_gray_600_background"
android:visibility="@{model.isVideoEnabled ? View.VISIBLE : View.GONE}"
app:layout_constraintWidth_percent="0.45"
app:layout_constraintTop_toBottomOf="@id/handle"
app:layout_constraintStart_toEndOf="@id/audio_stats"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@id/fec_stats"
app:layout_constraintBottom_toBottomOf="parent"
android:orientation="vertical">
@ -120,8 +115,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="@{model.videoCodec, default=@string/call_stats_codec_label}"
android:textColor="@color/white"
android:maxLines="1"
@ -133,8 +126,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="@{model.videoBandwidth, default=@string/call_stats_bandwidth_label}"
android:textColor="@color/white"
android:maxLines="1"
@ -146,8 +137,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="@{model.videoResolution, default=@string/call_stats_resolution_label}"
android:textColor="@color/white"
android:maxLines="1"
@ -159,8 +148,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="10dp"
android:text="@{model.videoFps, default=@string/call_stats_fps_label}"
android:textColor="@color/white"
@ -170,6 +157,68 @@
</LinearLayout>
<LinearLayout
android:id="@+id/fec_stats"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="20dp"
android:background="@drawable/shape_squircle_gray_600_background"
android:visibility="@{model.fecEnabled ? View.VISIBLE : View.GONE}"
app:layout_constraintVertical_bias="0"
app:layout_constraintTop_toBottomOf="@id/handle"
app:layout_constraintStart_toEndOf="@id/video_stats"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style_700"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/call_stats_fec_title"
android:textSize="12sp"
android:textColor="@color/white"
android:gravity="center" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@{model.lostPackets, default=@string/call_stats_fec_lost_packets_label}"
android:textColor="@color/white"
android:maxLines="1"
android:ellipsize="end"
android:gravity="center" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@{model.repairedPackets, default=@string/call_stats_fec_repaired_packets_label}"
android:textColor="@color/white"
android:maxLines="1"
android:ellipsize="end"
android:gravity="center" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@{model.fecBandwidth, default=@string/call_stats_fec_lost_bandwidth_label}"
android:textColor="@color/white"
android:maxLines="1"
android:ellipsize="end"
android:gravity="center" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

View file

@ -62,8 +62,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="@{model.audioCodec, default=@string/call_stats_codec_label}"
android:textColor="@color/white"
android:maxLines="1"
@ -75,8 +73,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="10dp"
android:text="@{model.audioBandwidth, default=@string/call_stats_bandwidth_label}"
android:textColor="@color/white"
@ -98,7 +94,7 @@
app:layout_constraintTop_toBottomOf="@id/audio_stats"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toTopOf="@id/fec_stats"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView
@ -116,8 +112,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="@{model.videoCodec, default=@string/call_stats_codec_label}"
android:textColor="@color/white"
android:maxLines="1"
@ -129,8 +123,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="@{model.videoBandwidth, default=@string/call_stats_bandwidth_label}"
android:textColor="@color/white"
android:maxLines="1"
@ -142,8 +134,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="@{model.videoResolution, default=@string/call_stats_resolution_label}"
android:textColor="@color/white"
android:maxLines="1"
@ -155,8 +145,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="10dp"
android:text="@{model.videoFps, default=@string/call_stats_fps_label}"
android:textColor="@color/white"
@ -166,6 +154,66 @@
</LinearLayout>
<LinearLayout
android:id="@+id/fec_stats"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginBottom="20dp"
android:background="@drawable/shape_squircle_gray_600_background"
android:visibility="@{model.fecEnabled ? View.VISIBLE : View.GONE}"
app:layout_constraintTop_toBottomOf="@id/video_stats"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style_700"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/call_stats_fec_title"
android:textSize="12sp"
android:textColor="@color/white"
android:gravity="center" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@{model.lostPackets, default=@string/call_stats_fec_lost_packets_label}"
android:textColor="@color/white"
android:maxLines="1"
android:ellipsize="end"
android:gravity="center" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@{model.repairedPackets, default=@string/call_stats_fec_repaired_packets_label}"
android:textColor="@color/white"
android:maxLines="1"
android:ellipsize="end"
android:gravity="center" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@{model.fecBandwidth, default=@string/call_stats_fec_lost_bandwidth_label}"
android:textColor="@color/white"
android:maxLines="1"
android:ellipsize="end"
android:gravity="center" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

View file

@ -618,6 +618,10 @@
<string name="call_stats_video_title">Vidéo</string>
<string name="call_stats_resolution_label">Résolution : %s</string>
<string name="call_stats_fps_label">FPS : %s</string>
<string name="call_stats_fec_title">FEC</string>
<string name="call_stats_fec_lost_packets_label">Paquets perdus : %s</string>
<string name="call_stats_fec_repaired_packets_label">Paquets réparés : %s</string>
<string name="call_stats_fec_lost_bandwidth_label">Bande passante : %s</string>
<string name="call_stats_media_encryption_title">Chiffrement du média</string>
<string name="call_stats_media_encryption">Chiffrement : %s</string>

View file

@ -656,6 +656,10 @@
<string name="call_stats_video_title">Video</string>
<string name="call_stats_resolution_label">Resolution: %s</string>
<string name="call_stats_fps_label">FPS: %s</string>
<string name="call_stats_fec_title">FEC</string>
<string name="call_stats_fec_lost_packets_label">Lost packets: %s</string>
<string name="call_stats_fec_repaired_packets_label">Repaired packets: %s</string>
<string name="call_stats_fec_lost_bandwidth_label">Bandwidth: %s</string>
<string name="call_stats_media_encryption_title">Media encryption</string>
<string name="call_stats_media_encryption">Media encryption: %s</string>