aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Config.hpp7
-rw-r--r--include/FileAnalyzer.hpp10
-rw-r--r--include/VideoPlayer.hpp33
3 files changed, 37 insertions, 13 deletions
diff --git a/include/Config.hpp b/include/Config.hpp
index b2abbf1..ee9e190 100644
--- a/include/Config.hpp
+++ b/include/Config.hpp
@@ -36,6 +36,12 @@ namespace QuickMedia {
bool sort_chapters_by_name = false;
};
+ struct LocalAnimeConfig {
+ std::string directory;
+ bool sort_by_name = false;
+ bool sort_episodes_by_name = true;
+ };
+
struct Config {
Config() = default;
Config(const Config&) = delete;
@@ -47,6 +53,7 @@ namespace QuickMedia {
InputConfig input;
VideoConfig video;
LocalMangaConfig local_manga;
+ LocalAnimeConfig local_anime;
bool use_system_fonts = false;
bool use_system_mpv_config = false;
std::string theme = "default";
diff --git a/include/FileAnalyzer.hpp b/include/FileAnalyzer.hpp
index b06ef91..acc62d7 100644
--- a/include/FileAnalyzer.hpp
+++ b/include/FileAnalyzer.hpp
@@ -5,6 +5,8 @@
#include <string>
namespace QuickMedia {
+ class FileAnalyzer;
+
struct Dimensions {
int width;
int height;
@@ -17,6 +19,7 @@ namespace QuickMedia {
VIDEO_MPEG,
VIDEO_WEBM,
VIDEO_FLV,
+ VIDEO_WMV,
AUDIO_BASIC,
AUDIO_AIFF,
AUDIO_MPEG,
@@ -40,13 +43,15 @@ namespace QuickMedia {
bool is_video_ext(const char *ext);
// Set |width| or |height| to 0 to disable scaling.
- // This function is async.
- bool video_get_first_frame(const char *filepath, const char *destination_path, int width = 0, int height = 0);
+ // TODO: Make this async
+ bool video_get_first_frame(const FileAnalyzer &file, const char *destination_path, int width = 0, int height = 0);
class FileAnalyzer {
public:
FileAnalyzer();
bool load_file(const char *filepath, bool load_file_metadata = true);
+
+ const std::string& get_filepath() const;
ContentType get_content_type() const;
size_t get_file_size() const;
std::optional<Dimensions> get_dimensions() const;
@@ -55,6 +60,7 @@ namespace QuickMedia {
FileAnalyzer(FileAnalyzer&) = delete;
FileAnalyzer& operator=(FileAnalyzer&) = delete;
private:
+ std::string filepath;
ContentType content_type;
size_t file_size;
std::optional<Dimensions> dimensions;
diff --git a/include/VideoPlayer.hpp b/include/VideoPlayer.hpp
index f75d76f..989bfd2 100644
--- a/include/VideoPlayer.hpp
+++ b/include/VideoPlayer.hpp
@@ -33,14 +33,31 @@ namespace QuickMedia {
EXITED
};
+ struct StartupArgs {
+ std::string path;
+ std::string audio_path;
+ mgl::WindowHandle parent_window;
+ bool no_video = false;
+ bool use_system_mpv_config = false;
+ bool use_system_input_config = false; // use_system_mpv_config has to be true for this
+ bool keep_open = false;
+ std::string resource_root;
+ int monitor_height = 1080;
+ bool use_youtube_dl = false;
+ std::string title;
+ std::string start_time;
+ std::vector<MediaChapter> chapters;
+ std::string plugin_name;
+ };
+
// @event_callback is called from another thread
- VideoPlayer(bool no_video, bool use_system_mpv_config, bool keep_open, EventCallbackFunc event_callback, VideoPlayerWindowCreateCallback window_create_callback, const std::string &resource_root, int monitor_height, std::string plugin_name);
+ VideoPlayer(StartupArgs startup_args, EventCallbackFunc event_callback, VideoPlayerWindowCreateCallback window_create_callback);
~VideoPlayer();
VideoPlayer(const VideoPlayer&) = delete;
VideoPlayer& operator=(const VideoPlayer&) = delete;
// |audio_path| is only set when video and audio are separate files/urls.
- Error load_video(const char *path, const char *audio_path, mgl::WindowHandle parent_window, bool use_youtube_dl, const std::string &title, const std::string &start_time = "", const std::vector<MediaChapter> &chapters = {});
+ Error load_video();
// Should be called every update frame
Error update();
@@ -52,24 +69,19 @@ namespace QuickMedia {
private:
uint32_t get_next_request_id();
Error send_command(Json::Value &json_root, Json::Value *result, Json::ValueType result_type);
- Error launch_video_process(const char *path, const char *audio_path, mgl::WindowHandle parent_window, const std::string &title, const std::string &start_time);
+ Error launch_video_process();
VideoPlayer::Error read_ipc_func();
private:
- std::string plugin_name;
- bool no_video;
- bool use_system_mpv_config;
- bool keep_open;
- bool use_youtube_dl;
+ StartupArgs startup_args;
+
pid_t video_process_id;
mgl::Clock retry_timer;
int connect_tries;
int find_window_tries;
- int monitor_height;
int ipc_socket = -1;
EventCallbackFunc event_callback;
VideoPlayerWindowCreateCallback window_create_callback;
mgl::WindowHandle window_handle;
- mgl::WindowHandle parent_window;
Display *display;
unsigned int request_id_counter;
unsigned int expected_request_id;
@@ -81,7 +93,6 @@ namespace QuickMedia {
ERROR
};
ResponseDataStatus response_data_status;
- std::string resource_root;
char tmp_chapters_filepath[27];
};
}