aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO2
-rw-r--r--include/VideoPlayer.hpp3
-rw-r--r--src/QuickMedia.cpp27
-rw-r--r--src/VideoPlayer.cpp9
4 files changed, 35 insertions, 6 deletions
diff --git a/TODO b/TODO
index 71bd2dd..c53a2c9 100644
--- a/TODO
+++ b/TODO
@@ -162,7 +162,7 @@ Remove reply formatting from edited text in room description in room list.
Add option to decline and mute user in invites. This is to combat invite spam, where muted users cant invite you.
Searching in channel page should search in the channel instead of filter, because with filtering we only filter the videos we have loaded in the channel page and the channel page uses pagination; so we may have only loaded 20 videos while the channel may actually have 2000 videos.
Allow hiding videos so they dont show up in recommendations and related videos.
-Limit youtube-dl video resolution to <= largest monitor resolution. This is absolutely required for smooth playback on pinephone. Also add an option to select video resolution, if we want to use less power and less bandwidth.
+Add an option to select video resolution, if we want to use less power and less bandwidth for example.
Use mpv option --gpu-context=x11egl on pinephone to force xwayland on wayland, to be able to embed the mpv window inside the quickmedia.
Read marker may be incorrect if the last message in a room has an earlier timestamp than a previous message (as seen in element and matrix api). Setting read marker to a previous message seems to be ignored silently by synapse. To fix this we would have to sort messages by unsigned age field instead (I guess?), or save the read marker in user account data specifically for quickmedia (under an unique namespace).
Replies to the local user shouldn't remove the red text. Maybe fix this by checking if the reply to message user is the local user or when the replied to message has loaded then make the reply red if its a reply to us. Also for existing messages check if the message is a notification message and then make the message red.
diff --git a/include/VideoPlayer.hpp b/include/VideoPlayer.hpp
index 51985e6..b2326bb 100644
--- a/include/VideoPlayer.hpp
+++ b/include/VideoPlayer.hpp
@@ -36,7 +36,7 @@ namespace QuickMedia {
};
// @event_callback is called from another thread
- VideoPlayer(bool use_tor, bool no_video, bool use_system_mpv_config, bool resume_playback, bool keep_open, EventCallbackFunc event_callback, VideoPlayerWindowCreateCallback window_create_callback, const std::string &resource_root);
+ VideoPlayer(bool use_tor, bool no_video, bool use_system_mpv_config, bool resume_playback, bool keep_open, EventCallbackFunc event_callback, VideoPlayerWindowCreateCallback window_create_callback, const std::string &resource_root, int monitor_height);
~VideoPlayer();
VideoPlayer(const VideoPlayer&) = delete;
VideoPlayer& operator=(const VideoPlayer&) = delete;
@@ -84,6 +84,7 @@ namespace QuickMedia {
sf::Clock retry_timer;
int connect_tries;
int find_window_tries;
+ int monitor_height;
struct sockaddr_un ipc_addr;
char ipc_server_path[L_tmpnam];
EventCallbackFunc event_callback;
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 41c2c6e..719345d 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -80,6 +80,21 @@ static int get_monitor_max_hz(Display *display) {
return 60;
}
+static int get_largest_monitor_height(Display *display) {
+ XRRScreenResources *screen_res = XRRGetScreenResources(display, DefaultRootWindow(display));
+ if(screen_res) {
+ int max_height = 0;
+ for(int i = 0; i < screen_res->nmode; ++i) {
+ max_height = std::max(max_height, (int)screen_res->modes[i].height);
+ }
+ XRRFreeScreenResources(screen_res);
+ if(max_height == 0)
+ max_height = 1080;
+ return std::max(max_height, 480);
+ }
+ return 1080;
+}
+
static void get_screen_resolution(Display *display, int *width, int *height) {
*width = DefaultScreenOfDisplay(display)->width;
*height = DefaultScreenOfDisplay(display)->height;
@@ -1721,7 +1736,7 @@ namespace QuickMedia {
video_url_converted = video_url;
}
- video_player = std::make_unique<VideoPlayer>(use_tor, no_video, use_system_mpv_config, resume_video, is_matrix, video_event_callback, on_window_create, resources_root);
+ video_player = std::make_unique<VideoPlayer>(use_tor, no_video, use_system_mpv_config, resume_video, is_matrix, video_event_callback, on_window_create, resources_root, get_largest_monitor_height(disp));
VideoPlayer::Error err = video_player->load_video(video_url_converted.c_str(), window.getSystemHandle(), plugin_name);
if(err != VideoPlayer::Error::OK) {
std::string err_msg = "Failed to play url: ";
@@ -3254,7 +3269,7 @@ namespace QuickMedia {
} else {
Message *orig_message = static_cast<Message*>(body_item->userdata);
body_item->set_description(message_get_body_remove_formatting(message.get()));
- if(message_contains_user_mention(message->body, my_display_name) || message_contains_user_mention(message->body, me->user_id) || (orig_message && orig_message->user == me))
+ if(message_contains_user_mention(message->body, my_display_name) || message_contains_user_mention(message->body, me->user_id) || (orig_message && orig_message->user == me && message->user != me))
body_item->set_description_color(sf::Color(255, 100, 100));
else
body_item->set_description_color(sf::Color::White);
@@ -3289,7 +3304,7 @@ namespace QuickMedia {
} else {
Message *orig_message = static_cast<Message*>(body_item->userdata);
body_item->set_description(message_get_body_remove_formatting(message.get()));
- if(message_contains_user_mention(message->body, my_display_name) || message_contains_user_mention(message->body, me->user_id) || (orig_message && orig_message->user == me))
+ if(message_contains_user_mention(message->body, my_display_name) || message_contains_user_mention(message->body, me->user_id) || (orig_message && orig_message->user == me && message->user != me))
body_item->set_description_color(sf::Color(255, 100, 100));
else
body_item->set_description_color(sf::Color::White);
@@ -3694,6 +3709,8 @@ namespace QuickMedia {
body_item->embedded_item->reactions.clear();
if(related_body_item->userdata && static_cast<Message*>(related_body_item->userdata)->user == me)
body_item->set_description_color(sf::Color(255, 100, 100));
+ else
+ body_item->set_description_color(sf::Color::White);
body_item->embedded_item_status = FetchStatus::FINISHED_LOADING;
return;
}
@@ -3720,6 +3737,8 @@ namespace QuickMedia {
body_item->reactions.clear();
if(message_contains_user_mention(related_body_item->get_description(), current_room->get_user_display_name(me)) || message_contains_user_mention(related_body_item->get_description(), me->user_id))
body_item->set_description_color(sf::Color(255, 100, 100));
+ else
+ body_item->set_description_color(sf::Color::White);
event_data->status = FetchStatus::FINISHED_LOADING;
event_data->message = static_cast<Message*>(related_body_item->userdata);
body_item->userdata = event_data;
@@ -3774,6 +3793,8 @@ namespace QuickMedia {
body_item->embedded_item->reactions.clear();
if((related_body_item->userdata && static_cast<Message*>(related_body_item->userdata)->user == me) || message_contains_user_mention(message->body, current_room->get_user_display_name(me)) || message_contains_user_mention(message->body, me->user_id))
body_item->set_description_color(sf::Color(255, 100, 100));
+ else
+ body_item->set_description_color(sf::Color::White);
body_item->embedded_item_status = FetchStatus::FINISHED_LOADING;
return;
}
diff --git a/src/VideoPlayer.cpp b/src/VideoPlayer.cpp
index bc37710..4653c5b 100644
--- a/src/VideoPlayer.cpp
+++ b/src/VideoPlayer.cpp
@@ -18,7 +18,7 @@ const int MAX_RETRIES_CONNECT = 1000;
const int READ_TIMEOUT_MS = 200;
namespace QuickMedia {
- VideoPlayer::VideoPlayer(bool use_tor, bool no_video, bool use_system_mpv_config, bool resume_playback, bool keep_open, EventCallbackFunc _event_callback, VideoPlayerWindowCreateCallback _window_create_callback, const std::string &resource_root) :
+ VideoPlayer::VideoPlayer(bool use_tor, bool no_video, bool use_system_mpv_config, bool resume_playback, bool keep_open, EventCallbackFunc _event_callback, VideoPlayerWindowCreateCallback _window_create_callback, const std::string &resource_root, int monitor_height) :
exit_status(0),
use_tor(use_tor),
no_video(no_video),
@@ -30,6 +30,7 @@ namespace QuickMedia {
connected_to_ipc(false),
connect_tries(0),
find_window_tries(0),
+ monitor_height(monitor_height),
event_callback(_event_callback),
window_create_callback(_window_create_callback),
window_handle(0),
@@ -44,6 +45,7 @@ namespace QuickMedia {
display = XOpenDisplay(NULL);
if (!display)
throw std::runtime_error("Failed to open display to X11 server");
+ fprintf(stderr, "Video max height: %d\n", monitor_height);
}
VideoPlayer::~VideoPlayer() {
@@ -89,6 +91,8 @@ namespace QuickMedia {
create_directory_recursive(mpv_watch_later_dir);
std::string watch_later_dir = "--watch-later-directory=" + mpv_watch_later_dir.data;
+ std::string ytdl_format = "--ytdl-format=bestvideo[height<=?" + std::to_string(monitor_height) + "]+bestaudio/best";
+
// TODO: Resume playback if the last video played matches the first video played next time QuickMedia is launched
args.insert(args.end(), {
"mpv",
@@ -101,6 +105,9 @@ namespace QuickMedia {
watch_later_dir.c_str(),
"--cache-on-disk=yes",
"--ytdl-raw-options=sub-lang=\"en,eng,enUS,en-US\",write-sub=",
+ ytdl_format.c_str(),
+ // TODO: Disable hr seek on low power devices?
+ "--hr-seek=yes",
input_conf.c_str(),
wid_arg.c_str()
});