VideoManager.h 3.55 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 19 20 21 22 23 24

#include "QGCLoggingCategory.h"
#include "VideoSurface.h"
#include "VideoReceiver.h"
#include "QGCToolbox.h"

Q_DECLARE_LOGGING_CATEGORY(VideoManagerLog)

25 26
class VideoSettings;

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

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

35 36 37 38 39
    Q_PROPERTY(bool             hasVideo            READ    hasVideo                                    NOTIFY hasVideoChanged)
    Q_PROPERTY(bool             isGStreamer         READ    isGStreamer                                 NOTIFY isGStreamerChanged)
    Q_PROPERTY(QString          videoSourceID       READ    videoSourceID                               NOTIFY videoSourceIDChanged)
    Q_PROPERTY(bool             videoRunning        READ    videoRunning                                NOTIFY videoRunningChanged)
    Q_PROPERTY(bool             uvcEnabled          READ    uvcEnabled                                  CONSTANT)
40 41
    Q_PROPERTY(VideoSurface*    videoSurface        READ    videoSurface                                CONSTANT)
    Q_PROPERTY(VideoReceiver*   videoReceiver       READ    videoReceiver                               CONSTANT)
42 43
    Q_PROPERTY(QString          imageFile           READ    imageFile                                   NOTIFY imageFileChanged)
    Q_PROPERTY(bool             showFullScreen      READ    showFullScreen  WRITE setShowFullScreen     NOTIFY showFullScreenChanged)
44

45 46 47 48
    bool        hasVideo            ();
    bool        isGStreamer         ();
    bool        videoRunning        () { return _videoRunning; }
    QString     videoSourceID       () { return _videoSourceID; }
49 50
    QString     imageFile           () { return _imageFile; }
    bool        showFullScreen      () { return _showFullScreen; }
51

52 53 54
    VideoSurface*   videoSurface    () { return _videoSurface; }
    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        grabImage           (QString imageFile);
    void        setShowFullScreen   (bool show) { _showFullScreen = show; emit showFullScreenChanged(); }
63

64 65 66 67 68 69 70 71
    // Override from QGCTool
    void        setToolbox          (QGCToolbox *toolbox);

signals:
    void hasVideoChanged        ();
    void videoRunningChanged    ();
    void isGStreamerChanged     ();
    void videoSourceIDChanged   ();
72 73
    void imageFileChanged       ();
    void showFullScreenChanged  ();
74

75 76
private slots:
    void _videoSourceChanged(void);
77 78 79
    void _udpPortChanged(void);
    void _rtspUrlChanged(void);

80
private:
81
    void _updateTimer           ();
82
    void _updateSettings        ();
83
    void _updateVideo           ();
84 85
    void _restartVideo          ();

86

87 88 89
    VideoSurface*   _videoSurface;
    VideoReceiver*  _videoReceiver;
    bool            _videoRunning;
90
#if defined(QGC_GST_STREAMING)
91
    QTimer          _frameTimer;
92
#endif
93 94 95
    QString         _videoSourceID;
    bool            _init;
    VideoSettings*  _videoSettings;
96 97
    QString         _imageFile;
    bool            _showFullScreen;
98 99 100
};

#endif