Seite 1 von 1

QProcess bekommt kein output

Verfasst: 24. Mai 2010 07:05
von t_b
Hallo,

Ich habe das Problem, dass QProcess kein Output bekommt und habe die Vermutung, dass dies an dem eigentlichen Programm rtmpdump 2.2d windows liegt.
Hier jedoch erst einmal mein Code:

Code: Alles auswählen

#include "ptest.h"
#include <QProcess>
#include <QByteArray>
#include <QHBoxLayout>
#include <QPushButton>
#include <QDir>
#include <QCoreApplication>

PTest::PTest(QWidget *parent) :
    QWidget(parent)
{
    process = new QProcess;
    edit = new QPlainTextEdit;
    edit->setReadOnly(true);
    edit->appendPlainText("Start download");
    QString c = QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + "/rtmpdump.exe");
    process->start(c,
                   QStringList()
                   << "-o"
                   << "movie.flv"
                   << "--host"
                   << "vod.daserste.de"
                   << "--port"
                   << "1935"
                   << "--protocol"
                   << "rtmp"
                   << "--stop"
                   << "10"
                   << "--playpath"
                   << "mp4:videoportal/mediathek/Tatort/c_120000/129195/format133590.f4v"
                   << "--swfUrl"
                   << "http://www.ardmediathek.de/ard/static/swf/Aardvark.swf"
                   << "--swfsize"
                   << "90694"
                   << "--swfhash"
                   << "66b5e55cbf5e3dcf3866cffd412d5582c001ecbf407846aa23549a97e5b07689"
                   << "--tcUrl"
                   << "rtmp://vod.daserste.de/ardfs"
                   << "--pageUrl"
                   << "http://www.ardmediathek.de/ard/servlet/content/2600?inPopup=true"
                   << "--app"
                   << "ardfs"
                   << "--flashVer"
                   << "WIN 10,0,42,34"
                   << "--verbose"
                   );


    QPushButton *quit = new QPushButton("Stop download");
    QHBoxLayout *layout = new QHBoxLayout;
    layout->addWidget(quit);
    layout->addWidget(edit);

    setLayout(layout);
    connect(quit,SIGNAL(clicked()),this,SLOT(Quit()));
    connect(process,SIGNAL(readyReadStandardOutput()),this,SLOT(Output()));
    connect(process,SIGNAL(finished(int)),this,SLOT(Finish(int)));
}

void PTest::Quit() {
    process->close();
    edit->appendPlainText("Download stopped!");
}

void PTest::Output() {
      static QByteArray output;
      output = process->readAllStandardOutput();
      edit->appendPlainText(output);
}

void PTest::Finish(int i) {
    edit->appendPlainText(QVariant(i).toString());
}
Ich habe mir dann mal die Mühe gemacht, und den sourcecode von rtmpdump 2.2d durchsucht, dabei gibt es diese funktion für die Ausgabe:

Code: Alles auswählen

void RTMP_LogPrintf(const char *format, ...)
{
	char str[MAX_PRINT_LEN]="";
	int len;
	va_list args;
	va_start(args, format);
	len = vsnprintf(str, MAX_PRINT_LEN-1, format, args);
	va_end(args);

	if ( RTMP_debuglevel==RTMP_LOGCRIT )
		return;

	if ( !fmsg ) fmsg = stderr;

	if (neednl) {
		putc('\n', fmsg);
		neednl = 0;
	}

    if (len > MAX_PRINT_LEN-1)
          len = MAX_PRINT_LEN-1;
	fprintf(fmsg, "%s", str);
    if (str[len-1] == '\n')
		fflush(fmsg);
}
Wenn ich das jedoch richtig interpretiere, dann ist es kein Pufferproblem, da ein flush nach jeder zeile ausgeführt wird.[/quote]

Verfasst: 24. Mai 2010 11:59
von CLRS530
Wieso verbindest du die 2 Signale erste nach Start()? Da ist doch recht klar, dass du das Signal niemals erhalten wirst.

Code: Alles auswählen

connect(process,SIGNAL(readyReadStandardOutput()),this,SLOT(Output())); 
connect(process,SIGNAL(finished(int)),this,SLOT(Finish(int)));

Verfasst: 24. Mai 2010 13:35
von t_b
Weil ich bisher dachte, dass dieses keine unterschied macht, da doch die signale /slots über den MOC verarbeitet werden.

Ich hab es dennoch geändert, und habe immer noch das gleiche Problem. Die Exit-Codes bekomme ich, den Rest nicht. Auch ein ReadAll(StandardErrors) hat nichts zu tage geführt.