File indexing completed on 2024-12-29 05:17:37

0001 /*
0002  * App to render feeds coming from xdg-desktop-portal
0003  *
0004  * SPDX-License-Identifier: LicenseRef-KDE-Accepted-GPL
0005  * SPDX-FileCopyrightText: 2023 Aleix Pol <aleixpol@kde.org>
0006  */
0007 
0008 #pragma once
0009 
0010 #include <QObject>
0011 #include <QDBusObjectPath>
0012 #include <PipeWireRecord>
0013 
0014 class QTimer;
0015 class ContentsWindow;
0016 class PipeWireSourceItem;
0017 
0018 class KStatusNotifierItem;
0019 
0020 struct Stream {
0021     uint nodeId;
0022     QVariantMap opts;
0023 };
0024 
0025 class OrgFreedesktopPortalScreenCastInterface;
0026 
0027 class XwaylandVideoBridge : public QObject
0028 {
0029     Q_OBJECT
0030 public:
0031     XwaylandVideoBridge(QObject* parent = nullptr);
0032     ~XwaylandVideoBridge() override;
0033 
0034     enum CursorMode {
0035         Hidden = 1,
0036         Embedded = 2,
0037         Metadata = 4
0038     };
0039     Q_ENUM(CursorMode);
0040     Q_DECLARE_FLAGS(CursorModes, CursorMode)
0041 
0042     enum SourceTypes {
0043         Monitor = 1,
0044         Window = 2
0045     };
0046     Q_ENUM(SourceTypes);
0047 
0048     void setDuration(int duration);
0049 
0050 public Q_SLOTS:
0051     void response(uint code, const QVariantMap& results);
0052 
0053 private:
0054     void init();
0055     void startStream(const QDBusObjectPath &path);
0056     void handleStreams(const QVector<Stream> &streams);
0057     void start();
0058     void closeSession();
0059     void closed();
0060 
0061     OrgFreedesktopPortalScreenCastInterface *iface;
0062     QDBusObjectPath m_path;
0063     QString m_handleToken;
0064 
0065     QTimer *m_quitTimer;
0066     QScopedPointer<ContentsWindow> m_window;
0067     PipeWireSourceItem *m_pipeWireItem = nullptr;
0068     KStatusNotifierItem *m_sni;
0069 };