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
614b39c9
Commit
614b39c9
authored
Feb 18, 2020
by
Andrew Voznytsa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use VideoReceiverLog category for video streaming stuff
parent
4fdc5f5f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
41 deletions
+44
-41
VideoReceiver.cc
src/VideoStreaming/VideoReceiver.cc
+40
-39
VideoStreaming.cc
src/VideoStreaming/VideoStreaming.cc
+4
-2
No files found.
src/VideoStreaming/VideoReceiver.cc
View file @
614b39c9
...
...
@@ -118,7 +118,7 @@ newPadCB(GstElement* element, GstPad* pad, gpointer data)
g_free
(
description
);
GstElement
*
sink
=
GST_ELEMENT
(
data
);
if
(
gst_element_link_pads
(
element
,
name
,
sink
,
"sink"
)
==
false
)
qC
ritical
(
)
<<
"newPadCB : failed to link elements
\n
"
;
qC
Critical
(
VideoReceiverLog
)
<<
"newPadCB : failed to link elements
\n
"
;
g_free
(
name
);
}
...
...
@@ -130,7 +130,7 @@ autoplugQueryCaps(GstElement* bin, GstPad* pad, GstElement* element, GstQuery* q
GstPad
*
sinkpad
=
gst_element_get_static_pad
(
glupload
,
"sink"
);
if
(
!
sinkpad
)
{
qC
ritical
(
)
<<
"autoplugQueryCaps(): No sink pad found"
;
qC
Critical
(
VideoReceiverLog
)
<<
"autoplugQueryCaps(): No sink pad found"
;
return
FALSE
;
}
...
...
@@ -161,7 +161,7 @@ autoplugQueryContext(GstElement* bin, GstPad* pad, GstElement* element, GstQuery
GstPad
*
sinkpad
=
gst_element_get_static_pad
(
glsink
,
"sink"
);
if
(
!
sinkpad
){
qC
ritical
(
)
<<
"autoplugQueryContext(): No sink pad found"
;
qC
Critical
(
VideoReceiverLog
)
<<
"autoplugQueryContext(): No sink pad found"
;
return
FALSE
;
}
...
...
@@ -206,7 +206,7 @@ _wrapWithGhostPad(GstElement* element, GstPad* pad, gpointer data)
gst_pad_set_active
(
ghostpad
,
TRUE
);
if
(
!
gst_element_add_pad
(
GST_ELEMENT_PARENT
(
element
),
ghostpad
))
{
qC
ritical
(
)
<<
"Failed to add ghost pad to source"
;
qC
Critical
(
VideoReceiverLog
)
<<
"Failed to add ghost pad to source"
;
}
}
...
...
@@ -224,7 +224,6 @@ _linkPadWithOptionalBuffer(GstElement* element, GstPad* pad, gpointer data)
if
(
!
gst_caps_is_any
(
caps
)
&&
gst_caps_can_intersect
(
caps
,
filter
))
{
isRtpPad
=
TRUE
;
}
gst_caps_unref
(
caps
);
caps
=
nullptr
;
}
...
...
@@ -253,13 +252,13 @@ _linkPadWithOptionalBuffer(GstElement* element, GstPad* pad, gpointer data)
pad
=
gst_element_get_static_pad
(
buffer
,
"src"
);
element
=
buffer
;
}
else
{
qC
ritical
(
)
<<
"_wrapWithGhostPad partially failed. Error with gst_pad_link()"
;
qC
Debug
(
VideoReceiverLog
)
<<
"_wrapWithGhostPad partially failed. Error with gst_pad_link()"
;
}
}
else
{
qC
ritical
(
)
<<
"_wrapWithGhostPad partially failed. Error with gst_element_get_static_pad()"
;
qC
Debug
(
VideoReceiverLog
)
<<
"_wrapWithGhostPad partially failed. Error with gst_element_get_static_pad()"
;
}
}
else
{
qC
ritical
(
)
<<
"_wrapWithGhostPad partially failed. Error with gst_element_factory_make('rtpjitterbuffer')"
;
qC
Debug
(
VideoReceiverLog
)
<<
"_wrapWithGhostPad partially failed. Error with gst_element_factory_make('rtpjitterbuffer')"
;
}
}
...
...
@@ -298,7 +297,7 @@ GstElement*
VideoReceiver
::
_makeSource
(
const
QString
&
uri
)
{
if
(
uri
.
isEmpty
())
{
qC
ritical
(
)
<<
"VideoReceiver::_makeSource() failed because URI is not specified"
;
qC
Critical
(
VideoReceiverLog
)
<<
"VideoReceiver::_makeSource() failed because URI is not specified"
;
return
nullptr
;
}
...
...
@@ -334,12 +333,12 @@ VideoReceiver::_makeSource(const QString& uri)
if
(
isUdp264
)
{
if
((
caps
=
gst_caps_from_string
(
"application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264"
))
==
nullptr
)
{
qC
ritical
(
)
<<
"VideoReceiver::_makeSource() failed. Error with gst_caps_from_string()"
;
qC
Critical
(
VideoReceiverLog
)
<<
"VideoReceiver::_makeSource() failed. Error with gst_caps_from_string()"
;
break
;
}
}
else
if
(
isUdp264
)
{
if
((
caps
=
gst_caps_from_string
(
"application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H265"
))
==
nullptr
)
{
qC
ritical
(
)
<<
"VideoReceiver::_makeSource() failed. Error with gst_caps_from_string()"
;
qC
Critical
(
VideoReceiverLog
)
<<
"VideoReceiver::_makeSource() failed. Error with gst_caps_from_string()"
;
break
;
}
}
...
...
@@ -351,11 +350,11 @@ VideoReceiver::_makeSource(const QString& uri)
}
}
}
else
{
q
Warning
(
)
<<
"VideoReceiver::_makeSource(): URI is not recognized"
;
q
CDebug
(
VideoReceiverLog
)
<<
"VideoReceiver::_makeSource(): URI is not recognized"
;
}
if
(
!
source
)
{
qC
ritical
(
)
<<
"VideoReceiver::_makeSource() failed. Error with gst_element_factory_make() for data source"
;
qC
Critical
(
VideoReceiverLog
)
<<
"VideoReceiver::_makeSource() failed. Error with gst_element_factory_make() for data source"
;
break
;
}
...
...
@@ -373,7 +372,7 @@ VideoReceiver::_makeSource(const QString& uri)
}
if
((
bin
=
gst_bin_new
(
"sourcebin"
))
==
nullptr
)
{
qC
ritical
(
)
<<
"VideoReceiver::_makeSource() failed. Error with gst_bin_new('sourcebin')"
;
qC
Critical
(
VideoReceiverLog
)
<<
"VideoReceiver::_makeSource() failed. Error with gst_bin_new('sourcebin')"
;
break
;
}
...
...
@@ -386,19 +385,19 @@ VideoReceiver::_makeSource(const QString& uri)
if
(
probeRes
&
1
)
{
if
(
probeRes
&
2
)
{
if
((
buffer
=
gst_element_factory_make
(
"rtpjitterbuffer"
,
nullptr
))
==
nullptr
)
{
qC
ritical
(
)
<<
"VideoReceiver::_makeSource() failed. Error with gst_element_factory_make('rtpjitterbuffer')"
;
qC
Critical
(
VideoReceiverLog
)
<<
"VideoReceiver::_makeSource() failed. Error with gst_element_factory_make('rtpjitterbuffer')"
;
break
;
}
gst_bin_add
(
GST_BIN
(
bin
),
buffer
);
if
(
!
gst_element_link_many
(
source
,
buffer
,
parser
,
nullptr
))
{
qC
ritical
(
)
<<
"VideoReceiver::_makeSource() failed. Error with gst_element_link()"
;
qC
Critical
(
VideoReceiverLog
)
<<
"VideoReceiver::_makeSource() failed. Error with gst_element_link()"
;
break
;
}
}
else
{
if
(
!
gst_element_link
(
source
,
parser
))
{
qC
ritical
(
)
<<
"VideoReceiver::_makeSource() failed. Error with gst_element_link()"
;
qC
Critical
(
VideoReceiverLog
)
<<
"VideoReceiver::_makeSource() failed. Error with gst_element_link()"
;
break
;
}
}
...
...
@@ -542,14 +541,14 @@ VideoReceiver::start()
#endif
if
(
uri
.
isEmpty
())
{
qC
ritical
(
)
<<
"VideoReceiver::start() failed because URI is not specified"
;
qC
Debug
(
VideoReceiverLog
)
<<
"VideoReceiver::start() failed because URI is not specified"
;
return
;
}
bool
useTcpConnection
=
uri
.
contains
(
"rtsp://"
)
||
uri
.
contains
(
"tcp://"
);
if
(
_videoSink
==
nullptr
)
{
qC
ritical
(
)
<<
"VideoReceiver::start() failed because video sink is not set"
;
qC
Warning
(
VideoReceiverLog
)
<<
"VideoReceiver::start() failed because video sink is not set"
;
return
;
}
if
(
_running
)
{
...
...
@@ -577,31 +576,31 @@ VideoReceiver::start()
do
{
if
((
_pipeline
=
gst_pipeline_new
(
"receiver"
))
==
nullptr
)
{
qC
ritical
(
)
<<
"VideoReceiver::start() failed. Error with gst_pipeline_new()"
;
qC
Critical
(
VideoReceiverLog
)
<<
"VideoReceiver::start() failed. Error with gst_pipeline_new()"
;
break
;
}
g_object_set
(
_pipeline
,
"message-forward"
,
TRUE
,
nullptr
);
if
((
source
=
_makeSource
(
uri
))
==
nullptr
)
{
qC
ritical
(
)
<<
"VideoReceiver::start() failed. Error with _makeSource()"
;
qC
Critical
(
VideoReceiverLog
)
<<
"VideoReceiver::start() failed. Error with _makeSource()"
;
break
;
}
if
((
_tee
=
gst_element_factory_make
(
"tee"
,
nullptr
))
==
nullptr
)
{
qC
ritical
(
)
<<
"VideoReceiver::start() failed. Error with gst_element_factory_make('tee')"
;
qC
Critical
(
VideoReceiverLog
)
<<
"VideoReceiver::start() failed. Error with gst_element_factory_make('tee')"
;
break
;
}
if
((
queue
=
gst_element_factory_make
(
"queue"
,
nullptr
))
==
nullptr
)
{
// TODO: We may want to add queue2 max-size-buffers=1 to get lower latency
// We should compare gstreamer scripts to QGroundControl to determine the need
qC
ritical
(
)
<<
"VideoReceiver::start() failed. Error with gst_element_factory_make('queue')"
;
qC
Critical
(
VideoReceiverLog
)
<<
"VideoReceiver::start() failed. Error with gst_element_factory_make('queue')"
;
break
;
}
if
((
decoder
=
gst_element_factory_make
(
"decodebin"
,
"decoder"
))
==
nullptr
)
{
qC
ritical
(
)
<<
"VideoReceiver::start() failed. Error with gst_element_factory_make('decodebin')"
;
qC
Critical
(
VideoReceiverLog
)
<<
"VideoReceiver::start() failed. Error with gst_element_factory_make('decodebin')"
;
break
;
}
...
...
@@ -612,7 +611,7 @@ VideoReceiver::start()
g_signal_connect
(
source
,
"pad-added"
,
G_CALLBACK
(
newPadCB
),
_tee
);
if
(
!
gst_element_link_many
(
_tee
,
queue
,
decoder
,
nullptr
))
{
qC
ritical
(
)
<<
"Unable to link UDP elements."
;
qC
Critical
(
VideoReceiverLog
)
<<
"Unable to link UDP elements."
;
break
;
}
...
...
@@ -636,7 +635,7 @@ VideoReceiver::start()
}
while
(
0
);
if
(
!
running
)
{
qC
ritical
(
)
<<
"VideoReceiver::start() failed"
;
qC
Critical
(
VideoReceiverLog
)
<<
"VideoReceiver::start() failed"
;
// In newer versions, the pipeline will clean up all references that are added to it
if
(
_pipeline
!=
nullptr
)
{
...
...
@@ -700,7 +699,7 @@ VideoReceiver::stop()
gst_object_unref
(
bus
);
if
(
GST_MESSAGE_TYPE
(
message
)
==
GST_MESSAGE_ERROR
)
{
_shutdownPipeline
();
qC
ritical
(
)
<<
"Error stopping pipeline!"
;
qC
Critical
(
VideoReceiverLog
)
<<
"Error stopping pipeline!"
;
}
else
if
(
GST_MESSAGE_TYPE
(
message
)
==
GST_MESSAGE_EOS
)
{
_handleEOS
();
}
...
...
@@ -767,7 +766,7 @@ VideoReceiver::_handleEOS() {
}
else
if
(
_recording
&&
_sink
->
removing
)
{
_shutdownRecordingBranch
();
}
else
{
q
Warning
(
)
<<
"VideoReceiver: Unexpected EOS!"
;
q
CWarning
(
VideoReceiverLog
)
<<
"VideoReceiver: Unexpected EOS!"
;
_handleError
();
}
}
...
...
@@ -799,7 +798,7 @@ VideoReceiver::_onBusMessage(GstBus* bus, GstMessage* msg, gpointer data)
GError
*
error
;
gst_message_parse_error
(
msg
,
&
error
,
&
debug
);
g_free
(
debug
);
qC
ritical
(
)
<<
error
->
message
;
qC
Critical
(
VideoReceiverLog
)
<<
error
->
message
;
g_error_free
(
error
);
pThis
->
msgErrorReceived
();
}
...
...
@@ -900,7 +899,7 @@ VideoReceiver::setVideoSink(GstElement* videoSink)
gst_object_unref
(
pad
);
pad
=
nullptr
;
}
else
{
qC
Debug
(
VideoReceiverLog
)
<<
"Unable to find sink pad of video sink"
;
qC
Critical
(
VideoReceiverLog
)
<<
"Unable to find sink pad of video sink"
;
}
}
}
...
...
@@ -930,26 +929,26 @@ VideoReceiver::_makeFileSink(const QString& videoFile, unsigned format)
do
{
if
((
mux
=
gst_element_factory_make
(
kVideoMuxes
[
format
],
nullptr
))
==
nullptr
)
{
qC
ritical
(
)
<<
"VideoReceiver::_makeFileSink() failed. Error with gst_element_factory_make('"
<<
kVideoMuxes
[
format
]
<<
"')"
;
qC
Critical
(
VideoReceiverLog
)
<<
"VideoReceiver::_makeFileSink() failed. Error with gst_element_factory_make('"
<<
kVideoMuxes
[
format
]
<<
"')"
;
break
;
}
if
((
sink
=
gst_element_factory_make
(
"filesink"
,
nullptr
))
==
nullptr
)
{
qC
ritical
(
)
<<
"VideoReceiver::_makeFileSink() failed. Error with gst_element_factory_make('filesink')"
;
qC
Critical
(
VideoReceiverLog
)
<<
"VideoReceiver::_makeFileSink() failed. Error with gst_element_factory_make('filesink')"
;
break
;
}
g_object_set
(
static_cast
<
gpointer
>
(
sink
),
"location"
,
qPrintable
(
videoFile
),
nullptr
);
if
((
bin
=
gst_bin_new
(
"sinkbin"
))
==
nullptr
)
{
qC
ritical
(
)
<<
"VideoReceiver::_makeFileSink() failed. Error with gst_bin_new('sinkbin')"
;
qC
Critical
(
VideoReceiverLog
)
<<
"VideoReceiver::_makeFileSink() failed. Error with gst_bin_new('sinkbin')"
;
break
;
}
GstPadTemplate
*
padTemplate
;
if
((
padTemplate
=
gst_element_class_get_pad_template
(
GST_ELEMENT_GET_CLASS
(
mux
),
"video_%u"
))
==
nullptr
)
{
qC
ritical
(
)
<<
"VideoReceiver::_makeFileSink() failed. Error with gst_element_class_get_pad_template(mux)"
;
qC
Critical
(
VideoReceiverLog
)
<<
"VideoReceiver::_makeFileSink() failed. Error with gst_element_class_get_pad_template(mux)"
;
break
;
}
...
...
@@ -957,7 +956,7 @@ VideoReceiver::_makeFileSink(const QString& videoFile, unsigned format)
GstPad
*
pad
;
if
((
pad
=
gst_element_request_pad
(
mux
,
padTemplate
,
nullptr
,
nullptr
))
==
nullptr
)
{
qC
ritical
(
)
<<
"VideoReceiver::_makeFileSink() failed. Error with gst_element_request_pad(mux)"
;
qC
Critical
(
VideoReceiverLog
)
<<
"VideoReceiver::_makeFileSink() failed. Error with gst_element_request_pad(mux)"
;
break
;
}
...
...
@@ -973,7 +972,7 @@ VideoReceiver::_makeFileSink(const QString& videoFile, unsigned format)
pad
=
nullptr
;
if
(
!
gst_element_link
(
mux
,
sink
))
{
qC
ritical
(
)
<<
"VideoReceiver::_makeFileSink() failed. Error with gst_element_link()"
;
qC
Critical
(
VideoReceiverLog
)
<<
"VideoReceiver::_makeFileSink() failed. Error with gst_element_link()"
;
break
;
}
...
...
@@ -1028,10 +1027,12 @@ VideoReceiver::startRecording(const QString &videoFile)
qgcApp
()
->
showMessage
(
tr
(
"Unabled to record video. Video save path must be specified in Settings."
));
return
;
}
_videoFile
=
savePath
+
"/"
+
(
videoFile
.
isEmpty
()
?
QDateTime
::
currentDateTime
().
toString
(
"yyyy-MM-dd_hh.mm.ss"
)
:
videoFile
)
+
"."
+
kVideoExtensions
[
muxIdx
];
qDebug
()
<<
"New video file:"
<<
_videoFile
;
qCDebug
(
VideoReceiverLog
)
<<
"New video file:"
<<
_videoFile
;
emit
videoFileChanged
();
...
...
@@ -1042,7 +1043,7 @@ VideoReceiver::startRecording(const QString &videoFile)
_sink
->
removing
=
false
;
if
(
!
_sink
->
teepad
||
!
_sink
->
queue
||
!
_sink
->
filesink
)
{
qC
ritical
(
)
<<
"VideoReceiver::startRecording() failed to make _sink elements"
;
qC
Critical
(
VideoReceiverLog
)
<<
"VideoReceiver::startRecording() failed to make _sink elements"
;
return
;
}
...
...
@@ -1210,7 +1211,7 @@ VideoReceiver::_keyframeWatch(GstPad* pad, GstPadProbeInfo* info, gpointer user_
// Add the filesink once we have a valid I-frame
gst_bin_add
(
GST_BIN
(
pThis
->
_pipeline
),
pThis
->
_sink
->
filesink
);
if
(
!
gst_element_link
(
pThis
->
_sink
->
queue
,
pThis
->
_sink
->
filesink
))
{
qC
ritical
(
)
<<
"Failed to link queue and file sink"
;
qC
Critical
(
VideoReceiverLog
)
<<
"Failed to link queue and file sink"
;
}
gst_element_sync_state_with_parent
(
pThis
->
_sink
->
filesink
);
...
...
src/VideoStreaming/VideoStreaming.cc
View file @
614b39c9
...
...
@@ -17,6 +17,8 @@
#include <QtQml>
#include <QDebug>
#include "VideoReceiver.h"
#if defined(QGC_GST_STREAMING)
#include <gst/gst.h>
...
...
@@ -146,7 +148,7 @@ void initializeVideoStreaming(int &argc, char* argv[], int gstDebuglevel)
GError
*
error
=
nullptr
;
if
(
!
gst_init_check
(
&
argc
,
&
argv
,
&
error
))
{
qC
ritical
(
)
<<
"gst_init_check() failed: "
<<
error
->
message
;
qC
Critical
(
VideoReceiverLog
)
<<
"gst_init_check() failed: "
<<
error
->
message
;
g_error_free
(
error
);
}
...
...
@@ -192,7 +194,7 @@ void initializeVideoStreaming(int &argc, char* argv[], int gstDebuglevel)
gst_object_unref
(
sink
);
sink
=
nullptr
;
}
else
{
qC
ritical
(
)
<<
"unable to find qmlglsink - you need to build it yourself and add to GST_PLUGIN_PATH"
;
qC
Critical
(
VideoReceiverLog
)
<<
"unable to find qmlglsink - you need to build it yourself and add to GST_PLUGIN_PATH"
;
}
GST_PLUGIN_STATIC_REGISTER
(
qgc
);
...
...
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