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

Merge pull request #6033 from bluerobotics/gst-debugging

Add gstreamer debug log option, and dot file output
parents be5cc436 a9305264
...@@ -311,8 +311,20 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) ...@@ -311,8 +311,20 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
} }
#endif #endif
// gstreamer debug settings
QString savePath, gstDebugLevel;
if (settings.contains(AppSettings::savePathName)) {
savePath = settings.value("SavePath").toString() + "/Logs/gst"; // hardcode log path here, appsetting is not available yet
if (!QDir(savePath).exists()) {
QDir().mkdir(savePath);
}
}
if (settings.contains(AppSettings::gstDebugName)) {
gstDebugLevel = "*:" + settings.value("GstreamerDebugLevel").toString();
}
// Initialize Video Streaming // Initialize Video Streaming
initializeVideoStreaming(argc, argv); initializeVideoStreaming(argc, argv, savePath.toUtf8().data(), gstDebugLevel.toUtf8().data());
_toolbox = new QGCToolbox(this); _toolbox = new QGCToolbox(this);
_toolbox->setChildToolboxes(); _toolbox->setChildToolboxes();
......
...@@ -15,6 +15,8 @@ import QtQuick.Dialogs 1.2 ...@@ -15,6 +15,8 @@ import QtQuick.Dialogs 1.2
import QGroundControl 1.0 import QGroundControl 1.0
import QGroundControl.Palette 1.0 import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0 import QGroundControl.Controls 1.0
import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0
import QGroundControl.Controllers 1.0 import QGroundControl.Controllers 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
...@@ -140,6 +142,24 @@ QGCView { ...@@ -140,6 +142,24 @@ QGCView {
text: qsTr("Save App Log") text: qsTr("Save App Log")
} }
QGCLabel {
id: gstLabel
anchors.baseline: gstCombo.baseline
anchors.right: gstCombo.left
anchors.rightMargin: ScreenTools.defaultFontPixelWidth
text: "gstreamer debug level:"
}
FactComboBox {
id: gstCombo
anchors.right: followTail.left
anchors.rightMargin: ScreenTools.defaultFontPixelWidth*20
anchors.bottom: parent.bottom
width: ScreenTools.defaultFontPixelWidth*20
model: ["disabled", "1", "2", "3", "4", "5", "6", "7", "8"]
fact: QGroundControl.settingsManager.appSettings.gstDebug
}
BusyIndicator { BusyIndicator {
id: writeBusy id: writeBusy
anchors.bottom: writeButton.bottom anchors.bottom: writeButton.bottom
......
...@@ -103,6 +103,13 @@ ...@@ -103,6 +103,13 @@
"type": "bool", "type": "bool",
"defaultValue": false "defaultValue": false
}, },
{
"name": "GstreamerDebugLevel",
"shortDescription": "Video streaming debug",
"longDescription": "Sets the environment variable GST_DEBUG for all pipeline elements on boot.",
"type": "uint8",
"defaultValue": 0
},
{ {
"name": "AutoLoadMissions", "name": "AutoLoadMissions",
"shortDescription": "AutoLoad mission on vehicle connect", "shortDescription": "AutoLoad mission on vehicle connect",
......
...@@ -36,6 +36,7 @@ const char* AppSettings::autoLoadMissionsName = "AutoLoa ...@@ -36,6 +36,7 @@ const char* AppSettings::autoLoadMissionsName = "AutoLoa
const char* AppSettings::mapboxTokenName = "MapboxToken"; const char* AppSettings::mapboxTokenName = "MapboxToken";
const char* AppSettings::esriTokenName = "EsriToken"; const char* AppSettings::esriTokenName = "EsriToken";
const char* AppSettings::defaultFirmwareTypeName = "DefaultFirmwareType"; const char* AppSettings::defaultFirmwareTypeName = "DefaultFirmwareType";
const char* AppSettings::gstDebugName = "GstreamerDebugLevel";
const char* AppSettings::parameterFileExtension = "params"; const char* AppSettings::parameterFileExtension = "params";
const char* AppSettings::planFileExtension = "plan"; const char* AppSettings::planFileExtension = "plan";
...@@ -75,6 +76,7 @@ AppSettings::AppSettings(QObject* parent) ...@@ -75,6 +76,7 @@ AppSettings::AppSettings(QObject* parent)
, _mapboxTokenFact(NULL) , _mapboxTokenFact(NULL)
, _esriTokenFact(NULL) , _esriTokenFact(NULL)
, _defaultFirmwareTypeFact(NULL) , _defaultFirmwareTypeFact(NULL)
, _gstDebugFact(NULL)
{ {
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
qmlRegisterUncreatableType<AppSettings>("QGroundControl.SettingsManager", 1, 0, "AppSettings", "Reference only"); qmlRegisterUncreatableType<AppSettings>("QGroundControl.SettingsManager", 1, 0, "AppSettings", "Reference only");
...@@ -232,6 +234,15 @@ Fact* AppSettings::virtualJoystick(void) ...@@ -232,6 +234,15 @@ Fact* AppSettings::virtualJoystick(void)
return _virtualJoystickFact; return _virtualJoystickFact;
} }
Fact* AppSettings::gstDebug(void)
{
if (!_gstDebugFact) {
_gstDebugFact = _createSettingsFact(gstDebugName);
}
return _gstDebugFact;
}
Fact* AppSettings::indoorPalette(void) Fact* AppSettings::indoorPalette(void)
{ {
if (!_indoorPaletteFact) { if (!_indoorPaletteFact) {
......
...@@ -40,6 +40,7 @@ public: ...@@ -40,6 +40,7 @@ public:
Q_PROPERTY(Fact* mapboxToken READ mapboxToken CONSTANT) Q_PROPERTY(Fact* mapboxToken READ mapboxToken CONSTANT)
Q_PROPERTY(Fact* esriToken READ esriToken CONSTANT) Q_PROPERTY(Fact* esriToken READ esriToken CONSTANT)
Q_PROPERTY(Fact* defaultFirmwareType READ defaultFirmwareType CONSTANT) Q_PROPERTY(Fact* defaultFirmwareType READ defaultFirmwareType CONSTANT)
Q_PROPERTY(Fact* gstDebug READ gstDebug CONSTANT)
Q_PROPERTY(QString missionSavePath READ missionSavePath NOTIFY savePathsChanged) Q_PROPERTY(QString missionSavePath READ missionSavePath NOTIFY savePathsChanged)
Q_PROPERTY(QString parameterSavePath READ parameterSavePath NOTIFY savePathsChanged) Q_PROPERTY(QString parameterSavePath READ parameterSavePath NOTIFY savePathsChanged)
...@@ -75,6 +76,7 @@ public: ...@@ -75,6 +76,7 @@ public:
Fact* mapboxToken (void); Fact* mapboxToken (void);
Fact* esriToken (void); Fact* esriToken (void);
Fact* defaultFirmwareType (void); Fact* defaultFirmwareType (void);
Fact* gstDebug (void);
QString missionSavePath (void); QString missionSavePath (void);
QString parameterSavePath (void); QString parameterSavePath (void);
...@@ -107,6 +109,7 @@ public: ...@@ -107,6 +109,7 @@ public:
static const char* mapboxTokenName; static const char* mapboxTokenName;
static const char* esriTokenName; static const char* esriTokenName;
static const char* defaultFirmwareTypeName; static const char* defaultFirmwareTypeName;
static const char* gstDebugName;
// Application wide file extensions // Application wide file extensions
static const char* parameterFileExtension; static const char* parameterFileExtension;
...@@ -154,6 +157,7 @@ private: ...@@ -154,6 +157,7 @@ private:
SettingsFact* _mapboxTokenFact; SettingsFact* _mapboxTokenFact;
SettingsFact* _esriTokenFact; SettingsFact* _esriTokenFact;
SettingsFact* _defaultFirmwareTypeFact; SettingsFact* _defaultFirmwareTypeFact;
SettingsFact* _gstDebugFact;
}; };
#endif #endif
...@@ -366,6 +366,7 @@ VideoReceiver::start() ...@@ -366,6 +366,7 @@ VideoReceiver::start()
bus = NULL; bus = NULL;
} }
GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(_pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "pipeline-paused");
running = gst_element_set_state(_pipeline, GST_STATE_PLAYING) != GST_STATE_CHANGE_FAILURE; running = gst_element_set_state(_pipeline, GST_STATE_PLAYING) != GST_STATE_CHANGE_FAILURE;
} while(0); } while(0);
...@@ -419,6 +420,7 @@ VideoReceiver::start() ...@@ -419,6 +420,7 @@ VideoReceiver::start()
_running = false; _running = false;
} else { } else {
GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(_pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "pipeline-playing");
_running = true; _running = true;
qCDebug(VideoReceiverLog) << "Running"; qCDebug(VideoReceiverLog) << "Running";
} }
...@@ -676,6 +678,8 @@ VideoReceiver::startRecording(const QString &videoFile) ...@@ -676,6 +678,8 @@ VideoReceiver::startRecording(const QString &videoFile)
gst_pad_link(_sink->teepad, sinkpad); gst_pad_link(_sink->teepad, sinkpad);
gst_object_unref(sinkpad); gst_object_unref(sinkpad);
GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(_pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "pipeline-recording");
_recording = true; _recording = true;
emit recordingChanged(); emit recordingChanged();
qCDebug(VideoReceiverLog) << "Recording started"; qCDebug(VideoReceiverLog) << "Recording started";
......
...@@ -101,7 +101,7 @@ int start_logger(const char *app_name) ...@@ -101,7 +101,7 @@ int start_logger(const char *app_name)
} }
#endif #endif
void initializeVideoStreaming(int &argc, char* argv[]) void initializeVideoStreaming(int &argc, char* argv[], char* logpath, char* debuglevel)
{ {
#if defined(QGC_GST_STREAMING) #if defined(QGC_GST_STREAMING)
#ifdef __macos__ #ifdef __macos__
...@@ -119,12 +119,19 @@ void initializeVideoStreaming(int &argc, char* argv[]) ...@@ -119,12 +119,19 @@ void initializeVideoStreaming(int &argc, char* argv[])
QString currentDir = QCoreApplication::applicationDirPath(); QString currentDir = QCoreApplication::applicationDirPath();
qgcputenv("GST_PLUGIN_PATH", currentDir, "/gstreamer-plugins"); qgcputenv("GST_PLUGIN_PATH", currentDir, "/gstreamer-plugins");
#endif #endif
// Initialize GStreamer // Initialize GStreamer
#ifdef ANDDROID_GST_DEBUG if (logpath) {
start_logger("gst_log"); if (debuglevel) {
qputenv("GST_DEBUG", "*:4"); qputenv("GST_DEBUG", debuglevel);
qputenv("GST_DEBUG_NO_COLOR", "1"); }
#endif qputenv("GST_DEBUG_NO_COLOR", "1");
qputenv("GST_DEBUG_FILE", QString("%1/%2").arg(logpath).arg("gstreamer-log.txt").toUtf8());
qputenv("GST_DEBUG_DUMP_DOT_DIR", logpath);
}
GError* error = NULL; GError* error = NULL;
if (!gst_init_check(&argc, &argv, &error)) { if (!gst_init_check(&argc, &argv, &error)) {
qCritical() << "gst_init_check() failed: " << error->message; qCritical() << "gst_init_check() failed: " << error->message;
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#ifndef VIDEO_STREAMING_H #ifndef VIDEO_STREAMING_H
#define VIDEO_STREAMING_H #define VIDEO_STREAMING_H
extern void initializeVideoStreaming (int &argc, char *argv[]); extern void initializeVideoStreaming (int &argc, char *argv[], char* filename, char* debuglevel);
extern void shutdownVideoStreaming (); extern void shutdownVideoStreaming ();
#endif // VIDEO_STREAMING_H #endif // VIDEO_STREAMING_H
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