ImGui panel that streams live screenshots from a running Mesen2 emulator via socket and displays them as a GPU texture preview. More...
#include <mesen_screenshot_panel.h>
Public Member Functions | |
| MesenScreenshotPanel () | |
| ~MesenScreenshotPanel () | |
| MesenScreenshotPanel (const MesenScreenshotPanel &)=delete | |
| MesenScreenshotPanel & | operator= (const MesenScreenshotPanel &)=delete |
| void | Draw () |
| void | SetClient (std::shared_ptr< emu::mesen::MesenSocketClient > client) |
| bool | IsConnected () const |
| void | Connect () |
| void | ConnectToPath (const std::string &socket_path) |
| void | Disconnect () |
Private Member Functions | |
| void | DrawConnectionHeader () |
| void | DrawControlsToolbar () |
| void | DrawPreviewArea () |
| void | DrawStatusBar () |
| void | RefreshSocketList () |
| void | CaptureScreenshot () |
| void | UpdateTexture (const std::vector< uint8_t > &rgba, int width, int height) |
| void | EnsureTexture (int width, int height) |
| void | DestroyTexture () |
Static Private Member Functions | |
| static std::vector< uint8_t > | DecodeBase64 (const std::string &encoded) |
| static bool | DecodePngToRgba (const std::vector< uint8_t > &png_data, std::vector< uint8_t > &rgba_out, int &width_out, int &height_out) |
Private Attributes | |
| std::shared_ptr< emu::mesen::MesenSocketClient > | client_ |
| SDL_Texture * | texture_ = nullptr |
| int | texture_width_ = 0 |
| int | texture_height_ = 0 |
| int | frame_width_ = 0 |
| int | frame_height_ = 0 |
| uint64_t | frame_counter_ = 0 |
| float | last_capture_latency_ms_ = 0.0f |
| bool | frame_stale_ = false |
| bool | streaming_ = false |
| float | target_fps_ = 10.0f |
| float | time_accumulator_ = 0.0f |
| std::string | connection_error_ |
| std::vector< std::string > | socket_paths_ |
| int | selected_socket_index_ = -1 |
| char | socket_path_buffer_ [256] = {} |
| std::string | status_message_ |
ImGui panel that streams live screenshots from a running Mesen2 emulator via socket and displays them as a GPU texture preview.
The panel polls the Mesen2 Screenshot() API at a configurable rate, decodes the base64-encoded PNG response to RGBA pixels, uploads them to an SDL texture, and renders the result with ImGui::Image().
Definition at line 22 of file mesen_screenshot_panel.h.
| yaze::editor::MesenScreenshotPanel::MesenScreenshotPanel | ( | ) |
Definition at line 178 of file mesen_screenshot_panel.cc.
References client_, yaze::emu::mesen::MesenClientRegistry::GetOrCreate(), RefreshSocketList(), selected_socket_index_, socket_path_buffer_, and socket_paths_.

| yaze::editor::MesenScreenshotPanel::~MesenScreenshotPanel | ( | ) |
Definition at line 188 of file mesen_screenshot_panel.cc.
References DestroyTexture().

|
delete |
|
delete |
| void yaze::editor::MesenScreenshotPanel::Draw | ( | ) |
Definition at line 358 of file mesen_screenshot_panel.cc.
References CaptureScreenshot(), DrawConnectionHeader(), DrawControlsToolbar(), DrawPreviewArea(), DrawStatusBar(), IsConnected(), yaze::editor::AgentUI::PopPanelStyle(), yaze::editor::AgentUI::PushPanelStyle(), RefreshSocketList(), streaming_, target_fps_, and time_accumulator_.
| void yaze::editor::MesenScreenshotPanel::SetClient | ( | std::shared_ptr< emu::mesen::MesenSocketClient > | client | ) |
Definition at line 194 of file mesen_screenshot_panel.cc.
References client_, and yaze::emu::mesen::MesenClientRegistry::SetClient().

| bool yaze::editor::MesenScreenshotPanel::IsConnected | ( | ) | const |
Definition at line 200 of file mesen_screenshot_panel.cc.
References client_.
Referenced by CaptureScreenshot(), Draw(), DrawConnectionHeader(), and DrawStatusBar().
| void yaze::editor::MesenScreenshotPanel::Connect | ( | ) |
Definition at line 204 of file mesen_screenshot_panel.cc.
References client_, connection_error_, yaze::emu::mesen::MesenClientRegistry::GetOrCreate(), and yaze::emu::mesen::MesenClientRegistry::SetClient().
Referenced by DrawConnectionHeader().

| void yaze::editor::MesenScreenshotPanel::ConnectToPath | ( | const std::string & | socket_path | ) |
Definition at line 217 of file mesen_screenshot_panel.cc.
References client_, connection_error_, yaze::emu::mesen::MesenClientRegistry::GetOrCreate(), and yaze::emu::mesen::MesenClientRegistry::SetClient().
Referenced by DrawConnectionHeader().

| void yaze::editor::MesenScreenshotPanel::Disconnect | ( | ) |
Definition at line 230 of file mesen_screenshot_panel.cc.
References client_, and streaming_.
Referenced by DrawConnectionHeader().
|
private |
Definition at line 399 of file mesen_screenshot_panel.cc.
References Connect(), connection_error_, ConnectToPath(), Disconnect(), yaze::editor::AgentUI::GetTheme(), ICON_MD_AUTO_MODE, ICON_MD_CAMERA_ALT, ICON_MD_CHECK_CIRCLE, ICON_MD_ERROR, ICON_MD_LINK, ICON_MD_LINK_OFF, ICON_MD_REFRESH, IsConnected(), RefreshSocketList(), selected_socket_index_, socket_path_buffer_, and socket_paths_.
Referenced by Draw().
|
private |
Definition at line 480 of file mesen_screenshot_panel.cc.
References CaptureScreenshot(), ICON_MD_PAUSE, ICON_MD_PHOTO_CAMERA, ICON_MD_PLAY_ARROW, streaming_, target_fps_, and time_accumulator_.
Referenced by Draw().

|
private |
Definition at line 511 of file mesen_screenshot_panel.cc.
References frame_counter_, frame_height_, frame_stale_, frame_width_, yaze::editor::AgentUI::GetTheme(), last_capture_latency_ms_, and texture_.
Referenced by Draw().

|
private |
Definition at line 568 of file mesen_screenshot_panel.cc.
References yaze::editor::AgentUI::GetTheme(), ICON_MD_FIBER_MANUAL_RECORD, IsConnected(), socket_path_buffer_, status_message_, streaming_, and target_fps_.
Referenced by Draw().

|
private |
Definition at line 237 of file mesen_screenshot_panel.cc.
References yaze::emu::mesen::MesenSocketClient::ListAvailableSockets(), selected_socket_index_, socket_path_buffer_, and socket_paths_.
Referenced by Draw(), DrawConnectionHeader(), and MesenScreenshotPanel().

|
private |
Definition at line 313 of file mesen_screenshot_panel.cc.
References client_, DecodeBase64(), DecodePngToRgba(), frame_counter_, frame_height_, frame_stale_, frame_width_, IsConnected(), last_capture_latency_ms_, status_message_, and UpdateTexture().
Referenced by Draw(), and DrawControlsToolbar().

|
private |
Definition at line 290 of file mesen_screenshot_panel.cc.
References EnsureTexture(), and texture_.
Referenced by CaptureScreenshot().

|
private |
Definition at line 257 of file mesen_screenshot_panel.cc.
References DestroyTexture(), texture_, texture_height_, and texture_width_.
Referenced by UpdateTexture().

|
private |
Definition at line 300 of file mesen_screenshot_panel.cc.
References texture_, texture_height_, and texture_width_.
Referenced by EnsureTexture(), and ~MesenScreenshotPanel().
|
staticprivate |
Definition at line 51 of file mesen_screenshot_panel.cc.
Referenced by CaptureScreenshot().
|
staticprivate |
Definition at line 98 of file mesen_screenshot_panel.cc.
Referenced by CaptureScreenshot().
|
private |
Definition at line 57 of file mesen_screenshot_panel.h.
Referenced by CaptureScreenshot(), Connect(), ConnectToPath(), Disconnect(), IsConnected(), MesenScreenshotPanel(), and SetClient().
|
private |
Definition at line 60 of file mesen_screenshot_panel.h.
Referenced by DestroyTexture(), DrawPreviewArea(), EnsureTexture(), and UpdateTexture().
|
private |
Definition at line 61 of file mesen_screenshot_panel.h.
Referenced by DestroyTexture(), and EnsureTexture().
|
private |
Definition at line 62 of file mesen_screenshot_panel.h.
Referenced by DestroyTexture(), and EnsureTexture().
|
private |
Definition at line 65 of file mesen_screenshot_panel.h.
Referenced by CaptureScreenshot(), and DrawPreviewArea().
|
private |
Definition at line 66 of file mesen_screenshot_panel.h.
Referenced by CaptureScreenshot(), and DrawPreviewArea().
|
private |
Definition at line 67 of file mesen_screenshot_panel.h.
Referenced by CaptureScreenshot(), and DrawPreviewArea().
|
private |
Definition at line 68 of file mesen_screenshot_panel.h.
Referenced by CaptureScreenshot(), and DrawPreviewArea().
|
private |
Definition at line 69 of file mesen_screenshot_panel.h.
Referenced by CaptureScreenshot(), and DrawPreviewArea().
|
private |
Definition at line 72 of file mesen_screenshot_panel.h.
Referenced by Disconnect(), Draw(), DrawControlsToolbar(), and DrawStatusBar().
|
private |
Definition at line 73 of file mesen_screenshot_panel.h.
Referenced by Draw(), DrawControlsToolbar(), and DrawStatusBar().
|
private |
Definition at line 74 of file mesen_screenshot_panel.h.
Referenced by Draw(), and DrawControlsToolbar().
|
private |
Definition at line 77 of file mesen_screenshot_panel.h.
Referenced by Connect(), ConnectToPath(), and DrawConnectionHeader().
|
private |
Definition at line 78 of file mesen_screenshot_panel.h.
Referenced by DrawConnectionHeader(), MesenScreenshotPanel(), and RefreshSocketList().
|
private |
Definition at line 79 of file mesen_screenshot_panel.h.
Referenced by DrawConnectionHeader(), MesenScreenshotPanel(), and RefreshSocketList().
|
private |
Definition at line 80 of file mesen_screenshot_panel.h.
Referenced by DrawConnectionHeader(), DrawStatusBar(), MesenScreenshotPanel(), and RefreshSocketList().
|
private |
Definition at line 81 of file mesen_screenshot_panel.h.
Referenced by CaptureScreenshot(), and DrawStatusBar().