VideoReceiver.h 1.59 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (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.
 *
 ****************************************************************************/
Gus Grubba's avatar
Gus Grubba committed
9 10 11 12 13 14 15 16 17 18 19 20


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

#ifndef VIDEORECEIVER_H
#define VIDEORECEIVER_H

#include <QObject>
21 22 23
#include <QTimer>
#include <QTcpSocket>

24
#if defined(QGC_GST_STREAMING)
Gus Grubba's avatar
Gus Grubba committed
25
#include <gst/gst.h>
26
#endif
Gus Grubba's avatar
Gus Grubba committed
27 28 29 30 31 32 33 34

class VideoReceiver : public QObject
{
    Q_OBJECT
public:
    explicit VideoReceiver(QObject* parent = 0);
    ~VideoReceiver();

35
#if defined(QGC_GST_STREAMING)
Gus Grubba's avatar
Gus Grubba committed
36
    void setVideoSink(GstElement* sink);
37
#endif
Gus Grubba's avatar
Gus Grubba committed
38

39 40 41 42 43 44 45 46 47 48 49
public slots:
    void start      ();
    void stop       ();
    void setUri     (const QString& uri);

private slots:
#if defined(QGC_GST_STREAMING)
    void _timeout       ();
    void _connected     ();
    void _socketError   (QAbstractSocket::SocketError socketError);
#endif
Gus Grubba's avatar
Gus Grubba committed
50 51

private:
52 53

#if defined(QGC_GST_STREAMING)
Gus Grubba's avatar
Gus Grubba committed
54 55
    void            _onBusMessage(GstMessage* message);
    static gboolean _onBusMessage(GstBus* bus, GstMessage* msg, gpointer data);
56
#endif
Gus Grubba's avatar
Gus Grubba committed
57 58

    QString     _uri;
59 60

#if defined(QGC_GST_STREAMING)
Gus Grubba's avatar
Gus Grubba committed
61 62
    GstElement* _pipeline;
    GstElement* _videoSink;
63 64
#endif

65 66 67 68 69 70
    //-- Wait for Video Server to show up before starting
#if defined(QGC_GST_STREAMING)
    QTimer      _timer;
    QTcpSocket* _socket;
    bool        _serverPresent;
#endif
Gus Grubba's avatar
Gus Grubba committed
71 72 73
};

#endif // VIDEORECEIVER_H