-
Notifications
You must be signed in to change notification settings - Fork 0
/
Extensions.kt
160 lines (146 loc) · 4.44 KB
/
Extensions.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
package io.agora.rtc.base
import android.graphics.Rect
import io.agora.rtc.IRtcEngineEventHandler.*
import io.agora.rtc.models.UserInfo
fun UserInfo.toMap(): Map<String, Any?> {
return hashMapOf(
"uid" to uid,
"userAccount" to userAccount
)
}
fun LocalAudioStats.toMap(): Map<String, Any?> {
return hashMapOf(
"numChannels" to numChannels,
"sentSampleRate" to sentSampleRate,
"sentBitrate" to sentBitrate,
"txPacketLossRate" to txPacketLossRate
)
}
fun RtcStats.toMap(): Map<String, Any?> {
return hashMapOf(
"totalDuration" to totalDuration,
"txBytes" to txBytes,
"rxBytes" to rxBytes,
"txAudioBytes" to txAudioBytes,
"txVideoBytes" to txVideoBytes,
"rxAudioBytes" to rxAudioBytes,
"rxVideoBytes" to rxVideoBytes,
"txKBitRate" to txKBitRate,
"rxKBitRate" to rxKBitRate,
"txAudioKBitRate" to txAudioKBitRate,
"rxAudioKBitRate" to rxAudioKBitRate,
"txVideoKBitRate" to txVideoKBitRate,
"rxVideoKBitRate" to rxVideoKBitRate,
"users" to users,
"lastmileDelay" to lastmileDelay,
"txPacketLossRate" to txPacketLossRate,
"rxPacketLossRate" to rxPacketLossRate,
"cpuTotalUsage" to cpuTotalUsage,
"cpuAppUsage" to cpuAppUsage,
"gatewayRtt" to gatewayRtt,
"memoryAppUsageRatio" to memoryAppUsageRatio,
"memoryTotalUsageRatio" to memoryTotalUsageRatio,
"memoryAppUsageInKbytes" to memoryAppUsageInKbytes
)
}
fun Rect.toMap(): Map<String, Any?> {
return hashMapOf(
"left" to left,
"top" to top,
"right" to right,
"bottom" to bottom
)
}
fun RemoteAudioStats.toMap(): Map<String, Any?> {
return hashMapOf(
"uid" to uid,
"quality" to quality,
"networkTransportDelay" to networkTransportDelay,
"jitterBufferDelay" to jitterBufferDelay,
"audioLossRate" to audioLossRate,
"numChannels" to numChannels,
"receivedSampleRate" to receivedSampleRate,
"receivedBitrate" to receivedBitrate,
"totalFrozenTime" to totalFrozenTime,
"frozenRate" to frozenRate,
"totalActiveTime" to totalActiveTime,
"publishDuration" to publishDuration,
"qoeQuality" to qoeQuality,
"qualityChangedReason" to qualityChangedReason,
"mosValue" to mosValue
)
}
fun LocalVideoStats.toMap(): Map<String, Any?> {
return hashMapOf(
"sentBitrate" to sentBitrate,
"sentFrameRate" to sentFrameRate,
"encoderOutputFrameRate" to encoderOutputFrameRate,
"rendererOutputFrameRate" to rendererOutputFrameRate,
"targetBitrate" to targetBitrate,
"targetFrameRate" to targetFrameRate,
"qualityAdaptIndication" to qualityAdaptIndication,
"encodedBitrate" to encodedBitrate,
"encodedFrameWidth" to encodedFrameWidth,
"encodedFrameHeight" to encodedFrameHeight,
"encodedFrameCount" to encodedFrameCount,
"codecType" to codecType,
"txPacketLossRate" to txPacketLossRate,
"captureFrameRate" to captureFrameRate,
"captureBrightnessLevel" to captureBrightnessLevel
)
}
fun RemoteVideoStats.toMap(): Map<String, Any?> {
return hashMapOf(
"uid" to uid,
"delay" to delay,
"width" to width,
"height" to height,
"receivedBitrate" to receivedBitrate,
"decoderOutputFrameRate" to decoderOutputFrameRate,
"rendererOutputFrameRate" to rendererOutputFrameRate,
"packetLossRate" to packetLossRate,
"rxStreamType" to rxStreamType,
"totalFrozenTime" to totalFrozenTime,
"frozenRate" to frozenRate,
"totalActiveTime" to totalActiveTime,
"publishDuration" to publishDuration
)
}
fun AudioVolumeInfo.toMap(): Map<String, Any?> {
return hashMapOf(
"uid" to uid,
"volume" to volume,
"vad" to vad,
"channelId" to channelId
)
}
fun Array<out AudioVolumeInfo>.toMapList(): List<Map<String, Any?>> {
return List(size) { this[it].toMap() }
}
fun LastmileProbeResult.LastmileProbeOneWayResult.toMap(): Map<String, Any?> {
return hashMapOf(
"packetLossRate" to packetLossRate,
"jitter" to jitter,
"availableBandwidth" to availableBandwidth
)
}
fun LastmileProbeResult.toMap(): Map<String, Any?> {
return hashMapOf(
"state" to state,
"rtt" to rtt,
"uplinkReport" to uplinkReport.toMap(),
"downlinkReport" to downlinkReport.toMap()
)
}
fun AgoraFacePositionInfo.toMap(): Map<String, Any?> {
return hashMapOf(
"x" to x,
"y" to y,
"width" to width,
"height" to height,
"distance" to distance
)
}
fun Array<out AgoraFacePositionInfo>.toMapList(): List<Map<String, Any?>> {
return List(size) { this[it].toMap() }
}