VideoManager.h 4.88 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/


#ifndef VideoManager_H
#define VideoManager_H

#include <QObject>
#include <QTimer>
16
#include <QTime>
17
#include <QUrl>
18

19
#include "QGCMAVLink.h"
20 21 22 23 24 25
#include "QGCLoggingCategory.h"
#include "VideoReceiver.h"
#include "QGCToolbox.h"

Q_DECLARE_LOGGING_CATEGORY(VideoManagerLog)

26
class VideoSettings;
27
class Vehicle;
28
class Joystick;
29

30 31 32 33 34
class VideoManager : public QGCTool
{
    Q_OBJECT

public:
35
    VideoManager    (QGCApplication* app, QGCToolbox* toolbox);
36 37
    ~VideoManager   ();

38 39 40 41 42 43 44
    Q_PROPERTY(bool             hasVideo                READ    hasVideo                                    NOTIFY hasVideoChanged)
    Q_PROPERTY(bool             isGStreamer             READ    isGStreamer                                 NOTIFY isGStreamerChanged)
    Q_PROPERTY(bool             isTaisync               READ    isTaisync       WRITE   setIsTaisync        NOTIFY isTaisyncChanged)
    Q_PROPERTY(QString          videoSourceID           READ    videoSourceID                               NOTIFY videoSourceIDChanged)
    Q_PROPERTY(bool             uvcEnabled              READ    uvcEnabled                                  CONSTANT)
    Q_PROPERTY(bool             fullScreen              READ    fullScreen      WRITE   setfullScreen       NOTIFY fullScreenChanged)
    Q_PROPERTY(VideoReceiver*   videoReceiver           READ    videoReceiver                               CONSTANT)
45
    Q_PROPERTY(VideoReceiver*   thermalVideoReceiver    READ    thermalVideoReceiver                        CONSTANT)
46
    Q_PROPERTY(double           aspectRatio             READ    aspectRatio                                 NOTIFY aspectRatioChanged)
47 48 49
    Q_PROPERTY(double           thermalAspectRatio      READ    thermalAspectRatio                          NOTIFY aspectRatioChanged)
    Q_PROPERTY(double           hfov                    READ    hfov                                        NOTIFY aspectRatioChanged)
    Q_PROPERTY(double           thermalHfov             READ    thermalHfov                                 NOTIFY aspectRatioChanged)
50
    Q_PROPERTY(bool             autoStreamConfigured    READ    autoStreamConfigured                        NOTIFY autoStreamConfiguredChanged)
51
    Q_PROPERTY(bool             hasThermal              READ    hasThermal                                  NOTIFY aspectRatioChanged)
52

53 54
    bool        hasVideo            ();
    bool        isGStreamer         ();
55
    bool        isAutoStream        ();
56
    bool        isTaisync           () { return _isTaisync; }
57
    bool        fullScreen          () { return _fullScreen; }
58
    QString     videoSourceID       () { return _videoSourceID; }
59
    double      aspectRatio         ();
60 61 62
    double      thermalAspectRatio  ();
    double      hfov                ();
    double      thermalHfov         ();
63
    bool        autoStreamConfigured();
64
    bool        hasThermal          ();
65

66 67
    VideoReceiver*  videoReceiver           () { return _videoReceiver; }
    VideoReceiver*  thermalVideoReceiver    () { return _thermalVideoReceiver; }
68

69 70 71 72 73 74
#if defined(QGC_DISABLE_UVC)
    bool        uvcEnabled          () { return false; }
#else
    bool        uvcEnabled          ();
#endif

75
    void        setfullScreen       (bool f) { _fullScreen = f; emit fullScreenChanged(); }
76
    void        setIsTaisync        (bool t) { _isTaisync = t;  emit isTaisyncChanged(); }
77

78 79 80
    // Override from QGCTool
    void        setToolbox          (QGCToolbox *toolbox);

81 82
    Q_INVOKABLE void startVideo     ();
    Q_INVOKABLE void stopVideo      ();
Patrick José Pereira's avatar
Patrick José Pereira committed
83

84
signals:
85 86 87
    void hasVideoChanged            ();
    void isGStreamerChanged         ();
    void videoSourceIDChanged       ();
88
    void fullScreenChanged          ();
89
    void isAutoStreamChanged        ();
90
    void isTaisyncChanged           ();
91 92
    void aspectRatioChanged         ();
    void autoStreamConfiguredChanged();
93

94
private slots:
95 96 97
    void _videoSourceChanged        ();
    void _udpPortChanged            ();
    void _rtspUrlChanged            ();
98
    void _tcpUrlChanged             ();
Gus Grubba's avatar
Gus Grubba committed
99
    void _updateUVC                 ();
100
    void _setActiveVehicle          (Vehicle* vehicle);
101 102
    void _aspectRatioChanged        ();
    void _restartVideo              ();
103

104
private:
105
    void _updateSettings            ();
106

107
private:
108 109 110 111
    bool            _isTaisync              = false;
    VideoReceiver*  _videoReceiver          = nullptr;
    VideoReceiver*  _thermalVideoReceiver   = nullptr;
    VideoSettings*  _videoSettings          = nullptr;
112
    QString         _videoSourceID;
113 114
    bool            _fullScreen             = false;
    Vehicle*        _activeVehicle          = nullptr;
115 116 117
};

#endif