You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

47 lines
1.9 KiB

// tests/test_video_engine.cpp — smoke-тест декодера VideoPlayerEngine (FFmpeg)
// Запуск: test_video_engine <путь_к_mp4>
#include "../src/videoplayer_engine.h"
#include <QApplication>
#include <QTimer>
#include <QEventLoop>
#include <QDebug>
#include <cstdio>
int main(int argc, char** argv) {
QApplication app(argc, argv);
if (argc < 2) { qCritical("usage: test_video_engine <video.mp4>"); return 2; }
QString path = argv[1];
VideoPlayerEngine eng;
int frames = 0, opened = 0, errors = 0, finished = 0;
qint64 lastPos = -1;
int width = 0, height = 0; qint64 dur = 0; bool hasAudio = false;
QObject::connect(&eng, &VideoPlayerEngine::opened,
[&](int w, int h, qint64 d, bool a) { opened++; width = w; height = h; dur = d; hasAudio = a; });
QObject::connect(&eng, &VideoPlayerEngine::framePresented, [&]() { frames++; });
QObject::connect(&eng, &VideoPlayerEngine::positionChanged, [&](qint64 p) { lastPos = p; });
QObject::connect(&eng, &VideoPlayerEngine::error, [&](const QString& m) { errors++; qCritical("engine error: %s", qPrintable(m)); });
QObject::connect(&eng, &VideoPlayerEngine::finished, [&]() { finished++; });
eng.open(path);
QEventLoop loop;
QTimer timer;
timer.setSingleShot(true);
QObject::connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
timer.start(5000);
loop.exec();
eng.close();
qInfo("opened=%d (%dx%d dur=%lldms audio=%d) frames=%d finished=%d errors=%d lastPos=%lldms",
opened, width, height, (long long)dur, hasAudio ? 1 : 0, frames, finished, errors, (long long)lastPos);
int rc = 0;
if (opened != 1) { qCritical("FAIL: opened != 1"); rc = 1; }
if (frames <= 0) { qCritical("FAIL: no frames presented"); rc = 1; }
if (errors > 0) { qCritical("FAIL: errors present"); rc = 1; }
qInfo(rc == 0 ? "PASS" : "FAIL");
return rc;
}