VideoManager.h 3.98 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 45 46
    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)
    Q_PROPERTY(double           aspectRatio             READ    aspectRatio                                 NOTIFY aspectRatioChanged)
    Q_PROPERTY(bool             autoStreamConfigured    READ    autoStreamConfigured                        NOTIFY autoStreamConfiguredChanged)
47

48 49
    bool        hasVideo            ();
    bool        isGStreamer         ();
50
    bool        isAutoStream        ();
51
    bool        isTaisync           () { return _isTaisync; }
52
    bool        fullScreen          () { return _fullScreen; }
53
    QString     videoSourceID       () { return _videoSourceID; }
54
    double      aspectRatio         ();
55
    bool        autoStreamConfigured();
56

57 58
    VideoReceiver*  videoReceiver   () { return _videoReceiver; }

59 60 61 62 63 64
#if defined(QGC_DISABLE_UVC)
    bool        uvcEnabled          () { return false; }
#else
    bool        uvcEnabled          ();
#endif

65
    void        setfullScreen       (bool f) { _fullScreen = f; emit fullScreenChanged(); }
66
    void        setIsTaisync        (bool t) { _isTaisync = t;  emit isTaisyncChanged(); }
67

68 69 70
    // Override from QGCTool
    void        setToolbox          (QGCToolbox *toolbox);

71 72
    Q_INVOKABLE void startVideo     () { _videoReceiver->start(); }
    Q_INVOKABLE void stopVideo      () { _videoReceiver->stop();  }
Patrick José Pereira's avatar
Patrick José Pereira committed
73

74
signals:
75 76 77
    void hasVideoChanged            ();
    void isGStreamerChanged         ();
    void videoSourceIDChanged       ();
78
    void fullScreenChanged          ();
79
    void isAutoStreamChanged        ();
80
    void isTaisyncChanged           ();
81 82
    void aspectRatioChanged         ();
    void autoStreamConfiguredChanged();
83

84
private slots:
85 86 87
    void _videoSourceChanged        ();
    void _udpPortChanged            ();
    void _rtspUrlChanged            ();
88
    void _tcpUrlChanged             ();
Gus Grubba's avatar
Gus Grubba committed
89
    void _updateUVC                 ();
90
    void _setActiveVehicle          (Vehicle* vehicle);
91 92
    void _aspectRatioChanged        ();
    void _restartVideo              ();
93

94
private:
95
    void _updateSettings            ();
96

97 98 99 100
private:
    bool            _isTaisync          = false;
    VideoReceiver*  _videoReceiver      = nullptr;
    VideoSettings*  _videoSettings      = nullptr;
101
    QString         _videoSourceID;
102 103
    bool            _fullScreen         = false;
    Vehicle*        _activeVehicle      = nullptr;
104 105 106
};

#endif