mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-04-03 10:16:29 +09:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c8dd9c4db | ||
|
|
c7fcf251e3 | ||
|
|
6d58b2495d | ||
|
|
347eced060 | ||
|
|
6449133c57 | ||
|
|
1168e68278 | ||
|
|
4836c661ce | ||
|
|
f0bbbbe4a9 | ||
|
|
d9a1e5c2eb | ||
|
|
b6c59e1049 |
12
README.md
12
README.md
@@ -2,9 +2,7 @@
|
||||
|
||||
# GPU Screen Recorder UI
|
||||
A fullscreen overlay UI for [GPU Screen Recorder](https://git.dec05eba.com/gpu-screen-recorder/about/) in the style of ShadowPlay.\
|
||||
The application is currently primarly designed for X11 but it can run on Wayland as well through XWayland, with some caveats because of Wayland limitations.\
|
||||
Note: This software is still in early alpha. Expect bugs, and please report any if you experience them. Some are already known, but it doesn't hurt to report them anyways.\
|
||||
You can report an issue by emailing the issue to dec05eba@protonmail.com.
|
||||
The application is currently primarly designed for X11 but it can run on Wayland as well through XWayland, with some caveats because of Wayland limitations.
|
||||
|
||||
# Usage
|
||||
Run `gsr-ui` and press `Left Alt+Z` to show/hide the UI. You can start the overlay UI at system startup by running `systemctl enable --now --user gpu-screen-recorder-ui`.
|
||||
@@ -42,6 +40,9 @@ This might cause issues for you if you use input remapping software. To workarou
|
||||
# License
|
||||
This software is licensed under GPL3.0-only. Files under `fonts/` directory belong to the Noto Sans Google fonts project and they are licensed under `SIL Open Font License`. `images/default.cur` it part of the [Adwaita icon theme](https://gitlab.gnome.org/GNOME/adwaita-icon-theme/-/tree/master) which is licensed under `Creative Commons Attribution-Share Alike 3.0`.
|
||||
|
||||
# Reporting bugs, contributing patches, questions or donation
|
||||
See [https://git.dec05eba.com/?p=about](https://git.dec05eba.com/?p=about).
|
||||
|
||||
# Demo
|
||||
[](https://www.youtube.com/watch?v=SOqXusCTXXA)
|
||||
|
||||
@@ -49,11 +50,6 @@ This software is licensed under GPL3.0-only. Files under `fonts/` directory belo
|
||||

|
||||

|
||||
|
||||
# Donations
|
||||
If you want to donate you can donate via bitcoin or monero.
|
||||
* Bitcoin: bc1qqvuqnwrdyppf707ge27fqz2n9y9gu7lf5ypyuf
|
||||
* Monero: 4An9kp2qW1C9Gah7ewv4JzcNFQ5TAX7ineGCqXWK6vQnhsGGcRpNgcn8r9EC3tMcgY7vqCKs3nSRXhejMHBaGvFdN2egYet
|
||||
|
||||
# Known issues
|
||||
* When the UI is open the wallpaper is shown instead of the game on Hyprland. This is an issue with Hyprland. It cant be fixed until the UI is redesigned to not be a fullscreen overlay.
|
||||
* Opening the UI when a game is fullscreened can mess up the game window a bit on Hyprland. I believe this is an issue with Hyprland.
|
||||
|
||||
12
TODO
12
TODO
@@ -126,3 +126,15 @@ Add support for window capture. This should not prompt for window selection dire
|
||||
For screenshots window capture should exist but "follow focused" option should not exist.
|
||||
|
||||
Improve audio design. It should have a button to add/remove audio tracks and button to add audio into each audio track separately and "record audio from all applications except the selected ones" for each audio track. Then also remove the "merge audio tracks" option.
|
||||
|
||||
Make it possible to take a screenshot through a button in the ui instead of having to use hotkey.
|
||||
|
||||
Handle failing to save a replay. gsr should output "failed to save replay, or something like that" to make it possible to detect that.
|
||||
|
||||
Dont allow saving replay while a replay save is in progress.
|
||||
|
||||
Make input work with cjk input systems (such as fcitx).
|
||||
|
||||
System startup option should also support runit and some other init systems, not only soystemd.
|
||||
|
||||
Allow using a hotkey such as printscreen or any other non-alphanumeric key without a modifier. Allow that in gsr-ui and gsr-global-hotkeys. Update the ui to match that.
|
||||
Submodule depends/mglpp updated: 04a9fdec5a...b4ce16d4b9
Binary file not shown.
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.1 KiB |
@@ -11,6 +11,15 @@
|
||||
namespace gsr {
|
||||
struct SupportedCaptureOptions;
|
||||
|
||||
enum class ReplayStartupMode {
|
||||
DONT_TURN_ON_AUTOMATICALLY,
|
||||
TURN_ON_AT_SYSTEM_STARTUP,
|
||||
TURN_ON_AT_FULLSCREEN,
|
||||
TURN_ON_AT_POWER_SUPPLY_CONNECTED
|
||||
};
|
||||
|
||||
ReplayStartupMode replay_startup_string_to_type(const char *startup_mode_str);
|
||||
|
||||
struct ConfigHotkey {
|
||||
int64_t key = 0; // Mgl key
|
||||
uint32_t modifiers = 0; // HotkeyModifier
|
||||
|
||||
@@ -92,6 +92,7 @@ namespace gsr {
|
||||
void replay_status_update_status();
|
||||
void update_focused_fullscreen_status();
|
||||
void update_power_supply_status();
|
||||
void update_system_startup_status();
|
||||
|
||||
void on_stop_recording(int exit_code);
|
||||
|
||||
@@ -108,7 +109,7 @@ namespace gsr {
|
||||
void update_ui_replay_stopped();
|
||||
|
||||
void on_press_save_replay();
|
||||
void on_press_start_replay(bool disable_notification);
|
||||
bool on_press_start_replay(bool disable_notification);
|
||||
void on_press_start_record();
|
||||
void on_press_start_stream();
|
||||
void on_press_take_screenshot();
|
||||
@@ -197,6 +198,8 @@ namespace gsr {
|
||||
|
||||
mgl::Clock replay_save_clock;
|
||||
bool replay_save_show_notification = false;
|
||||
ReplayStartupMode replay_startup_mode = ReplayStartupMode::TURN_ON_AT_SYSTEM_STARTUP;
|
||||
bool try_replay_startup = true;
|
||||
|
||||
AudioPlayer audio_player;
|
||||
};
|
||||
|
||||
@@ -12,14 +12,14 @@ namespace gsr {
|
||||
};
|
||||
|
||||
// Arguments ending with NULL
|
||||
bool exec_program_daemonized(const char **args);
|
||||
bool exec_program_daemonized(const char **args, bool debug = true);
|
||||
// Arguments ending with NULL. |read_fd| can be NULL
|
||||
pid_t exec_program(const char **args, int *read_fd);
|
||||
pid_t exec_program(const char **args, int *read_fd, bool debug = true);
|
||||
// Arguments ending with NULL. Returns the exit status of the program or -1 on error
|
||||
int exec_program_get_stdout(const char **args, std::string &result);
|
||||
int exec_program_get_stdout(const char **args, std::string &result, bool debug = true);
|
||||
// Arguments ending with NULL. Returns the exit status of the program or -1 on error.
|
||||
// This works the same as |exec_program_get_stdout|, except on flatpak where this runs the program on the
|
||||
// host machine with flatpak-spawn --host
|
||||
int exec_program_on_host_get_stdout(const char **args, std::string &result);
|
||||
int exec_program_on_host_get_stdout(const char **args, std::string &result, bool debug = true);
|
||||
pid_t pidof(const char *process_name, pid_t ignore_pid);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
project('gsr-ui', ['c', 'cpp'], version : '1.2.0', default_options : ['warning_level=2', 'cpp_std=c++17'], subproject_dir : 'depends')
|
||||
project('gsr-ui', ['c', 'cpp'], version : '1.2.2', default_options : ['warning_level=2', 'cpp_std=c++17'], subproject_dir : 'depends')
|
||||
|
||||
if get_option('buildtype') == 'debug'
|
||||
add_project_arguments('-g3', language : ['c', 'cpp'])
|
||||
@@ -54,7 +54,7 @@ datadir = get_option('datadir')
|
||||
gsr_ui_resources_path = join_paths(prefix, datadir, 'gsr-ui')
|
||||
|
||||
add_project_arguments('-DGSR_UI_VERSION="' + meson.project_version() + '"', language: ['c', 'cpp'])
|
||||
add_project_arguments('-DGSR_FLATPAK_VERSION="5.1.5"', language: ['c', 'cpp'])
|
||||
add_project_arguments('-DGSR_FLATPAK_VERSION="5.1.7"', language: ['c', 'cpp'])
|
||||
|
||||
executable(
|
||||
meson.project_name(),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "gsr-ui"
|
||||
type = "executable"
|
||||
version = "1.2.0"
|
||||
version = "1.2.2"
|
||||
platforms = ["posix"]
|
||||
|
||||
[lang.cpp]
|
||||
@@ -15,4 +15,4 @@ xcomposite = ">=0"
|
||||
xfixes = ">=0"
|
||||
xi = ">=0"
|
||||
xcursor = ">=1"
|
||||
libpulse-simple = ">=0"
|
||||
libpulse-simple = ">=0"
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <limits.h>
|
||||
#include <inttypes.h>
|
||||
#include <libgen.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <mglpp/window/Keyboard.hpp>
|
||||
|
||||
@@ -45,6 +46,19 @@ namespace gsr {
|
||||
}
|
||||
}
|
||||
|
||||
ReplayStartupMode replay_startup_string_to_type(const char *startup_mode_str) {
|
||||
if(strcmp(startup_mode_str, "dont_turn_on_automatically") == 0)
|
||||
return ReplayStartupMode::DONT_TURN_ON_AUTOMATICALLY;
|
||||
else if(strcmp(startup_mode_str, "turn_on_at_system_startup") == 0)
|
||||
return ReplayStartupMode::TURN_ON_AT_SYSTEM_STARTUP;
|
||||
else if(strcmp(startup_mode_str, "turn_on_at_fullscreen") == 0)
|
||||
return ReplayStartupMode::TURN_ON_AT_FULLSCREEN;
|
||||
else if(strcmp(startup_mode_str, "turn_on_at_power_supply_connected") == 0)
|
||||
return ReplayStartupMode::TURN_ON_AT_POWER_SUPPLY_CONNECTED;
|
||||
else
|
||||
return ReplayStartupMode::DONT_TURN_ON_AUTOMATICALLY;
|
||||
}
|
||||
|
||||
bool ConfigHotkey::operator==(const ConfigHotkey &other) const {
|
||||
return key == other.key && modifiers == other.modifiers;
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ namespace gsr {
|
||||
|
||||
std::string stdout_str;
|
||||
const char *args[] = { "gpu-screen-recorder", "--list-audio-devices", nullptr };
|
||||
if(exec_program_get_stdout(args, stdout_str) != 0) {
|
||||
if(exec_program_get_stdout(args, stdout_str, false) != 0) {
|
||||
fprintf(stderr, "error: 'gpu-screen-recorder --list-audio-devices' failed\n");
|
||||
return audio_devices;
|
||||
}
|
||||
|
||||
153
src/Overlay.cpp
153
src/Overlay.cpp
@@ -22,6 +22,7 @@
|
||||
#include <poll.h>
|
||||
#include <malloc.h>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
@@ -41,8 +42,10 @@ extern "C" {
|
||||
namespace gsr {
|
||||
static const mgl::Color bg_color(0, 0, 0, 100);
|
||||
static const double force_window_on_top_timeout_seconds = 1.0;
|
||||
static const double replay_status_update_check_timeout_seconds = 1.0;
|
||||
static const double replay_status_update_check_timeout_seconds = 1.5;
|
||||
static const double replay_saving_notification_timeout_seconds = 0.5;
|
||||
static const double notification_timeout_seconds = 2.0;
|
||||
static const double notification_error_timeout_seconds = 5.0;
|
||||
|
||||
static mgl::Texture texture_from_ximage(XImage *img) {
|
||||
uint8_t *texture_data = (uint8_t*)malloc(img->width * img->height * 3);
|
||||
@@ -436,9 +439,7 @@ namespace gsr {
|
||||
init_color_theme(config, this->gsr_info);
|
||||
|
||||
power_supply_online_filepath = get_power_supply_online_filepath();
|
||||
|
||||
if(config.replay_config.turn_on_replay_automatically_mode == "turn_on_at_system_startup")
|
||||
on_press_start_replay(true);
|
||||
replay_startup_mode = replay_startup_string_to_type(config.replay_config.turn_on_replay_automatically_mode.c_str());
|
||||
|
||||
if(config.main_config.hotkeys_enable_option == "enable_hotkeys")
|
||||
global_hotkeys = register_linux_hotkeys(this, GlobalHotkeysLinux::GrabType::ALL);
|
||||
@@ -1070,8 +1071,9 @@ namespace gsr {
|
||||
if(id == "settings") {
|
||||
auto replay_settings_page = std::make_unique<SettingsPage>(SettingsPage::Type::REPLAY, &gsr_info, config, &page_stack);
|
||||
replay_settings_page->on_config_changed = [this]() {
|
||||
replay_startup_mode = replay_startup_string_to_type(config.replay_config.turn_on_replay_automatically_mode.c_str());
|
||||
if(recording_status == RecordingStatus::REPLAY)
|
||||
show_notification("Replay settings have been modified.\nYou may need to restart replay to apply the changes.", 5.0, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::REPLAY);
|
||||
show_notification("Replay settings have been modified.\nYou may need to restart replay to apply the changes.", notification_timeout_seconds, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::REPLAY);
|
||||
};
|
||||
page_stack.push(std::move(replay_settings_page));
|
||||
} else if(id == "save") {
|
||||
@@ -1097,7 +1099,7 @@ namespace gsr {
|
||||
auto record_settings_page = std::make_unique<SettingsPage>(SettingsPage::Type::RECORD, &gsr_info, config, &page_stack);
|
||||
record_settings_page->on_config_changed = [this]() {
|
||||
if(recording_status == RecordingStatus::RECORD)
|
||||
show_notification("Recording settings have been modified.\nYou may need to restart recording to apply the changes.", 5.0, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::RECORD);
|
||||
show_notification("Recording settings have been modified.\nYou may need to restart recording to apply the changes.", notification_timeout_seconds, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::RECORD);
|
||||
};
|
||||
page_stack.push(std::move(record_settings_page));
|
||||
} else if(id == "pause") {
|
||||
@@ -1121,7 +1123,7 @@ namespace gsr {
|
||||
auto stream_settings_page = std::make_unique<SettingsPage>(SettingsPage::Type::STREAM, &gsr_info, config, &page_stack);
|
||||
stream_settings_page->on_config_changed = [this]() {
|
||||
if(recording_status == RecordingStatus::STREAM)
|
||||
show_notification("Streaming settings have been modified.\nYou may need to restart streaming to apply the changes.", 5.0, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::STREAM);
|
||||
show_notification("Streaming settings have been modified.\nYou may need to restart streaming to apply the changes.", notification_timeout_seconds, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::STREAM);
|
||||
};
|
||||
page_stack.push(std::move(stream_settings_page));
|
||||
} else if(id == "start") {
|
||||
@@ -1151,12 +1153,12 @@ namespace gsr {
|
||||
|
||||
if(exit_status == 127) {
|
||||
if(enable)
|
||||
show_notification("Failed to add GPU Screen Recorder to system startup.\nThis option only works on systems that use systemd.\nYou have to manually add \"gsr-ui\" to system startup on systems that uses another init system.", 10.0, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::NONE);
|
||||
show_notification("Failed to add GPU Screen Recorder to system startup.\nThis option only works on systems that use systemd.\nYou have to manually add \"gsr-ui\" to system startup on systems that uses another init system.", 7.0, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::NONE);
|
||||
} else {
|
||||
if(enable)
|
||||
show_notification("Failed to add GPU Screen Recorder to system startup", 3.0, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::NONE);
|
||||
show_notification("Failed to add GPU Screen Recorder to system startup", notification_timeout_seconds, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::NONE);
|
||||
else
|
||||
show_notification("Failed to remove GPU Screen Recorder from system startup", 3.0, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::NONE);
|
||||
show_notification("Failed to remove GPU Screen Recorder from system startup", notification_timeout_seconds, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::NONE);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1352,10 +1354,10 @@ namespace gsr {
|
||||
|
||||
if(paused) {
|
||||
update_ui_recording_unpaused();
|
||||
show_notification("Recording has been unpaused", 3.0, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::RECORD);
|
||||
show_notification("Recording has been unpaused", notification_timeout_seconds, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::RECORD);
|
||||
} else {
|
||||
update_ui_recording_paused();
|
||||
show_notification("Recording has been paused", 3.0, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::RECORD);
|
||||
show_notification("Recording has been paused", notification_timeout_seconds, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::RECORD);
|
||||
}
|
||||
|
||||
kill(gpu_screen_recorder_process, SIGUSR2);
|
||||
@@ -1539,7 +1541,7 @@ namespace gsr {
|
||||
case NotificationType::STREAM:
|
||||
break;
|
||||
}
|
||||
show_notification(text.c_str(), 3.0, mgl::Color(255, 255, 255), get_color_theme().tint_color, notification_type);
|
||||
show_notification(text.c_str(), notification_timeout_seconds, mgl::Color(255, 255, 255), get_color_theme().tint_color, notification_type);
|
||||
}
|
||||
|
||||
void Overlay::on_replay_saved(const char *replay_saved_filepath) {
|
||||
@@ -1548,14 +1550,14 @@ namespace gsr {
|
||||
save_video_in_current_game_directory(replay_saved_filepath, NotificationType::REPLAY);
|
||||
} else {
|
||||
const std::string text = "Saved replay to '" + filepath_get_filename(replay_saved_filepath) + "'";
|
||||
show_notification(text.c_str(), 3.0, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::REPLAY);
|
||||
show_notification(text.c_str(), notification_timeout_seconds, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::REPLAY);
|
||||
}
|
||||
}
|
||||
|
||||
void Overlay::update_gsr_replay_save() {
|
||||
if(replay_save_show_notification && replay_save_clock.get_elapsed_time_seconds() >= replay_saving_notification_timeout_seconds) {
|
||||
replay_save_show_notification = false;
|
||||
show_notification("Saving replay, this might take some time", 3.0, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::REPLAY);
|
||||
show_notification("Saving replay, this might take some time", notification_timeout_seconds, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::REPLAY);
|
||||
}
|
||||
|
||||
if(gpu_screen_recorder_process_output_file) {
|
||||
@@ -1598,10 +1600,10 @@ namespace gsr {
|
||||
update_ui_replay_stopped();
|
||||
if(exit_code == 0) {
|
||||
if(config.replay_config.show_replay_stopped_notifications)
|
||||
show_notification("Replay stopped", 3.0, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::REPLAY);
|
||||
show_notification("Replay stopped", notification_timeout_seconds, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::REPLAY);
|
||||
} else {
|
||||
fprintf(stderr, "Warning: gpu-screen-recorder (%d) exited with exit status %d\n", (int)gpu_screen_recorder_process, exit_code);
|
||||
show_notification("Replay stopped because of an error. Verify if settings are correct", 3.0, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::REPLAY);
|
||||
show_notification("Replay stopped because of an error. Verify if settings are correct", notification_timeout_seconds, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::REPLAY);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1614,10 +1616,10 @@ namespace gsr {
|
||||
update_ui_streaming_stopped();
|
||||
if(exit_code == 0) {
|
||||
if(config.streaming_config.show_streaming_stopped_notifications)
|
||||
show_notification("Streaming has stopped", 3.0, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::STREAM);
|
||||
show_notification("Streaming has stopped", notification_timeout_seconds, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::STREAM);
|
||||
} else {
|
||||
fprintf(stderr, "Warning: gpu-screen-recorder (%d) exited with exit status %d\n", (int)gpu_screen_recorder_process, exit_code);
|
||||
show_notification("Streaming stopped because of an error. Verify if settings are correct", 3.0, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::STREAM);
|
||||
show_notification("Streaming stopped because of an error. Verify if settings are correct", notification_timeout_seconds, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::STREAM);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1646,16 +1648,43 @@ namespace gsr {
|
||||
save_video_in_current_game_directory(screenshot_filepath.c_str(), NotificationType::SCREENSHOT);
|
||||
} else {
|
||||
const std::string text = "Saved screenshot to '" + filepath_get_filename(screenshot_filepath.c_str()) + "'";
|
||||
show_notification(text.c_str(), 3.0, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::SCREENSHOT);
|
||||
show_notification(text.c_str(), notification_timeout_seconds, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::SCREENSHOT);
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "Warning: gpu-screen-recorder (%d) exited with exit status %d\n", (int)gpu_screen_recorder_screenshot_process, exit_code);
|
||||
show_notification("Failed to take a screenshot. Verify if settings are correct", 3.0, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::SCREENSHOT);
|
||||
show_notification("Failed to take a screenshot. Verify if settings are correct", notification_timeout_seconds, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::SCREENSHOT);
|
||||
}
|
||||
|
||||
gpu_screen_recorder_screenshot_process = -1;
|
||||
}
|
||||
|
||||
static bool starts_with(std::string_view str, const char *substr) {
|
||||
size_t len = strlen(substr);
|
||||
return str.size() >= len && memcmp(str.data(), substr, len) == 0;
|
||||
}
|
||||
|
||||
static bool are_all_audio_tracks_available_to_capture(const std::vector<std::string> &audio_tracks) {
|
||||
const auto audio_devices = get_audio_devices();
|
||||
for(const std::string &audio_track : audio_tracks) {
|
||||
std::string_view audio_track_name(audio_track.c_str());
|
||||
const bool is_app_audio = starts_with(audio_track_name, "app:");
|
||||
if(is_app_audio)
|
||||
continue;
|
||||
|
||||
if(starts_with(audio_track_name, "device:"))
|
||||
audio_track_name.remove_prefix(7);
|
||||
|
||||
auto it = std::find_if(audio_devices.begin(), audio_devices.end(), [&](const auto &audio_device) {
|
||||
return audio_device.name == audio_track_name;
|
||||
});
|
||||
if(it == audio_devices.end()) {
|
||||
//fprintf(stderr, "Audio not ready\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Overlay::replay_status_update_status() {
|
||||
if(replay_status_update_clock.get_elapsed_time_seconds() < replay_status_update_check_timeout_seconds)
|
||||
return;
|
||||
@@ -1663,10 +1692,11 @@ namespace gsr {
|
||||
replay_status_update_clock.restart();
|
||||
update_focused_fullscreen_status();
|
||||
update_power_supply_status();
|
||||
update_system_startup_status();
|
||||
}
|
||||
|
||||
void Overlay::update_focused_fullscreen_status() {
|
||||
if(config.replay_config.turn_on_replay_automatically_mode != "turn_on_at_fullscreen")
|
||||
if(replay_startup_mode != ReplayStartupMode::TURN_ON_AT_FULLSCREEN)
|
||||
return;
|
||||
|
||||
mgl_context *context = mgl_get_context();
|
||||
@@ -1679,39 +1709,51 @@ namespace gsr {
|
||||
const bool prev_focused_window_is_fullscreen = focused_window_is_fullscreen;
|
||||
focused_window_is_fullscreen = focused_window != 0 && window_is_fullscreen(display, focused_window);
|
||||
if(focused_window_is_fullscreen != prev_focused_window_is_fullscreen) {
|
||||
if(recording_status == RecordingStatus::NONE && focused_window_is_fullscreen)
|
||||
on_press_start_replay(false);
|
||||
else if(recording_status == RecordingStatus::REPLAY && !focused_window_is_fullscreen)
|
||||
if(recording_status == RecordingStatus::NONE && focused_window_is_fullscreen) {
|
||||
if(are_all_audio_tracks_available_to_capture(config.replay_config.record_options.audio_tracks))
|
||||
on_press_start_replay(false);
|
||||
} else if(recording_status == RecordingStatus::REPLAY && !focused_window_is_fullscreen) {
|
||||
on_press_start_replay(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Instead of checking power supply status periodically listen to power supply event
|
||||
void Overlay::update_power_supply_status() {
|
||||
if(config.replay_config.turn_on_replay_automatically_mode != "turn_on_at_power_supply_connected")
|
||||
if(replay_startup_mode != ReplayStartupMode::TURN_ON_AT_POWER_SUPPLY_CONNECTED)
|
||||
return;
|
||||
|
||||
const bool prev_power_supply_status = power_supply_connected;
|
||||
power_supply_connected = power_supply_online_filepath.empty() || power_supply_is_connected(power_supply_online_filepath.c_str());
|
||||
if(power_supply_connected != prev_power_supply_status) {
|
||||
if(recording_status == RecordingStatus::NONE && power_supply_connected)
|
||||
on_press_start_replay(false);
|
||||
else if(recording_status == RecordingStatus::REPLAY && !power_supply_connected)
|
||||
if(recording_status == RecordingStatus::NONE && power_supply_connected) {
|
||||
if(are_all_audio_tracks_available_to_capture(config.replay_config.record_options.audio_tracks))
|
||||
on_press_start_replay(false);
|
||||
} else if(recording_status == RecordingStatus::REPLAY && !power_supply_connected) {
|
||||
on_press_start_replay(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Overlay::update_system_startup_status() {
|
||||
if(replay_startup_mode != ReplayStartupMode::TURN_ON_AT_SYSTEM_STARTUP || recording_status != RecordingStatus::NONE || !try_replay_startup)
|
||||
return;
|
||||
|
||||
if(are_all_audio_tracks_available_to_capture(config.replay_config.record_options.audio_tracks))
|
||||
on_press_start_replay(true);
|
||||
}
|
||||
|
||||
void Overlay::on_stop_recording(int exit_code) {
|
||||
if(exit_code == 0) {
|
||||
if(config.record_config.save_video_in_game_folder) {
|
||||
save_video_in_current_game_directory(record_filepath.c_str(), NotificationType::RECORD);
|
||||
} else {
|
||||
const std::string text = "Saved recording to '" + filepath_get_filename(record_filepath.c_str()) + "'";
|
||||
show_notification(text.c_str(), 3.0, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::RECORD);
|
||||
show_notification(text.c_str(), notification_timeout_seconds, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::RECORD);
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "Warning: gpu-screen-recorder (%d) exited with exit status %d\n", (int)gpu_screen_recorder_process, exit_code);
|
||||
show_notification("Failed to start/save recording. Verify if settings are correct", 3.0, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::RECORD);
|
||||
show_notification("Failed to start/save recording. Verify if settings are correct", notification_timeout_seconds, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::RECORD);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1816,11 +1858,6 @@ namespace gsr {
|
||||
return container;
|
||||
}
|
||||
|
||||
static bool starts_with(std::string_view str, const char *substr) {
|
||||
size_t len = strlen(substr);
|
||||
return str.size() >= len && memcmp(str.data(), substr, len) == 0;
|
||||
}
|
||||
|
||||
static std::vector<std::string> create_audio_tracks_real_names(const std::vector<std::string> &audio_tracks, bool application_audio_invert, const GsrInfo &gsr_info) {
|
||||
std::vector<std::string> result;
|
||||
for(const std::string &audio_track : audio_tracks) {
|
||||
@@ -1906,21 +1943,22 @@ namespace gsr {
|
||||
kill(gpu_screen_recorder_process, SIGUSR1);
|
||||
}
|
||||
|
||||
void Overlay::on_press_start_replay(bool disable_notification) {
|
||||
bool Overlay::on_press_start_replay(bool disable_notification) {
|
||||
switch(recording_status) {
|
||||
case RecordingStatus::NONE:
|
||||
case RecordingStatus::REPLAY:
|
||||
break;
|
||||
case RecordingStatus::RECORD:
|
||||
show_notification("Unable to start replay when recording.\nStop recording before starting replay.", 5.0, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::RECORD);
|
||||
return;
|
||||
show_notification("Unable to start replay when recording.\nStop recording before starting replay.", notification_error_timeout_seconds, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::RECORD);
|
||||
return false;
|
||||
case RecordingStatus::STREAM:
|
||||
show_notification("Unable to start replay when streaming.\nStop streaming before starting replay.", 5.0, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::STREAM);
|
||||
return;
|
||||
show_notification("Unable to start replay when streaming.\nStop streaming before starting replay.", notification_error_timeout_seconds, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::STREAM);
|
||||
return false;
|
||||
}
|
||||
|
||||
paused = false;
|
||||
replay_save_show_notification = false;
|
||||
try_replay_startup = false;
|
||||
|
||||
// window->close();
|
||||
// usleep(1000 * 50); // 50 milliseconds
|
||||
@@ -1941,15 +1979,16 @@ namespace gsr {
|
||||
|
||||
// TODO: Show this with a slight delay to make sure it doesn't show up in the video
|
||||
if(!disable_notification && config.replay_config.show_replay_stopped_notifications)
|
||||
show_notification("Replay stopped", 3.0, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::REPLAY);
|
||||
return;
|
||||
show_notification("Replay stopped", notification_timeout_seconds, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::REPLAY);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!validate_capture_target(gsr_info, config.replay_config.record_options.record_area_option)) {
|
||||
char err_msg[256];
|
||||
snprintf(err_msg, sizeof(err_msg), "Failed to start replay, capture target \"%s\" is invalid. Please change capture target in settings", config.replay_config.record_options.record_area_option.c_str());
|
||||
show_notification(err_msg, 3.0, mgl::Color(255, 0, 0, 0), mgl::Color(255, 0, 0, 0), NotificationType::REPLAY);
|
||||
return;
|
||||
show_notification(err_msg, notification_error_timeout_seconds, mgl::Color(255, 0, 0, 0), mgl::Color(255, 0, 0, 0), NotificationType::REPLAY);
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: Validate input, fallback to valid values
|
||||
@@ -2023,7 +2062,9 @@ namespace gsr {
|
||||
// program and start another one. This can also be used to check when the notification has finished by checking with waitpid NOWAIT
|
||||
// to see when the program has exit.
|
||||
if(!disable_notification && config.replay_config.show_replay_started_notifications)
|
||||
show_notification("Replay has started", 3.0, get_color_theme().tint_color, get_color_theme().tint_color, NotificationType::REPLAY);
|
||||
show_notification("Replay has started", notification_timeout_seconds, get_color_theme().tint_color, get_color_theme().tint_color, NotificationType::REPLAY);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Overlay::on_press_start_record() {
|
||||
@@ -2032,10 +2073,10 @@ namespace gsr {
|
||||
case RecordingStatus::RECORD:
|
||||
break;
|
||||
case RecordingStatus::REPLAY:
|
||||
show_notification("Unable to start recording when replay is turned on.\nTurn off replay before starting recording.", 5.0, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::REPLAY);
|
||||
show_notification("Unable to start recording when replay is turned on.\nTurn off replay before starting recording.", notification_error_timeout_seconds, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::REPLAY);
|
||||
return;
|
||||
case RecordingStatus::STREAM:
|
||||
show_notification("Unable to start recording when streaming.\nStop streaming before starting recording.", 5.0, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::STREAM);
|
||||
show_notification("Unable to start recording when streaming.\nStop streaming before starting recording.", notification_error_timeout_seconds, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::STREAM);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2067,7 +2108,7 @@ namespace gsr {
|
||||
if(!validate_capture_target(gsr_info, config.record_config.record_options.record_area_option)) {
|
||||
char err_msg[256];
|
||||
snprintf(err_msg, sizeof(err_msg), "Failed to start recording, capture target \"%s\" is invalid. Please change capture target in settings", config.record_config.record_options.record_area_option.c_str());
|
||||
show_notification(err_msg, 3.0, mgl::Color(255, 0, 0, 0), mgl::Color(255, 0, 0, 0), NotificationType::RECORD);
|
||||
show_notification(err_msg, notification_error_timeout_seconds, mgl::Color(255, 0, 0, 0), mgl::Color(255, 0, 0, 0), NotificationType::RECORD);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2129,7 +2170,7 @@ namespace gsr {
|
||||
// 2...
|
||||
// 1...
|
||||
if(config.record_config.show_recording_started_notifications)
|
||||
show_notification("Recording has started", 3.0, get_color_theme().tint_color, get_color_theme().tint_color, NotificationType::RECORD);
|
||||
show_notification("Recording has started", notification_timeout_seconds, get_color_theme().tint_color, get_color_theme().tint_color, NotificationType::RECORD);
|
||||
}
|
||||
|
||||
static std::string streaming_get_url(const Config &config) {
|
||||
@@ -2170,10 +2211,10 @@ namespace gsr {
|
||||
case RecordingStatus::STREAM:
|
||||
break;
|
||||
case RecordingStatus::REPLAY:
|
||||
show_notification("Unable to start streaming when replay is turned on.\nTurn off replay before starting streaming.", 5.0, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::REPLAY);
|
||||
show_notification("Unable to start streaming when replay is turned on.\nTurn off replay before starting streaming.", notification_error_timeout_seconds, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::REPLAY);
|
||||
return;
|
||||
case RecordingStatus::RECORD:
|
||||
show_notification("Unable to start streaming when recording.\nStop recording before starting streaming.", 5.0, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::RECORD);
|
||||
show_notification("Unable to start streaming when recording.\nStop recording before starting streaming.", notification_error_timeout_seconds, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::RECORD);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2196,14 +2237,14 @@ namespace gsr {
|
||||
|
||||
// TODO: Show this with a slight delay to make sure it doesn't show up in the video
|
||||
if(config.streaming_config.show_streaming_stopped_notifications)
|
||||
show_notification("Streaming has stopped", 3.0, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::STREAM);
|
||||
show_notification("Streaming has stopped", notification_timeout_seconds, mgl::Color(255, 255, 255), get_color_theme().tint_color, NotificationType::STREAM);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!validate_capture_target(gsr_info, config.streaming_config.record_options.record_area_option)) {
|
||||
char err_msg[256];
|
||||
snprintf(err_msg, sizeof(err_msg), "Failed to start streaming, capture target \"%s\" is invalid. Please change capture target in settings", config.streaming_config.record_options.record_area_option.c_str());
|
||||
show_notification(err_msg, 3.0, mgl::Color(255, 0, 0, 0), mgl::Color(255, 0, 0, 0), NotificationType::STREAM);
|
||||
show_notification(err_msg, notification_error_timeout_seconds, mgl::Color(255, 0, 0, 0), mgl::Color(255, 0, 0, 0), NotificationType::STREAM);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2270,7 +2311,7 @@ namespace gsr {
|
||||
// program and start another one. This can also be used to check when the notification has finished by checking with waitpid NOWAIT
|
||||
// to see when the program has exit.
|
||||
if(config.streaming_config.show_streaming_started_notifications)
|
||||
show_notification("Streaming has started", 3.0, get_color_theme().tint_color, get_color_theme().tint_color, NotificationType::STREAM);
|
||||
show_notification("Streaming has started", notification_timeout_seconds, get_color_theme().tint_color, get_color_theme().tint_color, NotificationType::STREAM);
|
||||
}
|
||||
|
||||
void Overlay::on_press_take_screenshot() {
|
||||
@@ -2282,7 +2323,7 @@ namespace gsr {
|
||||
if(!validate_capture_target(gsr_info, config.screenshot_config.record_area_option)) {
|
||||
char err_msg[256];
|
||||
snprintf(err_msg, sizeof(err_msg), "Failed to take a screenshot, capture target \"%s\" is invalid. Please change capture target in settings", config.screenshot_config.record_area_option.c_str());
|
||||
show_notification(err_msg, 3.0, mgl::Color(255, 0, 0, 0), mgl::Color(255, 0, 0, 0), NotificationType::SCREENSHOT);
|
||||
show_notification(err_msg, notification_error_timeout_seconds, mgl::Color(255, 0, 0, 0), mgl::Color(255, 0, 0, 0), NotificationType::SCREENSHOT);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,12 +40,13 @@ namespace gsr {
|
||||
return num_args;
|
||||
}
|
||||
|
||||
bool exec_program_daemonized(const char **args) {
|
||||
bool exec_program_daemonized(const char **args, bool debug) {
|
||||
/* 1 argument */
|
||||
if(args[0] == nullptr)
|
||||
return false;
|
||||
|
||||
debug_print_args(args);
|
||||
if(debug)
|
||||
debug_print_args(args);
|
||||
|
||||
const pid_t pid = vfork();
|
||||
if(pid == -1) {
|
||||
@@ -72,7 +73,7 @@ namespace gsr {
|
||||
return true;
|
||||
}
|
||||
|
||||
pid_t exec_program(const char **args, int *read_fd) {
|
||||
pid_t exec_program(const char **args, int *read_fd, bool debug) {
|
||||
if(read_fd)
|
||||
*read_fd = -1;
|
||||
|
||||
@@ -84,7 +85,8 @@ namespace gsr {
|
||||
if(pipe(fds) == -1)
|
||||
return -1;
|
||||
|
||||
debug_print_args(args);
|
||||
if(debug)
|
||||
debug_print_args(args);
|
||||
|
||||
const pid_t pid = vfork();
|
||||
if(pid == -1) {
|
||||
@@ -110,10 +112,10 @@ namespace gsr {
|
||||
}
|
||||
}
|
||||
|
||||
int exec_program_get_stdout(const char **args, std::string &result) {
|
||||
int exec_program_get_stdout(const char **args, std::string &result, bool debug) {
|
||||
result.clear();
|
||||
int read_fd = -1;
|
||||
const pid_t process_id = exec_program(args, &read_fd);
|
||||
const pid_t process_id = exec_program(args, &read_fd, debug);
|
||||
if(process_id == -1)
|
||||
return -1;
|
||||
|
||||
@@ -152,7 +154,7 @@ namespace gsr {
|
||||
return exit_status;
|
||||
}
|
||||
|
||||
int exec_program_on_host_get_stdout(const char **args, std::string &result) {
|
||||
int exec_program_on_host_get_stdout(const char **args, std::string &result, bool debug) {
|
||||
if(count_num_args(args) > 64 - 3) {
|
||||
fprintf(stderr, "Error: too many arguments when trying to launch \"%s\"\n", args[0]);
|
||||
return -1;
|
||||
@@ -170,9 +172,9 @@ namespace gsr {
|
||||
}
|
||||
modified_args[i] = arg;
|
||||
}
|
||||
return exec_program_get_stdout(modified_args, result);
|
||||
return exec_program_get_stdout(modified_args, result, debug);
|
||||
} else {
|
||||
return exec_program_get_stdout(args, result);
|
||||
return exec_program_get_stdout(args, result, debug);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace gsr {
|
||||
|
||||
mgl::Text title_text("Press a key combination to use for the hotkey \"" + hotkey_configure_action_name + "\":", get_theme().title_font);
|
||||
mgl::Text hotkey_text(configure_hotkey_button->get_text(), get_theme().top_bar_font);
|
||||
mgl::Text description_text("The hotkey has to contain one or more of these keys: Alt, Ctrl, Shift and Super. Press Esc to cancel.", get_theme().body_font);
|
||||
mgl::Text description_text("The hotkey has to contain one or more of these keys: Alt, Ctrl, Shift and Super. Press Esc to cancel or Backspace to remove the hotkey.", get_theme().body_font);
|
||||
const float text_max_width = std::max(title_text.get_bounds().size.x, std::max(hotkey_text.get_bounds().size.x, description_text.get_bounds().size.x));
|
||||
|
||||
const float padding_horizontal = int(get_theme().window_height * 0.01f);
|
||||
@@ -470,6 +470,13 @@ namespace gsr {
|
||||
if(event.key.code == mgl::Keyboard::Escape)
|
||||
return false;
|
||||
|
||||
if(event.key.code == mgl::Keyboard::Backspace) {
|
||||
configure_config_hotkey = {mgl::Keyboard::Unknown, 0};
|
||||
configure_hotkey_button->set_text("");
|
||||
configure_hotkey_stop_and_save();
|
||||
return false;
|
||||
}
|
||||
|
||||
if(mgl::Keyboard::key_is_modifier(event.key.code)) {
|
||||
configure_config_hotkey.modifiers |= mgl_modifier_to_hotkey_modifier(event.key.code);
|
||||
configure_hotkey_button->set_text(configure_config_hotkey.to_string());
|
||||
@@ -612,10 +619,12 @@ namespace gsr {
|
||||
ConfigHotkey *config_hotkey = configure_hotkey_get_config_by_active_type();
|
||||
if(config_hotkey_button && config_hotkey) {
|
||||
bool hotkey_used_by_another_action = false;
|
||||
for_each_config_hotkey([&](ConfigHotkey *config_hotkey_item) {
|
||||
if(config_hotkey_item != config_hotkey && *config_hotkey_item == configure_config_hotkey)
|
||||
hotkey_used_by_another_action = true;
|
||||
});
|
||||
if(configure_config_hotkey.key != mgl::Keyboard::Unknown) {
|
||||
for_each_config_hotkey([&](ConfigHotkey *config_hotkey_item) {
|
||||
if(config_hotkey_item != config_hotkey && *config_hotkey_item == configure_config_hotkey)
|
||||
hotkey_used_by_another_action = true;
|
||||
});
|
||||
}
|
||||
|
||||
if(hotkey_used_by_another_action) {
|
||||
const std::string error_msg = "The hotkey \"" + configure_config_hotkey.to_string() + " is already used for something else";
|
||||
|
||||
@@ -191,8 +191,10 @@ namespace gsr {
|
||||
|
||||
std::unique_ptr<ComboBox> ScreenshotSettingsPage::create_image_format_box() {
|
||||
auto box = std::make_unique<ComboBox>(&get_theme().body_font);
|
||||
box->add_item("jpg", "jpg");
|
||||
box->add_item("png", "png");
|
||||
if(gsr_info->supported_image_formats.jpeg)
|
||||
box->add_item("jpg", "jpg");
|
||||
if(gsr_info->supported_image_formats.png)
|
||||
box->add_item("png", "png");
|
||||
image_format_box_ptr = box.get();
|
||||
return box;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user