Revision control

Copy as Markdown

// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef WINDOW_CAPTURE_GRABBER_H
#define WINDOW_CAPTURE_GRABBER_H
#include <QtMultimedia/qvideosink.h>
#include <chrono>
#include <vector>
/*!
The FrameGrabber stores frames that arrive from the window capture,
and is used to inspect captured frames in the tests.
*/
class FrameGrabber : public QVideoSink
{
Q_OBJECT
public:
FrameGrabber();
const std::vector<QVideoFrame> &getFrames() const;
/*!
Wait for at least \a minCount frames that are no older than noOlderThanTime.
Returns empty if not enough frames arrived, or if grabber was stopped before global timeout
elapsed.
*/
std::vector<QVideoFrame> waitAndTakeFrames(size_t minCount, qint64 noOlderThanTime = 0);
std::chrono::milliseconds durationBetweenFrames(qsizetype frameCount = 1);
bool isStopped() const;
public slots:
void stop();
private:
std::vector<QVideoFrame> m_frames;
bool m_stopped = false;
};
#endif