Commit b95bb4cb authored by Andrew Voznytsa's avatar Andrew Voznytsa

Switch gstreamer to use Qt log API by default

parent d040b949
......@@ -319,27 +319,12 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
#endif
// Gstreamer debug settings
#if defined(__ios__) || defined(__android__)
// 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);
}
int gstDebugLevel = 0;
if (settings.contains(AppSettings::gstDebugLevelName)) {
gstDebugLevel = "*:" + settings.value(AppSettings::gstDebugLevelName).toString();
gstDebugLevel = settings.value(AppSettings::gstDebugLevelName).toInt();
}
// Initialize Video Streaming
initializeVideoStreaming(argc, argv, savePath.toUtf8().data(), gstDebugLevel.toUtf8().data());
#endif
initializeVideoStreaming(argc, argv, gstDebugLevel);
_toolbox = new QGCToolbox(this);
_toolbox->setChildToolboxes();
......
......@@ -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.
### 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
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 @@
#if defined(QGC_GST_STREAMING)
#include <gst/gst.h>
#if defined(__android__)
#include <android/log.h>
static void gst_android_log(GstDebugCategory * category,
GstDebugLevel level,
const gchar * file,
const gchar * function,
gint line,
GObject * object,
GstDebugMessage * message,
gpointer data)
#include "QGCLoggingCategory.h"
QGC_LOGGING_CATEGORY(GstreamerLog, "GstreamerLog")
static void qt_gst_log(GstDebugCategory * category,
GstDebugLevel level,
const gchar * file,
const gchar * function,
gint line,
GObject * object,
GstDebugMessage * message,
gpointer data)
{
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));
if (level > gst_debug_category_get_threshold(category)) {
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"
#endif
#else
......@@ -81,7 +111,7 @@ static void qgcputenv(const QString& key, const QString& root, const QString& pa
#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)
#ifdef Q_OS_MAC
......@@ -100,22 +130,15 @@ void initializeVideoStreaming(int &argc, char* argv[], char* logpath, char* debu
qgcputenv("GST_PLUGIN_PATH", currentDir, "/gstreamer-plugins");
#endif
//-- Generic initialization
if (qgetenv("GST_DEBUG").isEmpty() && logpath) {
QString gstDebugFile = QString("%1/%2").arg(logpath).arg("gstreamer-log.txt");
qDebug() << "GStreamer debug output:" << gstDebugFile;
if (debuglevel) {
qputenv("GST_DEBUG", debuglevel);
}
qputenv("GST_DEBUG_NO_COLOR", "1");
qputenv("GST_DEBUG_FILE", gstDebugFile.toUtf8());
qputenv("GST_DEBUG_DUMP_DOT_DIR", logpath);
//-- If gstreamer debugging is not configured via environment then use internal QT logging
if (qgetenv("GST_DEBUG").isEmpty()) {
gst_debug_set_default_threshold(static_cast<GstDebugLevel>(gstDebuglevel));
gst_debug_remove_log_function(gst_debug_log_default);
gst_debug_add_log_function(qt_gst_log, nullptr, nullptr);
}
// Initialize GStreamer
#if defined(__android__)
gst_debug_add_log_function(gst_android_log, nullptr, nullptr);
#elif defined(__ios__)
#if defined(__ios__)
//-- iOS specific initialization
gst_ios_pre_init();
#endif
......@@ -175,7 +198,6 @@ void initializeVideoStreaming(int &argc, char* argv[], char* logpath, char* debu
qmlRegisterType<GLVideoItemStub>("org.freedesktop.gstreamer.GLVideoItem", 1, 0, "GstGLVideoItem");
Q_UNUSED(argc)
Q_UNUSED(argv)
Q_UNUSED(logpath)
Q_UNUSED(debuglevel)
#endif
}
......@@ -16,4 +16,4 @@
#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