Unverified Commit 6c8477f8 authored by Gus Grubba's avatar Gus Grubba Committed by GitHub

Merge pull request #7146 from mavlink/cameraAndVideo

Camera and Video Streams
parents 93d38743 80a12fd1
Subproject commit 90d9b285e01fe8bfa3b4e8868ca71c5537d43302 Subproject commit c847642263deefa584691eebade8b29a25264442
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -27,9 +27,10 @@ public: ...@@ -27,9 +27,10 @@ public:
QGCCameraManager(Vehicle* vehicle); QGCCameraManager(Vehicle* vehicle);
virtual ~QGCCameraManager(); virtual ~QGCCameraManager();
Q_PROPERTY(QmlObjectListModel* cameras READ cameras NOTIFY camerasChanged) Q_PROPERTY(QmlObjectListModel* cameras READ cameras NOTIFY camerasChanged)
Q_PROPERTY(QStringList cameraLabels READ cameraLabels NOTIFY cameraLabelsChanged) Q_PROPERTY(QStringList cameraLabels READ cameraLabels NOTIFY cameraLabelsChanged)
Q_PROPERTY(int currentCamera READ currentCamera WRITE setCurrentCamera NOTIFY currentCameraChanged) Q_PROPERTY(QGCCameraControl* currentCameraInstance READ currentCameraInstance NOTIFY currentCameraChanged)
Q_PROPERTY(int currentCamera READ currentCamera WRITE setCurrentCamera NOTIFY currentCameraChanged)
//-- Return a list of cameras provided by this vehicle //-- Return a list of cameras provided by this vehicle
virtual QmlObjectListModel* cameras () { return &_cameras; } virtual QmlObjectListModel* cameras () { return &_cameras; }
...@@ -37,13 +38,17 @@ public: ...@@ -37,13 +38,17 @@ public:
virtual QStringList cameraLabels () { return _cameraLabels; } virtual QStringList cameraLabels () { return _cameraLabels; }
//-- Current selected camera //-- Current selected camera
virtual int currentCamera () { return _currentCamera; } virtual int currentCamera () { return _currentCamera; }
virtual QGCCameraControl* currentCameraInstance();
//-- Set current camera //-- Set current camera
virtual void setCurrentCamera (int sel); virtual void setCurrentCamera (int sel);
//-- Current stream
virtual QGCVideoStreamInfo* currentStreamInstance();
signals: signals:
void camerasChanged (); void camerasChanged ();
void cameraLabelsChanged (); void cameraLabelsChanged ();
void currentCameraChanged (); void currentCameraChanged ();
void streamChanged ();
protected slots: protected slots:
virtual void _vehicleReady (bool ready); virtual void _vehicleReady (bool ready);
...@@ -51,6 +56,8 @@ protected slots: ...@@ -51,6 +56,8 @@ protected slots:
virtual void _activeJoystickChanged (Joystick* joystick); virtual void _activeJoystickChanged (Joystick* joystick);
virtual void _stepZoom (int direction); virtual void _stepZoom (int direction);
virtual void _stepCamera (int direction); virtual void _stepCamera (int direction);
virtual void _stepStream (int direction);
virtual void _cameraTimeout ();
protected: protected:
virtual QGCCameraControl* _findCamera (int id); virtual QGCCameraControl* _findCamera (int id);
...@@ -62,16 +69,29 @@ protected: ...@@ -62,16 +69,29 @@ protected:
virtual void _handleParamAck (const mavlink_message_t& message); virtual void _handleParamAck (const mavlink_message_t& message);
virtual void _handleParamValue (const mavlink_message_t& message); virtual void _handleParamValue (const mavlink_message_t& message);
virtual void _handleCaptureStatus (const mavlink_message_t& message); virtual void _handleCaptureStatus (const mavlink_message_t& message);
virtual void _handleVideoStreamInfo (const mavlink_message_t& message);
virtual void _handleVideoStreamStatus(const mavlink_message_t& message);
protected: protected:
class CameraStruct : public QObject {
public:
CameraStruct(QObject* parent);
QTime lastHeartbeat;
bool infoReceived = false;
bool gaveUp = false;
int tryCount = 0;
};
Vehicle* _vehicle = nullptr; Vehicle* _vehicle = nullptr;
Joystick* _activeJoystick = nullptr; Joystick* _activeJoystick = nullptr;
bool _vehicleReadyState = false; bool _vehicleReadyState = false;
int _currentTask = 0; int _currentTask = 0;
QmlObjectListModel _cameras; QmlObjectListModel _cameras;
QStringList _cameraLabels; QStringList _cameraLabels;
QMap<int, bool> _cameraInfoRequested;
int _currentCamera = 0; int _currentCamera = 0;
QTime _lastZoomChange; QTime _lastZoomChange;
QTime _lastCameraChange; QTime _lastCameraChange;
QTimer _cameraTimer;
QMap<int, CameraStruct*> _cameraInfoRequest;
}; };
...@@ -31,9 +31,7 @@ Item { ...@@ -31,9 +31,7 @@ Item {
property int _curCameraIndex: _dynamicCameras ? _dynamicCameras.currentCamera : 0 property int _curCameraIndex: _dynamicCameras ? _dynamicCameras.currentCamera : 0
property bool _isCamera: _dynamicCameras ? _dynamicCameras.cameras.count > 0 : false property bool _isCamera: _dynamicCameras ? _dynamicCameras.cameras.count > 0 : false
property var _camera: _isCamera ? _dynamicCameras.cameras.get(_curCameraIndex) : null property var _camera: _isCamera ? _dynamicCameras.cameras.get(_curCameraIndex) : null
property bool _hasCameraZoom: _camera && _camera.hasZoom property bool _hasZoom: _camera && _camera.hasZoom
property bool _hasVideoZoom: QGroundControl.videoManager.hasZoom
property bool _hasZoom: _hasCameraZoom || _hasVideoZoom
property int _fitMode: QGroundControl.settingsManager.videoSettings.videoFit.rawValue property int _fitMode: QGroundControl.settingsManager.videoSettings.videoFit.rawValue
Rectangle { Rectangle {
id: noVideo id: noVideo
...@@ -141,13 +139,7 @@ Item { ...@@ -141,13 +139,7 @@ Item {
z = Math.round(pinch.scale) z = Math.round(pinch.scale)
} }
if(pinchZoom.zoom != z) { if(pinchZoom.zoom != z) {
//-- Camera zoom takes predence _camera.stepZoom(z)
if(_hasCameraZoom) {
_camera.stepZoom(z)
} else if (_hasVideoZoom) {
//-- Video zoom is for dumb cameras that only stream (do not present a camera interface)
QGroundControl.videoManager.stepZoom(z)
}
} }
} }
} }
......
This diff is collapsed.
...@@ -35,18 +35,15 @@ public: ...@@ -35,18 +35,15 @@ public:
VideoManager (QGCApplication* app, QGCToolbox* toolbox); VideoManager (QGCApplication* app, QGCToolbox* toolbox);
~VideoManager (); ~VideoManager ();
Q_PROPERTY(bool hasVideo READ hasVideo NOTIFY hasVideoChanged) Q_PROPERTY(bool hasVideo READ hasVideo NOTIFY hasVideoChanged)
Q_PROPERTY(bool isGStreamer READ isGStreamer NOTIFY isGStreamerChanged) Q_PROPERTY(bool isGStreamer READ isGStreamer NOTIFY isGStreamerChanged)
Q_PROPERTY(bool isAutoStream READ isAutoStream NOTIFY isAutoStreamChanged) Q_PROPERTY(bool isTaisync READ isTaisync WRITE setIsTaisync NOTIFY isTaisyncChanged)
Q_PROPERTY(bool isTaisync READ isTaisync WRITE setIsTaisync NOTIFY isTaisyncChanged) Q_PROPERTY(QString videoSourceID READ videoSourceID NOTIFY videoSourceIDChanged)
Q_PROPERTY(QString videoSourceID READ videoSourceID NOTIFY videoSourceIDChanged) Q_PROPERTY(bool uvcEnabled READ uvcEnabled CONSTANT)
Q_PROPERTY(bool uvcEnabled READ uvcEnabled CONSTANT) Q_PROPERTY(bool fullScreen READ fullScreen WRITE setfullScreen NOTIFY fullScreenChanged)
Q_PROPERTY(bool fullScreen READ fullScreen WRITE setfullScreen NOTIFY fullScreenChanged) Q_PROPERTY(VideoReceiver* videoReceiver READ videoReceiver CONSTANT)
Q_PROPERTY(VideoReceiver* videoReceiver READ videoReceiver CONSTANT) Q_PROPERTY(double aspectRatio READ aspectRatio NOTIFY aspectRatioChanged)
Q_PROPERTY(double aspectRatio READ aspectRatio NOTIFY streamInfoChanged) Q_PROPERTY(bool autoStreamConfigured READ autoStreamConfigured NOTIFY autoStreamConfiguredChanged)
Q_PROPERTY(bool hasZoom READ hasZoom NOTIFY streamInfoChanged)
Q_PROPERTY(int streamCount READ streamCount NOTIFY streamCountChanged)
Q_PROPERTY(int currentStream READ currentStream WRITE setCurrentStream NOTIFY currentStreamChanged)
bool hasVideo (); bool hasVideo ();
bool isGStreamer (); bool isGStreamer ();
...@@ -54,11 +51,8 @@ public: ...@@ -54,11 +51,8 @@ public:
bool isTaisync () { return _isTaisync; } bool isTaisync () { return _isTaisync; }
bool fullScreen () { return _fullScreen; } bool fullScreen () { return _fullScreen; }
QString videoSourceID () { return _videoSourceID; } QString videoSourceID () { return _videoSourceID; }
QString autoURL () { return QString(_streamInfo.uri); }
double aspectRatio (); double aspectRatio ();
bool hasZoom () { return _streamInfo.flags & VIDEO_STREAM_HAS_BASIC_ZOOM; } bool autoStreamConfigured();
int currentStream () { return _currentStream; }
int streamCount () { return _streamInfo.count; }
VideoReceiver* videoReceiver () { return _videoReceiver; } VideoReceiver* videoReceiver () { return _videoReceiver; }
...@@ -70,15 +64,12 @@ public: ...@@ -70,15 +64,12 @@ public:
void setfullScreen (bool f) { _fullScreen = f; emit fullScreenChanged(); } void setfullScreen (bool f) { _fullScreen = f; emit fullScreenChanged(); }
void setIsTaisync (bool t) { _isTaisync = t; emit isTaisyncChanged(); } void setIsTaisync (bool t) { _isTaisync = t; emit isTaisyncChanged(); }
void setCurrentStream (int stream);
// Override from QGCTool // Override from QGCTool
void setToolbox (QGCToolbox *toolbox); void setToolbox (QGCToolbox *toolbox);
Q_INVOKABLE void startVideo () { _videoReceiver->start(); } Q_INVOKABLE void startVideo () { _videoReceiver->start(); }
Q_INVOKABLE void stopVideo () { _videoReceiver->stop(); } Q_INVOKABLE void stopVideo () { _videoReceiver->stop(); }
Q_INVOKABLE void stepZoom (int direction);
Q_INVOKABLE void stepStream (int direction);
signals: signals:
void hasVideoChanged (); void hasVideoChanged ();
...@@ -86,10 +77,9 @@ signals: ...@@ -86,10 +77,9 @@ signals:
void videoSourceIDChanged (); void videoSourceIDChanged ();
void fullScreenChanged (); void fullScreenChanged ();
void isAutoStreamChanged (); void isAutoStreamChanged ();
void streamInfoChanged ();
void isTaisyncChanged (); void isTaisyncChanged ();
void currentStreamChanged (); void aspectRatioChanged ();
void streamCountChanged (); void autoStreamConfiguredChanged();
private slots: private slots:
void _videoSourceChanged (); void _videoSourceChanged ();
...@@ -97,14 +87,12 @@ private slots: ...@@ -97,14 +87,12 @@ private slots:
void _rtspUrlChanged (); void _rtspUrlChanged ();
void _tcpUrlChanged (); void _tcpUrlChanged ();
void _updateUVC (); void _updateUVC ();
void _streamInfoChanged ();
void _setActiveVehicle (Vehicle* vehicle); void _setActiveVehicle (Vehicle* vehicle);
void _activeJoystickChanged (Joystick* joystick); void _aspectRatioChanged ();
void _vehicleMessageReceived (const mavlink_message_t& message); void _restartVideo ();
private: private:
void _updateSettings (); void _updateSettings ();
void _restartVideo ();
private: private:
bool _isTaisync = false; bool _isTaisync = false;
...@@ -113,13 +101,6 @@ private: ...@@ -113,13 +101,6 @@ private:
QString _videoSourceID; QString _videoSourceID;
bool _fullScreen = false; bool _fullScreen = false;
Vehicle* _activeVehicle = nullptr; Vehicle* _activeVehicle = nullptr;
Joystick* _activeJoystick = nullptr;
mavlink_video_stream_information_t _streamInfo;
bool _hasAutoStream = false;
uint8_t _videoStreamCompID = 0;
int _currentStream = 1;
QTime _lastZoomChange;
QTime _lastStreamChange;
}; };
#endif #endif
...@@ -414,6 +414,7 @@ void QGCApplication::_initCommon(void) ...@@ -414,6 +414,7 @@ void QGCApplication::_initCommon(void)
qmlRegisterUncreatableType<ParameterManager> (kQGCVehicle, 1, 0, "ParameterManager", kRefOnly); qmlRegisterUncreatableType<ParameterManager> (kQGCVehicle, 1, 0, "ParameterManager", kRefOnly);
qmlRegisterUncreatableType<QGCCameraManager> (kQGCVehicle, 1, 0, "QGCCameraManager", kRefOnly); qmlRegisterUncreatableType<QGCCameraManager> (kQGCVehicle, 1, 0, "QGCCameraManager", kRefOnly);
qmlRegisterUncreatableType<QGCCameraControl> (kQGCVehicle, 1, 0, "QGCCameraControl", kRefOnly); qmlRegisterUncreatableType<QGCCameraControl> (kQGCVehicle, 1, 0, "QGCCameraControl", kRefOnly);
qmlRegisterUncreatableType<QGCVideoStreamInfo> (kQGCVehicle, 1, 0, "QGCVideoStreamInfo", kRefOnly);
qmlRegisterUncreatableType<LinkInterface> (kQGCVehicle, 1, 0, "LinkInterface", kRefOnly); qmlRegisterUncreatableType<LinkInterface> (kQGCVehicle, 1, 0, "LinkInterface", kRefOnly);
qmlRegisterUncreatableType<MissionController> (kQGCControllers, 1, 0, "MissionController", kRefOnly); qmlRegisterUncreatableType<MissionController> (kQGCControllers, 1, 0, "MissionController", kRefOnly);
qmlRegisterUncreatableType<GeoFenceController> (kQGCControllers, 1, 0, "GeoFenceController", kRefOnly); qmlRegisterUncreatableType<GeoFenceController> (kQGCControllers, 1, 0, "GeoFenceController", kRefOnly);
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
const char* VideoSettings::videoSourceNoVideo = "No Video Available"; const char* VideoSettings::videoSourceNoVideo = "No Video Available";
const char* VideoSettings::videoDisabled = "Video Stream Disabled"; const char* VideoSettings::videoDisabled = "Video Stream Disabled";
const char* VideoSettings::videoSourceAuto = "Automatic Video Stream";
const char* VideoSettings::videoSourceRTSP = "RTSP Video Stream"; const char* VideoSettings::videoSourceRTSP = "RTSP Video Stream";
const char* VideoSettings::videoSourceUDP = "UDP Video Stream"; const char* VideoSettings::videoSourceUDP = "UDP Video Stream";
const char* VideoSettings::videoSourceTCP = "TCP-MPEG2 Video Stream"; const char* VideoSettings::videoSourceTCP = "TCP-MPEG2 Video Stream";
...@@ -35,7 +34,6 @@ DECLARE_SETTINGGROUP(Video, "Video") ...@@ -35,7 +34,6 @@ DECLARE_SETTINGGROUP(Video, "Video")
// Setup enum values for videoSource settings into meta data // Setup enum values for videoSource settings into meta data
QStringList videoSourceList; QStringList videoSourceList;
#ifdef QGC_GST_STREAMING #ifdef QGC_GST_STREAMING
videoSourceList.append(videoSourceAuto);
videoSourceList.append(videoSourceRTSP); videoSourceList.append(videoSourceRTSP);
#ifndef NO_UDP_VIDEO #ifndef NO_UDP_VIDEO
videoSourceList.append(videoSourceUDP); videoSourceList.append(videoSourceUDP);
...@@ -133,10 +131,16 @@ bool VideoSettings::streamConfigured(void) ...@@ -133,10 +131,16 @@ bool VideoSettings::streamConfigured(void)
#if !defined(QGC_GST_STREAMING) #if !defined(QGC_GST_STREAMING)
return false; return false;
#endif #endif
//-- First, check if it's disabled
QString vSource = videoSource()->rawValue().toString(); QString vSource = videoSource()->rawValue().toString();
if(vSource == videoSourceNoVideo || vSource == videoDisabled) { if(vSource == videoSourceNoVideo || vSource == videoDisabled) {
return false; return false;
} }
//-- Check if it's autoconfigured
if(qgcApp()->toolbox()->videoManager()->autoStreamConfigured()) {
qCDebug(VideoManagerLog) << "Stream auto configured";
return true;
}
//-- If UDP, check if port is set //-- If UDP, check if port is set
if(vSource == videoSourceUDP) { if(vSource == videoSourceUDP) {
qCDebug(VideoManagerLog) << "Testing configuration for UDP Stream:" << udpPort()->rawValue().toInt(); qCDebug(VideoManagerLog) << "Testing configuration for UDP Stream:" << udpPort()->rawValue().toInt();
...@@ -157,11 +161,6 @@ bool VideoSettings::streamConfigured(void) ...@@ -157,11 +161,6 @@ bool VideoSettings::streamConfigured(void)
qCDebug(VideoManagerLog) << "Testing configuration for MPEG-TS Stream:" << udpPort()->rawValue().toInt(); qCDebug(VideoManagerLog) << "Testing configuration for MPEG-TS Stream:" << udpPort()->rawValue().toInt();
return udpPort()->rawValue().toInt() != 0; return udpPort()->rawValue().toInt() != 0;
} }
//-- If Auto, check for received URL
if(vSource == videoSourceAuto) {
qCDebug(VideoManagerLog) << "Testing configuration for Auto Stream:" << qgcApp()->toolbox()->videoManager()->autoURL();
return !qgcApp()->toolbox()->videoManager()->autoURL().isEmpty();
}
return false; return false;
} }
......
...@@ -36,14 +36,12 @@ public: ...@@ -36,14 +36,12 @@ public:
DEFINE_SETTINGFACT(disableWhenDisarmed) DEFINE_SETTINGFACT(disableWhenDisarmed)
Q_PROPERTY(bool streamConfigured READ streamConfigured NOTIFY streamConfiguredChanged) Q_PROPERTY(bool streamConfigured READ streamConfigured NOTIFY streamConfiguredChanged)
Q_PROPERTY(QString autoVideoSource READ autoVideoSource CONSTANT)
Q_PROPERTY(QString rtspVideoSource READ rtspVideoSource CONSTANT) Q_PROPERTY(QString rtspVideoSource READ rtspVideoSource CONSTANT)
Q_PROPERTY(QString udpVideoSource READ udpVideoSource CONSTANT) Q_PROPERTY(QString udpVideoSource READ udpVideoSource CONSTANT)
Q_PROPERTY(QString tcpVideoSource READ tcpVideoSource CONSTANT) Q_PROPERTY(QString tcpVideoSource READ tcpVideoSource CONSTANT)
Q_PROPERTY(QString mpegtsVideoSource READ mpegtsVideoSource CONSTANT) Q_PROPERTY(QString mpegtsVideoSource READ mpegtsVideoSource CONSTANT)
bool streamConfigured (); bool streamConfigured ();
QString autoVideoSource () { return videoSourceAuto; }
QString rtspVideoSource () { return videoSourceRTSP; } QString rtspVideoSource () { return videoSourceRTSP; }
QString udpVideoSource () { return videoSourceUDP; } QString udpVideoSource () { return videoSourceUDP; }
QString tcpVideoSource () { return videoSourceTCP; } QString tcpVideoSource () { return videoSourceTCP; }
...@@ -53,7 +51,6 @@ public: ...@@ -53,7 +51,6 @@ public:
static const char* videoDisabled; static const char* videoDisabled;
static const char* videoSourceUDP; static const char* videoSourceUDP;
static const char* videoSourceRTSP; static const char* videoSourceRTSP;
static const char* videoSourceAuto;
static const char* videoSourceTCP; static const char* videoSourceTCP;
static const char* videoSourceMPEGTS; static const char* videoSourceMPEGTS;
......
...@@ -47,7 +47,6 @@ QGCView { ...@@ -47,7 +47,6 @@ QGCView {
property string _videoSource: QGroundControl.settingsManager.videoSettings.videoSource.value property string _videoSource: QGroundControl.settingsManager.videoSettings.videoSource.value
property bool _isGst: QGroundControl.videoManager.isGStreamer property bool _isGst: QGroundControl.videoManager.isGStreamer
property bool _isAutoStream: QGroundControl.videoManager.isAutoStream
property bool _isUDP: _isGst && _videoSource === QGroundControl.settingsManager.videoSettings.udpVideoSource property bool _isUDP: _isGst && _videoSource === QGroundControl.settingsManager.videoSettings.udpVideoSource
property bool _isRTSP: _isGst && _videoSource === QGroundControl.settingsManager.videoSettings.rtspVideoSource property bool _isRTSP: _isGst && _videoSource === QGroundControl.settingsManager.videoSettings.rtspVideoSource
property bool _isTCP: _isGst && _videoSource === QGroundControl.settingsManager.videoSettings.tcpVideoSource property bool _isTCP: _isGst && _videoSource === QGroundControl.settingsManager.videoSettings.tcpVideoSource
...@@ -691,7 +690,7 @@ QGCView { ...@@ -691,7 +690,7 @@ QGCView {
QGCLabel { QGCLabel {
id: videoSectionLabel id: videoSectionLabel
text: qsTr("Video") text: qsTr("Video")
visible: QGroundControl.settingsManager.videoSettings.visible visible: QGroundControl.settingsManager.videoSettings.visible && !QGroundControl.videoManager.autoStreamConfigured
} }
Rectangle { Rectangle {
Layout.preferredWidth: videoGrid.width + (_margins * 2) Layout.preferredWidth: videoGrid.width + (_margins * 2)
...@@ -751,12 +750,12 @@ QGCView { ...@@ -751,12 +750,12 @@ QGCView {
} }
QGCLabel { QGCLabel {
text: qsTr("Aspect Ratio") text: qsTr("Aspect Ratio")
visible: !_isAutoStream && _isGst && QGroundControl.settingsManager.videoSettings.aspectRatio.visible visible: _isGst && QGroundControl.settingsManager.videoSettings.aspectRatio.visible
} }
FactTextField { FactTextField {
Layout.preferredWidth: _comboFieldWidth Layout.preferredWidth: _comboFieldWidth
fact: QGroundControl.settingsManager.videoSettings.aspectRatio fact: QGroundControl.settingsManager.videoSettings.aspectRatio
visible: !_isAutoStream && _isGst && QGroundControl.settingsManager.videoSettings.aspectRatio.visible visible: _isGst && QGroundControl.settingsManager.videoSettings.aspectRatio.visible
} }
QGCLabel { QGCLabel {
...@@ -776,10 +775,10 @@ QGCView { ...@@ -776,10 +775,10 @@ QGCView {
QGCLabel { QGCLabel {
id: videoRecSectionLabel id: videoRecSectionLabel
text: qsTr("Video Recording") text: qsTr("Video Recording")
visible: QGroundControl.settingsManager.videoSettings.visible && _isGst visible: (QGroundControl.settingsManager.videoSettings.visible && _isGst) || QGroundControl.videoManager.autoStreamConfigured
} }
Rectangle { Rectangle {
Layout.preferredWidth: videoRecCol.width + (_margins * 2) Layout.preferredWidth: videoRecCol.width + (_margins * 2)
Layout.preferredHeight: videoRecCol.height + (_margins * 2) Layout.preferredHeight: videoRecCol.height + (_margins * 2)
Layout.fillWidth: true Layout.fillWidth: true
color: qgcPal.windowShade color: qgcPal.windowShade
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment