Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qpipewire_support.cpp
Go to the documentation of this file.
1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
6#include <QtCore/qspan.h>
7#include <QtMultimedia/private/qmultimedia_enum_to_string_converter_p.h>
8
9#include <pipewire/version.h>
10#include <spa/debug/pod.h>
11
12#include <cstdarg>
13
15
16// debug support
17QDebug operator<<(QDebug dbg, const spa_dict &dict)
18{
19 QSpan<const spa_dict_item> items{ dict.items, dict.n_items };
20
21 QDebugStateSaver saver(dbg);
22 dbg.nospace();
23
24 for (const spa_dict_item &item : items)
25 dbg << item.key << "=" << item.value << ", ";
26 return dbg;
27}
28
29#if PW_CHECK_VERSION(0, 3, 65)
30
31namespace {
32
33struct QtSpaDebugContext : ::spa_debug_context
34{
35 explicit QtSpaDebugContext(QDebug dbg)
36 : ::spa_debug_context{},
37 dbg{
38 std::move(dbg),
39 }
40 {
41 ::spa_debug_context::log = &doLog;
42 }
43
44 static void doLog(::spa_debug_context *ctx, const char *fmt, ...)
45 {
46 std::va_list args;
47 va_start(args, fmt);
48 QString logString = QString::vasprintf(fmt, args);
49 va_end(args);
50
51 auto *self = static_cast<QtSpaDebugContext *>(ctx);
52 self->dbg << logString;
53 }
54
55 QDebug dbg;
56};
57
58} // namespace
59
60QDebug operator<<(QDebug dbg, const spa_pod &pod)
61{
62 QtSpaDebugContext context{ std::move(dbg) };
63
64 spa_debugc_pod(&context, 0, nullptr, &pod);
65 return std::move(context.dbg);
66}
67
68#else
69
70QDebug operator<<(QDebug dbg, const spa_pod &)
71{
72 dbg << "QDebug operator<<(QDebug, const spa_pod &) not implemented: minimum requirement: "
73 "pipewire-0.3.65";
74 return dbg;
75}
76
77#endif
78
79// clang-format off
81 (PW_STREAM_STATE_ERROR, "error")
82 (PW_STREAM_STATE_UNCONNECTED, "unconnected")
83 (PW_STREAM_STATE_CONNECTING, "connecting")
84 (PW_STREAM_STATE_PAUSED, "paused")
85 (PW_STREAM_STATE_STREAMING, "streaming")
86 );
87// clang-format on
88
90
91QDebug operator<<(QDebug dbg, const pw_time &state)
92{
93 // pw_time may have more members, but those are only required to exist in 0.3.55 and later
94 dbg << QStringLiteral(u"pw_time{now: %1ns, rate: %2/%3, ticks: %4, delay: %5, queued: %6}")
95 .arg(state.now)
96 .arg(state.rate.num)
97 .arg(state.rate.denom)
98 .arg(state.ticks)
99 .arg(state.delay)
100 .arg(state.queued);
101 return dbg;
102}
103
104QT_END_NAMESPACE
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2568
QT_MM_MAKE_STRING_RESOLVER(pw_stream_state, QtMultimediaPrivate::EnumName,(PW_STREAM_STATE_ERROR, "error")(PW_STREAM_STATE_UNCONNECTED, "unconnected")(PW_STREAM_STATE_CONNECTING, "connecting")(PW_STREAM_STATE_PAUSED, "paused")(PW_STREAM_STATE_STREAMING, "streaming"))
QT_MM_DEFINE_QDEBUG_ENUM(pw_stream_state)
QDebug operator<<(QDebug dbg, const pw_time &state)
QDebug operator<<(QDebug dbg, const spa_pod &pod)