mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-03-31 09:17:04 +09:00
Add hotkeys for replay and streaming, finish everything
This commit is contained in:
2
TODO
2
TODO
@@ -55,3 +55,5 @@ Look at /home/dec05eba/git/global-hotkeys for hotkeys.
|
|||||||
Show navigation breadcrumbs for settings and deeper navigation (such as selecting a directory to save videos).
|
Show navigation breadcrumbs for settings and deeper navigation (such as selecting a directory to save videos).
|
||||||
|
|
||||||
If recording stops because of an error then the ui wont be running and we wont get a notification that recording failed.
|
If recording stops because of an error then the ui wont be running and we wont get a notification that recording failed.
|
||||||
|
|
||||||
|
Add option to hide stream key like a password input.
|
||||||
BIN
images/save.png
Normal file
BIN
images/save.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 614 B |
@@ -7,6 +7,8 @@
|
|||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
namespace gsr {
|
namespace gsr {
|
||||||
|
struct GsrInfo;
|
||||||
|
|
||||||
struct ConfigHotkey {
|
struct ConfigHotkey {
|
||||||
int64_t keysym = 0;
|
int64_t keysym = 0;
|
||||||
uint32_t modifiers = 0;
|
uint32_t modifiers = 0;
|
||||||
@@ -86,7 +88,7 @@ namespace gsr {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct Config {
|
struct Config {
|
||||||
Config();
|
Config(const GsrInfo &gsr_info);
|
||||||
|
|
||||||
MainConfig main_config;
|
MainConfig main_config;
|
||||||
StreamingConfig streaming_config;
|
StreamingConfig streaming_config;
|
||||||
@@ -94,6 +96,6 @@ namespace gsr {
|
|||||||
ReplayConfig replay_config;
|
ReplayConfig replay_config;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::optional<Config> read_config();
|
std::optional<Config> read_config(const GsrInfo &gsr_info);
|
||||||
void save_config(Config &config);
|
void save_config(Config &config);
|
||||||
}
|
}
|
||||||
@@ -45,6 +45,9 @@ namespace gsr {
|
|||||||
void toggle_show();
|
void toggle_show();
|
||||||
void toggle_record();
|
void toggle_record();
|
||||||
void toggle_pause();
|
void toggle_pause();
|
||||||
|
void toggle_stream();
|
||||||
|
void toggle_replay();
|
||||||
|
void save_replay();
|
||||||
void show_notification(const char *str, double timeout_seconds, mgl::Color icon_color, mgl::Color bg_color, NotificationType notification_type);
|
void show_notification(const char *str, double timeout_seconds, mgl::Color icon_color, mgl::Color bg_color, NotificationType notification_type);
|
||||||
bool is_open() const;
|
bool is_open() const;
|
||||||
private:
|
private:
|
||||||
@@ -59,9 +62,16 @@ namespace gsr {
|
|||||||
void update_ui_recording_started();
|
void update_ui_recording_started();
|
||||||
void update_ui_recording_stopped();
|
void update_ui_recording_stopped();
|
||||||
|
|
||||||
void on_press_start_replay(const std::string &id);
|
void update_ui_streaming_started();
|
||||||
void on_press_start_record(const std::string &id);
|
void update_ui_streaming_stopped();
|
||||||
void on_press_start_stream(const std::string &id);
|
|
||||||
|
void update_ui_replay_started();
|
||||||
|
void update_ui_replay_stopped();
|
||||||
|
|
||||||
|
void on_press_save_replay();
|
||||||
|
void on_press_start_replay();
|
||||||
|
void on_press_start_record();
|
||||||
|
void on_press_start_stream();
|
||||||
bool update_compositor_texture(const mgl_monitor *monitor);
|
bool update_compositor_texture(const mgl_monitor *monitor);
|
||||||
private:
|
private:
|
||||||
using KeyBindingCallback = std::function<void()>;
|
using KeyBindingCallback = std::function<void()>;
|
||||||
@@ -92,7 +102,7 @@ namespace gsr {
|
|||||||
uint64_t default_cursor = 0;
|
uint64_t default_cursor = 0;
|
||||||
pid_t gpu_screen_recorder_process = -1;
|
pid_t gpu_screen_recorder_process = -1;
|
||||||
pid_t notification_process = -1;
|
pid_t notification_process = -1;
|
||||||
std::optional<Config> config;
|
Config config;
|
||||||
DropdownButton *replay_dropdown_button_ptr = nullptr;
|
DropdownButton *replay_dropdown_button_ptr = nullptr;
|
||||||
DropdownButton *record_dropdown_button_ptr = nullptr;
|
DropdownButton *record_dropdown_button_ptr = nullptr;
|
||||||
DropdownButton *stream_dropdown_button_ptr = nullptr;
|
DropdownButton *stream_dropdown_button_ptr = nullptr;
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ namespace gsr {
|
|||||||
mgl::Texture play_texture;
|
mgl::Texture play_texture;
|
||||||
mgl::Texture stop_texture;
|
mgl::Texture stop_texture;
|
||||||
mgl::Texture pause_texture;
|
mgl::Texture pause_texture;
|
||||||
|
mgl::Texture save_texture;
|
||||||
|
|
||||||
double double_click_timeout_seconds = 0.4;
|
double double_click_timeout_seconds = 0.4;
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace gsr {
|
|||||||
STREAM
|
STREAM
|
||||||
};
|
};
|
||||||
|
|
||||||
SettingsPage(Type type, const GsrInfo &gsr_info, std::vector<AudioDevice> audio_devices, std::optional<Config> &config, PageStack *page_stack);
|
SettingsPage(Type type, const GsrInfo &gsr_info, std::vector<AudioDevice> audio_devices, Config &config, PageStack *page_stack);
|
||||||
SettingsPage(const SettingsPage&) = delete;
|
SettingsPage(const SettingsPage&) = delete;
|
||||||
SettingsPage& operator=(const SettingsPage&) = delete;
|
SettingsPage& operator=(const SettingsPage&) = delete;
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ namespace gsr {
|
|||||||
void save_stream();
|
void save_stream();
|
||||||
private:
|
private:
|
||||||
Type type;
|
Type type;
|
||||||
std::optional<Config> &config;
|
Config &config;
|
||||||
std::vector<AudioDevice> audio_devices;
|
std::vector<AudioDevice> audio_devices;
|
||||||
|
|
||||||
GsrPage *content_page_ptr = nullptr;
|
GsrPage *content_page_ptr = nullptr;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "../include/Config.hpp"
|
#include "../include/Config.hpp"
|
||||||
#include "../include/Utils.hpp"
|
#include "../include/Utils.hpp"
|
||||||
|
#include "../include/GsrInfo.hpp"
|
||||||
#include <variant>
|
#include <variant>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
@@ -12,11 +13,23 @@
|
|||||||
#define CONFIG_FILE_VERSION 1
|
#define CONFIG_FILE_VERSION 1
|
||||||
|
|
||||||
namespace gsr {
|
namespace gsr {
|
||||||
Config::Config() {
|
Config::Config(const GsrInfo &gsr_info) {
|
||||||
const std::string default_save_directory = get_videos_dir();
|
const std::string default_save_directory = get_videos_dir();
|
||||||
|
|
||||||
streaming_config.record_options.video_quality = "custom";
|
streaming_config.record_options.video_quality = "custom";
|
||||||
|
streaming_config.record_options.audio_tracks.push_back("default_output");
|
||||||
|
|
||||||
record_config.save_directory = default_save_directory;
|
record_config.save_directory = default_save_directory;
|
||||||
|
record_config.record_options.audio_tracks.push_back("default_output");
|
||||||
|
|
||||||
replay_config.save_directory = default_save_directory;
|
replay_config.save_directory = default_save_directory;
|
||||||
|
replay_config.record_options.audio_tracks.push_back("default_output");
|
||||||
|
|
||||||
|
if(!gsr_info.supported_capture_options.monitors.empty()) {
|
||||||
|
streaming_config.record_options.record_area_option = gsr_info.supported_capture_options.monitors.front().name;
|
||||||
|
record_config.record_options.record_area_option = gsr_info.supported_capture_options.monitors.front().name;
|
||||||
|
replay_config.record_options.record_area_option = gsr_info.supported_capture_options.monitors.front().name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::optional<KeyValue> parse_key_value(std::string_view line) {
|
static std::optional<KeyValue> parse_key_value(std::string_view line) {
|
||||||
@@ -117,7 +130,7 @@ namespace gsr {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<Config> read_config() {
|
std::optional<Config> read_config(const GsrInfo &gsr_info) {
|
||||||
std::optional<Config> config;
|
std::optional<Config> config;
|
||||||
|
|
||||||
const std::string config_path = get_config_dir() + "/config_ui";
|
const std::string config_path = get_config_dir() + "/config_ui";
|
||||||
@@ -127,7 +140,11 @@ namespace gsr {
|
|||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
config = Config();
|
config = Config(gsr_info);
|
||||||
|
config->streaming_config.record_options.audio_tracks.clear();
|
||||||
|
config->record_config.record_options.audio_tracks.clear();
|
||||||
|
config->replay_config.record_options.audio_tracks.clear();
|
||||||
|
|
||||||
auto config_options = get_config_options(config.value());
|
auto config_options = get_config_options(config.value());
|
||||||
|
|
||||||
string_split_char(file_content, '\n', [&](std::string_view line) {
|
string_split_char(file_content, '\n', [&](std::string_view line) {
|
||||||
|
|||||||
519
src/Overlay.cpp
519
src/Overlay.cpp
@@ -187,14 +187,15 @@ namespace gsr {
|
|||||||
Overlay::Overlay(mgl::Window &window, std::string resources_path, GsrInfo gsr_info, egl_functions egl_funcs, mgl::Color bg_color) :
|
Overlay::Overlay(mgl::Window &window, std::string resources_path, GsrInfo gsr_info, egl_functions egl_funcs, mgl::Color bg_color) :
|
||||||
window(window),
|
window(window),
|
||||||
resources_path(std::move(resources_path)),
|
resources_path(std::move(resources_path)),
|
||||||
gsr_info(std::move(gsr_info)),
|
gsr_info(gsr_info),
|
||||||
egl_funcs(egl_funcs),
|
egl_funcs(egl_funcs),
|
||||||
bg_color(bg_color),
|
bg_color(bg_color),
|
||||||
bg_screenshot_overlay({0.0f, 0.0f}),
|
bg_screenshot_overlay({0.0f, 0.0f}),
|
||||||
top_bar_background({0.0f, 0.0f}),
|
top_bar_background({0.0f, 0.0f}),
|
||||||
top_bar_text("GPU Screen Recorder", get_theme().top_bar_font),
|
top_bar_text("GPU Screen Recorder", get_theme().top_bar_font),
|
||||||
logo_sprite(&get_theme().logo_texture),
|
logo_sprite(&get_theme().logo_texture),
|
||||||
close_button_widget({0.0f, 0.0f})
|
close_button_widget({0.0f, 0.0f}),
|
||||||
|
config(gsr_info)
|
||||||
{
|
{
|
||||||
memset(&window_texture, 0, sizeof(window_texture));
|
memset(&window_texture, 0, sizeof(window_texture));
|
||||||
|
|
||||||
@@ -206,6 +207,10 @@ namespace gsr {
|
|||||||
key_bindings[0].callback = [this]() {
|
key_bindings[0].callback = [this]() {
|
||||||
page_stack.pop();
|
page_stack.pop();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::optional<Config> new_config = read_config(gsr_info);
|
||||||
|
if(new_config)
|
||||||
|
config = std::move(new_config.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
Overlay::~Overlay() {
|
Overlay::~Overlay() {
|
||||||
@@ -231,7 +236,7 @@ namespace gsr {
|
|||||||
gpu_screen_recorder_process = -1;
|
gpu_screen_recorder_process = -1;
|
||||||
|
|
||||||
// TODO: Show this with a slight delay to make sure it doesn't show up in the video
|
// TODO: Show this with a slight delay to make sure it doesn't show up in the video
|
||||||
if(config->record_config.show_video_saved_notifications)
|
if(recording_status == RecordingStatus::RECORD && config.record_config.show_video_saved_notifications)
|
||||||
show_notification("Recording has been saved", 3.0, mgl::Color(255, 255, 255), get_theme().tint_color, NotificationType::RECORD);
|
show_notification("Recording has been saved", 3.0, mgl::Color(255, 255, 255), get_theme().tint_color, NotificationType::RECORD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -312,7 +317,6 @@ namespace gsr {
|
|||||||
update_compositor_texture(focused_monitor);
|
update_compositor_texture(focused_monitor);
|
||||||
|
|
||||||
audio_devices = get_audio_devices();
|
audio_devices = get_audio_devices();
|
||||||
config = read_config();
|
|
||||||
|
|
||||||
bg_screenshot_overlay = mgl::Rectangle(mgl::vec2f(get_theme().window_width, get_theme().window_height));
|
bg_screenshot_overlay = mgl::Rectangle(mgl::vec2f(get_theme().window_width, get_theme().window_height));
|
||||||
top_bar_background = mgl::Rectangle(mgl::vec2f(get_theme().window_width, get_theme().window_height*0.06f).floor());
|
top_bar_background = mgl::Rectangle(mgl::vec2f(get_theme().window_width, get_theme().window_height*0.06f).floor());
|
||||||
@@ -351,9 +355,20 @@ namespace gsr {
|
|||||||
mgl::vec2f(button_width, button_height));
|
mgl::vec2f(button_width, button_height));
|
||||||
replay_dropdown_button_ptr = button.get();
|
replay_dropdown_button_ptr = button.get();
|
||||||
button->add_item("Turn on", "start", "Alt+Shift+F10");
|
button->add_item("Turn on", "start", "Alt+Shift+F10");
|
||||||
|
button->add_item("Save", "save", "Alt+F10");
|
||||||
button->add_item("Settings", "settings");
|
button->add_item("Settings", "settings");
|
||||||
button->set_item_icon("start", &get_theme().play_texture);
|
button->set_item_icon("start", &get_theme().play_texture);
|
||||||
button->on_click = std::bind(&Overlay::on_press_start_replay, this, std::placeholders::_1);
|
button->set_item_icon("save", &get_theme().save_texture);
|
||||||
|
button->on_click = [this](const std::string &id) {
|
||||||
|
if(id == "settings") {
|
||||||
|
auto replay_settings_page = std::make_unique<SettingsPage>(SettingsPage::Type::REPLAY, gsr_info, audio_devices, config, &page_stack);
|
||||||
|
page_stack.push(std::move(replay_settings_page));
|
||||||
|
} else if(id == "save") {
|
||||||
|
on_press_save_replay();
|
||||||
|
} else if(id == "start") {
|
||||||
|
on_press_start_replay();
|
||||||
|
}
|
||||||
|
};
|
||||||
main_buttons_list->add_widget(std::move(button));
|
main_buttons_list->add_widget(std::move(button));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@@ -365,7 +380,16 @@ namespace gsr {
|
|||||||
button->add_item("Settings", "settings");
|
button->add_item("Settings", "settings");
|
||||||
button->set_item_icon("start", &get_theme().play_texture);
|
button->set_item_icon("start", &get_theme().play_texture);
|
||||||
button->set_item_icon("pause", &get_theme().pause_texture);
|
button->set_item_icon("pause", &get_theme().pause_texture);
|
||||||
button->on_click = std::bind(&Overlay::on_press_start_record, this, std::placeholders::_1);
|
button->on_click = [this](const std::string &id) {
|
||||||
|
if(id == "settings") {
|
||||||
|
auto record_settings_page = std::make_unique<SettingsPage>(SettingsPage::Type::RECORD, gsr_info, audio_devices, config, &page_stack);
|
||||||
|
page_stack.push(std::move(record_settings_page));
|
||||||
|
} else if(id == "pause") {
|
||||||
|
toggle_pause();
|
||||||
|
} else if(id == "start") {
|
||||||
|
on_press_start_record();
|
||||||
|
}
|
||||||
|
};
|
||||||
main_buttons_list->add_widget(std::move(button));
|
main_buttons_list->add_widget(std::move(button));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@@ -375,7 +399,14 @@ namespace gsr {
|
|||||||
button->add_item("Start", "start", "Alt+F8");
|
button->add_item("Start", "start", "Alt+F8");
|
||||||
button->add_item("Settings", "settings");
|
button->add_item("Settings", "settings");
|
||||||
button->set_item_icon("start", &get_theme().play_texture);
|
button->set_item_icon("start", &get_theme().play_texture);
|
||||||
button->on_click = std::bind(&Overlay::on_press_start_stream, this, std::placeholders::_1);
|
button->on_click = [this](const std::string &id) {
|
||||||
|
if(id == "settings") {
|
||||||
|
auto stream_settings_page = std::make_unique<SettingsPage>(SettingsPage::Type::STREAM, gsr_info, audio_devices, config, &page_stack);
|
||||||
|
page_stack.push(std::move(stream_settings_page));
|
||||||
|
} else if(id == "start") {
|
||||||
|
on_press_start_stream();
|
||||||
|
}
|
||||||
|
};
|
||||||
main_buttons_list->add_widget(std::move(button));
|
main_buttons_list->add_widget(std::move(button));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -427,11 +458,11 @@ namespace gsr {
|
|||||||
// TODO: Hmm, these dont work in owlboy. Maybe owlboy uses xi2 and that breaks this (does it?).
|
// TODO: Hmm, these dont work in owlboy. Maybe owlboy uses xi2 and that breaks this (does it?).
|
||||||
// Remove these grabs when debugging with a debugger, or your X11 session will appear frozen
|
// Remove these grabs when debugging with a debugger, or your X11 session will appear frozen
|
||||||
|
|
||||||
XGrabPointer(display, window.get_system_handle(), True,
|
// XGrabPointer(display, window.get_system_handle(), True,
|
||||||
ButtonPressMask | ButtonReleaseMask | PointerMotionMask |
|
// ButtonPressMask | ButtonReleaseMask | PointerMotionMask |
|
||||||
Button1MotionMask | Button2MotionMask | Button3MotionMask | Button4MotionMask | Button5MotionMask |
|
// Button1MotionMask | Button2MotionMask | Button3MotionMask | Button4MotionMask | Button5MotionMask |
|
||||||
ButtonMotionMask,
|
// ButtonMotionMask,
|
||||||
GrabModeAsync, GrabModeAsync, None, default_cursor, CurrentTime);
|
// GrabModeAsync, GrabModeAsync, None, default_cursor, CurrentTime);
|
||||||
// TODO: This breaks global hotkeys
|
// TODO: This breaks global hotkeys
|
||||||
//XGrabKeyboard(display, window.get_system_handle(), True, GrabModeAsync, GrabModeAsync, CurrentTime);
|
//XGrabKeyboard(display, window.get_system_handle(), True, GrabModeAsync, GrabModeAsync, CurrentTime);
|
||||||
|
|
||||||
@@ -448,8 +479,21 @@ namespace gsr {
|
|||||||
event.mouse_move.y = window.get_mouse_position().y;
|
event.mouse_move.y = window.get_mouse_position().y;
|
||||||
on_event(event, window);
|
on_event(event, window);
|
||||||
|
|
||||||
if(gpu_screen_recorder_process > 0 && recording_status == RecordingStatus::RECORD)
|
if(gpu_screen_recorder_process > 0) {
|
||||||
update_ui_recording_started();
|
switch(recording_status) {
|
||||||
|
case RecordingStatus::NONE:
|
||||||
|
break;
|
||||||
|
case RecordingStatus::REPLAY:
|
||||||
|
update_ui_replay_started();
|
||||||
|
break;
|
||||||
|
case RecordingStatus::RECORD:
|
||||||
|
update_ui_recording_started();
|
||||||
|
break;
|
||||||
|
case RecordingStatus::STREAM:
|
||||||
|
update_ui_streaming_started();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(paused)
|
if(paused)
|
||||||
update_ui_recording_paused();
|
update_ui_recording_paused();
|
||||||
@@ -481,7 +525,7 @@ namespace gsr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Overlay::toggle_record() {
|
void Overlay::toggle_record() {
|
||||||
on_press_start_record("start");
|
on_press_start_record();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overlay::toggle_pause() {
|
void Overlay::toggle_pause() {
|
||||||
@@ -500,6 +544,18 @@ namespace gsr {
|
|||||||
paused = !paused;
|
paused = !paused;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Overlay::toggle_stream() {
|
||||||
|
on_press_start_stream();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Overlay::toggle_replay() {
|
||||||
|
on_press_start_replay();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Overlay::save_replay() {
|
||||||
|
on_press_save_replay();
|
||||||
|
}
|
||||||
|
|
||||||
static const char* notification_type_to_string(NotificationType notification_type) {
|
static const char* notification_type_to_string(NotificationType notification_type) {
|
||||||
switch(notification_type) {
|
switch(notification_type) {
|
||||||
case NotificationType::NONE: return nullptr;
|
case NotificationType::NONE: return nullptr;
|
||||||
@@ -533,7 +589,7 @@ namespace gsr {
|
|||||||
if(notification_process > 0) {
|
if(notification_process > 0) {
|
||||||
kill(notification_process, SIGKILL);
|
kill(notification_process, SIGKILL);
|
||||||
int status = 0;
|
int status = 0;
|
||||||
waitpid(gpu_screen_recorder_process, &status, 0);
|
waitpid(notification_process, &status, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
notification_process = exec_program(notification_args);
|
notification_process = exec_program(notification_args);
|
||||||
@@ -548,7 +604,7 @@ namespace gsr {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
int status;
|
int status;
|
||||||
if(waitpid(gpu_screen_recorder_process, &status, WNOHANG) == 0) {
|
if(waitpid(notification_process, &status, WNOHANG) == 0) {
|
||||||
// Still running
|
// Still running
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -583,17 +639,46 @@ namespace gsr {
|
|||||||
exit_code = WEXITSTATUS(status);
|
exit_code = WEXITSTATUS(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch(recording_status) {
|
||||||
|
case RecordingStatus::NONE:
|
||||||
|
break;
|
||||||
|
case RecordingStatus::REPLAY: {
|
||||||
|
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_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", 3.0, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::REPLAY);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RecordingStatus::RECORD: {
|
||||||
|
update_ui_recording_stopped();
|
||||||
|
if(exit_code == 0) {
|
||||||
|
if(config.record_config.show_video_saved_notifications)
|
||||||
|
show_notification("Recording has been saved", 3.0, mgl::Color(255, 255, 255), get_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", 3.0, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::RECORD);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RecordingStatus::STREAM: {
|
||||||
|
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_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", 3.0, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::STREAM);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gpu_screen_recorder_process = -1;
|
gpu_screen_recorder_process = -1;
|
||||||
recording_status = RecordingStatus::NONE;
|
recording_status = RecordingStatus::NONE;
|
||||||
update_ui_recording_stopped();
|
|
||||||
|
|
||||||
if(exit_code == 0) {
|
|
||||||
if(config->record_config.show_video_saved_notifications)
|
|
||||||
show_notification("Recording has been saved", 3.0, mgl::Color(255, 255, 255), get_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", 3.0, mgl::Color(255, 0, 0), mgl::Color(255, 0, 0), NotificationType::RECORD);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overlay::update_ui_recording_paused() {
|
void Overlay::update_ui_recording_paused() {
|
||||||
@@ -634,25 +719,44 @@ namespace gsr {
|
|||||||
record_dropdown_button_ptr->set_item_icon("start", &get_theme().play_texture);
|
record_dropdown_button_ptr->set_item_icon("start", &get_theme().play_texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overlay::on_press_start_replay(const std::string &id) {
|
void Overlay::update_ui_streaming_started() {
|
||||||
if(id == "settings") {
|
if(!visible)
|
||||||
auto replay_settings_page = std::make_unique<SettingsPage>(SettingsPage::Type::REPLAY, gsr_info, audio_devices, config, &page_stack);
|
|
||||||
page_stack.push(std::move(replay_settings_page));
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
/*
|
|
||||||
char window_to_record_str[32];
|
|
||||||
snprintf(window_to_record_str, sizeof(window_to_record_str), "%ld", target_window);
|
|
||||||
|
|
||||||
const char *args[] = {
|
stream_dropdown_button_ptr->set_item_label("start", "Stop");
|
||||||
"gpu-screen-recorder", "-w", window_to_record_str,
|
stream_dropdown_button_ptr->set_activated(true);
|
||||||
"-c", "mp4",
|
stream_dropdown_button_ptr->set_description("Streaming");
|
||||||
"-f", "60",
|
stream_dropdown_button_ptr->set_item_icon("start", &get_theme().stop_texture);
|
||||||
"-o", "/home/dec05eba/Videos/gpu-screen-recorder.mp4",
|
}
|
||||||
nullptr
|
|
||||||
};
|
void Overlay::update_ui_streaming_stopped() {
|
||||||
exec_program_daemonized(args);
|
if(!visible)
|
||||||
*/
|
return;
|
||||||
|
|
||||||
|
stream_dropdown_button_ptr->set_item_label("start", "Start");
|
||||||
|
stream_dropdown_button_ptr->set_activated(false);
|
||||||
|
stream_dropdown_button_ptr->set_description("Not streaming");
|
||||||
|
stream_dropdown_button_ptr->set_item_icon("start", &get_theme().play_texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Overlay::update_ui_replay_started() {
|
||||||
|
if(!visible)
|
||||||
|
return;
|
||||||
|
|
||||||
|
replay_dropdown_button_ptr->set_item_label("start", "Turn off");
|
||||||
|
replay_dropdown_button_ptr->set_activated(true);
|
||||||
|
replay_dropdown_button_ptr->set_description("On");
|
||||||
|
replay_dropdown_button_ptr->set_item_icon("start", &get_theme().stop_texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Overlay::update_ui_replay_stopped() {
|
||||||
|
if(!visible)
|
||||||
|
return;
|
||||||
|
|
||||||
|
replay_dropdown_button_ptr->set_item_label("start", "Turn on");
|
||||||
|
replay_dropdown_button_ptr->set_activated(false);
|
||||||
|
replay_dropdown_button_ptr->set_description("Off");
|
||||||
|
replay_dropdown_button_ptr->set_item_icon("start", &get_theme().play_texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string get_date_str() {
|
static std::string get_date_str() {
|
||||||
@@ -684,25 +788,138 @@ namespace gsr {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overlay::on_press_start_record(const std::string &id) {
|
void Overlay::on_press_save_replay() {
|
||||||
|
if(recording_status != RecordingStatus::REPLAY || gpu_screen_recorder_process <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
kill(gpu_screen_recorder_process, SIGUSR1);
|
||||||
|
if(config.replay_config.show_replay_saved_notifications)
|
||||||
|
show_notification("Replay saved", 3.0, mgl::Color(255, 255, 255), get_theme().tint_color, NotificationType::REPLAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Overlay::on_press_start_replay() {
|
||||||
|
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", 3.0, mgl::Color(255, 255, 255), get_theme().tint_color, NotificationType::RECORD);
|
||||||
|
return;
|
||||||
|
case RecordingStatus::STREAM:
|
||||||
|
show_notification("Unable to start replay when streaming.\nStop streaming before starting replay", 3.0, mgl::Color(255, 255, 255), get_theme().tint_color, NotificationType::STREAM);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
paused = false;
|
||||||
|
|
||||||
|
// window.close();
|
||||||
|
// usleep(1000 * 50); // 50 milliseconds
|
||||||
|
|
||||||
|
if(gpu_screen_recorder_process > 0) {
|
||||||
|
kill(gpu_screen_recorder_process, SIGINT);
|
||||||
|
int status;
|
||||||
|
if(waitpid(gpu_screen_recorder_process, &status, 0) == -1) {
|
||||||
|
perror("waitpid failed");
|
||||||
|
/* Ignore... */
|
||||||
|
}
|
||||||
|
|
||||||
|
gpu_screen_recorder_process = -1;
|
||||||
|
recording_status = RecordingStatus::NONE;
|
||||||
|
update_ui_replay_stopped();
|
||||||
|
|
||||||
|
// TODO: Show this with a slight delay to make sure it doesn't show up in the video
|
||||||
|
if(config.replay_config.show_replay_stopped_notifications)
|
||||||
|
show_notification("Replay stopped", 3.0, mgl::Color(255, 255, 255), get_theme().tint_color, NotificationType::REPLAY);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
audio_devices = get_audio_devices();
|
audio_devices = get_audio_devices();
|
||||||
|
|
||||||
if(id == "settings") {
|
// TODO: Validate input, fallback to valid values
|
||||||
auto record_settings_page = std::make_unique<SettingsPage>(SettingsPage::Type::RECORD, gsr_info, audio_devices, config, &page_stack);
|
const std::string fps = std::to_string(config.replay_config.record_options.fps);
|
||||||
page_stack.push(std::move(record_settings_page));
|
const std::string video_bitrate = std::to_string(config.replay_config.record_options.video_bitrate);
|
||||||
return;
|
const std::string output_file = config.replay_config.save_directory + "/Video_" + get_date_str() + "." + container_to_file_extension(config.replay_config.container.c_str());
|
||||||
|
const std::string audio_tracks_merged = merge_audio_tracks(config.replay_config.record_options.audio_tracks);
|
||||||
|
const std::string framerate_mode = config.replay_config.record_options.framerate_mode == "auto" ? "vfr" : config.replay_config.record_options.framerate_mode;
|
||||||
|
|
||||||
|
char region[64];
|
||||||
|
snprintf(region, sizeof(region), "%dx%d", (int)config.replay_config.record_options.record_area_width, (int)config.replay_config.record_options.record_area_height);
|
||||||
|
|
||||||
|
if(config.replay_config.record_options.record_area_option != "focused" && config.replay_config.record_options.change_video_resolution)
|
||||||
|
snprintf(region, sizeof(region), "%dx%d", (int)config.replay_config.record_options.video_width, (int)config.replay_config.record_options.video_height);
|
||||||
|
|
||||||
|
std::vector<const char*> args = {
|
||||||
|
"gpu-screen-recorder", "-w", config.replay_config.record_options.record_area_option.c_str(),
|
||||||
|
"-c", config.replay_config.container.c_str(),
|
||||||
|
"-ac", config.replay_config.record_options.audio_codec.c_str(),
|
||||||
|
"-cursor", config.replay_config.record_options.record_cursor ? "yes" : "no",
|
||||||
|
"-cr", config.replay_config.record_options.color_range.c_str(),
|
||||||
|
"-fm", framerate_mode.c_str(),
|
||||||
|
"-k", config.replay_config.record_options.video_codec.c_str(),
|
||||||
|
"-f", fps.c_str(),
|
||||||
|
"-o", output_file.c_str()
|
||||||
|
};
|
||||||
|
|
||||||
|
if(config.replay_config.record_options.video_quality == "custom") {
|
||||||
|
args.push_back("-bm");
|
||||||
|
args.push_back("cbr");
|
||||||
|
args.push_back("-q");
|
||||||
|
args.push_back(video_bitrate.c_str());
|
||||||
|
} else {
|
||||||
|
args.push_back("-q");
|
||||||
|
args.push_back(config.replay_config.record_options.video_quality.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(id == "pause") {
|
if(config.replay_config.record_options.record_area_option == "focused" || config.replay_config.record_options.change_video_resolution) {
|
||||||
toggle_pause();
|
args.push_back("-s");
|
||||||
return;
|
args.push_back(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(id != "start")
|
if(config.replay_config.record_options.merge_audio_tracks) {
|
||||||
return;
|
args.push_back("-a");
|
||||||
|
args.push_back(audio_tracks_merged.c_str());
|
||||||
|
} else {
|
||||||
|
for(const std::string &audio_track : config.replay_config.record_options.audio_tracks) {
|
||||||
|
args.push_back("-a");
|
||||||
|
args.push_back(audio_track.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!config)
|
args.push_back(nullptr);
|
||||||
config = Config();
|
|
||||||
|
gpu_screen_recorder_process = exec_program(args.data());
|
||||||
|
if(gpu_screen_recorder_process == -1) {
|
||||||
|
// TODO: Show notification failed to start
|
||||||
|
} else {
|
||||||
|
recording_status = RecordingStatus::REPLAY;
|
||||||
|
update_ui_replay_started();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Start recording after this notification has disappeared to make sure it doesn't show up in the video.
|
||||||
|
// Make clear to the user that the recording starts after the notification is gone.
|
||||||
|
// Maybe have the option in notification to show timer until its getting hidden, then the notification can say:
|
||||||
|
// Starting recording in 3...
|
||||||
|
// 2...
|
||||||
|
// 1...
|
||||||
|
// TODO: Do not run this is a daemon. Instead get the pid and when launching another notification close the current notification
|
||||||
|
// 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.replay_config.show_replay_started_notifications)
|
||||||
|
show_notification("Replay has started", 3.0, get_theme().tint_color, get_theme().tint_color, NotificationType::REPLAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Overlay::on_press_start_record() {
|
||||||
|
switch(recording_status) {
|
||||||
|
case RecordingStatus::NONE:
|
||||||
|
case RecordingStatus::RECORD:
|
||||||
|
break;
|
||||||
|
case RecordingStatus::REPLAY:
|
||||||
|
show_notification("Unable to start recording when replay is turned on.\nTurn off replay before starting recording", 3.0, mgl::Color(255, 255, 255), get_theme().tint_color, NotificationType::REPLAY);
|
||||||
|
return;
|
||||||
|
case RecordingStatus::STREAM:
|
||||||
|
show_notification("Unable to start recording when streaming.\nStop streaming before starting recording", 3.0, mgl::Color(255, 255, 255), get_theme().tint_color, NotificationType::STREAM);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
paused = false;
|
paused = false;
|
||||||
|
|
||||||
@@ -725,56 +942,58 @@ namespace gsr {
|
|||||||
update_ui_recording_stopped();
|
update_ui_recording_stopped();
|
||||||
|
|
||||||
// TODO: Show this with a slight delay to make sure it doesn't show up in the video
|
// TODO: Show this with a slight delay to make sure it doesn't show up in the video
|
||||||
if(config->record_config.show_video_saved_notifications)
|
if(config.record_config.show_video_saved_notifications)
|
||||||
show_notification("Recording has been saved", 3.0, mgl::Color(255, 255, 255), get_theme().tint_color, NotificationType::RECORD);
|
show_notification("Recording has been saved", 3.0, mgl::Color(255, 255, 255), get_theme().tint_color, NotificationType::RECORD);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
audio_devices = get_audio_devices();
|
||||||
|
|
||||||
// TODO: Validate input, fallback to valid values
|
// TODO: Validate input, fallback to valid values
|
||||||
const std::string fps = std::to_string(config->record_config.record_options.fps);
|
const std::string fps = std::to_string(config.record_config.record_options.fps);
|
||||||
const std::string video_bitrate = std::to_string(config->record_config.record_options.video_bitrate);
|
const std::string video_bitrate = std::to_string(config.record_config.record_options.video_bitrate);
|
||||||
const std::string output_file = config->record_config.save_directory + "/Video_" + get_date_str() + "." + container_to_file_extension(config->record_config.container.c_str());
|
const std::string output_file = config.record_config.save_directory + "/Video_" + get_date_str() + "." + container_to_file_extension(config.record_config.container.c_str());
|
||||||
const std::string audio_tracks_merged = merge_audio_tracks(config->record_config.record_options.audio_tracks);
|
const std::string audio_tracks_merged = merge_audio_tracks(config.record_config.record_options.audio_tracks);
|
||||||
const std::string framerate_mode = config->record_config.record_options.framerate_mode == "auto" ? "vfr" : config->record_config.record_options.framerate_mode;
|
const std::string framerate_mode = config.record_config.record_options.framerate_mode == "auto" ? "vfr" : config.record_config.record_options.framerate_mode;
|
||||||
|
|
||||||
char region[64];
|
char region[64];
|
||||||
snprintf(region, sizeof(region), "%dx%d", (int)config->record_config.record_options.record_area_width, (int)config->record_config.record_options.record_area_height);
|
snprintf(region, sizeof(region), "%dx%d", (int)config.record_config.record_options.record_area_width, (int)config.record_config.record_options.record_area_height);
|
||||||
|
|
||||||
if(config->record_config.record_options.record_area_option != "focused" && config->record_config.record_options.change_video_resolution)
|
if(config.record_config.record_options.record_area_option != "focused" && config.record_config.record_options.change_video_resolution)
|
||||||
snprintf(region, sizeof(region), "%dx%d", (int)config->record_config.record_options.video_width, (int)config->record_config.record_options.video_height);
|
snprintf(region, sizeof(region), "%dx%d", (int)config.record_config.record_options.video_width, (int)config.record_config.record_options.video_height);
|
||||||
|
|
||||||
std::vector<const char*> args = {
|
std::vector<const char*> args = {
|
||||||
"gpu-screen-recorder", "-w", config->record_config.record_options.record_area_option.c_str(),
|
"gpu-screen-recorder", "-w", config.record_config.record_options.record_area_option.c_str(),
|
||||||
"-c", config->record_config.container.c_str(),
|
"-c", config.record_config.container.c_str(),
|
||||||
"-ac", config->record_config.record_options.audio_codec.c_str(),
|
"-ac", config.record_config.record_options.audio_codec.c_str(),
|
||||||
"-cursor", config->record_config.record_options.record_cursor ? "yes" : "no",
|
"-cursor", config.record_config.record_options.record_cursor ? "yes" : "no",
|
||||||
"-cr", config->record_config.record_options.color_range.c_str(),
|
"-cr", config.record_config.record_options.color_range.c_str(),
|
||||||
"-fm", framerate_mode.c_str(),
|
"-fm", framerate_mode.c_str(),
|
||||||
"-k", config->record_config.record_options.video_codec.c_str(),
|
"-k", config.record_config.record_options.video_codec.c_str(),
|
||||||
"-f", fps.c_str(),
|
"-f", fps.c_str(),
|
||||||
"-o", output_file.c_str()
|
"-o", output_file.c_str()
|
||||||
};
|
};
|
||||||
|
|
||||||
if(config->record_config.record_options.video_quality == "custom") {
|
if(config.record_config.record_options.video_quality == "custom") {
|
||||||
args.push_back("-bm");
|
args.push_back("-bm");
|
||||||
args.push_back("cbr");
|
args.push_back("cbr");
|
||||||
args.push_back("-q");
|
args.push_back("-q");
|
||||||
args.push_back(video_bitrate.c_str());
|
args.push_back(video_bitrate.c_str());
|
||||||
} else {
|
} else {
|
||||||
args.push_back("-q");
|
args.push_back("-q");
|
||||||
args.push_back(config->record_config.record_options.video_quality.c_str());
|
args.push_back(config.record_config.record_options.video_quality.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(config->record_config.record_options.record_area_option == "focused" || config->record_config.record_options.change_video_resolution) {
|
if(config.record_config.record_options.record_area_option == "focused" || config.record_config.record_options.change_video_resolution) {
|
||||||
args.push_back("-s");
|
args.push_back("-s");
|
||||||
args.push_back(region);
|
args.push_back(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(config->record_config.record_options.merge_audio_tracks) {
|
if(config.record_config.record_options.merge_audio_tracks) {
|
||||||
args.push_back("-a");
|
args.push_back("-a");
|
||||||
args.push_back(audio_tracks_merged.c_str());
|
args.push_back(audio_tracks_merged.c_str());
|
||||||
} else {
|
} else {
|
||||||
for(const std::string &audio_track : config->record_config.record_options.audio_tracks) {
|
for(const std::string &audio_track : config.record_config.record_options.audio_tracks) {
|
||||||
args.push_back("-a");
|
args.push_back("-a");
|
||||||
args.push_back(audio_track.c_str());
|
args.push_back(audio_track.c_str());
|
||||||
}
|
}
|
||||||
@@ -799,7 +1018,7 @@ namespace gsr {
|
|||||||
// TODO: Do not run this is a daemon. Instead get the pid and when launching another notification close the current notification
|
// TODO: Do not run this is a daemon. Instead get the pid and when launching another notification close the current notification
|
||||||
// program and start another one. This can also be used to check when the notification has finished by checking with waitpid NOWAIT
|
// 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.
|
// to see when the program has exit.
|
||||||
if(config->record_config.show_recording_started_notifications)
|
if(config.record_config.show_recording_started_notifications)
|
||||||
show_notification("Recording has started", 3.0, get_theme().tint_color, get_theme().tint_color, NotificationType::RECORD);
|
show_notification("Recording has started", 3.0, get_theme().tint_color, get_theme().tint_color, NotificationType::RECORD);
|
||||||
//exit(0);
|
//exit(0);
|
||||||
// window.set_visible(false);
|
// window.set_visible(false);
|
||||||
@@ -809,12 +1028,152 @@ namespace gsr {
|
|||||||
// "Recording has started" 3.0 ./images/record.png 76b900
|
// "Recording has started" 3.0 ./images/record.png 76b900
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overlay::on_press_start_stream(const std::string &id) {
|
static std::string streaming_get_url(const Config &config) {
|
||||||
if(id == "settings") {
|
std::string url;
|
||||||
auto stream_settings_page = std::make_unique<SettingsPage>(SettingsPage::Type::STREAM, gsr_info, audio_devices, config, &page_stack);
|
if(config.streaming_config.streaming_service == "twitch") {
|
||||||
page_stack.push(std::move(stream_settings_page));
|
url += "rtmp://live.twitch.tv/app/";
|
||||||
|
url += config.streaming_config.twitch.stream_key;
|
||||||
|
} else if(config.streaming_config.streaming_service == "youtube") {
|
||||||
|
url += "rtmp://a.rtmp.youtube.com/live2/";
|
||||||
|
url += config.streaming_config.youtube.stream_key;
|
||||||
|
} else if(config.streaming_config.streaming_service == "custom") {
|
||||||
|
url = config.streaming_config.custom.url;
|
||||||
|
if(url.size() >= 7 && strncmp(url.c_str(), "rtmp://", 7) == 0)
|
||||||
|
{}
|
||||||
|
else if(url.size() >= 8 && strncmp(url.c_str(), "rtmps://", 8) == 0)
|
||||||
|
{}
|
||||||
|
else if(url.size() >= 7 && strncmp(url.c_str(), "rtsp://", 7) == 0)
|
||||||
|
{}
|
||||||
|
else if(url.size() >= 6 && strncmp(url.c_str(), "srt://", 6) == 0)
|
||||||
|
{}
|
||||||
|
else if(url.size() >= 7 && strncmp(url.c_str(), "http://", 7) == 0)
|
||||||
|
{}
|
||||||
|
else if(url.size() >= 8 && strncmp(url.c_str(), "https://", 8) == 0)
|
||||||
|
{}
|
||||||
|
else if(url.size() >= 6 && strncmp(url.c_str(), "tcp://", 6) == 0)
|
||||||
|
{}
|
||||||
|
else if(url.size() >= 6 && strncmp(url.c_str(), "udp://", 6) == 0)
|
||||||
|
{}
|
||||||
|
else
|
||||||
|
url = "rtmp://" + url;
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Overlay::on_press_start_stream() {
|
||||||
|
switch(recording_status) {
|
||||||
|
case RecordingStatus::NONE:
|
||||||
|
case RecordingStatus::STREAM:
|
||||||
|
break;
|
||||||
|
case RecordingStatus::REPLAY:
|
||||||
|
show_notification("Unable to start streaming when replay is turned on.\nTurn off replay before starting streaming", 3.0, mgl::Color(255, 255, 255), get_theme().tint_color, NotificationType::REPLAY);
|
||||||
|
return;
|
||||||
|
case RecordingStatus::RECORD:
|
||||||
|
show_notification("Unable to start streaming when recording.\nStop recording before starting streaming", 3.0, mgl::Color(255, 255, 255), get_theme().tint_color, NotificationType::RECORD);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
paused = false;
|
||||||
|
|
||||||
|
// window.close();
|
||||||
|
// usleep(1000 * 50); // 50 milliseconds
|
||||||
|
|
||||||
|
if(gpu_screen_recorder_process > 0) {
|
||||||
|
kill(gpu_screen_recorder_process, SIGINT);
|
||||||
|
int status;
|
||||||
|
if(waitpid(gpu_screen_recorder_process, &status, 0) == -1) {
|
||||||
|
perror("waitpid failed");
|
||||||
|
/* Ignore... */
|
||||||
|
}
|
||||||
|
|
||||||
|
gpu_screen_recorder_process = -1;
|
||||||
|
recording_status = RecordingStatus::NONE;
|
||||||
|
update_ui_streaming_stopped();
|
||||||
|
|
||||||
|
// 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_theme().tint_color, NotificationType::STREAM);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
audio_devices = get_audio_devices();
|
||||||
|
|
||||||
|
// TODO: Validate input, fallback to valid values
|
||||||
|
const std::string fps = std::to_string(config.streaming_config.record_options.fps);
|
||||||
|
const std::string video_bitrate = std::to_string(config.streaming_config.record_options.video_bitrate);
|
||||||
|
const std::string audio_tracks_merged = merge_audio_tracks(config.streaming_config.record_options.audio_tracks);
|
||||||
|
const std::string framerate_mode = config.streaming_config.record_options.framerate_mode == "auto" ? "vfr" : config.streaming_config.record_options.framerate_mode;
|
||||||
|
|
||||||
|
std::string container = "flv";
|
||||||
|
if(config.streaming_config.streaming_service == "custom")
|
||||||
|
container = config.streaming_config.custom.container;
|
||||||
|
|
||||||
|
const std::string url = streaming_get_url(config);
|
||||||
|
|
||||||
|
char region[64];
|
||||||
|
snprintf(region, sizeof(region), "%dx%d", (int)config.streaming_config.record_options.record_area_width, (int)config.streaming_config.record_options.record_area_height);
|
||||||
|
|
||||||
|
if(config.record_config.record_options.record_area_option != "focused" && config.streaming_config.record_options.change_video_resolution)
|
||||||
|
snprintf(region, sizeof(region), "%dx%d", (int)config.streaming_config.record_options.video_width, (int)config.streaming_config.record_options.video_height);
|
||||||
|
|
||||||
|
std::vector<const char*> args = {
|
||||||
|
"gpu-screen-recorder", "-w", config.streaming_config.record_options.record_area_option.c_str(),
|
||||||
|
"-c", container.c_str(),
|
||||||
|
"-ac", config.streaming_config.record_options.audio_codec.c_str(),
|
||||||
|
"-cursor", config.streaming_config.record_options.record_cursor ? "yes" : "no",
|
||||||
|
"-cr", config.streaming_config.record_options.color_range.c_str(),
|
||||||
|
"-fm", framerate_mode.c_str(),
|
||||||
|
"-k", config.streaming_config.record_options.video_codec.c_str(),
|
||||||
|
"-f", fps.c_str(),
|
||||||
|
"-o", url.c_str()
|
||||||
|
};
|
||||||
|
|
||||||
|
if(config.streaming_config.record_options.video_quality == "custom") {
|
||||||
|
args.push_back("-bm");
|
||||||
|
args.push_back("cbr");
|
||||||
|
args.push_back("-q");
|
||||||
|
args.push_back(video_bitrate.c_str());
|
||||||
|
} else {
|
||||||
|
args.push_back("-q");
|
||||||
|
args.push_back(config.streaming_config.record_options.video_quality.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(config.streaming_config.record_options.record_area_option == "focused" || config.streaming_config.record_options.change_video_resolution) {
|
||||||
|
args.push_back("-s");
|
||||||
|
args.push_back(region);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(config.streaming_config.record_options.merge_audio_tracks) {
|
||||||
|
args.push_back("-a");
|
||||||
|
args.push_back(audio_tracks_merged.c_str());
|
||||||
|
} else {
|
||||||
|
for(const std::string &audio_track : config.streaming_config.record_options.audio_tracks) {
|
||||||
|
args.push_back("-a");
|
||||||
|
args.push_back(audio_track.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
args.push_back(nullptr);
|
||||||
|
|
||||||
|
gpu_screen_recorder_process = exec_program(args.data());
|
||||||
|
if(gpu_screen_recorder_process == -1) {
|
||||||
|
// TODO: Show notification failed to start
|
||||||
|
} else {
|
||||||
|
recording_status = RecordingStatus::STREAM;
|
||||||
|
update_ui_streaming_started();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Start recording after this notification has disappeared to make sure it doesn't show up in the video.
|
||||||
|
// Make clear to the user that the recording starts after the notification is gone.
|
||||||
|
// Maybe have the option in notification to show timer until its getting hidden, then the notification can say:
|
||||||
|
// Starting recording in 3...
|
||||||
|
// 2...
|
||||||
|
// 1...
|
||||||
|
// TODO: Do not run this is a daemon. Instead get the pid and when launching another notification close the current notification
|
||||||
|
// 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_theme().tint_color, get_theme().tint_color, NotificationType::STREAM);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Overlay::update_compositor_texture(const mgl_monitor *monitor) {
|
bool Overlay::update_compositor_texture(const mgl_monitor *monitor) {
|
||||||
|
|||||||
@@ -97,6 +97,9 @@ namespace gsr {
|
|||||||
if(!theme->pause_texture.load_from_file((resources_path + "images/pause.png").c_str()))
|
if(!theme->pause_texture.load_from_file((resources_path + "images/pause.png").c_str()))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
if(!theme->save_texture.load_from_file((resources_path + "images/save.png").c_str()))
|
||||||
|
goto error;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace gsr {
|
|||||||
set_text(text);
|
set_text(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Entry::on_event(mgl::Event &event, mgl::Window&, mgl::vec2f offset) {
|
bool Entry::on_event(mgl::Event &event, mgl::Window &window, mgl::vec2f offset) {
|
||||||
if(!visible)
|
if(!visible)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -33,6 +33,11 @@ namespace gsr {
|
|||||||
const size_t prev_index = mgl::utf8_get_start_of_codepoint((const unsigned char*)str.c_str(), str.size(), str.size());
|
const size_t prev_index = mgl::utf8_get_start_of_codepoint((const unsigned char*)str.c_str(), str.size(), str.size());
|
||||||
str.erase(prev_index, std::string::npos);
|
str.erase(prev_index, std::string::npos);
|
||||||
set_text(std::move(str));
|
set_text(std::move(str));
|
||||||
|
} else if(event.key.code == mgl::Keyboard::V && event.key.control) {
|
||||||
|
std::string clipboard_text = window.get_clipboard_string();
|
||||||
|
std::string str = text.get_string();
|
||||||
|
str += clipboard_text;
|
||||||
|
set_text(std::move(str));
|
||||||
}
|
}
|
||||||
} else if(event.type == mgl::Event::TextEntered && selected && event.text.codepoint >= 32) {
|
} else if(event.type == mgl::Event::TextEntered && selected && event.text.codepoint >= 32) {
|
||||||
std::string str = text.get_string();
|
std::string str = text.get_string();
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
#include <mglpp/window/Window.hpp>
|
#include <mglpp/window/Window.hpp>
|
||||||
|
|
||||||
namespace gsr {
|
namespace gsr {
|
||||||
SettingsPage::SettingsPage(Type type, const GsrInfo &gsr_info, std::vector<AudioDevice> audio_devices, std::optional<Config> &config, PageStack *page_stack) :
|
SettingsPage::SettingsPage(Type type, const GsrInfo &gsr_info, std::vector<AudioDevice> audio_devices, Config &config, PageStack *page_stack) :
|
||||||
StaticPage(mgl::vec2f(get_theme().window_width, get_theme().window_height).floor()),
|
StaticPage(mgl::vec2f(get_theme().window_width, get_theme().window_height).floor()),
|
||||||
type(type),
|
type(type),
|
||||||
config(config),
|
config(config),
|
||||||
@@ -718,9 +718,6 @@ namespace gsr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SettingsPage::load() {
|
void SettingsPage::load() {
|
||||||
if(!config)
|
|
||||||
return;
|
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case Type::REPLAY:
|
case Type::REPLAY:
|
||||||
load_replay();
|
load_replay();
|
||||||
@@ -735,9 +732,6 @@ namespace gsr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SettingsPage::save() {
|
void SettingsPage::save() {
|
||||||
if(!config)
|
|
||||||
config = Config();
|
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case Type::REPLAY:
|
case Type::REPLAY:
|
||||||
save_replay();
|
save_replay();
|
||||||
@@ -749,7 +743,7 @@ namespace gsr {
|
|||||||
save_stream();
|
save_stream();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
save_config(config.value());
|
save_config(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsPage::load_audio_tracks(RecordOptions &record_options) {
|
void SettingsPage::load_audio_tracks(RecordOptions &record_options) {
|
||||||
@@ -817,35 +811,35 @@ namespace gsr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SettingsPage::load_replay() {
|
void SettingsPage::load_replay() {
|
||||||
load_common(config->replay_config.record_options);
|
load_common(config.replay_config.record_options);
|
||||||
show_replay_started_notification_checkbox_ptr->set_checked(config->replay_config.show_replay_started_notifications);
|
show_replay_started_notification_checkbox_ptr->set_checked(config.replay_config.show_replay_started_notifications);
|
||||||
show_replay_stopped_notification_checkbox_ptr->set_checked(config->replay_config.show_replay_stopped_notifications);
|
show_replay_stopped_notification_checkbox_ptr->set_checked(config.replay_config.show_replay_stopped_notifications);
|
||||||
show_replay_saved_notification_checkbox_ptr->set_checked(config->replay_config.show_replay_saved_notifications);
|
show_replay_saved_notification_checkbox_ptr->set_checked(config.replay_config.show_replay_saved_notifications);
|
||||||
save_directory_button_ptr->set_text(config->replay_config.save_directory);
|
save_directory_button_ptr->set_text(config.replay_config.save_directory);
|
||||||
container_box_ptr->set_selected_item(config->replay_config.container);
|
container_box_ptr->set_selected_item(config.replay_config.container);
|
||||||
|
|
||||||
if(config->replay_config.replay_time < 5)
|
if(config.replay_config.replay_time < 5)
|
||||||
config->replay_config.replay_time = 5;
|
config.replay_config.replay_time = 5;
|
||||||
replay_time_entry_ptr->set_text(std::to_string(config->replay_config.replay_time));
|
replay_time_entry_ptr->set_text(std::to_string(config.replay_config.replay_time));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsPage::load_record() {
|
void SettingsPage::load_record() {
|
||||||
load_common(config->record_config.record_options);
|
load_common(config.record_config.record_options);
|
||||||
show_recording_started_notification_checkbox_ptr->set_checked(config->record_config.show_recording_started_notifications);
|
show_recording_started_notification_checkbox_ptr->set_checked(config.record_config.show_recording_started_notifications);
|
||||||
show_video_saved_notification_checkbox_ptr->set_checked(config->record_config.show_video_saved_notifications);
|
show_video_saved_notification_checkbox_ptr->set_checked(config.record_config.show_video_saved_notifications);
|
||||||
save_directory_button_ptr->set_text(config->record_config.save_directory);
|
save_directory_button_ptr->set_text(config.record_config.save_directory);
|
||||||
container_box_ptr->set_selected_item(config->record_config.container);
|
container_box_ptr->set_selected_item(config.record_config.container);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsPage::load_stream() {
|
void SettingsPage::load_stream() {
|
||||||
load_common(config->streaming_config.record_options);
|
load_common(config.streaming_config.record_options);
|
||||||
show_streaming_started_notification_checkbox_ptr->set_checked(config->streaming_config.show_streaming_started_notifications);
|
show_streaming_started_notification_checkbox_ptr->set_checked(config.streaming_config.show_streaming_started_notifications);
|
||||||
show_streaming_stopped_notification_checkbox_ptr->set_checked(config->streaming_config.show_streaming_stopped_notifications);
|
show_streaming_stopped_notification_checkbox_ptr->set_checked(config.streaming_config.show_streaming_stopped_notifications);
|
||||||
streaming_service_box_ptr->set_selected_item(config->streaming_config.streaming_service);
|
streaming_service_box_ptr->set_selected_item(config.streaming_config.streaming_service);
|
||||||
youtube_stream_key_entry_ptr->set_text(config->streaming_config.youtube.stream_key);
|
youtube_stream_key_entry_ptr->set_text(config.streaming_config.youtube.stream_key);
|
||||||
twitch_stream_key_entry_ptr->set_text(config->streaming_config.twitch.stream_key);
|
twitch_stream_key_entry_ptr->set_text(config.streaming_config.twitch.stream_key);
|
||||||
stream_url_entry_ptr->set_text(config->streaming_config.custom.url);
|
stream_url_entry_ptr->set_text(config.streaming_config.custom.url);
|
||||||
container_box_ptr->set_selected_item(config->streaming_config.custom.container);
|
container_box_ptr->set_selected_item(config.streaming_config.custom.container);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void save_audio_tracks(std::vector<std::string> &audio_tracks, List *audio_devices_list_ptr) {
|
static void save_audio_tracks(std::vector<std::string> &audio_tracks, List *audio_devices_list_ptr) {
|
||||||
@@ -924,36 +918,36 @@ namespace gsr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SettingsPage::save_replay() {
|
void SettingsPage::save_replay() {
|
||||||
save_common(config->replay_config.record_options);
|
save_common(config.replay_config.record_options);
|
||||||
config->replay_config.show_replay_started_notifications = show_replay_started_notification_checkbox_ptr->is_checked();
|
config.replay_config.show_replay_started_notifications = show_replay_started_notification_checkbox_ptr->is_checked();
|
||||||
config->replay_config.show_replay_stopped_notifications = show_replay_stopped_notification_checkbox_ptr->is_checked();
|
config.replay_config.show_replay_stopped_notifications = show_replay_stopped_notification_checkbox_ptr->is_checked();
|
||||||
config->replay_config.show_replay_saved_notifications = show_replay_saved_notification_checkbox_ptr->is_checked();
|
config.replay_config.show_replay_saved_notifications = show_replay_saved_notification_checkbox_ptr->is_checked();
|
||||||
config->replay_config.save_directory = save_directory_button_ptr->get_text();
|
config.replay_config.save_directory = save_directory_button_ptr->get_text();
|
||||||
config->replay_config.container = container_box_ptr->get_selected_id();
|
config.replay_config.container = container_box_ptr->get_selected_id();
|
||||||
config->replay_config.replay_time = atoi(replay_time_entry_ptr->get_text().c_str());
|
config.replay_config.replay_time = atoi(replay_time_entry_ptr->get_text().c_str());
|
||||||
|
|
||||||
if(config->replay_config.replay_time < 5) {
|
if(config.replay_config.replay_time < 5) {
|
||||||
config->replay_config.replay_time = 5;
|
config.replay_config.replay_time = 5;
|
||||||
replay_time_entry_ptr->set_text("5");
|
replay_time_entry_ptr->set_text("5");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsPage::save_record() {
|
void SettingsPage::save_record() {
|
||||||
save_common(config->record_config.record_options);
|
save_common(config.record_config.record_options);
|
||||||
config->record_config.show_recording_started_notifications = show_recording_started_notification_checkbox_ptr->is_checked();
|
config.record_config.show_recording_started_notifications = show_recording_started_notification_checkbox_ptr->is_checked();
|
||||||
config->record_config.show_video_saved_notifications = show_video_saved_notification_checkbox_ptr->is_checked();
|
config.record_config.show_video_saved_notifications = show_video_saved_notification_checkbox_ptr->is_checked();
|
||||||
config->record_config.save_directory = save_directory_button_ptr->get_text();
|
config.record_config.save_directory = save_directory_button_ptr->get_text();
|
||||||
config->record_config.container = container_box_ptr->get_selected_id();
|
config.record_config.container = container_box_ptr->get_selected_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsPage::save_stream() {
|
void SettingsPage::save_stream() {
|
||||||
save_common(config->streaming_config.record_options);
|
save_common(config.streaming_config.record_options);
|
||||||
config->streaming_config.show_streaming_started_notifications = show_streaming_started_notification_checkbox_ptr->is_checked();
|
config.streaming_config.show_streaming_started_notifications = show_streaming_started_notification_checkbox_ptr->is_checked();
|
||||||
config->streaming_config.show_streaming_stopped_notifications = show_streaming_stopped_notification_checkbox_ptr->is_checked();
|
config.streaming_config.show_streaming_stopped_notifications = show_streaming_stopped_notification_checkbox_ptr->is_checked();
|
||||||
config->streaming_config.streaming_service = streaming_service_box_ptr->get_selected_id();
|
config.streaming_config.streaming_service = streaming_service_box_ptr->get_selected_id();
|
||||||
config->streaming_config.youtube.stream_key = youtube_stream_key_entry_ptr->get_text();
|
config.streaming_config.youtube.stream_key = youtube_stream_key_entry_ptr->get_text();
|
||||||
config->streaming_config.twitch.stream_key = twitch_stream_key_entry_ptr->get_text();
|
config.streaming_config.twitch.stream_key = twitch_stream_key_entry_ptr->get_text();
|
||||||
config->streaming_config.custom.url = stream_url_entry_ptr->get_text();
|
config.streaming_config.custom.url = stream_url_entry_ptr->get_text();
|
||||||
config->streaming_config.custom.container = container_box_ptr->get_selected_id();
|
config.streaming_config.custom.container = container_box_ptr->get_selected_id();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
66
src/main.cpp
66
src/main.cpp
@@ -31,11 +31,6 @@ extern "C" {
|
|||||||
|
|
||||||
const mgl::Color bg_color(0, 0, 0, 100);
|
const mgl::Color bg_color(0, 0, 0, 100);
|
||||||
|
|
||||||
static void usage() {
|
|
||||||
fprintf(stderr, "usage: gsr-ui [toggle-record|toggle-pause]\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void startup_error(const char *msg) {
|
static void startup_error(const char *msg) {
|
||||||
fprintf(stderr, "Error: %s\n", msg);
|
fprintf(stderr, "Error: %s\n", msg);
|
||||||
exit(1);
|
exit(1);
|
||||||
@@ -48,15 +43,10 @@ static void sigint_handler(int signal) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
(void)argc;
|
||||||
|
(void)argv;
|
||||||
setlocale(LC_ALL, "C"); // Sigh... stupid C
|
setlocale(LC_ALL, "C"); // Sigh... stupid C
|
||||||
|
|
||||||
if(argc > 3)
|
|
||||||
usage();
|
|
||||||
|
|
||||||
const char *action = NULL;
|
|
||||||
if(argc > 1)
|
|
||||||
action = argv[1];
|
|
||||||
|
|
||||||
signal(SIGINT, sigint_handler);
|
signal(SIGINT, sigint_handler);
|
||||||
|
|
||||||
gsr::GsrInfo gsr_info;
|
gsr::GsrInfo gsr_info;
|
||||||
@@ -73,7 +63,7 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string resources_path;
|
std::string resources_path;
|
||||||
if(access("images/gpu_screen_recorder_logo.png", F_OK) == 0) {
|
if(access("sibs-build", F_OK) == 0) {
|
||||||
resources_path = "./";
|
resources_path = "./";
|
||||||
} else {
|
} else {
|
||||||
#ifdef GSR_UI_RESOURCES_PATH
|
#ifdef GSR_UI_RESOURCES_PATH
|
||||||
@@ -130,33 +120,57 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
fprintf(stderr, "info: gsr ui is now ready, waiting for inputs. Press alt+z to show/hide the overlay\n");
|
fprintf(stderr, "info: gsr ui is now ready, waiting for inputs. Press alt+z to show/hide the overlay\n");
|
||||||
|
|
||||||
gsr::Overlay overlay(window, resources_path, gsr_info, egl_funcs, bg_color);
|
auto overlay = std::make_unique<gsr::Overlay>(window, resources_path, gsr_info, egl_funcs, bg_color);
|
||||||
//overlay.show();
|
//overlay.show();
|
||||||
|
|
||||||
gsr::GlobalHotkeysX11 global_hotkeys;
|
gsr::GlobalHotkeysX11 global_hotkeys;
|
||||||
const bool show_hotkey_registered = global_hotkeys.bind_key_press({ XK_z, Mod1Mask }, "open/hide", [&](const std::string &id) {
|
const bool show_hotkey_registered = global_hotkeys.bind_key_press({ XK_z, Mod1Mask }, "show/hide", [&](const std::string &id) {
|
||||||
fprintf(stderr, "pressed %s\n", id.c_str());
|
fprintf(stderr, "pressed %s\n", id.c_str());
|
||||||
overlay.toggle_show();
|
overlay->toggle_show();
|
||||||
});
|
});
|
||||||
|
|
||||||
const bool record_hotkey_registered = global_hotkeys.bind_key_press({ XK_F9, Mod1Mask }, "record/save", [&](const std::string &id) {
|
const bool record_hotkey_registered = global_hotkeys.bind_key_press({ XK_F9, Mod1Mask }, "record", [&](const std::string &id) {
|
||||||
fprintf(stderr, "pressed %s\n", id.c_str());
|
fprintf(stderr, "pressed %s\n", id.c_str());
|
||||||
overlay.toggle_record();
|
overlay->toggle_record();
|
||||||
});
|
});
|
||||||
|
|
||||||
const bool pause_hotkey_registered = global_hotkeys.bind_key_press({ XK_F7, Mod1Mask }, "pause/unpause", [&](const std::string &id) {
|
const bool pause_hotkey_registered = global_hotkeys.bind_key_press({ XK_F7, Mod1Mask }, "pause", [&](const std::string &id) {
|
||||||
fprintf(stderr, "pressed %s\n", id.c_str());
|
fprintf(stderr, "pressed %s\n", id.c_str());
|
||||||
overlay.toggle_pause();
|
overlay->toggle_pause();
|
||||||
|
});
|
||||||
|
|
||||||
|
const bool stream_hotkey_registered = global_hotkeys.bind_key_press({ XK_F8, Mod1Mask }, "stream", [&](const std::string &id) {
|
||||||
|
fprintf(stderr, "pressed %s\n", id.c_str());
|
||||||
|
overlay->toggle_stream();
|
||||||
|
});
|
||||||
|
|
||||||
|
const bool replay_hotkey_registered = global_hotkeys.bind_key_press({ XK_F10, ShiftMask | Mod1Mask }, "replay start", [&](const std::string &id) {
|
||||||
|
fprintf(stderr, "pressed %s\n", id.c_str());
|
||||||
|
overlay->toggle_replay();
|
||||||
|
});
|
||||||
|
|
||||||
|
const bool replay_save_hotkey_registered = global_hotkeys.bind_key_press({ XK_F10, Mod1Mask }, "replay save", [&](const std::string &id) {
|
||||||
|
fprintf(stderr, "pressed %s\n", id.c_str());
|
||||||
|
overlay->save_replay();
|
||||||
});
|
});
|
||||||
|
|
||||||
if(!show_hotkey_registered)
|
if(!show_hotkey_registered)
|
||||||
fprintf(stderr, "error: failed to register hotkey alt+z for showing the overlay because the hotkey is registed by another program\n");
|
fprintf(stderr, "error: failed to register hotkey alt+z for showing the overlay because the hotkey is registered by another program\n");
|
||||||
|
|
||||||
if(!record_hotkey_registered)
|
if(!record_hotkey_registered)
|
||||||
fprintf(stderr, "error: failed to register hotkey alt+f9 for recording because the hotkey is registed by another program\n");
|
fprintf(stderr, "error: failed to register hotkey alt+f9 for recording because the hotkey is registered by another program\n");
|
||||||
|
|
||||||
if(!pause_hotkey_registered)
|
if(!pause_hotkey_registered)
|
||||||
fprintf(stderr, "error: failed to register hotkey alt+f7 for pausing because the hotkey is registed by another program\n");
|
fprintf(stderr, "error: failed to register hotkey alt+f7 for pausing because the hotkey is registered by another program\n");
|
||||||
|
|
||||||
|
if(!stream_hotkey_registered)
|
||||||
|
fprintf(stderr, "error: failed to register hotkey alt+f8 for streaming because the hotkey is registered by another program\n");
|
||||||
|
|
||||||
|
if(!replay_hotkey_registered)
|
||||||
|
fprintf(stderr, "error: failed to register hotkey alt+shift+f10 for starting replay because the hotkey is registered by another program\n");
|
||||||
|
|
||||||
|
if(!replay_save_hotkey_registered)
|
||||||
|
fprintf(stderr, "error: failed to register hotkey alt+f10 for saving replay because the hotkey is registered by another program\n");
|
||||||
|
|
||||||
mgl::Event event;
|
mgl::Event event;
|
||||||
mgl::Clock frame_delta_clock;
|
mgl::Clock frame_delta_clock;
|
||||||
@@ -167,14 +181,16 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
global_hotkeys.poll_events();
|
global_hotkeys.poll_events();
|
||||||
while(window.poll_event(event)) {
|
while(window.poll_event(event)) {
|
||||||
overlay.on_event(event, window);
|
overlay->on_event(event, window);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.clear(bg_color);
|
window.clear(bg_color);
|
||||||
overlay.draw(window);
|
overlay->draw(window);
|
||||||
window.display();
|
window.display();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
overlay.reset();
|
||||||
|
|
||||||
fprintf(stderr, "info: shutting down!\n");
|
fprintf(stderr, "info: shutting down!\n");
|
||||||
gsr::deinit_theme();
|
gsr::deinit_theme();
|
||||||
window.close();
|
window.close();
|
||||||
|
|||||||
Reference in New Issue
Block a user