Commit c70a6fa4 authored by Gus Grubba's avatar Gus Grubba

Expose VideoReceiver allowing plugins to override it.

parent 3df9b40f
......@@ -78,7 +78,7 @@ VideoManager::setToolbox(QGCToolbox *toolbox)
emit isGStreamerChanged();
qCDebug(VideoManagerLog) << "New Video Source:" << videoSource;
_videoReceiver = new VideoReceiver(this);
_videoReceiver = toolbox->corePlugin()->createVideoReceiver(this);
_updateSettings();
if(isGStreamer()) {
_videoReceiver->start();
......
......@@ -63,6 +63,7 @@ VideoReceiver::VideoReceiver(QObject* parent)
, _videoSink(NULL)
, _socket(NULL)
, _serverPresent(false)
, _rtspTestInterval_ms(5000)
#endif
, _videoSurface(NULL)
, _videoRunning(false)
......@@ -164,9 +165,9 @@ VideoReceiver::_socketError(QAbstractSocket::SocketError socketError)
Q_UNUSED(socketError);
_socket->deleteLater();
_socket = NULL;
//-- Try again in 5 seconds
//-- Try again in a while
if(_videoSettings->streamEnabled()->rawValue().toBool()) {
_timer.start(5000);
_timer.start(_rtspTestInterval_ms);
}
}
#endif
......@@ -194,7 +195,7 @@ VideoReceiver::_timeout()
connect(_socket, static_cast<void (QTcpSocket::*)(QAbstractSocket::SocketError)>(&QTcpSocket::error), this, &VideoReceiver::_socketError);
connect(_socket, &QTcpSocket::connected, this, &VideoReceiver::_connected);
_socket->connectToHost(url.host(), url.port());
_timer.start(5000);
_timer.start(_rtspTestInterval_ms);
}
}
#endif
......
......@@ -49,54 +49,54 @@ public:
~VideoReceiver();
#if defined(QGC_GST_STREAMING)
bool running () { return _running; }
bool recording () { return _recording; }
bool streaming () { return _streaming; }
bool starting () { return _starting; }
bool stopping () { return _stopping; }
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
VideoSurface* videoSurface () { return _videoSurface; }
bool videoRunning () { return _videoRunning; }
QString imageFile () { return _imageFile; }
QString videoFile () { return _videoFile; }
bool showFullScreen () { return _showFullScreen; }
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; }
void grabImage (QString imageFile);
virtual void grabImage (QString imageFile);
void setShowFullScreen (bool show) { _showFullScreen = show; emit showFullScreenChanged(); }
virtual void setShowFullScreen (bool show) { _showFullScreen = show; emit showFullScreenChanged(); }
signals:
void videoRunningChanged ();
void imageFileChanged ();
void videoFileChanged ();
void showFullScreenChanged ();
void videoRunningChanged ();
void imageFileChanged ();
void videoFileChanged ();
void showFullScreenChanged ();
#if defined(QGC_GST_STREAMING)
void recordingChanged ();
void msgErrorReceived ();
void msgEOSReceived ();
void msgStateChangedReceived ();
void recordingChanged ();
void msgErrorReceived ();
void msgEOSReceived ();
void msgStateChangedReceived ();
#endif
public slots:
void start ();
void stop ();
void setUri (const QString& uri);
void stopRecording ();
void startRecording (const QString& videoFile = QString());
private slots:
void _updateTimer ();
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)
void _timeout ();
void _connected ();
void _socketError (QAbstractSocket::SocketError socketError);
void _handleError ();
void _handleEOS ();
void _handleStateChanged ();
virtual void _timeout ();
virtual void _connected ();
virtual void _socketError (QAbstractSocket::SocketError socketError);
virtual void _handleError ();
virtual void _handleEOS ();
virtual void _handleStateChanged ();
#endif
private:
protected:
#if defined(QGC_GST_STREAMING)
typedef struct
......@@ -121,11 +121,12 @@ private:
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);
void _detachRecordingBranch (GstPadProbeInfo* info);
void _shutdownRecordingBranch();
void _shutdownPipeline ();
void _cleanupOldVideos ();
void _setVideoSink (GstElement* sink);
virtual void _detachRecordingBranch (GstPadProbeInfo* info);
virtual void _shutdownRecordingBranch();
virtual void _shutdownPipeline ();
virtual void _cleanupOldVideos ();
virtual void _setVideoSink (GstElement* sink);
GstElement* _pipeline;
GstElement* _pipelineStopRec;
......@@ -136,6 +137,7 @@ private:
QTimer _timer;
QTcpSocket* _socket;
bool _serverPresent;
int _rtspTestInterval_ms;
#endif
......
......@@ -15,6 +15,7 @@
#include "SettingsManager.h"
#include "AppMessages.h"
#include "QmlObjectListModel.h"
#include "VideoReceiver.h"
#include <QtQml>
#include <QQmlEngine>
......@@ -286,3 +287,8 @@ QmlObjectListModel* QGCCorePlugin::customMapItems(void)
{
return &_p->_emptyCustomMapItems;
}
VideoReceiver* QGCCorePlugin::createVideoReceiver(QObject* parent)
{
return new VideoReceiver(parent);
}
......@@ -31,6 +31,7 @@ class QQmlApplicationEngine;
class Vehicle;
class LinkInterface;
class QmlObjectListModel;
class VideoReceiver;
class QGCCorePlugin : public QGCTool
{
......@@ -98,6 +99,9 @@ public:
/// Allows the plugin to override the creation of the root (native) window.
virtual QQmlApplicationEngine* createRootWindow(QObject* parent);
/// Allows the plugin to override the creation of VideoReceiver.
virtual VideoReceiver* createVideoReceiver(QObject* parent);
/// Allows the plugin to see all mavlink traffic to a vehicle
/// @return true: Allow vehicle to continue processing, false: Vehicle should not process message
virtual bool mavlinkMessage(Vehicle* vehicle, LinkInterface* link, mavlink_message_t message);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment