Unverified Commit f68eccd4 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #6368 from bluerobotics/patrickelectric/fix#164

Fix video popup on windows
parents 8176dd37 2acdf6cf
...@@ -212,7 +212,23 @@ QGCView { ...@@ -212,7 +212,23 @@ QGCView {
_flightVideo.state = "unpopup" _flightVideo.state = "unpopup"
videoWindow.visible = false videoWindow.visible = false
} }
}
/* This timer will startVideo again after the popup window appears and is loaded.
* Such approach was the only one to avoid a crash for windows users
*/
Timer {
id: videoPopUpTimer
interval: 2000;
running: false;
repeat: false
onTriggered: {
// If state is popup, the next one will be popup-finished
if (_flightVideo.state == "popup") {
_flightVideo.state = "popup-finished"
}
QGroundControl.videoManager.startVideo()
}
} }
QGCMapPalette { id: mapPal; lightColors: _mainIsMap ? _flightMap.isSatelliteMap : true } QGCMapPalette { id: mapPal; lightColors: _mainIsMap ? _flightMap.isSatelliteMap : true }
...@@ -270,6 +286,20 @@ QGCView { ...@@ -270,6 +286,20 @@ QGCView {
anchors.left: _panel.left anchors.left: _panel.left
anchors.bottom: _panel.bottom anchors.bottom: _panel.bottom
visible: QGroundControl.videoManager.hasVideo && (!_mainIsMap || _isPipVisible) visible: QGroundControl.videoManager.hasVideo && (!_mainIsMap || _isPipVisible)
onParentChanged: {
/* If video comes back from popup
* correct anchors.
* Such thing is not possible with ParentChange.
*/
if(parent == _panel) {
// Do anchors again after popup
anchors.left = _panel.left
anchors.bottom = _panel.bottom
anchors.margins = ScreenTools.defaultFontPixelHeight
}
}
states: [ states: [
State { State {
name: "pipMode" name: "pipMode"
...@@ -296,36 +326,41 @@ QGCView { ...@@ -296,36 +326,41 @@ QGCView {
State { State {
name: "popup" name: "popup"
StateChangeScript { StateChangeScript {
script: QGroundControl.videoManager.stopVideo() script: {
// Stop video, restart it again with Timer
// Avoiding crashs if ParentChange is not yet done
QGroundControl.videoManager.stopVideo()
videoPopUpTimer.running = true
}
} }
PropertyChanges {
target: _flightVideoPipControl
inPopup: true
}
},
State {
name: "popup-finished"
ParentChange { ParentChange {
target: _flightVideo target: _flightVideo
parent: videoItem parent: videoItem
x: 0 x: 0
y: 0 y: 0
width: videoWindow.width width: videoItem.width
height: videoWindow.height height: videoItem.height
}
PropertyChanges {
target: _flightVideoPipControl
inPopup: true
} }
}, },
State { State {
name: "unpopup" name: "unpopup"
StateChangeScript { StateChangeScript {
script: QGroundControl.videoManager.stopVideo() script: {
QGroundControl.videoManager.stopVideo()
videoPopUpTimer.running = true
}
} }
ParentChange { ParentChange {
target: _flightVideo target: _flightVideo
parent: _panel parent: _panel
} }
PropertyChanges {
target: _flightVideo
anchors.left: _panel.left
anchors.bottom: _panel.bottom
anchors.margins: ScreenTools.defaultFontPixelHeight
}
PropertyChanges { PropertyChanges {
target: _flightVideoPipControl target: _flightVideoPipControl
inPopup: false inPopup: false
......
...@@ -56,7 +56,7 @@ public: ...@@ -56,7 +56,7 @@ public:
// Override from QGCTool // Override from QGCTool
void setToolbox (QGCToolbox *toolbox); void setToolbox (QGCToolbox *toolbox);
Q_INVOKABLE void startVideo() {_videoReceiver->stop();}; Q_INVOKABLE void startVideo() {_videoReceiver->start();};
Q_INVOKABLE void stopVideo() {_videoReceiver->stop();}; Q_INVOKABLE void stopVideo() {_videoReceiver->stop();};
signals: signals:
......
...@@ -218,6 +218,7 @@ VideoReceiver::start() ...@@ -218,6 +218,7 @@ VideoReceiver::start()
return; return;
} }
#if defined(QGC_GST_STREAMING) #if defined(QGC_GST_STREAMING)
_stop = false;
qCDebug(VideoReceiverLog) << "start()"; qCDebug(VideoReceiverLog) << "start()";
if (_uri.isEmpty()) { if (_uri.isEmpty()) {
...@@ -433,6 +434,7 @@ void ...@@ -433,6 +434,7 @@ void
VideoReceiver::stop() VideoReceiver::stop()
{ {
#if defined(QGC_GST_STREAMING) #if defined(QGC_GST_STREAMING)
_stop = true;
qCDebug(VideoReceiverLog) << "stop()"; qCDebug(VideoReceiverLog) << "stop()";
if(!_streaming) { if(!_streaming) {
_shutdownPipeline(); _shutdownPipeline();
...@@ -870,9 +872,11 @@ VideoReceiver::_updateTimer() ...@@ -870,9 +872,11 @@ VideoReceiver::_updateTimer()
} }
if(elapsed > (time_t)timeout && _videoSurface) { if(elapsed > (time_t)timeout && _videoSurface) {
stop(); stop();
// We want to start it back again with _updateTimer
_stop = false;
} }
} else { } else {
if(!running() && !_uri.isEmpty() && _videoSettings->streamEnabled()->rawValue().toBool()) { if(!_stop && !running() && !_uri.isEmpty() && _videoSettings->streamEnabled()->rawValue().toBool()) {
start(); start();
} }
} }
......
...@@ -114,6 +114,7 @@ private: ...@@ -114,6 +114,7 @@ private:
bool _streaming; bool _streaming;
bool _starting; bool _starting;
bool _stopping; bool _stopping;
bool _stop;
Sink* _sink; Sink* _sink;
GstElement* _tee; GstElement* _tee;
......
...@@ -52,14 +52,18 @@ void VideoNode::setMaterialTypeSolidBlack() ...@@ -52,14 +52,18 @@ void VideoNode::setMaterialTypeSolidBlack()
void VideoNode::setCurrentFrame(GstBuffer* buffer) void VideoNode::setCurrentFrame(GstBuffer* buffer)
{ {
Q_ASSERT (m_materialType == MaterialTypeVideo); if (m_materialType != MaterialTypeVideo) {
return;
}
static_cast<VideoMaterial*>(material())->setCurrentFrame(buffer); static_cast<VideoMaterial*>(material())->setCurrentFrame(buffer);
markDirty(DirtyMaterial); markDirty(DirtyMaterial);
} }
void VideoNode::updateColors(int brightness, int contrast, int hue, int saturation) void VideoNode::updateColors(int brightness, int contrast, int hue, int saturation)
{ {
Q_ASSERT (m_materialType == MaterialTypeVideo); if (m_materialType != MaterialTypeVideo) {
return;
}
static_cast<VideoMaterial*>(material())->updateColors(brightness, contrast, hue, saturation); static_cast<VideoMaterial*>(material())->updateColors(brightness, contrast, hue, saturation);
markDirty(DirtyMaterial); markDirty(DirtyMaterial);
} }
......
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