6#include <QtCore/QFuture>
8#include <QtCore/QObject>
9#include <QtCore/QPointer>
10#include <QtCore/QString>
11#include <QtQml/QQmlListProperty>
12#include <QtQmlIntegration/QtQmlIntegration>
44 Q_MOC_INCLUDE(
"UVCCameraController.h")
45 Q_MOC_INCLUDE(
"VideoStreamController.h")
108 Q_INVOKABLE
void grabImage(
const QString& imageFile = QString());
110 Q_INVOKABLE
void startRecording(
const QString& baseName = QString());
122 void init(QQuickWindow* mainWindow);
131 QQmlListProperty<VideoStreamController>
sources();
155 bool isUvc()
const {
return !_uvcVideoSourceID.isEmpty(); }
201 enum class InitState : uint8_t
210 struct AdvertisedStream
212 QPointer<QGCVideoStreamInfo> streamInfo;
213 QPointer<MavlinkCameraControlInterface> camera;
218 void _connectSettings();
219 void _onMainWindowReady();
220 void _watchBackendInit(
const QFuture<bool>& future);
221 void _onBackendInitComplete(
bool success);
224 bool _backendInitFinished()
const {
return (_initState == InitState::Ready) || (_initState == InitState::Failed); }
226 void _createVideoReceivers();
228 void _restartSources();
233 void _updateStateNow();
234 void _setActiveVehicle(Vehicle* vehicle);
236 void _updateStreamInfo();
240 void _setAdvertisedStreams(
const AdvertisedStream& current, QGCVideoStreamInfo* thermal,
241 const QList<AdvertisedStream>& others);
245 void _updateTileStreams(
int count);
247 VideoStreamController* _tileStream(
const QGCVideoStreamInfo* streamInfo)
const;
249 void _nameExtraStreams();
250 void _connectSource(VideoStreamController* source);
252 void _onApplicationStateChanged(Qt::ApplicationState state);
254 void _updateSourceSummary();
255 void _onArmedChanged(
bool armed);
256 void _communicationLostChanged(
bool communicationLost);
259 void _reconnectStreams();
261 VideoSettings*
const _videoSettings;
263 UVCCameraController*
const _uvcCamera;
264 VideoStreamController* _primaryStream;
265 VideoStreamController*
const _thermalStream;
266 VideoStreamController*
const _cameraSource;
268 QList<VideoStreamController*> _tileStreams;
269 QList<VideoStreamController*> _sources;
270 bool _displaySuspended =
false;
271 VideoStreamController* _measuredSource;
272 VideoRecordingService*
const _recordingService;
273 VideoTelemetryOverlay*
const _telemetryOverlay;
274 std::function<VideoReceiver*(QObject* parent)> _receiverFactory;
276 std::function<bool(
const QString& camera)> _cameraAttached;
277 QPointer<Vehicle> _activeVehicle;
279 QList<AdvertisedStream> _otherStreams;
281 InitState _initState = InitState::NotStarted;
282 QFuture<bool> _backendInitFuture;
284 bool _hasMainWindow =
false;
285 bool _cleanedUp =
false;
287 bool _updatingState =
false;
288 bool _updateStatePending =
false;
289 bool _fullScreen =
false;
290 bool _videoStopped =
false;
292 int _tileStreamSerial = 0;
295 bool _disabledWhileDisarmed =
false;
296 bool _autoStreamConfigured =
false;
297 bool _degraded =
false;
298 bool _hasThermal =
false;
299 bool _hasUvcCamera =
false;
300 bool _hasVideo =
false;
301 bool _isStreamSource =
false;
303 QString _uvcVideoSourceID;
Abstract base class for all camera controls: real and simulated.
Encapsulates the contents of a VIDEO_STREAM_INFORMATION message.
bool isStreamSource() const
NoVideoReason noVideoReason() const
Q_INVOKABLE void selectSource(VideoStreamController *source)
void setTileRoom(int room)
void startVideoBackendInit()
Starts the video backend's asynchronous global init. GUI thread only, like everything else here.
Q_INVOKABLE void stopRecording()
void uvcVideoSourceIDChanged()
Q_INVOKABLE void startVideo()
Undoes stopVideo() and "disable when disarmed", and reconnects the streams.
bool autoStreamConfigured() const
void hasUvcCameraChanged()
UVCCameraController * uvcCamera() const
NoVideoReason
Why a video view without a picture has none.
@ DisabledWhileDisarmed
VideoSettings::disableWhenDisarmed, until the vehicle arms.
@ Waiting
Nothing keeps the video from playing: it is awaited.
@ Stopped
stopVideo(), until startVideo().
double thermalAspectRatio() const
void isStreamSourceChanged()
VideoStreamController * measuredSource() const
friend class VideoManagerTest
static VideoManager * instance()
VideoManager(QObject *parent=nullptr)
QString uvcVideoSourceID() const
void autoStreamConfiguredChanged()
Q_INVOKABLE void startRecording(const QString &baseName=QString())
See VideoRecordingService::startRecording().
VideoStreamController * primaryStream() const
void init(QQuickWindow *mainWindow)
Q_INVOKABLE void stopVideo()
Stops the sources, and any recording, until startVideo().
void setFullScreen(bool on)
double aspectRatio() const
friend class VideoManagerInitTest
bool waitForVideoBackendReady()
Blocks until the backend init finishes, starting it if needed. True when the backend is ready.
VideoStreamController * thermalStream() const
void noVideoReasonChanged()
void measuredSourceChanged()
void primaryStreamChanged()
friend class TopLevelViewsTest
The source of the vehicle's current stream, or of the stream the settings configure....
QQmlListProperty< VideoStreamController > sources()
void recordingChanged(bool recording)
void aspectRatioChanged()
void telemetryOverlayTextChanged()
QString telemetryOverlayText() const
bool hasUvcCamera() const
friend class VideoManagerVehicleTest
Q_INVOKABLE void grabImage(const QString &imageFile=QString())