1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
23 #include "renderjob.h"
25 static QDBusConnection connection(QLatin1String(""));
27 RenderJob::RenderJob(bool erase, QString renderer, QString player, QString scenelist, QString dest, QStringList args, int in, int out) : QObject() {
28 m_scenelist = scenelist;
33 m_renderProcess = new QProcess;
36 if (in != -1) m_args << "in=" + QString::number(in);
37 if (out != -1) m_args << "out=" + QString::number(out);
38 m_args << "-consumer" << "avformat:" + m_dest << "progress=1" << args;
39 connect(m_renderProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotIsOver(int, QProcess::ExitStatus)));
40 connect(m_renderProcess, SIGNAL(readyReadStandardError()), this, SLOT(receivedStderr()));
41 m_renderProcess->setReadChannel(QProcess::StandardError);
45 RenderJob::~RenderJob() {
46 delete m_renderProcess;
49 void RenderJob::receivedStderr() {
50 QString result = QString(m_renderProcess->readAllStandardError());
51 result = result.simplified();
52 result = result.section(" ", -1);
53 int pro = result.toInt();
54 if (pro > m_progress) {
56 QDBusReply<QString> reply = m_jobUiserver->call("setPercent", (uint) m_progress);
60 void RenderJob::start() {
61 QDBusInterface kuiserver("org.kde.JobViewServer", "/JobViewServer", "org.kde.JobViewServer");
62 QDBusReply<QDBusObjectPath> objectPath = kuiserver.call("requestView", "kdenlive", "kdenlive", 1);
63 QString reply = ((QDBusObjectPath) objectPath).path();
64 m_jobUiserver = new QDBusInterface("org.kde.JobViewServer", reply, "org.kde.JobView");
65 m_jobUiserver->call("setInfoMessage", tr("Rendering %1").arg(m_dest));
66 m_renderProcess->start(m_prog, m_args);
70 void RenderJob::slotIsOver(int exitcode, QProcess::ExitStatus status) {
71 QDBusReply<QString> reply = m_jobUiserver->call("terminate", "");
76 if (m_player != "-") {
79 QProcess::startDetached(m_player, args);
84 #include "renderjob.moc"