Files
plezy/windows/runner/mpv/mpv_plugin.h
T

62 lines
1.8 KiB
C++
Raw Normal View History

2025-12-01 15:30:28 +01:00
#ifndef MPV_PLUGIN_H_
#define MPV_PLUGIN_H_
#include <flutter/encodable_value.h>
#include <flutter/event_channel.h>
#include <flutter/event_stream_handler_functions.h>
#include <flutter/method_channel.h>
#include <flutter/plugin_registrar_windows.h>
#include <flutter/standard_method_codec.h>
2026-05-03 08:23:44 +02:00
#include <functional>
2025-12-01 15:30:28 +01:00
#include <memory>
2026-05-03 08:23:44 +02:00
#include <mutex>
2025-12-01 15:30:28 +01:00
#include <optional>
2026-05-03 08:23:44 +02:00
#include <queue>
2025-12-01 15:30:28 +01:00
#include "display_mode_manager.h"
2025-12-01 15:30:28 +01:00
#include "mpv_core.h"
#include "mpv_player.h"
// C-style registration function for the plugin.
2026-05-01 05:47:13 +02:00
void MpvPlayerPluginRegisterWithRegistrar(FlutterDesktopPluginRegistrarRef registrar);
2025-12-01 15:30:28 +01:00
namespace mpv {
class MpvPlayerPlugin : public flutter::Plugin {
public:
static void RegisterWithRegistrar(flutter::PluginRegistrarWindows* registrar);
MpvPlayerPlugin(flutter::PluginRegistrarWindows* registrar);
virtual ~MpvPlayerPlugin();
private:
void HandleMethodCall(
const flutter::MethodCall<flutter::EncodableValue>& method_call,
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
void SendEvent(const flutter::EncodableValue& event);
2026-05-03 08:23:44 +02:00
void PostToPlatformThread(std::function<void()> task);
void DrainPlatformTasks();
2025-12-01 15:30:28 +01:00
HWND GetWindow();
HWND GetChildWindow();
flutter::PluginRegistrarWindows* registrar_;
2026-05-03 08:23:44 +02:00
DWORD platform_thread_id_;
HWND flutter_window_ = nullptr;
2026-05-01 05:47:13 +02:00
std::unique_ptr<flutter::MethodChannel<flutter::EncodableValue>> method_channel_;
std::unique_ptr<flutter::EventChannel<flutter::EncodableValue>> event_channel_;
2025-12-01 15:30:28 +01:00
std::unique_ptr<flutter::EventSink<flutter::EncodableValue>> event_sink_;
std::unique_ptr<MpvPlayer> player_;
DisplayModeManager display_mode_manager_;
2025-12-01 15:30:28 +01:00
std::optional<int32_t> proc_id_;
2026-05-03 08:23:44 +02:00
std::mutex platform_tasks_mutex_;
std::queue<std::function<void()>> platform_tasks_;
2025-12-01 15:30:28 +01:00
};
} // namespace mpv
#endif // MPV_PLUGIN_H_