|
4 | 4 | #include <pipewire/node.h> |
5 | 5 | #include <pipewire/type.h> |
6 | 6 | #include <qcontainerfwd.h> |
| 7 | +#include <qflags.h> |
7 | 8 | #include <qmap.h> |
8 | 9 | #include <qobject.h> |
9 | 10 | #include <qqmlintegration.h> |
@@ -86,12 +87,71 @@ class PwAudioChannel: public QObject { |
86 | 87 | /// including aux and custom channel ranges. |
87 | 88 | Q_INVOKABLE static QString toString(qs::service::pipewire::PwAudioChannel::Enum value); |
88 | 89 | }; |
| 90 | +///! The type of a pipewire node. |
| 91 | +/// Use bitwise comparisons to filter for audio, video, sink, source or stream nodes |
| 92 | +class PwNodeType: public QObject { |
| 93 | + Q_OBJECT; |
| 94 | + QML_ELEMENT; |
| 95 | + QML_SINGLETON; |
89 | 96 |
|
90 | | -enum class PwNodeType : quint8 { |
91 | | - Untracked, |
92 | | - Audio, |
| 97 | +public: |
| 98 | + enum Flag : quint8 { |
| 99 | + // A Pipewire node which is not being managed. |
| 100 | + Untracked = 0b0, |
| 101 | + // This flag is set when this node is an Audio node. |
| 102 | + Audio = 0b1, |
| 103 | + // This flag is set when this node is an Video node. |
| 104 | + Video = 0b10, |
| 105 | + // This flag is set when this node is a stream node. |
| 106 | + Stream = 0b100, |
| 107 | + // This flag is set when this node is producing some form of data, |
| 108 | + // such as a microphone, screenshare or webcam. |
| 109 | + Source = 0b1000, |
| 110 | + // This flag is set when this node is receiving data. |
| 111 | + Sink = 0b10000, |
| 112 | + // A sink for audio samples, like an audio card. |
| 113 | + // |
| 114 | + // This is equivalent to the media class `Video/Source` and is |
| 115 | + // composed of the @@PwNodeType.Audio and @@PwNodeType.Sink flags. |
| 116 | + AudioSink = Audio | Sink, |
| 117 | + // A source of audio samples like a microphone. |
| 118 | + // |
| 119 | + // This is quivalent to the media class `Video/Sink` and is composed |
| 120 | + // of the @@PwNodeType.Audio and @@PwNodeType.Source flags. |
| 121 | + AudioSource = Audio | Source, |
| 122 | + // A node that is both a sink and a source. |
| 123 | + // |
| 124 | + // This is equivalent to the media class `Audio/Duplex` and is composed of the |
| 125 | + // @@PwNodeType.Audio, @@PwNodeType.Source and @@PwNodeType.Sink flags. |
| 126 | + AudioDuplex = Audio | Sink | Source, |
| 127 | + // A playback stream. |
| 128 | + // |
| 129 | + // This is equivalent to the media class `Stream/Output/Audio` and is composed |
| 130 | + // of the @@PwNodeType.Audio, @@PwNodeType.Sink and @@PwNodeType.Stream flags. |
| 131 | + AudioOutStream = Audio | Sink | Stream, |
| 132 | + // A capture stream. |
| 133 | + // |
| 134 | + // This is equivalent to the media class `Stream/Input/Audio` and is composed |
| 135 | + // of the @@PwNodeType.Audio, @@PwNodeType.Source and @@PwNodeType.Stream flags. |
| 136 | + AudioInStream = Audio | Source | Stream, |
| 137 | + // A producer of video, like a webcam or a screenshare. |
| 138 | + // |
| 139 | + // This is equivalent to the media class `Video/Source` and is composed |
| 140 | + // of the @@PwNodeType.Video and @@PwNodeType.Source flags. |
| 141 | + VideoSource = Video | Source, |
| 142 | + // A consumer of video, such as a program that is recieving a video stream. |
| 143 | + // |
| 144 | + // This is equivalent to the media class `Video/Sink` and is composed of the |
| 145 | + // @@PwNodeType.Video and @@PwNodeType.Sink flags. |
| 146 | + VideoSink = Video | Sink, |
| 147 | + }; |
| 148 | + Q_ENUM(Flag) |
| 149 | + Q_DECLARE_FLAGS(Flags, Flag) |
| 150 | + Q_INVOKABLE static QString toString(qs::service::pipewire::PwNodeType::Flags type); |
93 | 151 | }; |
94 | 152 |
|
| 153 | +Q_DECLARE_OPERATORS_FOR_FLAGS(PwNodeType::Flags) |
| 154 | + |
95 | 155 | class PwNode; |
96 | 156 |
|
97 | 157 | struct PwVolumeProps { |
@@ -169,9 +229,8 @@ class PwNode: public PwBindable<pw_node, PW_TYPE_INTERFACE_Node, PW_VERSION_NODE |
169 | 229 | QString nick; |
170 | 230 | QMap<QString, QString> properties; |
171 | 231 |
|
172 | | - PwNodeType type = PwNodeType::Untracked; |
173 | | - bool isSink = false; |
174 | | - bool isStream = false; |
| 232 | + PwNodeType::Flags type = PwNodeType::Untracked; |
| 233 | + |
175 | 234 | bool ready = false; |
176 | 235 |
|
177 | 236 | PwNodeBoundData* boundData = nullptr; |
|
0 commit comments