VideoManager.h 4.01 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
    Q_PROPERTY(bool             isTaisync           READ    isTaisync       WRITE   setIsTaisync        NOTIFY isTaisyncChanged)
40 41
    Q_PROPERTY(QString          videoSourceID       READ    videoSourceID                               NOTIFY videoSourceIDChanged)
    Q_PROPERTY(bool             uvcEnabled          READ    uvcEnabled                                  CONSTANT)
42
    Q_PROPERTY(bool             fullScreen          READ    fullScreen      WRITE   setfullScreen       NOTIFY fullScreenChanged)
43
    Q_PROPERTY(VideoReceiver*   videoReceiver       READ    videoReceiver                               CONSTANT)
44
    Q_PROPERTY(double           aspectRatio         READ    aspectRatio                                 NOTIFY aspectRatioChanged)
45

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

55 56
    VideoReceiver*  videoReceiver   () { return _videoReceiver; }

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

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

66 67 68
    // Override from QGCTool
    void        setToolbox          (QGCToolbox *toolbox);

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

72
signals:
73 74 75
    void hasVideoChanged            ();
    void isGStreamerChanged         ();
    void videoSourceIDChanged       ();
76
    void fullScreenChanged          ();
77 78
    void isAutoStreamChanged        ();
    void aspectRatioChanged         ();
79
    void isTaisyncChanged           ();
80

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

91
private:
92 93
    void _updateSettings            ();
    void _restartVideo              ();
94

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

#endif