File indexing completed on 2024-04-21 16:13:07
0001 /* 0002 SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez <aleixpol@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #pragma once 0008 0009 #include <QObject> 0010 0011 #include <kpipewire_export.h> 0012 0013 struct PipeWireRecordPrivate; 0014 0015 class KPIPEWIRE_EXPORT PipeWireRecord : public QObject 0016 { 0017 Q_OBJECT 0018 /// Specify the pipewire node id that we want to record 0019 Q_PROPERTY(uint nodeId READ nodeId WRITE setNodeId NOTIFY nodeIdChanged) 0020 /** 0021 * Specifies the file descriptor we are connected to, if none 0 will be returned 0022 * 0023 * Transfers the ownership of the fd, will close it when it's done with it. 0024 */ 0025 Q_PROPERTY(uint fd READ fd WRITE setFd NOTIFY fdChanged) 0026 Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged) 0027 Q_PROPERTY(QString output READ output WRITE setOutput NOTIFY outputChanged) 0028 Q_PROPERTY(State state READ state NOTIFY stateChanged) 0029 Q_PROPERTY(QString extension READ extension NOTIFY encoderChanged) 0030 Q_PROPERTY(QByteArray encoder READ encoder WRITE setEncoder NOTIFY encoderChanged) 0031 public: 0032 PipeWireRecord(QObject *parent = nullptr); 0033 ~PipeWireRecord() override; 0034 0035 enum State { 0036 Idle, //< ready to get started 0037 Recording, //< actively recording 0038 Rendering, //< recording is over but the video file is still being written 0039 }; 0040 Q_ENUM(State) 0041 0042 void setNodeId(uint nodeId); 0043 uint nodeId() const; 0044 0045 void setFd(uint fd); 0046 uint fd() const; 0047 0048 bool isActive() const; 0049 void setActive(bool active); 0050 State state() const; 0051 0052 QString output() const; 0053 void setOutput(const QString &output); 0054 0055 /** 0056 * Set the FFmpeg @p encoder that will be used to create the video 0057 * 0058 * They can be inspected using: 0059 * ffmpeg -encoders | grep "^ V" 0060 */ 0061 void setEncoder(const QByteArray &encoder); 0062 QByteArray encoder() const; 0063 0064 /// Returns the encoders that are tested to work, sorted by preference 0065 QList<QByteArray> suggestedEncoders() const; 0066 0067 QString currentExtension() const; 0068 Q_DECL_DEPRECATED static QString extension(); 0069 0070 Q_SIGNALS: 0071 void activeChanged(bool active); 0072 void nodeIdChanged(uint nodeId); 0073 void fdChanged(uint fd); 0074 void outputChanged(const QString &output); 0075 void errorFound(const QString &error); 0076 void stateChanged(); 0077 void encoderChanged(); 0078 0079 private: 0080 void refresh(); 0081 QScopedPointer<PipeWireRecordPrivate> d; 0082 };