File indexing completed on 2024-04-21 04:50:52

0001 /*
0002     SPDX-FileCopyrightText: 2007 Jean-Baptiste Mardelle <jb@kdenlive.org>
0003 
0004     SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005 */
0006 
0007 #pragma once
0008 
0009 #ifdef NODBUS
0010 #include <QLocalSocket>
0011 #else
0012 #include <QDBusInterface>
0013 #endif
0014 #include <QDateTime>
0015 #include <QEventLoop>
0016 #include <QFile>
0017 #include <QObject>
0018 #include <QProcess>
0019 // Testing
0020 #include <QTextStream>
0021 
0022 class RenderJob : public QObject
0023 {
0024     Q_OBJECT
0025 
0026 public:
0027     RenderJob(const QString &render, const QString &scenelist, const QString &target, int pid = -1, int in = -1, int out = -1,
0028               const QString &subtitleFile = QString(), QObject *parent = nullptr);
0029     ~RenderJob() override;
0030 
0031 public Q_SLOTS:
0032     void start();
0033 
0034 private Q_SLOTS:
0035     void slotIsOver(QProcess::ExitStatus status, bool isWritable = true);
0036     void receivedStderr();
0037     void slotAbort();
0038     void slotAbort(const QString &url);
0039     void slotCheckProcess(QProcess::ProcessState state);
0040     void slotCheckSubtitleProcess(int exitCode, QProcess::ExitStatus exitStatus);
0041     void receivedSubtitleProgress();
0042 
0043 private:
0044     QString m_scenelist;
0045     QString m_dest;
0046     int m_progress;
0047     QString m_prog;
0048 #ifdef NODBUS
0049     QLocalSocket* m_kdenlivesocket;
0050 #else
0051     QDBusInterface *m_jobUiserver;
0052     QDBusInterface *m_kdenliveinterface;
0053 #endif
0054     /** @brief Used to create a temporary file for logging. */
0055     QFile m_logfile;
0056     bool m_erase;
0057     int m_seconds;
0058     int m_frame;
0059     int m_framein;
0060     int m_frameout;
0061     /** @brief The process id of the Kdenlive instance, used to get the dbus service. */
0062     int m_pid;
0063     bool m_dualpass;
0064     QString m_subtitleFile;
0065     QString m_temporaryRenderFile;
0066     QProcess *m_renderProcess;
0067     QProcess *m_subsProcess;
0068     QEventLoop m_looper;
0069     QString m_errorMessage;
0070     QList<QVariant> m_dbusargs;
0071     QDateTime m_startTime;
0072     QStringList m_args;
0073     /** @brief Used to write to the log file. */
0074     QTextStream m_logstream;
0075 #ifdef NODBUS
0076     void fromServer();
0077 #else
0078     void initKdenliveDbusInterface();
0079 #endif
0080     void sendFinish(int status, const QString &error);
0081     void updateProgress(int speed = -1);
0082     void sendProgress();
0083 
0084 Q_SIGNALS:
0085     void renderingFinished();
0086 };