Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qffmpegencoderthread_p.h
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3#ifndef QFFMPEGENCODERTHREAD_P_H
4#define QFFMPEGENCODERTHREAD_P_H
5
6#include "qffmpegthread_p.h"
7
9
10namespace QFFmpeg {
11
12class RecordingEngine;
13
15{
17public:
18 EncoderThread(RecordingEngine &recordingEngine);
19 virtual void setPaused(bool paused);
20
21 bool canPushFrame() const { return m_canPushFrame.load(std::memory_order_relaxed); }
22protected:
24
25 virtual bool checkIfCanPushFrame() const = 0;
26
28 {
29 return QScopeGuard([this, locker = ConsumerThread::lockLoopData()]() mutable {
30 const bool canPush = !m_paused && checkIfCanPushFrame();
31 locker.unlock();
32 if (m_canPushFrame.exchange(canPush, std::memory_order_relaxed) != canPush)
34 });
35 }
36
39
40protected:
41 bool m_paused = false;
42 std::atomic_bool m_canPushFrame = false;
44};
45
46} // namespace QFFmpeg
47
49
50#endif
FFmpeg thread that is used to implement a consumer pattern.
QMutexLocker< QMutex > lockLoopData() const
Locks the loop data mutex.
virtual void setPaused(bool paused)
RecordingEngine & m_recordingEngine
virtual bool checkIfCanPushFrame() const =0
EncoderThread(RecordingEngine &recordingEngine)
Combined button and popup list for selecting options.
QScopeGuard(F(&)()) -> QScopeGuard< F(*)()>
#define Q_OBJECT
#define Q_SIGNALS
#define emit