5#include <QtCore/QString>
15std::atomic_bool g_externalPluginLoaderFailed {
false};
17void glib_print_handler(
const gchar *
string)
19 qCInfo(GStreamerLoggingLog) << string;
22void glib_printerr_handler(
const gchar *
string)
24 qCWarning(GStreamerLoggingLog) << string;
27void glib_log_handler(
const gchar *log_domain, GLogLevelFlags log_level,
28 const gchar *message, gpointer user_data)
31 const QString domain = log_domain ? QString::fromUtf8(log_domain) : QStringLiteral(
"GLib");
32 const QString msg = QString::fromUtf8(message);
34 if (msg.contains(QStringLiteral(
"External plugin loader failed"), Qt::CaseInsensitive)) {
35 g_externalPluginLoaderFailed.store(
true);
38 if (msg.contains(QStringLiteral(
"pygobject initialization failed"), Qt::CaseInsensitive)) {
39 qCDebug(GStreamerLoggingLog) << domain << msg;
43 switch (log_level & G_LOG_LEVEL_MASK) {
44 case G_LOG_LEVEL_ERROR:
45 case G_LOG_LEVEL_CRITICAL:
46 qCCritical(GStreamerLoggingLog) << domain << msg;
48 case G_LOG_LEVEL_WARNING:
49 qCWarning(GStreamerLoggingLog) << domain << msg;
51 case G_LOG_LEVEL_MESSAGE:
52 case G_LOG_LEVEL_INFO:
53 qCInfo(GStreamerLoggingLog) << domain << msg;
55 case G_LOG_LEVEL_DEBUG:
57 qCDebug(GStreamerLoggingLog) << domain << msg;
69 g_externalPluginLoaderFailed.store(
false);
74 return g_externalPluginLoaderFailed.load();
79 g_set_print_handler(glib_print_handler);
80 g_set_printerr_handler(glib_printerr_handler);
81 g_log_set_default_handler(glib_log_handler,
nullptr);
87 const gchar *function,
90 GstDebugMessage *message,
95 if (level > gst_debug_category_get_threshold(category)) {
99 QMessageLogger log(file, line, function);
101 struct GFree {
void operator()(gchar *p)
const { g_free(p); } };
102 const std::unique_ptr<gchar, GFree> object_info(
103 gst_info_strdup_printf(
"%" GST_PTR_FORMAT,
object));
106 case GST_LEVEL_ERROR:
107 log.critical(GStreamerAPILog,
"%s %s", object_info.get(), gst_debug_message_get(message));
109 case GST_LEVEL_WARNING:
110 log.warning(GStreamerAPILog,
"%s %s", object_info.get(), gst_debug_message_get(message));
112 case GST_LEVEL_FIXME:
114 log.info(GStreamerAPILog,
"%s %s", object_info.get(), gst_debug_message_get(message));
116 case GST_LEVEL_DEBUG:
121 case GST_LEVEL_TRACE:
122 case GST_LEVEL_MEMDUMP:
124 log.debug(GStreamerAPILog,
"%s %s", object_info.get(), gst_debug_message_get(message));
#define QGC_LOGGING_CATEGORY_ON(name, categoryStr)
#define QGC_LOGGING_CATEGORY(name, categoryStr)
void qtGstLog(GstDebugCategory *category, GstDebugLevel level, const gchar *file, const gchar *function, gint line, GObject *object, GstDebugMessage *message, gpointer data)
bool didExternalPluginLoaderFail()
void redirectGLibLogging()
void resetExternalPluginLoaderFailure()