qmlfrontend/engine_interface.h
author Pekka Ristola <pekkarr@protonmail.com>
Mon, 27 Jan 2025 19:08:05 +0100
changeset 16096 dbdb98dafd80
parent 16045 4933920eba89
child 16116 8da5a118120b
permissions -rw-r--r--
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 ENGINE_H
#define ENGINE_H

#include <stddef.h>
#include <stdint.h>

#include "../rust/lib-hedgewars-engine/target/lib-hedgewars-engine.hpp"

#ifndef Q_NAMESPACE
#define Q_NAMESPACE
#endif

#ifndef Q_ENUM_NS
#define Q_ENUM_NS(x)
#endif

#ifndef Q_DECLARE_METATYPE
#define Q_DECLARE_METATYPE(x)
#endif

namespace Engine {
extern "C" {

using EngineInstance = hwengine::EngineInstance;
using PreviewInfo = hwengine::PreviewInfo;

using hedgewars_engine_protocol_version_t =
    decltype(hwengine::hedgewars_engine_protocol_version);

using start_engine_t = decltype(hwengine::start_engine);
using generate_preview_t = decltype(hwengine::generate_preview);
using dispose_preview_t = decltype(hwengine::dispose_preview);
using cleanup_t = decltype(hwengine::cleanup);
using send_ipc_t = decltype(hwengine::send_ipc);
using read_ipc_t = decltype(hwengine::read_ipc);
using setup_current_gl_context_t = decltype(hwengine::setup_current_gl_context);
using render_frame_t = decltype(hwengine::render_frame);
using advance_simulation_t = decltype(hwengine::advance_simulation);
using move_camera_t = decltype(hwengine::move_camera);

using simple_event_t = decltype(hwengine::simple_event);
using long_event_t = decltype(hwengine::long_event);
using positioned_event_t = decltype(hwengine::positioned_event);

}  // extern "C"

Q_NAMESPACE

/*
using SimpleEventType = hwengine::SimpleEventType;
using LongEventType = hwengine::LongEventType;
using LongEventState = hwengine::LongEventState;
using PositionedEventType = hwengine::PositionedEventType;
*/

// NOTE: have to copy these to be able to register then in Qt meta object system
enum class LongEventState {
  Set,
  Unset,
};

enum class LongEventType {
  ArrowUp,
  ArrowDown,
  ArrowLeft,
  ArrowRight,
  Precision,
  Attack,
};

enum class PositionedEventType {
  CursorMove,
  CursorClick,
};

enum class SimpleEventType {
  SwitchHedgehog,
  Timer,
  LongJump,
  HighJump,
  Accept,
  Deny,
};

Q_ENUM_NS(SimpleEventType)
Q_ENUM_NS(LongEventType)
Q_ENUM_NS(LongEventState)
Q_ENUM_NS(PositionedEventType)

};  // namespace Engine

#endif  // ENGINE_H