4import QGroundControl.Controls
6import "VideoStreamFormat.js" as VideoStreamFormat
8// The health of one video stream, from its controller's stats; shown only while the stream is measured. The camera's
9// advertised values follow the measured ones when they are known.
13 required property VideoStreamController stream
15 readonly property videoStreamStats _stats: stream.stats
16 readonly property size _videoSize: stream.videoSize
17 readonly property var _info: stream.streamInfo
18 readonly property real _cameraFps: _info ? _info.framerate : 0
19 readonly property real _cameraKbps: _info ? _info.bitrate / 1000 : 0
20 readonly property size _cameraSize: _info ? _info.resolution : Qt.size(0, 0)
21 readonly property bool _cameraSizeDiffers: _cameraSize.width > 0 && (_cameraSize.width !== _videoSize.width
22 || _cameraSize.height !== _videoSize.height)
23 readonly property string _videoText: _videoSize.width > 0
24 ? qsTr("%1 × %2 %3").arg(_videoSize.width).arg(_videoSize.height)
27 readonly property string _decoderText: _stats.hardwareDecoder ? qsTr("%1 (hardware)").arg(_stats.decoder)
28 : qsTr("%1 (software)").arg(_stats.decoder)
30 function _withCamera(measured, camera) {
31 return camera !== "" ? qsTr("%1 (camera %2)").arg(measured).arg(camera) : measured
38 labelText: root.stream.transport
39 visible: root.stream.transport !== ""
44 labelText: root.stream.uri
45 labelTextElide: Text.ElideMiddle
46 labelMaximumWidth: ScreenTools.defaultFontPixelWidth * 40
47 visible: root.stream.uri !== ""
51 label: qsTr("Camera stream")
52 labelText: root._info ? root._info.name : ""
53 visible: labelText !== ""
56 // Frames shown: none for a stream that isn't decoded, as the thermal stream while its view is off.
58 label: qsTr("Frame rate")
59 labelText: root._withCamera(qsTr("%1 fps").arg(root._stats.fps.toFixed(1)),
60 root._cameraFps > 0 ? qsTr("%1 fps").arg(root._cameraFps.toFixed(0)) : "")
61 visible: root.stream.decoding
65 label: qsTr("Dropped")
66 labelText: qsTr("%n frame(s)", "", root._stats.framesDropped)
70 label: qsTr("Bitrate")
71 labelText: root._withCamera(VideoStreamFormat.bitrateText(root._stats.bitrateKbps),
72 root._cameraKbps > 0 ? VideoStreamFormat.bitrateText(root._cameraKbps) : "")
73 visible: root._stats.bitrateKbps >= 0
78 labelText: root._withCamera(root._videoText, root._cameraSizeDiffers
79 ? qsTr("%1 × %2").arg(root._cameraSize.width).arg(root._cameraSize.height) : "")
80 visible: root._videoText !== ""
84 label: qsTr("Keyframe interval")
85 labelText: qsTr("%1 s").arg((root._stats.keyframeIntervalMs / 1000).toFixed(1))
86 visible: root._stats.keyframeIntervalMs >= 0
90 label: qsTr("Decoder")
91 labelText: root._decoderText
92 visible: root._stats.decoder !== ""
96 label: qsTr("Decoder restarts")
97 labelText: root._stats.decoderRestarts
98 visible: root._stats.decoderRestarts > 0
102 label: qsTr("Display path")
103 labelText: root._stats.gpuPath
104 visible: root._stats.gpuPath !== ""
108 label: qsTr("GPU fallbacks")
109 labelText: qsTr("%n frame(s)", "", root._stats.gpuFallbacks)
110 visible: root._stats.gpuFallbacks > 0
114 label: qsTr("Latency")
115 labelText: qsTr("%1 ms").arg(root._stats.latencyMs.toFixed(0))
116 visible: root._stats.latencyMs >= 0
120 label: qsTr("Packet loss")
121 labelText: qsTr("%1% (%n packet(s))", "", root._stats.packetsLost).arg(root._stats.lossPercent.toFixed(1))
122 visible: root._stats.hasRtpStats
126 label: qsTr("Jitter")
127 labelText: qsTr("%1 ms").arg(root._stats.jitterMs.toFixed(1))
128 visible: root._stats.jitterMs >= 0
131 // Only a jitter buffer tells them.
133 label: qsTr("Late / duplicate packets")
134 labelText: qsTr("%1 / %2").arg(root._stats.packetsLate).arg(root._stats.packetsDuplicate)
135 visible: root._stats.packetsLate >= 0
139 label: qsTr("Retransmissions")
140 labelText: qsTr("%1 requested, %2 recovered").arg(root._stats.rtxRequested).arg(root._stats.rtxRecovered)
141 visible: root._stats.rtxRequested > 0
145 label: qsTr("Uptime")
146 labelText: VideoStreamFormat.durationText(root._stats.uptimeMs)
150 label: qsTr("Reconnects")
151 labelText: root._stats.reconnects
152 visible: root._stats.reconnects > 0
156 label: qsTr("Recording")
157 labelText: qsTr("%1, %2").arg(VideoStreamFormat.durationText(root._stats.recordingMs))
158 .arg(QGroundControl.bigSizeToString(root._stats.recordingBytes))
159 visible: root._stats.recordingMs >= 0