Unverified Commit 58b88b67 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #8363 from andrewvoznytsa/pr-gstreamer-log

Switch gstreamer to use Qt log API by default
parents 42f2098b b95bb4cb
...@@ -319,27 +319,12 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) ...@@ -319,27 +319,12 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
#endif #endif
// Gstreamer debug settings // Gstreamer debug settings
#if defined(__ios__) || defined(__android__) int gstDebugLevel = 0;
// Initialize Video Streaming
initializeVideoStreaming(argc, argv, nullptr, nullptr);
#else
QString savePath, gstDebugLevel;
if (settings.contains(AppSettings::savePathName)) {
savePath = settings.value(AppSettings::savePathName).toString();
}
if(savePath.isEmpty()) {
savePath = "/tmp";
}
savePath = savePath + "/Logs/gst";
if (!QDir(savePath).exists()) {
QDir().mkpath(savePath);
}
if (settings.contains(AppSettings::gstDebugLevelName)) { if (settings.contains(AppSettings::gstDebugLevelName)) {
gstDebugLevel = "*:" + settings.value(AppSettings::gstDebugLevelName).toString(); gstDebugLevel = settings.value(AppSettings::gstDebugLevelName).toInt();
} }
// Initialize Video Streaming // Initialize Video Streaming
initializeVideoStreaming(argc, argv, savePath.toUtf8().data(), gstDebugLevel.toUtf8().data()); initializeVideoStreaming(argc, argv, gstDebugLevel);
#endif
_toolbox = new QGCToolbox(this); _toolbox = new QGCToolbox(this);
_toolbox->setChildToolboxes(); _toolbox->setChildToolboxes();
......
...@@ -7,6 +7,10 @@ To build video streaming support, you will need to install the GStreamer develop ...@@ -7,6 +7,10 @@ To build video streaming support, you will need to install the GStreamer develop
If you do have the proper GStreamer development libraries installed where QGC looks for it, the QGC build system will automatically use it and build video streaming support. If you would like to disable video streaming support, you can add **DISABLE_VIDEOSTREAMING** to the **DEFINES** build variable. If you do have the proper GStreamer development libraries installed where QGC looks for it, the QGC build system will automatically use it and build video streaming support. If you would like to disable video streaming support, you can add **DISABLE_VIDEOSTREAMING** to the **DEFINES** build variable.
### Gstreamer logs
For cases, when it is need to have more control over gstreamer logging than is availabe via QGroundControl's UI, it is possible to configure gstreamer logging via environment variables. Please see https://developer.gnome.org/gstreamer/stable/gst-running.html for details.
### UDP Pipeline ### UDP Pipeline
For the time being, the RTP UDP pipeline is somewhat hardcoded, using h.264 or h.265. It's best to use a camera capable of hardware encoding either h.264 (such as the Logitech C920) or h.265. On the sender end, for RTP (UDP Streaming) you would run something like this: For the time being, the RTP UDP pipeline is somewhat hardcoded, using h.264 or h.265. It's best to use a camera capable of hardware encoding either h.264 (such as the Logitech C920) or h.265. On the sender end, for RTP (UDP Streaming) you would run something like this:
......
...@@ -19,23 +19,53 @@ ...@@ -19,23 +19,53 @@
#if defined(QGC_GST_STREAMING) #if defined(QGC_GST_STREAMING)
#include <gst/gst.h> #include <gst/gst.h>
#if defined(__android__)
#include <android/log.h> #include "QGCLoggingCategory.h"
static void gst_android_log(GstDebugCategory * category, QGC_LOGGING_CATEGORY(GstreamerLog, "GstreamerLog")
GstDebugLevel level,
const gchar * file, static void qt_gst_log(GstDebugCategory * category,
const gchar * function, GstDebugLevel level,
gint line, const gchar * file,
GObject * object, const gchar * function,
GstDebugMessage * message, gint line,
gpointer data) GObject * object,
GstDebugMessage * message,
gpointer data)
{ {
if (level <= gst_debug_category_get_threshold (category)) { if (level > gst_debug_category_get_threshold(category)) {
__android_log_print(ANDROID_LOG_ERROR, "GST", "%s, %s: %s", file, function, gst_debug_message_get(message)); return;
} }
QMessageLogger log(file, line, function);
char* object_info = gst_info_strdup_printf("%" GST_PTR_FORMAT, static_cast<void*>(object));
switch (level) {
default:
case GST_LEVEL_ERROR:
log.critical(GstreamerLog, "%s %s", object_info, gst_debug_message_get(message));
break;
case GST_LEVEL_WARNING:
log.warning(GstreamerLog, "%s %s", object_info, gst_debug_message_get(message));
break;
case GST_LEVEL_FIXME:
case GST_LEVEL_INFO:
log.info(GstreamerLog, "%s %s", object_info, gst_debug_message_get(message));
break;
case GST_LEVEL_DEBUG:
case GST_LEVEL_LOG:
case GST_LEVEL_TRACE:
case GST_LEVEL_MEMDUMP:
log.debug(GstreamerLog, "%s %s", object_info, gst_debug_message_get(message));
break;
}
g_free(object_info);
object_info = nullptr;
} }
#elif defined(__ios__)
#if defined(__ios__)
#include "gst_ios_init.h" #include "gst_ios_init.h"
#endif #endif
#else #else
...@@ -81,7 +111,7 @@ static void qgcputenv(const QString& key, const QString& root, const QString& pa ...@@ -81,7 +111,7 @@ static void qgcputenv(const QString& key, const QString& root, const QString& pa
#endif #endif
#endif #endif
void initializeVideoStreaming(int &argc, char* argv[], char* logpath, char* debuglevel) void initializeVideoStreaming(int &argc, char* argv[], int gstDebuglevel)
{ {
#if defined(QGC_GST_STREAMING) #if defined(QGC_GST_STREAMING)
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
...@@ -100,22 +130,15 @@ void initializeVideoStreaming(int &argc, char* argv[], char* logpath, char* debu ...@@ -100,22 +130,15 @@ void initializeVideoStreaming(int &argc, char* argv[], char* logpath, char* debu
qgcputenv("GST_PLUGIN_PATH", currentDir, "/gstreamer-plugins"); qgcputenv("GST_PLUGIN_PATH", currentDir, "/gstreamer-plugins");
#endif #endif
//-- Generic initialization //-- If gstreamer debugging is not configured via environment then use internal QT logging
if (qgetenv("GST_DEBUG").isEmpty() && logpath) { if (qgetenv("GST_DEBUG").isEmpty()) {
QString gstDebugFile = QString("%1/%2").arg(logpath).arg("gstreamer-log.txt"); gst_debug_set_default_threshold(static_cast<GstDebugLevel>(gstDebuglevel));
qDebug() << "GStreamer debug output:" << gstDebugFile; gst_debug_remove_log_function(gst_debug_log_default);
if (debuglevel) { gst_debug_add_log_function(qt_gst_log, nullptr, nullptr);
qputenv("GST_DEBUG", debuglevel);
}
qputenv("GST_DEBUG_NO_COLOR", "1");
qputenv("GST_DEBUG_FILE", gstDebugFile.toUtf8());
qputenv("GST_DEBUG_DUMP_DOT_DIR", logpath);
} }
// Initialize GStreamer // Initialize GStreamer
#if defined(__android__) #if defined(__ios__)
gst_debug_add_log_function(gst_android_log, nullptr, nullptr);
#elif defined(__ios__)
//-- iOS specific initialization //-- iOS specific initialization
gst_ios_pre_init(); gst_ios_pre_init();
#endif #endif
...@@ -175,7 +198,6 @@ void initializeVideoStreaming(int &argc, char* argv[], char* logpath, char* debu ...@@ -175,7 +198,6 @@ void initializeVideoStreaming(int &argc, char* argv[], char* logpath, char* debu
qmlRegisterType<GLVideoItemStub>("org.freedesktop.gstreamer.GLVideoItem", 1, 0, "GstGLVideoItem"); qmlRegisterType<GLVideoItemStub>("org.freedesktop.gstreamer.GLVideoItem", 1, 0, "GstGLVideoItem");
Q_UNUSED(argc) Q_UNUSED(argc)
Q_UNUSED(argv) Q_UNUSED(argv)
Q_UNUSED(logpath)
Q_UNUSED(debuglevel) Q_UNUSED(debuglevel)
#endif #endif
} }
...@@ -16,4 +16,4 @@ ...@@ -16,4 +16,4 @@
#pragma once #pragma once
extern void initializeVideoStreaming (int &argc, char *argv[], char* filename, char* debuglevel); extern void initializeVideoStreaming (int &argc, char *argv[], int gstDebuglevel);
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