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
+17
View File
@@ -195,11 +195,25 @@ namespace api {
"\r\n";
send_all(socket, response);
}
std::atomic<unsigned short> LISTENING_PORT { 0 };
}
unsigned short stream_server_port() {
return LISTENING_PORT.load();
}
StreamServer::StreamServer(unsigned short port)
: port(port)
{
// WinXP builds compile in neither encoder, so there would be nothing to serve and
// every request would 404; taking the port instead only invites confused clients
if (stream_formats().empty()) {
log_warning("api::stream",
"this build has no video encoders, the video stream is unavailable");
return;
}
if (!this->open_listener()) {
// the stream was asked for explicitly, so say plainly that it is not there
log_warning("api::stream",
@@ -212,6 +226,8 @@ namespace api {
this->accept_worker();
});
LISTENING_PORT = this->port;
// deliberately not logging a full URL; local IPs would leak into shared logs
log_info("api::stream", "video stream is listening on port: {}", this->port);
log_warning("api::stream",
@@ -269,6 +285,7 @@ namespace api {
StreamServer::~StreamServer() {
this->running = false;
LISTENING_PORT = 0;
if (this->listener != INVALID_SOCKET) {
closesocket(this->listener);