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 ENGINEINSTANCE_H
#define ENGINEINSTANCE_H
#include <QImage>
#include <QObject>
#include <QOpenGLContext>
#include <memory>
#include "engine_interface.h"
#include "game_config.h"
class EngineInstance : public QObject {
Q_OBJECT
public:
explicit EngineInstance(const QString& libraryPath,const QString& dataPath,
QObject* parent = nullptr);
~EngineInstance() override;
Q_PROPERTY(bool isValid READ isValid NOTIFY isValidChanged)
void sendConfig(const GameConfig& config);
void renderFrame();
void setOpenGLContext(QOpenGLContext* context);
QImage generatePreview();
bool isValid() const;
signals:
void isValidChanged(bool isValid);
public slots:
void advance(quint32 ticks);
void moveCamera(const QPoint& delta);
void simpleEvent(Engine::SimpleEventType event_type);
void longEvent(Engine::LongEventType event_type,
Engine::LongEventState state);
void positionedEvent(Engine::PositionedEventType event_type, qint32 x,
qint32 y);
private:
std::unique_ptr<Engine::EngineInstance, Engine::cleanup_t*> m_instance;
Engine::hedgewars_engine_protocol_version_t*
hedgewars_engine_protocol_version;
Engine::start_engine_t* start_engine;
Engine::generate_preview_t* generate_preview;
Engine::dispose_preview_t* dispose_preview;
Engine::cleanup_t* cleanup;
Engine::send_ipc_t* send_ipc;
Engine::read_ipc_t* read_ipc;
Engine::setup_current_gl_context_t* setup_current_gl_context;
Engine::render_frame_t* render_frame;
Engine::advance_simulation_t* advance_simulation;
Engine::move_camera_t* move_camera;
Engine::simple_event_t* simple_event;
Engine::long_event_t* long_event;
Engine::positioned_event_t* positioned_event;
bool m_isValid;
};
#endif // ENGINEINSTANCE_H