VideoSurface.h 1.5 KB
Newer Older
1 2
/****************************************************************************
 *
3
 *   (c) 2009-2018 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 5 6 7 8
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
Gus Grubba's avatar
Gus Grubba committed
9 10 11 12 13 14 15 16


/**
 * @file
 *   @brief QGC Video Surface
 *   @author Gus Grubba <mavlink@grubba.com>
 */

17
#pragma once
Gus Grubba's avatar
Gus Grubba committed
18 19 20

#include <QtCore/QObject>

21
#if defined(QGC_GST_STREAMING)
Gus Grubba's avatar
Gus Grubba committed
22
#include <gst/gst.h>
23
#endif
Gus Grubba's avatar
Gus Grubba committed
24

25
#if defined(QGC_GST_STREAMING)
Gus Grubba's avatar
Gus Grubba committed
26
class VideoSurfacePrivate;
27
#endif
Gus Grubba's avatar
Gus Grubba committed
28 29 30 31 32 33 34 35 36 37 38 39 40

class VideoSurface : public QObject
{
    Q_OBJECT
    Q_DISABLE_COPY(VideoSurface)
public:
    explicit VideoSurface(QObject *parent = 0);
    virtual ~VideoSurface();

    /*! Returns the video sink element that provides this surface's image.
     * The element will be constructed the first time that this function
     * is called. The surface will always keep a reference to this element.
     */
41
#if defined(QGC_GST_STREAMING)
42
    GstElement* videoSink();
dogmaphobic's avatar
dogmaphobic committed
43 44
    time_t      lastFrame() { return _lastFrame; }
    void        setLastFrame(time_t t) { _lastFrame = t; }
45
#endif
Gus Grubba's avatar
Gus Grubba committed
46 47

protected:
48
#if defined(QGC_GST_STREAMING)
Gus Grubba's avatar
Gus Grubba committed
49 50
    void onUpdate();
    static void onUpdateThunk(GstElement* sink, gpointer data);
51
#endif
Gus Grubba's avatar
Gus Grubba committed
52 53 54

private:
    friend class VideoItem;
55
#if defined(QGC_GST_STREAMING)
Gus Grubba's avatar
Gus Grubba committed
56
    VideoSurfacePrivate * const _data;
57 58
    time_t  _lastFrame;
    bool    _refed;
59
#endif
Gus Grubba's avatar
Gus Grubba committed
60 61 62 63
};

Q_DECLARE_METATYPE(VideoSurface*)