File indexing completed on 2024-06-23 05:24:05
0001 // SPDX-FileCopyrightText: 2023 Aleix Pol Gonzalez <aleix.pol_gonzalez@mercedes-benz.com> 0002 // 0003 // SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0004 0005 #pragma once 0006 0007 #include "VideoStream.h" 0008 #include "krdp_export.h" 0009 0010 #include <PipeWireEncodedStream> 0011 #include <PipeWireSourceStream> 0012 0013 namespace KRdp 0014 { 0015 class Server; 0016 0017 class KRDP_EXPORT AbstractSession : public QObject 0018 { 0019 Q_OBJECT 0020 public: 0021 AbstractSession(Server *server); 0022 ~AbstractSession() override; 0023 0024 bool streamingEnabled() const; 0025 void setStreamingEnabled(bool enable); 0026 void setVideoFrameRate(quint32 framerate); 0027 void setActiveStream(int stream); 0028 void setVideoQuality(quint8 quality); 0029 0030 void requestStreamingEnable(QObject *requester); 0031 void requestStreamingDisable(QObject *requester); 0032 0033 /** 0034 * Send a new event to the portal. 0035 * 0036 * \param event The new event to send. 0037 */ 0038 virtual void sendEvent(QEvent *event) = 0; 0039 0040 Q_SIGNALS: 0041 void started(); 0042 void error(); 0043 0044 /** 0045 * Emitted whenever a new frame has been received. 0046 * 0047 * Received in this case means that the portal has sent the data and it has 0048 * been encoded by libav. 0049 */ 0050 void frameReceived(const VideoFrame &frame); 0051 0052 /** 0053 * Emitted whenever a new cursor update was received. 0054 * 0055 * These are separate from frames as RDP has a separate protocol for mouse 0056 * movement that is more performant than embedding things into the video 0057 * stream. 0058 */ 0059 void cursorUpdate(const PipeWireCursor &cursor); 0060 0061 protected: 0062 QSize size() const; 0063 QSize logicalSize() const; 0064 int activeStream() const; 0065 0066 void setStarted(bool started); 0067 void setSize(const QSize &size); 0068 void setLogicalSize(const QSize &size); 0069 PipeWireEncodedStream *stream(); 0070 0071 private: 0072 class Private; 0073 const std::unique_ptr<Private> d; 0074 }; 0075 0076 }