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
bc18446e
Commit
bc18446e
authored
Mar 31, 2020
by
Andrew Voznytsa
Browse files
emit all signals thru call to _dispatchNotification()
parent
c3c6662a
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/VideoReceiver/GstVideoReceiver.cc
View file @
bc18446e
...
...
@@ -78,7 +78,7 @@ GstVideoReceiver::start(const QString& uri, unsigned timeout)
if
(
_pipeline
)
{
qCDebug
(
VideoReceiverLog
)
<<
"Already running!"
;
_
n
otification
Handler
.
dispatch
([
this
](){
_
dispatchN
otification
([
this
](){
emit
onStartComplete
(
STATUS_INVALID_STATE
);
});
return
;
...
...
@@ -86,7 +86,7 @@ GstVideoReceiver::start(const QString& uri, unsigned timeout)
if
(
uri
.
isEmpty
())
{
qCDebug
(
VideoReceiverLog
)
<<
"Failed because URI is not specified"
;
_
n
otification
Handler
.
dispatch
([
this
](){
_
dispatchN
otification
([
this
](){
emit
onStartComplete
(
STATUS_INVALID_URL
);
});
return
;
...
...
@@ -231,14 +231,14 @@ GstVideoReceiver::start(const QString& uri, unsigned timeout)
}
}
_
n
otification
Handler
.
dispatch
([
this
](){
_
dispatchN
otification
([
this
](){
emit
onStartComplete
(
STATUS_FAIL
);
});
}
else
{
GST_DEBUG_BIN_TO_DOT_FILE
(
GST_BIN
(
_pipeline
),
GST_DEBUG_GRAPH_SHOW_ALL
,
"pipeline-started"
);
qCDebug
(
VideoReceiverLog
)
<<
"Started"
;
_
n
otification
Handler
.
dispatch
([
this
](){
_
dispatchN
otification
([
this
](){
emit
onStartComplete
(
STATUS_OK
);
});
}
...
...
@@ -319,12 +319,12 @@ GstVideoReceiver::stop(void)
if
(
_streaming
)
{
_streaming
=
false
;
qCDebug
(
VideoReceiverLog
)
<<
"Streaming stopped"
;
_
n
otification
Handler
.
dispatch
([
this
](){
_
dispatchN
otification
([
this
](){
emit
streamingChanged
();
});
}
else
{
qCDebug
(
VideoReceiverLog
)
<<
"Streaming did not start"
;
_
n
otification
Handler
.
dispatch
([
this
](){
_
dispatchN
otification
([
this
](){
emit
timeout
();
});
}
...
...
@@ -332,7 +332,7 @@ GstVideoReceiver::stop(void)
qCDebug
(
VideoReceiverLog
)
<<
"Stopped"
;
_
n
otification
Handler
.
dispatch
([
this
](){
_
dispatchN
otification
([
this
](){
emit
onStopComplete
(
STATUS_OK
);
});
}
...
...
@@ -368,7 +368,7 @@ GstVideoReceiver::startDecoding(void* sink)
if
(
_videoSink
!=
nullptr
||
_decoding
)
{
qCDebug
(
VideoReceiverLog
)
<<
"Already decoding!"
;
_
n
otification
Handler
.
dispatch
([
this
](){
_
dispatchN
otification
([
this
](){
emit
onStartDecodingComplete
(
STATUS_INVALID_STATE
);
});
return
;
...
...
@@ -378,7 +378,7 @@ GstVideoReceiver::startDecoding(void* sink)
if
((
pad
=
gst_element_get_static_pad
(
videoSink
,
"sink"
))
==
nullptr
)
{
qCCritical
(
VideoReceiverLog
)
<<
"Unable to find sink pad of video sink"
;
_
n
otification
Handler
.
dispatch
([
this
](){
_
dispatchN
otification
([
this
](){
emit
onStartDecodingComplete
(
STATUS_FAIL
);
});
return
;
...
...
@@ -397,7 +397,7 @@ GstVideoReceiver::startDecoding(void* sink)
_removingDecoder
=
false
;
if
(
!
_streaming
)
{
_
n
otification
Handler
.
dispatch
([
this
](){
_
dispatchN
otification
([
this
](){
emit
onStartDecodingComplete
(
STATUS_OK
);
});
return
;
...
...
@@ -405,7 +405,7 @@ GstVideoReceiver::startDecoding(void* sink)
if
(
!
_addDecoder
(
_decoderValve
))
{
qCCritical
(
VideoReceiverLog
)
<<
"_addDecoder() failed"
;
_
n
otification
Handler
.
dispatch
([
this
](){
_
dispatchN
otification
([
this
](){
emit
onStartDecodingComplete
(
STATUS_FAIL
);
});
return
;
...
...
@@ -415,7 +415,7 @@ GstVideoReceiver::startDecoding(void* sink)
qCDebug
(
VideoReceiverLog
)
<<
"Decoding started"
;
_
n
otification
Handler
.
dispatch
([
this
](){
_
dispatchN
otification
([
this
](){
emit
onStartDecodingComplete
(
STATUS_OK
);
});
}
...
...
@@ -435,7 +435,7 @@ GstVideoReceiver::stopDecoding(void)
// exit immediately if we are not decoding
if
(
_pipeline
==
nullptr
||
!
_decoding
)
{
qCDebug
(
VideoReceiverLog
)
<<
"Not decoding!"
;
_
n
otification
Handler
.
dispatch
([
this
](){
_
dispatchN
otification
([
this
](){
emit
onStopDecodingComplete
(
STATUS_INVALID_STATE
);
});
return
;
...
...
@@ -449,7 +449,7 @@ GstVideoReceiver::stopDecoding(void)
// FIXME: AV: it is much better to emit onStopDecodingComplete() after decoding is really stopped
// (which happens later due to async design) but as for now it is also not so bad...
_
n
otification
Handler
.
dispatch
([
this
,
ret
](){
_
dispatchN
otification
([
this
,
ret
](){
emit
onStopDecodingComplete
(
ret
?
STATUS_OK
:
STATUS_FAIL
);
});
}
...
...
@@ -469,7 +469,7 @@ GstVideoReceiver::startRecording(const QString& videoFile, FILE_FORMAT format)
if
(
_pipeline
==
nullptr
)
{
qCDebug
(
VideoReceiverLog
)
<<
"Streaming is not active!"
;
_
n
otification
Handler
.
dispatch
([
this
](){
_
dispatchN
otification
([
this
](){
emit
onStartRecordingComplete
(
STATUS_INVALID_STATE
);
});
return
;
...
...
@@ -477,7 +477,7 @@ GstVideoReceiver::startRecording(const QString& videoFile, FILE_FORMAT format)
if
(
_recording
)
{
qCDebug
(
VideoReceiverLog
)
<<
"Already recording!"
;
_
n
otification
Handler
.
dispatch
([
this
](){
_
dispatchN
otification
([
this
](){
emit
onStartRecordingComplete
(
STATUS_INVALID_STATE
);
});
return
;
...
...
@@ -487,7 +487,7 @@ GstVideoReceiver::startRecording(const QString& videoFile, FILE_FORMAT format)
if
((
_fileSink
=
_makeFileSink
(
videoFile
,
format
))
==
nullptr
)
{
qCCritical
(
VideoReceiverLog
)
<<
"_makeFileSink() failed"
;
_
n
otification
Handler
.
dispatch
([
this
](){
_
dispatchN
otification
([
this
](){
emit
onStartRecordingComplete
(
STATUS_FAIL
);
});
return
;
...
...
@@ -501,7 +501,7 @@ GstVideoReceiver::startRecording(const QString& videoFile, FILE_FORMAT format)
if
(
!
gst_element_link
(
_recorderValve
,
_fileSink
))
{
qCCritical
(
VideoReceiverLog
)
<<
"Failed to link valve and file sink"
;
_
n
otification
Handler
.
dispatch
([
this
](){
_
dispatchN
otification
([
this
](){
emit
onStartRecordingComplete
(
STATUS_FAIL
);
});
return
;
...
...
@@ -518,7 +518,7 @@ GstVideoReceiver::startRecording(const QString& videoFile, FILE_FORMAT format)
if
((
probepad
=
gst_element_get_static_pad
(
_recorderValve
,
"src"
))
==
nullptr
)
{
qCCritical
(
VideoReceiverLog
)
<<
"gst_element_get_static_pad() failed"
;
_
n
otification
Handler
.
dispatch
([
this
](){
_
dispatchN
otification
([
this
](){
emit
onStartRecordingComplete
(
STATUS_FAIL
);
});
return
;
...
...
@@ -532,7 +532,7 @@ GstVideoReceiver::startRecording(const QString& videoFile, FILE_FORMAT format)
_recording
=
true
;
qCDebug
(
VideoReceiverLog
)
<<
"Recording started"
;
_
n
otification
Handler
.
dispatch
([
this
](){
_
dispatchN
otification
([
this
](){
emit
onStartRecordingComplete
(
STATUS_OK
);
emit
recordingChanged
();
});
...
...
@@ -554,7 +554,7 @@ GstVideoReceiver::stopRecording(void)
// exit immediately if we are not recording
if
(
_pipeline
==
nullptr
||
!
_recording
)
{
qCDebug
(
VideoReceiverLog
)
<<
"Not recording!"
;
_
n
otification
Handler
.
dispatch
([
this
](){
_
dispatchN
otification
([
this
](){
emit
onStopRecordingComplete
(
STATUS_INVALID_STATE
);
});
return
;
...
...
@@ -568,7 +568,7 @@ GstVideoReceiver::stopRecording(void)
// FIXME: AV: it is much better to emit onStopRecordingComplete() after recording is really stopped
// (which happens later due to async design) but as for now it is also not so bad...
_
n
otification
Handler
.
dispatch
([
this
,
ret
](){
_
dispatchN
otification
([
this
,
ret
](){
emit
onStopRecordingComplete
(
ret
?
STATUS_OK
:
STATUS_FAIL
);
});
}
...
...
@@ -585,7 +585,7 @@ GstVideoReceiver::takeScreenshot(const QString& imageFile)
}
// FIXME: AV: record screenshot here
_
n
otification
Handler
.
dispatch
([
this
](){
_
dispatchN
otification
([
this
](){
emit
onTakeScreenshotComplete
(
STATUS_NOT_IMPLEMENTED
);
});
}
...
...
@@ -612,7 +612,7 @@ GstVideoReceiver::_watchdog(void)
if
(
now
-
_lastSourceFrameTime
>
_timeout
)
{
qCDebug
(
VideoReceiverLog
)
<<
"Stream timeout, no frames for "
<<
now
-
_lastSourceFrameTime
;
_
n
otification
Handler
.
dispatch
([
this
](){
_
dispatchN
otification
([
this
](){
emit
timeout
();
});
}
...
...
@@ -624,7 +624,7 @@ GstVideoReceiver::_watchdog(void)
if
(
now
-
_lastVideoFrameTime
>
_timeout
*
2
)
{
qCDebug
(
VideoReceiverLog
)
<<
"Video decoder timeout, no frames for "
<<
now
-
_lastVideoFrameTime
;
_
n
otification
Handler
.
dispatch
([
this
](){
_
dispatchN
otification
([
this
](){
emit
timeout
();
});
}
...
...
@@ -932,7 +932,7 @@ GstVideoReceiver::_onNewSourcePad(GstPad* pad)
if
(
!
_streaming
)
{
_streaming
=
true
;
qCDebug
(
VideoReceiverLog
)
<<
"Streaming started"
;
_
n
otification
Handler
.
dispatch
([
this
](){
_
dispatchN
otification
([
this
](){
emit
streamingChanged
();
});
}
...
...
@@ -1059,7 +1059,7 @@ GstVideoReceiver::_addVideoSink(GstPad* pad)
_decoding
=
true
;
qCDebug
(
VideoReceiverLog
)
<<
"Decoding started"
;
_
n
otification
Handler
.
dispatch
([
this
](){
_
dispatchN
otification
([
this
](){
emit
decodingChanged
();
});
...
...
@@ -1179,7 +1179,7 @@ GstVideoReceiver::_shutdownDecodingBranch(void)
if
(
_decoding
)
{
_decoding
=
false
;
qCDebug
(
VideoReceiverLog
)
<<
"Decoding stopped"
;
_
n
otification
Handler
.
dispatch
([
this
](){
_
dispatchN
otification
([
this
](){
emit
decodingChanged
();
});
}
...
...
@@ -1200,7 +1200,7 @@ GstVideoReceiver::_shutdownRecordingBranch(void)
if
(
_recording
)
{
_recording
=
false
;
qCDebug
(
VideoReceiverLog
)
<<
"Recording stopped"
;
_
n
otification
Handler
.
dispatch
([
this
](){
_
dispatchN
otification
([
this
](){
emit
recordingChanged
();
});
}
...
...
@@ -1208,6 +1208,12 @@ GstVideoReceiver::_shutdownRecordingBranch(void)
GST_DEBUG_BIN_TO_DOT_FILE
(
GST_BIN
(
_pipeline
),
GST_DEBUG_GRAPH_SHOW_ALL
,
"pipeline-recording-stopped"
);
}
void
GstVideoReceiver
::
_dispatchNotification
(
std
::
function
<
void
()
>
notification
)
{
_notificationHandler
.
dispatch
(
notification
);
}
gboolean
GstVideoReceiver
::
_onBusMessage
(
GstBus
*
bus
,
GstMessage
*
msg
,
gpointer
data
)
{
...
...
src/VideoReceiver/GstVideoReceiver.h
View file @
bc18446e
...
...
@@ -122,6 +122,8 @@ protected:
virtual
void
_shutdownDecodingBranch
(
void
);
virtual
void
_shutdownRecordingBranch
(
void
);
void
_dispatchNotification
(
std
::
function
<
void
()
>
notification
);
private:
static
gboolean
_onBusMessage
(
GstBus
*
bus
,
GstMessage
*
message
,
gpointer
user_data
);
static
void
_onNewPad
(
GstElement
*
element
,
GstPad
*
pad
,
gpointer
data
);
...
...
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