Unverified Commit ea13c0dc authored by Gus Grubba's avatar Gus Grubba Committed by GitHub

Merge pull request #6567 from mavlink/exposeVideoReceiver

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