VideoManager.h 3.58 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 <QUrl>
17

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

Q_DECLARE_LOGGING_CATEGORY(VideoManagerLog)

25
class VideoSettings;
26
class Vehicle;
27

28 29 30 31 32
class VideoManager : public QGCTool
{
    Q_OBJECT

public:
33
    VideoManager    (QGCApplication* app, QGCToolbox* toolbox);
34 35
    ~VideoManager   ();

36 37
    Q_PROPERTY(bool             hasVideo            READ    hasVideo                                    NOTIFY hasVideoChanged)
    Q_PROPERTY(bool             isGStreamer         READ    isGStreamer                                 NOTIFY isGStreamerChanged)
38
    Q_PROPERTY(bool             isAutoStream        READ    isAutoStream                                NOTIFY isAutoStreamChanged)
39 40
    Q_PROPERTY(QString          videoSourceID       READ    videoSourceID                               NOTIFY videoSourceIDChanged)
    Q_PROPERTY(bool             uvcEnabled          READ    uvcEnabled                                  CONSTANT)
41
    Q_PROPERTY(bool             fullScreen          READ    fullScreen      WRITE   setfullScreen       NOTIFY fullScreenChanged)
42
    Q_PROPERTY(VideoReceiver*   videoReceiver       READ    videoReceiver                               CONSTANT)
43
    Q_PROPERTY(double           aspectRatio         READ    aspectRatio                                 NOTIFY aspectRatioChanged)
44

45 46
    bool        hasVideo            ();
    bool        isGStreamer         ();
47
    bool        isAutoStream        ();
48
    bool        fullScreen          () { return _fullScreen; }
49
    QString     videoSourceID       () { return _videoSourceID; }
50 51
    QString     autoURL             () { return QString(_streamInfo.uri); }
    double      aspectRatio         ();
52

53 54
    VideoReceiver*  videoReceiver   () { return _videoReceiver; }

55 56 57 58 59 60
#if defined(QGC_DISABLE_UVC)
    bool        uvcEnabled          () { return false; }
#else
    bool        uvcEnabled          ();
#endif

61 62
    void        setfullScreen       (bool f) { _fullScreen = f; emit fullScreenChanged(); }

63 64 65
    // Override from QGCTool
    void        setToolbox          (QGCToolbox *toolbox);

Gus Grubba's avatar
Gus Grubba committed
66 67
    Q_INVOKABLE void startVideo()   {_videoReceiver->start();}
    Q_INVOKABLE void stopVideo()    {_videoReceiver->stop(); }
Patrick José Pereira's avatar
Patrick José Pereira committed
68

69
signals:
70 71 72
    void hasVideoChanged            ();
    void isGStreamerChanged         ();
    void videoSourceIDChanged       ();
73
    void fullScreenChanged          ();
74 75
    void isAutoStreamChanged        ();
    void aspectRatioChanged         ();
76

77
private slots:
78 79 80
    void _videoSourceChanged        ();
    void _udpPortChanged            ();
    void _rtspUrlChanged            ();
81
    void _tcpUrlChanged             ();
Gus Grubba's avatar
Gus Grubba committed
82
    void _updateUVC                 ();
83 84 85
    void _aspectRatioChanged        ();
    void _setActiveVehicle          (Vehicle* vehicle);
    void _vehicleMessageReceived    (const mavlink_message_t& message);
86

87
private:
88 89
    void _updateSettings            ();
    void _restartVideo              ();
90

91 92
    VideoReceiver*  _videoReceiver;
    VideoSettings*  _videoSettings;
93
    QString         _videoSourceID;
94
    bool            _fullScreen;
95 96
    Vehicle*        _activeVehicle;
    mavlink_video_stream_information_t _streamInfo;
97 98 99
};

#endif