VideoManager.h 4.37 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 25 26 27 28 29 30 31 32

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

Q_DECLARE_LOGGING_CATEGORY(VideoManagerLog)

class VideoManager : public QGCTool
{
    Q_OBJECT

public:
    VideoManager    (QGCApplication* app);
    ~VideoManager   ();

33 34 35 36 37 38 39 40 41 42 43 44 45
    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(QString          videoSource         READ    videoSource     WRITE setVideoSource        NOTIFY videoSourceChanged)
    Q_PROPERTY(QStringList      videoSourceList     READ    videoSourceList                             NOTIFY videoSourceListChanged)
    Q_PROPERTY(bool             videoRunning        READ    videoRunning                                NOTIFY videoRunningChanged)
    Q_PROPERTY(quint16          udpPort             READ    udpPort         WRITE setUdpPort            NOTIFY udpPortChanged)
    Q_PROPERTY(QString          rtspURL             READ    rtspURL         WRITE setRtspURL            NOTIFY rtspURLChanged)
    Q_PROPERTY(QString          videoSavePath       READ    videoSavePath                               NOTIFY videoSavePathChanged)
    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)
46 47

    Q_INVOKABLE void setVideoSavePathByUrl (QUrl url);
48 49 50 51 52 53 54

    bool        hasVideo            ();
    bool        isGStreamer         ();
    bool        videoRunning        () { return _videoRunning; }
    QString     videoSourceID       () { return _videoSourceID; }
    QString     videoSource         () { return _videoSource; }
    QStringList videoSourceList     ();
55 56
    quint16     udpPort             () { return _udpPort; }
    QString     rtspURL             () { return _rtspURL; }
57
    QString     videoSavePath       () { return _videoSavePath; }
58 59 60 61 62 63 64

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

65 66 67 68 69 70
#if defined(QGC_GST_STREAMING) && defined(QGC_ENABLE_VIDEORECORDING)
    bool        recordingEnabled    () { return true; }
#else
    bool        recordingEnabled    () { return false; }
#endif

71 72 73 74
    void        setVideoSource          (QString vSource);
    void        setUdpPort              (quint16 port);
    void        setRtspURL              (QString url);
    void        setVideoSavePath        (QString path);
75 76 77 78 79 80 81 82 83 84 85

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

signals:
    void hasVideoChanged        ();
    void videoRunningChanged    ();
    void videoSourceChanged     ();
    void videoSourceListChanged ();
    void isGStreamerChanged     ();
    void videoSourceIDChanged   ();
86 87
    void udpPortChanged         ();
    void rtspURLChanged         ();
88
    void videoSavePathChanged   ();
89 90

private:
91 92
    void _updateTimer           ();
    void _updateVideo           ();
93 94 95 96 97 98 99 100 101 102 103

private:
    VideoSurface*       _videoSurface;
    VideoReceiver*      _videoReceiver;
    bool                _videoRunning;
#if defined(QGC_GST_STREAMING)
    QTimer              _frameTimer;
#endif
    QString             _videoSource;
    QString             _videoSourceID;
    QStringList         _videoSourceList;
104 105
    quint16             _udpPort;
    QString             _rtspURL;
106
    QString             _videoSavePath;
107
    bool                _init;
108 109 110
};

#endif