api: get_streams (#886)

## Link to GitHub Issue or related Pull Request, if one exists
#0

## Description of change
MSE method of streaming video needs the dimensions up front. This new
api delivers that. Also provides an easier way to determine which
screens are available and a way to discover port number.

## Testing
See pending changes in substream project
This commit is contained in:
bicarus
2026-08-22 19:38:48 -07:00
committed by GitHub
parent d51de976b1
commit 95f10ed733
15 changed files with 280 additions and 6 deletions
+21
View File
@@ -1481,6 +1481,27 @@ void graphics_capture_skip(int screen) {
GRAPHICS_CAPTURE_CV[screen].notify_one();
}
bool graphics_capture_last_size(int screen, int *width, int *height) {
if (screen < 0 || screen >= static_cast<int>(GRAPHICS_CAPTURE_SCREEN_NO)) {
return false;
}
// consuming a frame clears the pixels but leaves the size, so this survives the read
std::lock_guard<std::mutex> lock(GRAPHICS_CAPTURE_BUFFER_M[screen]);
const auto &capture = GRAPHICS_CAPTURE_BUFFER[screen];
if (!capture.width || !capture.height) {
return false;
}
if (width != nullptr) {
*width = capture.width;
}
if (height != nullptr) {
*height = capture.height;
}
return true;
}
bool graphics_capture_receive_raw(int screen, std::shared_ptr<uint8_t[]> &out,
int divide, uint64_t *timestamp,
int *width, int *height) {
+3
View File
@@ -146,6 +146,9 @@ void graphics_capture_trigger(int screen);
bool graphics_capture_consume(int *screen);
void graphics_capture_enqueue(int screen, uint8_t *data, size_t width, size_t height);
void graphics_capture_skip(int screen);
// size of the last frame captured off this screen, before any caller side downscale; false
// until one has been captured, so it cannot report a size for a screen the game never drew
bool graphics_capture_last_size(int screen, int *width, int *height);
// on success `out` owns packed 24bpp RGB pixels, width * height * 3 bytes
bool graphics_capture_receive_raw(int screen, std::shared_ptr<uint8_t[]> &out,
int divide = 0,