Add support for ffmpeg 6.0
- Use the new send_frame/receive_packet API for encoding
- Use the new channel layout API for audio
- Fix audio recording
- Copy codec parameters to the stream parameters
- Set correct pts for audio frames
- Read audio samples from file directly to the refcounted AVFrame buffer instead of the `g_pSamples` buffer
- Use global AVPackets allocated with `av_packet_alloc`
- Stop trying to write more audio frames when `WriteAudioFrame` fails with a negative error code
- Fix segfault with `g_pContainer->url`. The field has to be allocated with `av_malloc` before writing to it. It's set to `NULL` by default.
- Properly free allocations with `avcodec_free_context` and `avformat_free_context`
#ifndef HWENGINE_H
#define HWENGINE_H
#include <QList>
#include <QObject>
#include "game_config.h"
#include "preview_acceptor.h"
class QQmlEngine;
class EngineInstance;
class HWEngine : public QObject {
Q_OBJECT
Q_PROPERTY(int previewHedgehogsCount READ previewHedgehogsCount NOTIFY
previewHedgehogsCountChanged)
Q_PROPERTY(PreviewAcceptor* previewAcceptor READ previewAcceptor WRITE
setPreviewAcceptor NOTIFY previewAcceptorChanged)
Q_PROPERTY(QString engineLibrary READ engineLibrary WRITE setEngineLibrary
NOTIFY engineLibraryChanged)
Q_PROPERTY(QString dataPath READ dataPath WRITE setDataPath NOTIFY dataPathChanged)
public:
explicit HWEngine(QObject* parent = nullptr);
~HWEngine() override;
Q_INVOKABLE void getPreview();
Q_INVOKABLE EngineInstance* runQuickGame();
int previewHedgehogsCount() const;
PreviewAcceptor* previewAcceptor() const;
QString engineLibrary() const;
const QString &dataPath() const;
void setDataPath(const QString &newDataPath);
public slots:
void setPreviewAcceptor(PreviewAcceptor* previewAcceptor);
void setEngineLibrary(const QString& engineLibrary);
signals:
void previewIsRendering();
void previewImageChanged();
void previewHogCountChanged(int count);
void gameFinished();
void previewHedgehogsCountChanged(int previewHedgehogsCount);
void previewAcceptorChanged(PreviewAcceptor* previewAcceptor);
void engineLibraryChanged(const QString& engineLibrary);
void dataPathChanged();
private:
QQmlEngine* m_engine;
GameConfig m_gameConfig;
int m_previewHedgehogsCount;
PreviewAcceptor* m_previewAcceptor;
QString m_engineLibrary;
QString m_dataPath;
};
#endif // HWENGINE_H