VideoManager.h 2.91 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 40 41 42
    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)
    Q_PROPERTY(VideoSurface*    videoSurface        MEMBER  _videoSurface                               CONSTANT)
    Q_PROPERTY(VideoReceiver*   videoReceiver       MEMBER  _videoReceiver                              CONSTANT)
    Q_PROPERTY(bool             recordingEnabled    READ    recordingEnabled                            CONSTANT)
43

44 45 46 47
    bool        hasVideo            ();
    bool        isGStreamer         ();
    bool        videoRunning        () { return _videoRunning; }
    QString     videoSourceID       () { return _videoSourceID; }
48 49 50 51 52 53 54

#if defined(QGC_DISABLE_UVC)
    bool        uvcEnabled          () { return false; }
#else
    bool        uvcEnabled          ();
#endif

55 56 57 58 59 60
#if defined(QGC_GST_STREAMING) && defined(QGC_ENABLE_VIDEORECORDING)
    bool        recordingEnabled    () { return true; }
#else
    bool        recordingEnabled    () { return false; }
#endif

61 62 63 64 65 66 67 68 69
    // Override from QGCTool
    void        setToolbox          (QGCToolbox *toolbox);

signals:
    void hasVideoChanged        ();
    void videoRunningChanged    ();
    void isGStreamerChanged     ();
    void videoSourceIDChanged   ();

70 71 72
private slots:
    void _videoSourceChanged(void);

73
private:
74 75
    void _updateTimer           ();
    void _updateVideo           ();
76

77 78 79
    VideoSurface*   _videoSurface;
    VideoReceiver*  _videoReceiver;
    bool            _videoRunning;
80
#if defined(QGC_GST_STREAMING)
81
    QTimer          _frameTimer;
82
#endif
83 84 85
    QString         _videoSourceID;
    bool            _init;
    VideoSettings*  _videoSettings;
86 87 88
};

#endif