Add webcam support

This commit is contained in:
dec05eba
2025-12-25 08:19:07 +01:00
parent 1971d4a288
commit 13562d2aa1
19 changed files with 531 additions and 26 deletions

View File

@@ -19,6 +19,8 @@ namespace gsr {
void draw(mgl::Window &window, mgl::vec2f offset) override;
void add_item(const std::string &text, const std::string &id);
void clear_items();
// The item can only be selected if it's enabled
void set_selected_item(const std::string &id, bool trigger_event = true, bool trigger_event_even_if_selection_not_changed = true);
void set_item_enabled(const std::string &id, bool enabled);

View File

@@ -25,6 +25,14 @@ namespace gsr {
INPUT
};
enum class WebcamBoxResizeCorner {
NONE,
//TOP_LEFT,
//TOP_RIGHT,
//BOTTOM_LEFT,
BOTTOM_RIGHT
};
class SettingsPage : public StaticPage {
public:
enum class Type {
@@ -58,6 +66,9 @@ namespace gsr {
std::unique_ptr<List> create_restore_portal_session_section();
std::unique_ptr<Widget> create_change_video_resolution_section();
std::unique_ptr<Widget> create_capture_target_section();
std::unique_ptr<List> create_webcam_sources();
std::unique_ptr<List> create_webcam_video_format();
std::unique_ptr<Widget> create_webcam_section();
std::unique_ptr<ComboBox> create_audio_device_selection_combobox(AudioDeviceType device_type);
std::unique_ptr<Button> create_remove_audio_device_button(List *audio_input_list_ptr, List *audio_device_list_ptr);
std::unique_ptr<List> create_audio_device(AudioDeviceType device_type, List *audio_input_list_ptr);
@@ -140,6 +151,8 @@ namespace gsr {
void save_stream();
void view_changed(bool advanced_view);
RecordOptions& get_current_record_options();
private:
Type type;
Config &config;
@@ -197,7 +210,29 @@ namespace gsr {
List *audio_track_section_list_ptr = nullptr;
CheckBox *led_indicator_checkbox_ptr = nullptr;
CheckBox *show_notification_checkbox_ptr = nullptr;
ComboBox *webcam_sources_box_ptr = nullptr;
ComboBox *webcam_video_format_box_ptr = nullptr;
List *webcam_body_list_ptr = nullptr;
CheckBox *flip_camera_horizontally_checkbox_ptr = nullptr;
PageStack *page_stack = nullptr;
mgl::vec2f webcam_box_pos;
mgl::vec2f webcam_box_size;
mgl::vec2f webcam_box_drawn_pos;
mgl::vec2f webcam_box_drawn_size;
mgl::vec2f webcam_box_grab_offset;
mgl::vec2f camera_screen_size;
mgl::vec2f screen_inner_size;
bool moving_webcam_box = false;
WebcamBoxResizeCorner webcam_resize_corner = WebcamBoxResizeCorner::NONE;
mgl::vec2f webcam_resize_start_pos;
mgl::vec2f webcam_box_pos_resize_start;
mgl::vec2f webcam_box_size_resize_start;
std::optional<GsrCamera> selected_camera;
};
}

View File

@@ -9,6 +9,10 @@ namespace mgl {
}
namespace gsr {
mgl::vec2i min_vec2i(mgl::vec2i a, mgl::vec2i b);
mgl::vec2i max_vec2i(mgl::vec2i a, mgl::vec2i b);
mgl::vec2i clamp_vec2i(mgl::vec2i value, mgl::vec2i min, mgl::vec2i max);
// Inner border
void draw_rectangle_outline(mgl::Window &window, mgl::vec2f pos, mgl::vec2f size, mgl::Color color, float border_size);
double get_frame_delta_seconds();