|
|
@ -71,6 +71,8 @@ VideoReceiver::VideoReceiver(QObject* parent) |
|
|
|
, _videoRunning(false) |
|
|
|
, _videoRunning(false) |
|
|
|
, _showFullScreen(false) |
|
|
|
, _showFullScreen(false) |
|
|
|
, _videoSettings(nullptr) |
|
|
|
, _videoSettings(nullptr) |
|
|
|
|
|
|
|
, _hwDecoderName(nullptr) |
|
|
|
|
|
|
|
, _swDecoderName("avdec_h264") |
|
|
|
{ |
|
|
|
{ |
|
|
|
_videoSurface = new VideoSurface; |
|
|
|
_videoSurface = new VideoSurface; |
|
|
|
_videoSettings = qgcApp()->toolbox()->settingsManager()->videoSettings();
|
|
|
|
_videoSettings = qgcApp()->toolbox()->settingsManager()->videoSettings();
|
|
|
@ -159,6 +161,10 @@ VideoReceiver::_restart_timeout() |
|
|
|
void |
|
|
|
void |
|
|
|
VideoReceiver::start() |
|
|
|
VideoReceiver::start() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (_uri.isEmpty()) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
qCDebug(VideoReceiverLog) << "start():" << _uri; |
|
|
|
if(qgcApp()->runningUnitTests()) { |
|
|
|
if(qgcApp()->runningUnitTests()) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -170,7 +176,6 @@ VideoReceiver::start() |
|
|
|
|
|
|
|
|
|
|
|
#if defined(QGC_GST_STREAMING) |
|
|
|
#if defined(QGC_GST_STREAMING) |
|
|
|
_stop = false; |
|
|
|
_stop = false; |
|
|
|
qCDebug(VideoReceiverLog) << "start():" << _uri; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(QGC_GST_TAISYNC_ENABLED) && (defined(__android__) || defined(__ios__)) |
|
|
|
#if defined(QGC_GST_TAISYNC_ENABLED) && (defined(__android__) || defined(__ios__)) |
|
|
|
//-- Taisync on iOS or Android sends a raw h.264 stream
|
|
|
|
//-- Taisync on iOS or Android sends a raw h.264 stream
|
|
|
@ -280,10 +285,13 @@ VideoReceiver::start() |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ((decoder = gst_element_factory_make(_decoderName, "decoder")) == nullptr) { |
|
|
|
if (!_hwDecoderName || (decoder = gst_element_factory_make(_hwDecoderName, "decoder")) == nullptr) { |
|
|
|
qCritical() << "VideoReceiver::start() failed. Error with gst_element_factory_make('" << _decoderName << "')"; |
|
|
|
qWarning() << "VideoReceiver::start() hardware decoding not available " << ((_hwDecoderName) ? _hwDecoderName : ""); |
|
|
|
|
|
|
|
if ((decoder = gst_element_factory_make(_swDecoderName, "decoder")) == nullptr) { |
|
|
|
|
|
|
|
qCritical() << "VideoReceiver::start() failed. Error with gst_element_factory_make('" << _swDecoderName << "')"; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ((queue1 = gst_element_factory_make("queue", nullptr)) == nullptr) { |
|
|
|
if ((queue1 = gst_element_factory_make("queue", nullptr)) == nullptr) { |
|
|
|
qCritical() << "VideoReceiver::start() failed. Error with gst_element_factory_make('queue') [1]"; |
|
|
|
qCritical() << "VideoReceiver::start() failed. Error with gst_element_factory_make('queue') [1]"; |
|
|
@ -470,6 +478,8 @@ VideoReceiver::_shutdownPipeline() { |
|
|
|
void |
|
|
|
void |
|
|
|
VideoReceiver::_handleError() { |
|
|
|
VideoReceiver::_handleError() { |
|
|
|
qCDebug(VideoReceiverLog) << "Gstreamer error!"; |
|
|
|
qCDebug(VideoReceiverLog) << "Gstreamer error!"; |
|
|
|
|
|
|
|
// If there was an error we switch to software decoding only
|
|
|
|
|
|
|
|
_tryWithHardwareDecoding = false; |
|
|
|
stop(); |
|
|
|
stop(); |
|
|
|
_restart_timer.start(_restart_time_ms); |
|
|
|
_restart_timer.start(_restart_time_ms); |
|
|
|
} |
|
|
|
} |
|
|
@ -580,17 +590,34 @@ VideoReceiver::_cleanupOldVideos() |
|
|
|
void |
|
|
|
void |
|
|
|
VideoReceiver::setVideoDecoder(VideoEncoding encoding) |
|
|
|
VideoReceiver::setVideoDecoder(VideoEncoding encoding) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
#if defined(Q_OS_MAC) |
|
|
|
|
|
|
|
_hwDecoderName = "vtdec"; |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
_hwDecoderName = "vaapidecode"; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
if (encoding == H265_HW || encoding == H265_SW) { |
|
|
|
if (encoding == H265_HW || encoding == H265_SW) { |
|
|
|
_depayName = "rtph265depay"; |
|
|
|
_depayName = "rtph265depay"; |
|
|
|
_parserName = "h265parse"; |
|
|
|
_parserName = "h265parse"; |
|
|
|
_decoderName = "avdec_h265"; |
|
|
|
#if defined(__android__) |
|
|
|
|
|
|
|
_hwDecoderName = "amcviddec-omxgooglehevcdecoder"; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
_swDecoderName = "avdec_h265"; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
_depayName = "rtph264depay"; |
|
|
|
_depayName = "rtph264depay"; |
|
|
|
_parserName = "h264parse"; |
|
|
|
_parserName = "h264parse"; |
|
|
|
_decoderName = "avdec_h264"; |
|
|
|
#if defined(__android__) |
|
|
|
|
|
|
|
_hwDecoderName = "amcviddec-omxgoogleh264decoder"; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
_swDecoderName = "avdec_h264"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!_tryWithHardwareDecoding) { |
|
|
|
|
|
|
|
_hwDecoderName = nullptr; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// When we finish our pipeline will look like this:
|
|
|
|
// When we finish our pipeline will look like this:
|
|
|
|
//
|
|
|
|
//
|
|
|
|