2023-03-12 13:47:05 +03:00
|
|
|
// SPDX-FileCopyrightText: Nheko Contributors
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-03-11 16:36:51 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifdef GSTREAMER_AVAILABLE
|
|
|
|
|
|
|
|
#include <QDBusConnection>
|
|
|
|
#include <QDBusMessage>
|
|
|
|
#include <QDBusPendingCallWatcher>
|
|
|
|
#include <QDBusPendingReply>
|
|
|
|
#include <QDBusUnixFileDescriptor>
|
|
|
|
#include <QObject>
|
2023-03-30 18:36:06 +03:00
|
|
|
#include <optional>
|
2023-03-11 16:36:51 +03:00
|
|
|
|
|
|
|
class ScreenCastPortal final : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
struct Stream
|
|
|
|
{
|
2023-03-30 00:01:53 +03:00
|
|
|
QDBusUnixFileDescriptor fd;
|
2023-03-11 16:36:51 +03:00
|
|
|
quint32 nodeId;
|
|
|
|
};
|
|
|
|
|
|
|
|
static ScreenCastPortal &instance()
|
|
|
|
{
|
|
|
|
static ScreenCastPortal instance;
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
void init();
|
|
|
|
const Stream *getStream() const;
|
|
|
|
bool ready() const;
|
|
|
|
void close(bool reinit = false);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void createSessionHandler(uint response, const QVariantMap &results);
|
|
|
|
void closedHandler(uint response, const QVariantMap &results);
|
|
|
|
void selectSourcesHandler(uint response, const QVariantMap &results);
|
|
|
|
void startHandler(uint response, const QVariantMap &results);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void readyChanged();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void createSession();
|
|
|
|
void getAvailableSourceTypes();
|
|
|
|
void getAvailableCursorModes();
|
|
|
|
void selectSources();
|
|
|
|
void start();
|
|
|
|
void openPipeWireRemote();
|
2023-03-30 00:01:53 +03:00
|
|
|
bool makeConnection(QString service,
|
|
|
|
QString path,
|
|
|
|
QString interface,
|
|
|
|
QString name,
|
|
|
|
const char *slot);
|
|
|
|
void removeConnection();
|
|
|
|
void disconnectClose();
|
2023-03-11 16:36:51 +03:00
|
|
|
QDBusObjectPath sessionHandle;
|
|
|
|
uint availableSourceTypes;
|
|
|
|
uint availableCursorModes;
|
|
|
|
|
|
|
|
Stream stream;
|
|
|
|
|
|
|
|
enum class State
|
|
|
|
{
|
|
|
|
Closed,
|
|
|
|
Starting,
|
|
|
|
Started,
|
|
|
|
Closing,
|
|
|
|
};
|
|
|
|
State state = State::Closed;
|
2023-03-30 00:01:53 +03:00
|
|
|
std::optional<std::array<QString, 5>> last_connection;
|
2023-03-11 16:36:51 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|