Add more config settings
This commit is contained in:
@@ -10,6 +10,11 @@ include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
|
|||||||
|
|
||||||
option(USE_LIBMPV "Use libmpv." ON)
|
option(USE_LIBMPV "Use libmpv." ON)
|
||||||
option(USE_PLAYER "Use player." OFF)
|
option(USE_PLAYER "Use player." OFF)
|
||||||
|
option(STATIC_CRT "Use static CRT" ON)
|
||||||
|
|
||||||
|
if (STATIC_CRT)
|
||||||
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
|
endif()
|
||||||
|
|
||||||
if (USE_LIBMPV AND USE_PLAYER)
|
if (USE_LIBMPV AND USE_PLAYER)
|
||||||
message(FATAL_ERROR "USE_LIBMPV and USE_PLAYER cannot be both enabled.")
|
message(FATAL_ERROR "USE_LIBMPV and USE_PLAYER cannot be both enabled.")
|
||||||
|
|||||||
14
config.cpp
14
config.cpp
@@ -42,6 +42,16 @@ bool Config::Load(std::string path) {
|
|||||||
}
|
}
|
||||||
std::string key = l.substr(0, eq_pos);
|
std::string key = l.substr(0, eq_pos);
|
||||||
std::string value = l.substr(eq_pos + 1);
|
std::string value = l.substr(eq_pos + 1);
|
||||||
|
#if HAVE_MPV
|
||||||
|
if (key.find("mpv-") == 0) {
|
||||||
|
key = key.substr(4);
|
||||||
|
if (str_util::tolower(key) == "wid") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
mpv.push_back(std::make_pair(key, value));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
configs[key] = value;
|
configs[key] = value;
|
||||||
}
|
}
|
||||||
free_file_reader(reader);
|
free_file_reader(reader);
|
||||||
@@ -49,6 +59,8 @@ bool Config::Load(std::string path) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if HAVE_PLAYER
|
||||||
|
|
||||||
bool Config::IsAppendLogging() {
|
bool Config::IsAppendLogging() {
|
||||||
auto re = configs.find("appendLogging");
|
auto re = configs.find("appendLogging");
|
||||||
if (re == configs.end()) {
|
if (re == configs.end()) {
|
||||||
@@ -99,3 +111,5 @@ uint32_t Config::VideoBuffer() {
|
|||||||
}
|
}
|
||||||
return std::stoul((*re).second);
|
return std::stoul((*re).second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
10
config.hpp
10
config.hpp
@@ -1,21 +1,31 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <list>
|
||||||
|
#include <utility>
|
||||||
|
#include "patch_config.h"
|
||||||
|
|
||||||
class Config {
|
class Config {
|
||||||
public:
|
public:
|
||||||
std::unordered_map<std::string, std::string> configs;
|
std::unordered_map<std::string, std::string> configs;
|
||||||
|
#if HAVE_MPV
|
||||||
|
std::list<std::pair<std::string, std::string>> mpv;
|
||||||
|
#endif
|
||||||
Config() {
|
Config() {
|
||||||
configs["defaultFont"] = "微软雅黑";
|
configs["defaultFont"] = "微软雅黑";
|
||||||
configs["stringReplaceFile"] = "";
|
configs["stringReplaceFile"] = "";
|
||||||
|
#if HAVE_PLAYER
|
||||||
configs["appendLogging"] = "false";
|
configs["appendLogging"] = "false";
|
||||||
configs["loggingFile"] = "";
|
configs["loggingFile"] = "";
|
||||||
configs["loggingLevel"] = "info";
|
configs["loggingLevel"] = "info";
|
||||||
configs["audioBuffer"] = "0";
|
configs["audioBuffer"] = "0";
|
||||||
configs["videoBuffer"] = "0";
|
configs["videoBuffer"] = "0";
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
bool Load(std::string path);
|
bool Load(std::string path);
|
||||||
|
#if HAVE_PLAYER
|
||||||
bool IsAppendLogging();
|
bool IsAppendLogging();
|
||||||
int LoggingLevel();
|
int LoggingLevel();
|
||||||
uint32_t AudioBuffer();
|
uint32_t AudioBuffer();
|
||||||
uint32_t VideoBuffer();
|
uint32_t VideoBuffer();
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|||||||
10
dllmain.cpp
10
dllmain.cpp
@@ -196,18 +196,14 @@ int64_t HookedOpenMediaFileAndGetDuration(DWORD* duration, const char* arcName,
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
HWND hwnd = *GetHwndPointer();
|
HWND hwnd = *GetHwndPointer();
|
||||||
int64_t wid = (int64_t)(intptr_t)hwnd;
|
int64_t wid = (int64_t)(uint32_t)hwnd;
|
||||||
mpv_set_option(player, "wid", MPV_FORMAT_INT64, &wid);
|
mpv_set_option(player, "wid", MPV_FORMAT_INT64, &wid);
|
||||||
mpv_set_option_string(player, "config", "no");
|
mpv_set_option_string(player, "config", "no");
|
||||||
mpv_set_option_string(player, "input-default-bindings", "no");
|
mpv_set_option_string(player, "input-default-bindings", "no");
|
||||||
mpv_set_option_string(player, "hwdec", "auto");
|
mpv_set_option_string(player, "hwdec", "auto");
|
||||||
mpv_set_option_string(player, "auto-window-resize", "no");
|
mpv_set_option_string(player, "auto-window-resize", "no");
|
||||||
// mpv_set_option_string(player, "fullscreen", "no");
|
for (auto& i : config.mpv) {
|
||||||
// mpv_set_option_string(player, "ontop", "no");
|
mpv_set_option_string(player, i.first.c_str(), i.second.c_str());
|
||||||
// mpv_set_option_string(player, "d3d11-exclusive-fs", "no");
|
|
||||||
auto loggingFile = config.configs["loggingFile"];
|
|
||||||
if (!loggingFile.empty()) {
|
|
||||||
mpv_set_option_string(player, "log-file", loggingFile.c_str());
|
|
||||||
}
|
}
|
||||||
const char* cmd[] = { "loadfile", videoName, nullptr };
|
const char* cmd[] = { "loadfile", videoName, nullptr };
|
||||||
err = mpv_command(player, cmd);
|
err = mpv_command(player, cmd);
|
||||||
|
|||||||
Reference in New Issue
Block a user