You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
153 lines
5.4 KiB
153 lines
5.4 KiB
/**************************************************************************** |
|
* |
|
* (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. |
|
* |
|
****************************************************************************/ |
|
|
|
|
|
/** |
|
* @file |
|
* @brief QGC Video Receiver |
|
* @author Gus Grubba <mavlink@grubba.com> |
|
*/ |
|
|
|
#ifndef VIDEORECEIVER_H |
|
#define VIDEORECEIVER_H |
|
|
|
#include "QGCLoggingCategory.h" |
|
#include <QObject> |
|
#include <QTimer> |
|
#include <QTcpSocket> |
|
|
|
#include "VideoSurface.h" |
|
|
|
#if defined(QGC_GST_STREAMING) |
|
#include <gst/gst.h> |
|
#endif |
|
|
|
Q_DECLARE_LOGGING_CATEGORY(VideoReceiverLog) |
|
|
|
class VideoSettings; |
|
|
|
class VideoReceiver : public QObject |
|
{ |
|
Q_OBJECT |
|
public: |
|
#if defined(QGC_GST_STREAMING) |
|
Q_PROPERTY(bool recording READ recording NOTIFY recordingChanged) |
|
#endif |
|
Q_PROPERTY(VideoSurface* videoSurface READ videoSurface CONSTANT) |
|
Q_PROPERTY(bool videoRunning READ videoRunning NOTIFY videoRunningChanged) |
|
Q_PROPERTY(QString imageFile READ imageFile NOTIFY imageFileChanged) |
|
Q_PROPERTY(QString videoFile READ videoFile NOTIFY videoFileChanged) |
|
Q_PROPERTY(bool showFullScreen READ showFullScreen WRITE setShowFullScreen NOTIFY showFullScreenChanged) |
|
|
|
explicit VideoReceiver(QObject* parent = 0); |
|
~VideoReceiver(); |
|
|
|
#if defined(QGC_GST_STREAMING) |
|
virtual bool running () { return _running; } |
|
virtual bool recording () { return _recording; } |
|
virtual bool streaming () { return _streaming; } |
|
virtual bool starting () { return _starting; } |
|
virtual bool stopping () { return _stopping; } |
|
#endif |
|
|
|
virtual VideoSurface* videoSurface () { return _videoSurface; } |
|
virtual bool videoRunning () { return _videoRunning; } |
|
virtual QString imageFile () { return _imageFile; } |
|
virtual QString videoFile () { return _videoFile; } |
|
virtual bool showFullScreen () { return _showFullScreen; } |
|
|
|
virtual void grabImage (QString imageFile); |
|
|
|
virtual void setShowFullScreen (bool show) { _showFullScreen = show; emit showFullScreenChanged(); } |
|
|
|
signals: |
|
void videoRunningChanged (); |
|
void imageFileChanged (); |
|
void videoFileChanged (); |
|
void showFullScreenChanged (); |
|
#if defined(QGC_GST_STREAMING) |
|
void recordingChanged (); |
|
void msgErrorReceived (); |
|
void msgEOSReceived (); |
|
void msgStateChangedReceived (); |
|
#endif |
|
|
|
public slots: |
|
virtual void start (); |
|
virtual void stop (); |
|
virtual void setUri (const QString& uri); |
|
virtual void stopRecording (); |
|
virtual void startRecording (const QString& videoFile = QString()); |
|
|
|
protected slots: |
|
virtual void _updateTimer (); |
|
#if defined(QGC_GST_STREAMING) |
|
virtual void _timeout (); |
|
virtual void _connected (); |
|
virtual void _socketError (QAbstractSocket::SocketError socketError); |
|
virtual void _handleError (); |
|
virtual void _handleEOS (); |
|
virtual void _handleStateChanged (); |
|
#endif |
|
|
|
protected: |
|
#if defined(QGC_GST_STREAMING) |
|
|
|
typedef struct |
|
{ |
|
GstPad* teepad; |
|
GstElement* queue; |
|
GstElement* mux; |
|
GstElement* filesink; |
|
GstElement* parse; |
|
gboolean removing; |
|
} Sink; |
|
|
|
bool _running; |
|
bool _recording; |
|
bool _streaming; |
|
bool _starting; |
|
bool _stopping; |
|
bool _stop; |
|
Sink* _sink; |
|
GstElement* _tee; |
|
|
|
static gboolean _onBusMessage (GstBus* bus, GstMessage* message, gpointer user_data); |
|
static GstPadProbeReturn _unlinkCallBack (GstPad* pad, GstPadProbeInfo* info, gpointer user_data); |
|
static GstPadProbeReturn _keyframeWatch (GstPad* pad, GstPadProbeInfo* info, gpointer user_data); |
|
|
|
virtual void _detachRecordingBranch (GstPadProbeInfo* info); |
|
virtual void _shutdownRecordingBranch(); |
|
virtual void _shutdownPipeline (); |
|
virtual void _cleanupOldVideos (); |
|
virtual void _setVideoSink (GstElement* sink); |
|
|
|
GstElement* _pipeline; |
|
GstElement* _pipelineStopRec; |
|
GstElement* _videoSink; |
|
|
|
//-- Wait for Video Server to show up before starting |
|
QTimer _frameTimer; |
|
QTimer _timer; |
|
QTcpSocket* _socket; |
|
bool _serverPresent; |
|
int _rtspTestInterval_ms; |
|
|
|
#endif |
|
|
|
QString _uri; |
|
QString _imageFile; |
|
QString _videoFile; |
|
VideoSurface* _videoSurface; |
|
bool _videoRunning; |
|
bool _showFullScreen; |
|
VideoSettings* _videoSettings; |
|
}; |
|
|
|
#endif // VIDEORECEIVER_H
|
|
|