diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc index a0e7d219e1fedcdae5bf4a2e9171abd2ab24272f..ec3d865182f5c6a34c42ab8291559ce7dfa4816f 100644 --- a/src/QGCApplication.cc +++ b/src/QGCApplication.cc @@ -311,8 +311,20 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) } #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 - initializeVideoStreaming(argc, argv); + initializeVideoStreaming(argc, argv, savePath.toUtf8().data(), gstDebugLevel.toUtf8().data()); _toolbox = new QGCToolbox(this); _toolbox->setChildToolboxes(); diff --git a/src/QmlControls/AppMessages.qml b/src/QmlControls/AppMessages.qml index ca82d67c3bd86f6d8d31087ec35b364e229d8a17..77cfe33dbcf87568996f245e31fb97a963e3b85c 100644 --- a/src/QmlControls/AppMessages.qml +++ b/src/QmlControls/AppMessages.qml @@ -15,6 +15,8 @@ import QtQuick.Dialogs 1.2 import QGroundControl 1.0 import QGroundControl.Palette 1.0 import QGroundControl.Controls 1.0 +import QGroundControl.FactSystem 1.0 +import QGroundControl.FactControls 1.0 import QGroundControl.Controllers 1.0 import QGroundControl.ScreenTools 1.0 @@ -140,6 +142,24 @@ QGCView { 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 { id: writeBusy anchors.bottom: writeButton.bottom diff --git a/src/Settings/App.SettingsGroup.json b/src/Settings/App.SettingsGroup.json index 5b9bd15c2219da680b21cb0f958944e8f6670df7..81520a00d83d844c8af5b5436cfe0616471935de 100644 --- a/src/Settings/App.SettingsGroup.json +++ b/src/Settings/App.SettingsGroup.json @@ -103,6 +103,13 @@ "type": "bool", "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", "shortDescription": "AutoLoad mission on vehicle connect", diff --git a/src/Settings/AppSettings.cc b/src/Settings/AppSettings.cc index 65068ef39ef40bd38d44838f2f86cffec647a62b..3e8b950e88401411b79425f9ede36e74db97f3eb 100644 --- a/src/Settings/AppSettings.cc +++ b/src/Settings/AppSettings.cc @@ -36,6 +36,7 @@ const char* AppSettings::autoLoadMissionsName = "AutoLoa const char* AppSettings::mapboxTokenName = "MapboxToken"; const char* AppSettings::esriTokenName = "EsriToken"; const char* AppSettings::defaultFirmwareTypeName = "DefaultFirmwareType"; +const char* AppSettings::gstDebugName = "GstreamerDebugLevel"; const char* AppSettings::parameterFileExtension = "params"; const char* AppSettings::planFileExtension = "plan"; @@ -75,6 +76,7 @@ AppSettings::AppSettings(QObject* parent) , _mapboxTokenFact(NULL) , _esriTokenFact(NULL) , _defaultFirmwareTypeFact(NULL) + , _gstDebugFact(NULL) { QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); qmlRegisterUncreatableType("QGroundControl.SettingsManager", 1, 0, "AppSettings", "Reference only"); @@ -232,6 +234,15 @@ Fact* AppSettings::virtualJoystick(void) return _virtualJoystickFact; } +Fact* AppSettings::gstDebug(void) +{ + if (!_gstDebugFact) { + _gstDebugFact = _createSettingsFact(gstDebugName); + } + + return _gstDebugFact; +} + Fact* AppSettings::indoorPalette(void) { if (!_indoorPaletteFact) { diff --git a/src/Settings/AppSettings.h b/src/Settings/AppSettings.h index 5b29ac37096b61e46ef5ca16e5b1b593edbf89e5..6b421aa35ddac5ce78e53ba0a85d3920af3992c7 100644 --- a/src/Settings/AppSettings.h +++ b/src/Settings/AppSettings.h @@ -40,6 +40,7 @@ public: Q_PROPERTY(Fact* mapboxToken READ mapboxToken CONSTANT) Q_PROPERTY(Fact* esriToken READ esriToken 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 parameterSavePath READ parameterSavePath NOTIFY savePathsChanged) @@ -75,6 +76,7 @@ public: Fact* mapboxToken (void); Fact* esriToken (void); Fact* defaultFirmwareType (void); + Fact* gstDebug (void); QString missionSavePath (void); QString parameterSavePath (void); @@ -107,6 +109,7 @@ public: static const char* mapboxTokenName; static const char* esriTokenName; static const char* defaultFirmwareTypeName; + static const char* gstDebugName; // Application wide file extensions static const char* parameterFileExtension; @@ -154,6 +157,7 @@ private: SettingsFact* _mapboxTokenFact; SettingsFact* _esriTokenFact; SettingsFact* _defaultFirmwareTypeFact; + SettingsFact* _gstDebugFact; }; #endif diff --git a/src/VideoStreaming/VideoReceiver.cc b/src/VideoStreaming/VideoReceiver.cc index 2e0ae789357a63538e74530572a5cf05c40fdf93..7f46d85650258331bfd533f0c89ed9d4e2d68e2c 100644 --- a/src/VideoStreaming/VideoReceiver.cc +++ b/src/VideoStreaming/VideoReceiver.cc @@ -366,6 +366,7 @@ VideoReceiver::start() 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; } while(0); @@ -419,6 +420,7 @@ VideoReceiver::start() _running = false; } else { + GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(_pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "pipeline-playing"); _running = true; qCDebug(VideoReceiverLog) << "Running"; } @@ -676,6 +678,8 @@ VideoReceiver::startRecording(const QString &videoFile) gst_pad_link(_sink->teepad, sinkpad); gst_object_unref(sinkpad); + GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(_pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "pipeline-recording"); + _recording = true; emit recordingChanged(); qCDebug(VideoReceiverLog) << "Recording started"; diff --git a/src/VideoStreaming/VideoStreaming.cc b/src/VideoStreaming/VideoStreaming.cc index 57579c3e97bfc171f51c265e7b766c03a825af48..b98c4e23e11e7e32bfde131b8ce02447dc21b4b2 100644 --- a/src/VideoStreaming/VideoStreaming.cc +++ b/src/VideoStreaming/VideoStreaming.cc @@ -101,7 +101,7 @@ int start_logger(const char *app_name) } #endif -void initializeVideoStreaming(int &argc, char* argv[]) +void initializeVideoStreaming(int &argc, char* argv[], char* logpath, char* debuglevel) { #if defined(QGC_GST_STREAMING) #ifdef __macos__ @@ -119,12 +119,19 @@ void initializeVideoStreaming(int &argc, char* argv[]) QString currentDir = QCoreApplication::applicationDirPath(); qgcputenv("GST_PLUGIN_PATH", currentDir, "/gstreamer-plugins"); #endif + + // Initialize GStreamer - #ifdef ANDDROID_GST_DEBUG - start_logger("gst_log"); - qputenv("GST_DEBUG", "*:4"); - qputenv("GST_DEBUG_NO_COLOR", "1"); - #endif + if (logpath) { + if (debuglevel) { + qputenv("GST_DEBUG", debuglevel); + } + 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; if (!gst_init_check(&argc, &argv, &error)) { qCritical() << "gst_init_check() failed: " << error->message; diff --git a/src/VideoStreaming/VideoStreaming.h b/src/VideoStreaming/VideoStreaming.h index 74b4281b5d33970bd3a5510e2f0311746850eee0..f918f6ed86af6b8a18192b7537187471fdc7d651 100644 --- a/src/VideoStreaming/VideoStreaming.h +++ b/src/VideoStreaming/VideoStreaming.h @@ -17,7 +17,7 @@ #ifndef 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 (); #endif // VIDEO_STREAMING_H