Windows project migration to platform/windows

This commit is contained in:
2025-09-28 03:47:43 +09:00
parent a75d7e769f
commit 484e4e0338
176 changed files with 2736 additions and 119 deletions

View File

@@ -0,0 +1,97 @@
// Pure console application that completely bypasses WinUI3
#include "pch.h"
// Minimal includes - NO WinUI3 dependencies
#include <mkvparser.hpp>
#include <dav1d.h>
#include "../src/Common/VideoTypes.h"
#include "../src/Decoder/VideoDecoderFactory.h"
#include "../src/FileIO/WebMFileReader.h"
#include "HeadlessDecoder.h"
using namespace Vav2Player;
// Forward declare WinUI3 entry point
extern "C" int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int);
// Our custom main that intercepts before WinUI3
int APIENTRY wWinMain(
_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
// Parse command line early
int argc = 0;
LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc);
if (argc >= 2) {
// Headless mode - run pure console version
LocalFree(argv);
// Set console mode
AllocConsole();
FILE* pCout; FILE* pCerr; FILE* pCin;
freopen_s(&pCout, "CONOUT$", "w", stdout);
freopen_s(&pCerr, "CONOUT$", "w", stderr);
freopen_s(&pCin, "CONIN$", "r", stdin);
// Convert args and run main
std::vector<std::string> args;
for (int i = 0; i < argc; i++) {
int size = WideCharToMultiByte(CP_UTF8, 0, argv[i], -1, NULL, 0, NULL, NULL);
std::string arg(size - 1, 0);
WideCharToMultiByte(CP_UTF8, 0, argv[i], -1, &arg[0], size, NULL, NULL);
args.push_back(arg);
}
// Convert to char* array
std::vector<char*> argv_char;
for (auto& arg : args) {
argv_char.push_back(&arg[0]);
}
return main(argc, argv_char.data());
} else {
// UI mode - hand off to WinUI3 (we can't easily do this without conflicts)
LocalFree(argv);
// This would require calling the original WinUI3 entry point
// For now, we'll implement a message
MessageBoxA(NULL, "UI mode should be launched separately", "Vav2Player", MB_OK);
return 0;
}
}
int main(int argc, char* argv[])
{
// Pure console mode - no WinUI3 at all
if (argc < 2) {
std::cout << "Usage: Vav2PlayerHeadless.exe <video_file.webm>" << std::endl;
return 1;
}
// Setup console
SetConsoleCP(CP_UTF8);
SetConsoleOutputCP(CP_UTF8);
std::cout << "[PURE_HEADLESS] Starting without WinUI3 libraries" << std::endl;
// Convert argument
std::string input_file = argv[1];
// Run decoder directly
bool success = false;
try {
HeadlessDecoder decoder;
success = decoder.ProcessFile(input_file);
}
catch (const std::exception& e) {
std::cerr << "Exception: " << e.what() << std::endl;
}
catch (...) {
std::cerr << "Unknown exception" << std::endl;
}
return success ? 0 : 1;
}