Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
bc18446e
Commit
bc18446e
authored
Mar 31, 2020
by
Andrew Voznytsa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
emit all signals thru call to _dispatchNotification()
parent
c3c6662a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
29 deletions
+37
-29
GstVideoReceiver.cc
src/VideoReceiver/GstVideoReceiver.cc
+35
-29
GstVideoReceiver.h
src/VideoReceiver/GstVideoReceiver.h
+2
-0
No files found.
src/VideoReceiver/GstVideoReceiver.cc
View file @
bc18446e
...
...
@@ -78,7 +78,7 @@ GstVideoReceiver::start(const QString& uri, unsigned timeout)
if
(
_pipeline
)
{
qCDebug
(
VideoReceiverLog
)
<<
"Already running!"
;
_
notificationHandler
.
dispatch
([
this
](){
_
dispatchNotification
([
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"
;
_
notificationHandler
.
dispatch
([
this
](){
_
dispatchNotification
([
this
](){
emit
onStartComplete
(
STATUS_INVALID_URL
);
});
return
;
...
...
@@ -231,14 +231,14 @@ GstVideoReceiver::start(const QString& uri, unsigned timeout)
}
}
_
notificationHandler
.
dispatch
([
this
](){
_
dispatchNotification
([
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"
;
_
notificationHandler
.
dispatch
([
this
](){
_
dispatchNotification
([
this
](){
emit
onStartComplete
(
STATUS_OK
);
});
}
...
...
@@ -319,12 +319,12 @@ GstVideoReceiver::stop(void)
if
(
_streaming
)
{
_streaming
=
false
;
qCDebug
(
VideoReceiverLog
)
<<
"Streaming stopped"
;
_
notificationHandler
.
dispatch
([
this
](){
_
dispatchNotification
([
this
](){
emit
streamingChanged
();
});
}
else
{
qCDebug
(
VideoReceiverLog
)
<<
"Streaming did not start"
;
_
notificationHandler
.
dispatch
([
this
](){
_
dispatchNotification
([
this
](){
emit
timeout
();
});
}
...
...
@@ -332,7 +332,7 @@ GstVideoReceiver::stop(void)
qCDebug
(
VideoReceiverLog
)
<<
"Stopped"
;
_
notificationHandler
.
dispatch
([
this
](){
_
dispatchNotification
([
this
](){
emit
onStopComplete
(
STATUS_OK
);
});
}
...
...
@@ -368,7 +368,7 @@ GstVideoReceiver::startDecoding(void* sink)
if
(
_videoSink
!=
nullptr
||
_decoding
)
{
qCDebug
(
VideoReceiverLog
)
<<
"Already decoding!"
;
_
notificationHandler
.
dispatch
([
this
](){
_
dispatchNotification
([
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"
;
_
notificationHandler
.
dispatch
([
this
](){
_
dispatchNotification
([
this
](){
emit
onStartDecodingComplete
(
STATUS_FAIL
);
});
return
;
...
...
@@ -397,7 +397,7 @@ GstVideoReceiver::startDecoding(void* sink)
_removingDecoder
=
false
;
if
(
!
_streaming
)
{
_
notificationHandler
.
dispatch
([
this
](){
_
dispatchNotification
([
this
](){
emit
onStartDecodingComplete
(
STATUS_OK
);
});
return
;
...
...
@@ -405,7 +405,7 @@ GstVideoReceiver::startDecoding(void* sink)
if
(
!
_addDecoder
(
_decoderValve
))
{
qCCritical
(
VideoReceiverLog
)
<<
"_addDecoder() failed"
;
_
notificationHandler
.
dispatch
([
this
](){
_
dispatchNotification
([
this
](){
emit
onStartDecodingComplete
(
STATUS_FAIL
);
});
return
;
...
...
@@ -415,7 +415,7 @@ GstVideoReceiver::startDecoding(void* sink)
qCDebug
(
VideoReceiverLog
)
<<
"Decoding started"
;
_
notificationHandler
.
dispatch
([
this
](){
_
dispatchNotification
([
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!"
;
_
notificationHandler
.
dispatch
([
this
](){
_
dispatchNotification
([
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...
_
notificationHandler
.
dispatch
([
this
,
ret
](){
_
dispatchNotification
([
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!"
;
_
notificationHandler
.
dispatch
([
this
](){
_
dispatchNotification
([
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!"
;
_
notificationHandler
.
dispatch
([
this
](){
_
dispatchNotification
([
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"
;
_
notificationHandler
.
dispatch
([
this
](){
_
dispatchNotification
([
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"
;
_
notificationHandler
.
dispatch
([
this
](){
_
dispatchNotification
([
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"
;
_
notificationHandler
.
dispatch
([
this
](){
_
dispatchNotification
([
this
](){
emit
onStartRecordingComplete
(
STATUS_FAIL
);
});
return
;
...
...
@@ -532,7 +532,7 @@ GstVideoReceiver::startRecording(const QString& videoFile, FILE_FORMAT format)
_recording
=
true
;
qCDebug
(
VideoReceiverLog
)
<<
"Recording started"
;
_
notificationHandler
.
dispatch
([
this
](){
_
dispatchNotification
([
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!"
;
_
notificationHandler
.
dispatch
([
this
](){
_
dispatchNotification
([
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...
_
notificationHandler
.
dispatch
([
this
,
ret
](){
_
dispatchNotification
([
this
,
ret
](){
emit
onStopRecordingComplete
(
ret
?
STATUS_OK
:
STATUS_FAIL
);
});
}
...
...
@@ -585,7 +585,7 @@ GstVideoReceiver::takeScreenshot(const QString& imageFile)
}
// FIXME: AV: record screenshot here
_
notificationHandler
.
dispatch
([
this
](){
_
dispatchNotification
([
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
;
_
notificationHandler
.
dispatch
([
this
](){
_
dispatchNotification
([
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
;
_
notificationHandler
.
dispatch
([
this
](){
_
dispatchNotification
([
this
](){
emit
timeout
();
});
}
...
...
@@ -932,7 +932,7 @@ GstVideoReceiver::_onNewSourcePad(GstPad* pad)
if
(
!
_streaming
)
{
_streaming
=
true
;
qCDebug
(
VideoReceiverLog
)
<<
"Streaming started"
;
_
notificationHandler
.
dispatch
([
this
](){
_
dispatchNotification
([
this
](){
emit
streamingChanged
();
});
}
...
...
@@ -1059,7 +1059,7 @@ GstVideoReceiver::_addVideoSink(GstPad* pad)
_decoding
=
true
;
qCDebug
(
VideoReceiverLog
)
<<
"Decoding started"
;
_
notificationHandler
.
dispatch
([
this
](){
_
dispatchNotification
([
this
](){
emit
decodingChanged
();
});
...
...
@@ -1179,7 +1179,7 @@ GstVideoReceiver::_shutdownDecodingBranch(void)
if
(
_decoding
)
{
_decoding
=
false
;
qCDebug
(
VideoReceiverLog
)
<<
"Decoding stopped"
;
_
notificationHandler
.
dispatch
([
this
](){
_
dispatchNotification
([
this
](){
emit
decodingChanged
();
});
}
...
...
@@ -1200,7 +1200,7 @@ GstVideoReceiver::_shutdownRecordingBranch(void)
if
(
_recording
)
{
_recording
=
false
;
qCDebug
(
VideoReceiverLog
)
<<
"Recording stopped"
;
_
notificationHandler
.
dispatch
([
this
](){
_
dispatchNotification
([
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
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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