VideoSurface.h 2.14 KB
Newer Older
Gus Grubba's avatar
Gus Grubba committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
/*=====================================================================

QGroundControl Open Source Ground Control Station

(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>

This file is part of the QGROUNDCONTROL project

    QGROUNDCONTROL is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    QGROUNDCONTROL is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.

======================================================================*/

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

#ifndef VIDEO_SURFACE_H
#define VIDEO_SURFACE_H

#include <QtCore/QObject>

35
#if defined(QGC_GST_STREAMING)
Gus Grubba's avatar
Gus Grubba committed
36
#include <gst/gst.h>
37
#endif
Gus Grubba's avatar
Gus Grubba committed
38

39
#if defined(QGC_GST_STREAMING)
Gus Grubba's avatar
Gus Grubba committed
40
class VideoSurfacePrivate;
41
#endif
Gus Grubba's avatar
Gus Grubba committed
42 43 44 45 46 47 48 49 50 51 52 53 54

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.
     */
55
#if defined(QGC_GST_STREAMING)
Gus Grubba's avatar
Gus Grubba committed
56
    GstElement* videoSink() const;
dogmaphobic's avatar
dogmaphobic committed
57 58
    time_t      lastFrame() { return _lastFrame; }
    void        setLastFrame(time_t t) { _lastFrame = t; }
59
#endif
Gus Grubba's avatar
Gus Grubba committed
60 61

protected:
62
#if defined(QGC_GST_STREAMING)
Gus Grubba's avatar
Gus Grubba committed
63 64
    void onUpdate();
    static void onUpdateThunk(GstElement* sink, gpointer data);
65
#endif
Gus Grubba's avatar
Gus Grubba committed
66 67 68

private:
    friend class VideoItem;
69
#if defined(QGC_GST_STREAMING)
Gus Grubba's avatar
Gus Grubba committed
70
    VideoSurfacePrivate * const _data;
dogmaphobic's avatar
dogmaphobic committed
71
    time_t _lastFrame;
72
#endif
Gus Grubba's avatar
Gus Grubba committed
73 74 75 76 77
};

Q_DECLARE_METATYPE(VideoSurface*)

#endif // VIDEO_SURFACE_H