1pragma ComponentBehavior: Bound
7import QGroundControl.Controls
9// One video source in a tile: its picture over its name, or why there is no picture. A tap makes the source the main
14 /// The source shown: a stream or the USB camera.
15 required property VideoStreamController source
16 /// The manager the source is one of.
17 property VideoManager videoManager: QGroundControl.videoManager
18 /// Whether the tile is on display, as its row is: the source plays into it only then.
19 property bool shown: true
21 readonly property bool _isCamera: root.source.role === VideoSourceRole.Camera
22 // A lost stream's last frame stays up, under a notice, while it reconnects.
23 readonly property bool _streamLost: !root._isCamera && root.source.reconnecting
24 readonly property bool _hasPicture: root.source.decoding || root._streamLost
25 readonly property real _margin: ScreenTools.defaultFontPixelWidth / 2
27 color: qgcPal.mapWidgetBorderDark
28 border.color: qgcPal.mapWidgetBorderLight
30 // The placeholder's picture is cropped to fill the tile, and a notice can be taller than a small one.
33 QGCPalette { id: qgcPal }
37 anchors.margins: root.border.width
38 videoManager: root.videoManager
39 visible: !root._hasPicture
42 // The source plays into its output: it has one only while the tile is on display, so the stream of a tile that
43 // isn't shown isn't decoded. Not by the tile's visibility: out of sight behind another view, as the Fly View is
44 // behind the Plan view, the stream plays on like the main picture's, or coming back would wait for a keyframe.
47 anchors.margins: root.border.width
49 visible: root._hasPicture
50 sourceComponent: root._isCamera ? cameraOutputComponent : streamOutputComponent
53 id: streamOutputComponent
57 fillMode: VideoOutput.PreserveAspectFit
62 id: cameraOutputComponent
65 camera: root.videoManager.uvcCamera
66 fillMode: VideoOutput.PreserveAspectFit
71 // Frozen video must not pass for live.
73 anchors.centerIn: parent
74 maximumWidth: root.width - (2 * root._margin)
75 text: qsTr("VIDEO LOST - RECONNECTING")
76 visible: root._streamLost
80 height: nameLabel.height + root._margin
81 color: qgcPal.mapWidgetBorderDark
83 visible: nameLabel.text !== ""
89 margins: root.border.width
95 text: root.source.displayName
96 color: qgcPal.mapWidgetBorderLight
97 font.pointSize: ScreenTools.smallFontPointSize
98 horizontalAlignment: Text.AlignHCenter
99 elide: Text.ElideRight
104 bottom: parent.bottom
105 margins: root._margin
111 onClicked: root.videoManager.selectSource(root.source)