Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
bbf9de58
Commit
bbf9de58
authored
Apr 10, 2020
by
Andrew Voznytsa
Browse files
Fix pre-configured video stream start
parent
2a1f755e
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/VideoManager/VideoManager.cc
View file @
bbf9de58
...
@@ -124,7 +124,12 @@ VideoManager::setToolbox(QGCToolbox *toolbox)
...
@@ -124,7 +124,12 @@ VideoManager::setToolbox(QGCToolbox *toolbox)
connect
(
_videoReceiver
[
0
],
&
VideoReceiver
::
onStartComplete
,
this
,
[
this
](
VideoReceiver
::
STATUS
status
)
{
connect
(
_videoReceiver
[
0
],
&
VideoReceiver
::
onStartComplete
,
this
,
[
this
](
VideoReceiver
::
STATUS
status
)
{
if
(
status
==
VideoReceiver
::
STATUS_OK
)
{
if
(
status
==
VideoReceiver
::
STATUS_OK
)
{
_videoStarted
[
0
]
=
true
;
_videoStarted
[
0
]
=
true
;
_videoReceiver
[
0
]
->
startDecoding
(
_videoSink
[
0
]);
if
(
_videoSink
[
0
]
!=
nullptr
)
{
// It is absolytely ok to have video receiver active (streaming) and decoding not active
// It should be handy for cases when you have many streams and want to show only some of them
// NOTE that even if decoder did not start it is still possible to record video
_videoReceiver
[
0
]
->
startDecoding
(
_videoSink
[
0
]);
}
}
else
if
(
status
==
VideoReceiver
::
STATUS_INVALID_URL
)
{
}
else
if
(
status
==
VideoReceiver
::
STATUS_INVALID_URL
)
{
// Invalid URL - don't restart
// Invalid URL - don't restart
}
else
if
(
status
==
VideoReceiver
::
STATUS_INVALID_STATE
)
{
}
else
if
(
status
==
VideoReceiver
::
STATUS_INVALID_STATE
)
{
...
@@ -180,7 +185,9 @@ VideoManager::setToolbox(QGCToolbox *toolbox)
...
@@ -180,7 +185,9 @@ VideoManager::setToolbox(QGCToolbox *toolbox)
connect
(
_videoReceiver
[
1
],
&
VideoReceiver
::
onStartComplete
,
this
,
[
this
](
VideoReceiver
::
STATUS
status
)
{
connect
(
_videoReceiver
[
1
],
&
VideoReceiver
::
onStartComplete
,
this
,
[
this
](
VideoReceiver
::
STATUS
status
)
{
if
(
status
==
VideoReceiver
::
STATUS_OK
)
{
if
(
status
==
VideoReceiver
::
STATUS_OK
)
{
_videoStarted
[
1
]
=
true
;
_videoStarted
[
1
]
=
true
;
_videoReceiver
[
1
]
->
startDecoding
(
_videoSink
[
1
]);
if
(
_videoSink
[
1
]
!=
nullptr
)
{
_videoReceiver
[
1
]
->
startDecoding
(
_videoSink
[
1
]);
}
}
else
if
(
status
==
VideoReceiver
::
STATUS_INVALID_URL
)
{
}
else
if
(
status
==
VideoReceiver
::
STATUS_INVALID_URL
)
{
// Invalid URL - don't restart
// Invalid URL - don't restart
}
else
if
(
status
==
VideoReceiver
::
STATUS_INVALID_STATE
)
{
}
else
if
(
status
==
VideoReceiver
::
STATUS_INVALID_STATE
)
{
...
@@ -573,7 +580,11 @@ VideoManager::_initVideo()
...
@@ -573,7 +580,11 @@ VideoManager::_initVideo()
if
(
widget
!=
nullptr
&&
_videoReceiver
[
0
]
!=
nullptr
)
{
if
(
widget
!=
nullptr
&&
_videoReceiver
[
0
]
!=
nullptr
)
{
_videoSink
[
0
]
=
qgcApp
()
->
toolbox
()
->
corePlugin
()
->
createVideoSink
(
this
,
widget
);
_videoSink
[
0
]
=
qgcApp
()
->
toolbox
()
->
corePlugin
()
->
createVideoSink
(
this
,
widget
);
if
(
_videoSink
[
0
]
==
nullptr
)
{
if
(
_videoSink
[
0
]
!=
nullptr
)
{
if
(
_videoStarted
[
0
])
{
_videoReceiver
[
0
]
->
startDecoding
(
_videoSink
[
0
]);
}
}
else
{
qCDebug
(
VideoManagerLog
)
<<
"createVideoSink() failed"
;
qCDebug
(
VideoManagerLog
)
<<
"createVideoSink() failed"
;
}
}
}
else
{
}
else
{
...
@@ -584,7 +595,11 @@ VideoManager::_initVideo()
...
@@ -584,7 +595,11 @@ VideoManager::_initVideo()
if
(
widget
!=
nullptr
&&
_videoReceiver
[
1
]
!=
nullptr
)
{
if
(
widget
!=
nullptr
&&
_videoReceiver
[
1
]
!=
nullptr
)
{
_videoSink
[
1
]
=
qgcApp
()
->
toolbox
()
->
corePlugin
()
->
createVideoSink
(
this
,
widget
);
_videoSink
[
1
]
=
qgcApp
()
->
toolbox
()
->
corePlugin
()
->
createVideoSink
(
this
,
widget
);
if
(
_videoSink
[
1
]
==
nullptr
)
{
if
(
_videoSink
[
1
]
!=
nullptr
)
{
if
(
_videoStarted
[
1
])
{
_videoReceiver
[
1
]
->
startDecoding
(
_videoSink
[
1
]);
}
}
else
{
qCDebug
(
VideoManagerLog
)
<<
"createVideoSink() failed"
;
qCDebug
(
VideoManagerLog
)
<<
"createVideoSink() failed"
;
}
}
}
else
{
}
else
{
...
@@ -741,7 +756,7 @@ VideoManager::_startReceiver(unsigned id)
...
@@ -741,7 +756,7 @@ VideoManager::_startReceiver(unsigned id)
if
(
id
>
1
)
{
if
(
id
>
1
)
{
qCDebug
(
VideoManagerLog
)
<<
"Unsupported receiver id"
<<
id
;
qCDebug
(
VideoManagerLog
)
<<
"Unsupported receiver id"
<<
id
;
}
else
if
(
_videoReceiver
[
id
]
!=
nullptr
&&
_videoSink
[
id
]
!=
nullptr
)
{
}
else
if
(
_videoReceiver
[
id
]
!=
nullptr
/*
&& _videoSink[id] != nullptr
*/
)
{
if
(
!
_videoUri
[
id
].
isEmpty
())
{
if
(
!
_videoUri
[
id
].
isEmpty
())
{
_videoReceiver
[
id
]
->
start
(
_videoUri
[
id
],
timeout
);
_videoReceiver
[
id
]
->
start
(
_videoUri
[
id
],
timeout
);
}
}
...
...
src/VideoManager/VideoManager.h
View file @
bbf9de58
...
@@ -158,6 +158,11 @@ protected:
...
@@ -158,6 +158,11 @@ protected:
VideoReceiver
*
_videoReceiver
[
2
]
=
{
nullptr
,
nullptr
};
VideoReceiver
*
_videoReceiver
[
2
]
=
{
nullptr
,
nullptr
};
void
*
_videoSink
[
2
]
=
{
nullptr
,
nullptr
};
void
*
_videoSink
[
2
]
=
{
nullptr
,
nullptr
};
QString
_videoUri
[
2
];
QString
_videoUri
[
2
];
// FIXME: AV: _videoStarted seems to be access from 3 different threads, from time to time
// 1) Video Receiver thread
// 2) Video Manager/main app thread
// 3) Qt rendering thread (during video sink creation process which should happen in this thread)
// It works for now but...
bool
_videoStarted
[
2
]
=
{
false
,
false
};
bool
_videoStarted
[
2
]
=
{
false
,
false
};
QAtomicInteger
<
bool
>
_streaming
=
false
;
QAtomicInteger
<
bool
>
_streaming
=
false
;
QAtomicInteger
<
bool
>
_decoding
=
false
;
QAtomicInteger
<
bool
>
_decoding
=
false
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment