aboutsummaryrefslogtreecommitdiff
path: root/include/VideoPlayer.hpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-08-09 03:35:56 +0200
committerdec05eba <dec05eba@protonmail.com>2019-08-09 03:36:07 +0200
commit73b077835dc6085c2642451fa7dbde629b9eadfc (patch)
treed6abfaae58f9ee918fda556b36a8078825cb2799 /include/VideoPlayer.hpp
parente061971e5f1dee5a6e1541bc88a192e9ca8e9422 (diff)
Readd video seek, make search asynchronous
Diffstat (limited to 'include/VideoPlayer.hpp')
-rw-r--r--include/VideoPlayer.hpp31
1 files changed, 25 insertions, 6 deletions
diff --git a/include/VideoPlayer.hpp b/include/VideoPlayer.hpp
index 9d30dc5..2266a16 100644
--- a/include/VideoPlayer.hpp
+++ b/include/VideoPlayer.hpp
@@ -4,12 +4,14 @@
#include <SFML/System/Clock.hpp>
#include <stdio.h>
#include <functional>
-#include <thread>
+#include <json/value.h>
#include <sys/un.h>
+#include <X11/Xlib.h>
namespace QuickMedia {
using EventCallbackFunc = std::function<void(const char *event_name)>;
+ using VideoPlayerWindowCreateCallback = std::function<void(sf::WindowHandle window)>;
// Currently this video player launches mpv and embeds it into the QuickMedia window
class VideoPlayer {
@@ -22,11 +24,17 @@ namespace QuickMedia {
FAIL_TO_CONNECT_TIMEOUT,
FAIL_NOT_CONNECTED,
FAIL_TO_SEND,
+ FAIL_TO_FIND_WINDOW,
+ FAIL_TO_FIND_WINDOW_TIMEOUT,
+ UNEXPECTED_WINDOW_ERROR,
+ FAIL_TO_READ,
+ READ_TIMEOUT,
+ READ_INCORRECT_TYPE,
INIT_FAILED
};
// @event_callback is called from another thread
- VideoPlayer(EventCallbackFunc event_callback);
+ VideoPlayer(EventCallbackFunc event_callback, VideoPlayerWindowCreateCallback window_create_callback);
~VideoPlayer();
VideoPlayer(const VideoPlayer&) = delete;
VideoPlayer& operator=(const VideoPlayer&) = delete;
@@ -37,20 +45,31 @@ namespace QuickMedia {
Error update();
Error toggle_pause();
+
+ // Progress is in range [0..1]
+ Error get_progress(double *result);
+ // Progress is in range [0..1]
+ Error set_progress(double progress);
private:
Error send_command(const char *cmd, size_t size);
Error launch_video_process(const char *path, sf::WindowHandle parent_window);
- void read_ipc_func();
+ VideoPlayer::Error read_ipc_func();
private:
pid_t video_process_id;
int ipc_socket;
bool connected_to_ipc;
- sf::Clock ipc_connect_retry_timer;
+ sf::Clock retry_timer;
int connect_tries;
+ int find_window_tries;
struct sockaddr_un ipc_addr;
char ipc_server_path[L_tmpnam];
EventCallbackFunc event_callback;
- std::thread event_read_thread;
- bool alive;
+ VideoPlayerWindowCreateCallback window_create_callback;
+ sf::WindowHandle window_handle;
+ sf::WindowHandle parent_window;
+ Display *display;
+ unsigned int request_id;
+ unsigned int expected_request_id;
+ Json::Value request_response_data;
};
}