feat(screencapture): H.264/H.265 VideoToolbox streaming under /mobilerun#1
Open
Timo972 wants to merge 4 commits into
Open
feat(screencapture): H.264/H.265 VideoToolbox streaming under /mobilerun#1Timo972 wants to merge 4 commits into
Timo972 wants to merge 4 commits into
Conversation
Add a live, hardware-encoded screen-capture stream exposed under a new
/mobilerun namespace, separate from default WDA routes. A shared capture
loop grabs and decodes each XCUIScreen screenshot once and fans it out to
one or more independent encoder sessions, each with its own codec,
resolution and TCP port, enabling concurrent multi-codec capture.
Pipeline: XCUIScreen screenshot -> CVPixelBuffer (aspect-preserving
letterbox) -> VTCompressionSession -> raw Annex-B elementary stream
(SPS/PPS prepended before each IDR) broadcast over a dedicated TCP port
with TCP_NODELAY for low latency.
Endpoints (id-scoped for multi-session fan-out):
POST /mobilerun/screencapture/start -> { id, port, ... }
GET /mobilerun/screencapture list sessions
GET /mobilerun/screencapture/:id session status
POST /mobilerun/screencapture/:id/keyframe force an IDR on demand
POST /mobilerun/screencapture/:id/stop stop one session
POST /mobilerun/screencapture/stop stop all
New files: FBPixelBufferConverter, FBVideoEncoder, FBVideoStreamSession,
FBVideoStreamManager, FBScreenCaptureCommands (+ unit tests for the
converter and encoder). Adds FBConfiguration.screenCaptureServerPort
(default 9200, SCREEN_CAPTURE_SERVER_PORT env) and wires session teardown
into FBWebServer.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Invalidate stale capture-loop callbacks via a generation token. A stop/start cycle no longer lets a dispatch_after block queued by a previous run revive itself and spawn a second concurrent capture loop. Each run carries a generation; callbacks whose generation no longer matches refuse to proceed or reschedule. - Reject out-of-range 'port' arguments (must be 0..65535) instead of silently wrapping the uint16_t cast (e.g. 65536 -> 0 -> unintended auto-assign). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
A 'codec' argument sent as JSON null or a non-string value reached -length/-lowercaseString on NSNull/NSNumber, raising an unhandled exception instead of the intended invalid-argument response. Guard that codec is an NSString before using string methods; an absent codec still defaults to h264. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Auto port assignment (port 0 / omitted) previously picked only the next port unused by this process's sessions and failed if the socket could not bind. When the default SCREEN_CAPTURE_SERVER_PORT (9200) is already held by another process (multi-WDA or a stale runner), start now scans forward over a range of ports until one binds, matching the documented auto-assign behavior. An explicitly requested port still fails fast on conflict. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a live, hardware-encoded screen-capture stream exposed under a new /mobilerun namespace, separate from default WDA routes. A shared capture loop grabs and decodes each XCUIScreen screenshot once and fans it out to one or more independent encoder sessions, each with its own codec, resolution and TCP port, enabling concurrent multi-codec capture.
Pipeline: XCUIScreen screenshot -> CVPixelBuffer (aspect-preserving letterbox) -> VTCompressionSession -> raw Annex-B elementary stream (SPS/PPS prepended before each IDR) broadcast over a dedicated TCP port with TCP_NODELAY for low latency.
Endpoints (id-scoped for multi-session fan-out):
POST /mobilerun/screencapture/start -> { id, port, ... }
GET /mobilerun/screencapture list sessions
GET /mobilerun/screencapture/:id session status
POST /mobilerun/screencapture/:id/keyframe force an IDR on demand
POST /mobilerun/screencapture/:id/stop stop one session
POST /mobilerun/screencapture/stop stop all
New files: FBPixelBufferConverter, FBVideoEncoder, FBVideoStreamSession, FBVideoStreamManager, FBScreenCaptureCommands (+ unit tests for the converter and encoder). Adds FBConfiguration.screenCaptureServerPort (default 9200, SCREEN_CAPTURE_SERVER_PORT env) and wires session teardown into FBWebServer.