diff --git a/custom-example/custom.pri b/custom-example/custom.pri index 03cd01094ad2646e004f5a088730d160e8e11920..ab24fd86fec77cb15340efc48e1d1a2196ca8b44 100644 --- a/custom-example/custom.pri +++ b/custom-example/custom.pri @@ -58,11 +58,13 @@ QML_IMPORT_PATH += \ # Our own, custom sources SOURCES += \ $$PWD/src/CustomPlugin.cc \ - $$PWD/src/CustomQuickInterface.cc + $$PWD/src/CustomQuickInterface.cc \ + $$PWD/src/CustomVideoManager.cc HEADERS += \ $$PWD/src/CustomPlugin.h \ - $$PWD/src/CustomQuickInterface.h + $$PWD/src/CustomQuickInterface.h \ + $$PWD/src/CustomVideoManager.h INCLUDEPATH += \ $$PWD/src \ diff --git a/custom-example/src/CustomPlugin.cc b/custom-example/src/CustomPlugin.cc index 87fc0d51b590a13d4fa7d734de9d29239ca3c93b..f715a4e681c9e38a02af37d5b4ab5b3368a37094 100644 --- a/custom-example/src/CustomPlugin.cc +++ b/custom-example/src/CustomPlugin.cc @@ -17,6 +17,7 @@ #include "CustomPlugin.h" #include "CustomQuickInterface.h" +#include "CustomVideoManager.h" #include "MultiVehicleManager.h" #include "QGCApplication.h" @@ -191,6 +192,13 @@ CustomPlugin::overrideSettingsGroupVisibility(QString name) return true; } +//----------------------------------------------------------------------------- +VideoManager* +CustomPlugin::createVideoManager(QGCApplication *app, QGCToolbox *toolbox) +{ + return new CustomVideoManager(app, toolbox); +} + //----------------------------------------------------------------------------- VideoReceiver* CustomPlugin::createVideoReceiver(QObject* parent) diff --git a/custom-example/src/CustomPlugin.h b/custom-example/src/CustomPlugin.h index b089c3e62798d83bee05fc7fe9177ff8b4e942bf..d97746f9a64a8ea659b628ac557ef62d8e070c8f 100644 --- a/custom-example/src/CustomPlugin.h +++ b/custom-example/src/CustomPlugin.h @@ -79,6 +79,7 @@ public: QString brandImageIndoor () const final; QString brandImageOutdoor () const final; bool overrideSettingsGroupVisibility (QString name) final; + VideoManager* createVideoManager (QGCApplication* app, QGCToolbox* toolbox) final; VideoReceiver* createVideoReceiver (QObject* parent) final; QQmlApplicationEngine* createRootWindow (QObject* parent) final; bool adjustSettingMetaData (const QString& settingsGroup, FactMetaData& metaData) final; diff --git a/custom-example/src/CustomVideoManager.cc b/custom-example/src/CustomVideoManager.cc new file mode 100644 index 0000000000000000000000000000000000000000..7e72973da3ef2bc323109ee7d2554fb2fcb8bb39 --- /dev/null +++ b/custom-example/src/CustomVideoManager.cc @@ -0,0 +1,39 @@ +/**************************************************************************** + * + * (c) 2009-2019 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +#include "CustomVideoManager.h" +#include "MultiVehicleManager.h" +#include "CustomCameraManager.h" +#include "CustomCameraControl.h" + +//----------------------------------------------------------------------------- +CustomVideoManager::CustomVideoManager(QGCApplication* app, QGCToolbox* toolbox) + : VideoManager(app, toolbox) +{ +} + +//----------------------------------------------------------------------------- +void +CustomVideoManager::_updateSettings() +{ + if(!_videoSettings || !_videoReceiver) + return; + //-- Check encoding + if(_activeVehicle && _activeVehicle->dynamicCameras()) { + CustomCameraControl* pCamera = dynamic_cast(_activeVehicle->dynamicCameras()->currentCameraInstance()); + if(pCamera) { + Fact *fact = pCamera->videoEncoding(); + if (fact) { + _videoReceiver->setVideoDecoder(static_cast(fact->rawValue().toInt())); + } + } + } + VideoManager::_updateSettings(); +} + diff --git a/custom-example/src/CustomVideoManager.h b/custom-example/src/CustomVideoManager.h new file mode 100644 index 0000000000000000000000000000000000000000..58d7fe158fe59e37aac93bccd8d5087908fb53c0 --- /dev/null +++ b/custom-example/src/CustomVideoManager.h @@ -0,0 +1,28 @@ +/**************************************************************************** + * + * (c) 2009-2019 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +#pragma once + +#include +#include +#include +#include + +#include "VideoManager.h" + +class CustomVideoManager : public VideoManager +{ + Q_OBJECT +public: + CustomVideoManager (QGCApplication* app, QGCToolbox* toolbox); + +protected: + void _updateSettings (); + +}; diff --git a/custom-example/src/FirmwarePlugin/CustomCameraControl.cc b/custom-example/src/FirmwarePlugin/CustomCameraControl.cc index 7817a46c30d0b3cc20a302499756165ff8c7d929..431192807c6595d7cfede5c008b52f64ce2c9713 100644 --- a/custom-example/src/FirmwarePlugin/CustomCameraControl.cc +++ b/custom-example/src/FirmwarePlugin/CustomCameraControl.cc @@ -19,6 +19,7 @@ QGC_LOGGING_CATEGORY(CustomCameraVerboseLog, "CustomCameraVerboseLog") static const char* kCAM_IRPALETTE = "CAM_IRPALETTE"; static const char* kCAM_NEXTVISION_IRPALETTE = "IR_SENS_POL"; +static const char* kCAM_ENC = "CAM_ENC"; //----------------------------------------------------------------------------- CustomCameraControl::CustomCameraControl(const mavlink_camera_information_t *info, Vehicle* vehicle, int compID, QObject* parent) @@ -116,6 +117,13 @@ CustomCameraControl::irPalette() return nullptr; } +//----------------------------------------------------------------------------- +Fact* +CustomCameraControl::videoEncoding() +{ + return _paramComplete ? getFact(kCAM_ENC) : nullptr; +} + //----------------------------------------------------------------------------- void CustomCameraControl::setThermalMode(ThermalViewMode mode) diff --git a/custom-example/src/FirmwarePlugin/CustomCameraControl.h b/custom-example/src/FirmwarePlugin/CustomCameraControl.h index 475ed336cc1dfc647376eeac48e60ac6c2997b3f..a52dae9b8a824d41d05f47e67327614c512498ef 100644 --- a/custom-example/src/FirmwarePlugin/CustomCameraControl.h +++ b/custom-example/src/FirmwarePlugin/CustomCameraControl.h @@ -29,8 +29,11 @@ public: CustomCameraControl(const mavlink_camera_information_t* info, Vehicle* vehicle, int compID, QObject* parent = nullptr); Q_PROPERTY(Fact* irPalette READ irPalette NOTIFY parametersReady) + Q_PROPERTY(Fact* videoEncoding READ videoEncoding NOTIFY parametersReady) Fact* irPalette (); + Fact* videoEncoding (); + bool takePhoto () override; bool stopTakePhoto () override; bool startVideo () override; diff --git a/src/Camera/QGCCameraControl.cc b/src/Camera/QGCCameraControl.cc index f50a6f5edf3fab61e13fbd5d4d14255733caa20d..ed694587ae7c375b37d5826dfed71c824344773b 100644 --- a/src/Camera/QGCCameraControl.cc +++ b/src/Camera/QGCCameraControl.cc @@ -70,9 +70,6 @@ const char* QGCCameraControl::kCAM_SHUTTERSPD = "CAM_SHUTTERSPD"; const char* QGCCameraControl::kCAM_APERTURE = "CAM_APERTURE"; const char* QGCCameraControl::kCAM_WBMODE = "CAM_WBMODE"; const char* QGCCameraControl::kCAM_MODE = "CAM_MODE"; -const char* QGCCameraControl::kCAM_BITRATE = "CAM_BITRATE"; -const char* QGCCameraControl::kCAM_FPS = "CAM_FPS"; -const char* QGCCameraControl::kCAM_ENC = "CAM_ENC"; //----------------------------------------------------------------------------- QGCCameraOptionExclusion::QGCCameraOptionExclusion(QObject* parent, QString param_, QString value_, QStringList exclusions_) @@ -2116,27 +2113,6 @@ QGCCameraControl::mode() return _paramComplete ? getFact(kCAM_MODE) : nullptr; } -//----------------------------------------------------------------------------- -Fact* -QGCCameraControl::bitRate() -{ - return _paramComplete ? getFact(kCAM_BITRATE) : nullptr; -} - -//----------------------------------------------------------------------------- -Fact* -QGCCameraControl::frameRate() -{ - return _paramComplete ? getFact(kCAM_FPS) : nullptr; -} - -//----------------------------------------------------------------------------- -Fact* -QGCCameraControl::videoEncoding() -{ - return _paramComplete ? getFact(kCAM_ENC) : nullptr; -} - //----------------------------------------------------------------------------- QGCVideoStreamInfo::QGCVideoStreamInfo(QObject* parent, const mavlink_video_stream_information_t *si) : QObject(parent) diff --git a/src/Camera/QGCCameraControl.h b/src/Camera/QGCCameraControl.h index d0a21df0c23059062e7ae6d0dccf048b54bbd765..95f099118d4f9aa7ad9b0036af86c568b6da685e 100644 --- a/src/Camera/QGCCameraControl.h +++ b/src/Camera/QGCCameraControl.h @@ -167,9 +167,6 @@ public: Q_PROPERTY(Fact* aperture READ aperture NOTIFY parametersReady) Q_PROPERTY(Fact* wb READ wb NOTIFY parametersReady) Q_PROPERTY(Fact* mode READ mode NOTIFY parametersReady) - Q_PROPERTY(Fact* bitRate READ bitRate NOTIFY parametersReady) - Q_PROPERTY(Fact* frameRate READ frameRate NOTIFY parametersReady) - Q_PROPERTY(Fact* videoEncoding READ videoEncoding NOTIFY parametersReady) Q_PROPERTY(QStringList activeSettings READ activeSettings NOTIFY activeSettingsChanged) Q_PROPERTY(VideoStatus videoStatus READ videoStatus NOTIFY videoStatusChanged) @@ -255,9 +252,6 @@ public: virtual Fact* aperture (); virtual Fact* wb (); virtual Fact* mode (); - virtual Fact* bitRate (); - virtual Fact* frameRate (); - virtual Fact* videoEncoding (); //-- Stream names to show the user (for selection) virtual QStringList streamLabels () { return _streamLabels; } @@ -289,7 +283,6 @@ public: //-- Allow controller to modify or invalidate parameter change virtual bool validateParameter (Fact* pFact, QVariant& newValue); - // Known Parameters static const char* kCAM_EV; static const char* kCAM_EXPMODE; @@ -298,9 +291,6 @@ public: static const char* kCAM_APERTURE; static const char* kCAM_WBMODE; static const char* kCAM_MODE; - static const char* kCAM_BITRATE; - static const char* kCAM_FPS; - static const char* kCAM_ENC; signals: void infoChanged (); diff --git a/src/FlightDisplay/VideoManager.cc b/src/FlightDisplay/VideoManager.cc index f8259272d6656455a9bdcdf06774baab00c0ff8b..23db603639cf17814efab55d158d29dd4e11dd81 100644 --- a/src/FlightDisplay/VideoManager.cc +++ b/src/FlightDisplay/VideoManager.cc @@ -279,13 +279,6 @@ VideoManager::_updateSettings() return; //-- Auto discovery if(_activeVehicle && _activeVehicle->dynamicCameras()) { - QGCCameraControl* pCamera = _activeVehicle->dynamicCameras()->currentCameraInstance(); - if(pCamera) { - Fact *fact = pCamera->videoEncoding(); - if (fact) { - _videoReceiver->setVideoDecoder(static_cast(fact->rawValue().toInt())); - } - } QGCVideoStreamInfo* pInfo = _activeVehicle->dynamicCameras()->currentStreamInstance(); if(pInfo) { qCDebug(VideoManagerLog) << "Configure primary stream: " << pInfo->uri(); diff --git a/src/FlightDisplay/VideoManager.h b/src/FlightDisplay/VideoManager.h index 7d9ad610b3e72aab41dd4ccfddeea32a67b86b96..dfeafdcdee32414ea7fb41b7763e0478067737ee 100644 --- a/src/FlightDisplay/VideoManager.h +++ b/src/FlightDisplay/VideoManager.h @@ -34,7 +34,7 @@ class VideoManager : public QGCTool public: VideoManager (QGCApplication* app, QGCToolbox* toolbox); - ~VideoManager (); + virtual ~VideoManager (); Q_PROPERTY(bool hasVideo READ hasVideo NOTIFY hasVideoChanged) Q_PROPERTY(bool isGStreamer READ isGStreamer NOTIFY isGStreamerChanged) @@ -51,34 +51,33 @@ public: Q_PROPERTY(bool autoStreamConfigured READ autoStreamConfigured NOTIFY autoStreamConfiguredChanged) Q_PROPERTY(bool hasThermal READ hasThermal NOTIFY aspectRatioChanged) - bool hasVideo (); - bool isGStreamer (); - bool isAutoStream (); - bool isTaisync () { return _isTaisync; } - bool fullScreen () { return _fullScreen; } - QString videoSourceID () { return _videoSourceID; } - double aspectRatio (); - double thermalAspectRatio (); - double hfov (); - double thermalHfov (); - bool autoStreamConfigured(); - bool hasThermal (); - void restartVideo (); - - VideoReceiver* videoReceiver () { return _videoReceiver; } - VideoReceiver* thermalVideoReceiver () { return _thermalVideoReceiver; } + virtual bool hasVideo (); + virtual bool isGStreamer (); + virtual bool isTaisync () { return _isTaisync; } + virtual bool fullScreen () { return _fullScreen; } + virtual QString videoSourceID () { return _videoSourceID; } + virtual double aspectRatio (); + virtual double thermalAspectRatio (); + virtual double hfov (); + virtual double thermalHfov (); + virtual bool autoStreamConfigured(); + virtual bool hasThermal (); + virtual void restartVideo (); + + virtual VideoReceiver* videoReceiver () { return _videoReceiver; } + virtual VideoReceiver* thermalVideoReceiver () { return _thermalVideoReceiver; } #if defined(QGC_DISABLE_UVC) - bool uvcEnabled () { return false; } + virtual bool uvcEnabled () { return false; } #else - bool uvcEnabled (); + virtual bool uvcEnabled (); #endif - void setfullScreen (bool f) { _fullScreen = f; emit fullScreenChanged(); } - void setIsTaisync (bool t) { _isTaisync = t; emit isTaisyncChanged(); } + virtual void setfullScreen (bool f) { _fullScreen = f; emit fullScreenChanged(); } + virtual void setIsTaisync (bool t) { _isTaisync = t; emit isTaisyncChanged(); } // Override from QGCTool - void setToolbox (QGCToolbox *toolbox); + virtual void setToolbox (QGCToolbox *toolbox); Q_INVOKABLE void startVideo (); Q_INVOKABLE void stopVideo (); @@ -93,7 +92,7 @@ signals: void aspectRatioChanged (); void autoStreamConfiguredChanged(); -private slots: +protected slots: void _videoSourceChanged (); void _udpPortChanged (); void _rtspUrlChanged (); @@ -102,10 +101,10 @@ private slots: void _setActiveVehicle (Vehicle* vehicle); void _aspectRatioChanged (); -private: +protected: void _updateSettings (); -private: +protected: SubtitleWriter _subtitleWriter; bool _isTaisync = false; VideoReceiver* _videoReceiver = nullptr; diff --git a/src/VideoStreaming/VideoReceiver.cc b/src/VideoStreaming/VideoReceiver.cc index cd62f8d11aa28864b44d8f4ecd5f75c57f08a430..dc963865bdd23d32500d91154bd1186405ce09d2 100644 --- a/src/VideoStreaming/VideoReceiver.cc +++ b/src/VideoStreaming/VideoReceiver.cc @@ -611,14 +611,14 @@ VideoReceiver::setVideoDecoder(VideoEncoding encoding) */ if (encoding == H265_HW || encoding == H265_SW) { - _depayName = "rtph265depay"; + _depayName = "rtph265depay"; _parserName = "h265parse"; #if defined(__android__) _hwDecoderName = "amcviddec-omxgooglehevcdecoder"; #endif _swDecoderName = "avdec_h265"; } else { - _depayName = "rtph264depay"; + _depayName = "rtph264depay"; _parserName = "h264parse"; #if defined(__android__) _hwDecoderName = "amcviddec-omxgoogleh264decoder"; @@ -630,6 +630,7 @@ VideoReceiver::setVideoDecoder(VideoEncoding encoding) _hwDecoderName = nullptr; } } + //----------------------------------------------------------------------------- // When we finish our pipeline will look like this: // diff --git a/src/api/QGCCorePlugin.cc b/src/api/QGCCorePlugin.cc index 91d95d27173ceb276f27521d00dc2f74beef927a..9c22b1924a0bcaba18f8e4053a58e8a27c4407a9 100644 --- a/src/api/QGCCorePlugin.cc +++ b/src/api/QGCCorePlugin.cc @@ -15,6 +15,7 @@ #include "SettingsManager.h" #include "AppMessages.h" #include "QmlObjectListModel.h" +#include "VideoManager.h" #include "VideoReceiver.h" #include "QGCLoggingCategory.h" #include "QGCCameraManager.h" @@ -408,6 +409,11 @@ QmlObjectListModel* QGCCorePlugin::customMapItems() return &_p->_emptyCustomMapItems; } +VideoManager* QGCCorePlugin::createVideoManager(QGCApplication *app, QGCToolbox *toolbox) +{ + return new VideoManager(app, toolbox); +} + VideoReceiver* QGCCorePlugin::createVideoReceiver(QObject* parent) { return new VideoReceiver(parent); diff --git a/src/api/QGCCorePlugin.h b/src/api/QGCCorePlugin.h index a299944da89f4bbb4cd6c3ddd70e599183c47338..3187789d945094ce6f4b1eb5aaa6eaaf7b2bffbe 100644 --- a/src/api/QGCCorePlugin.h +++ b/src/api/QGCCorePlugin.h @@ -104,6 +104,8 @@ public: /// Allows the plugin to override the creation of the root (native) window. virtual QQmlApplicationEngine* createRootWindow(QObject* parent); + /// Allows the plugin to override the creation of VideoManager. + virtual VideoManager* createVideoManager(QGCApplication* app, QGCToolbox* toolbox); /// Allows the plugin to override the creation of VideoReceiver. virtual VideoReceiver* createVideoReceiver(QObject* parent);