Skip to content

feat(capture): add screenshot and screen recording APIs for macOS and Windows - #112

Open
lijy91 wants to merge 3 commits into
mainfrom
feat/screen-capture
Open

lijy91 wants to merge 3 commits into
mainfrom
feat/screen-capture

Conversation

@lijy91

@lijy91 lijy91 commented Dec 1, 2026

Copy link
Copy Markdown
Member

Fresh PR rebased cleanly onto main (supersedes #86).

Summary

  • Add CaptureSource, ScreenCapturer, and ScreenRecorder public C++ APIs and generated C ABI (capture_source_c, screen_capturer_c, screen_recorder_c).
  • Implement macOS (ScreenCaptureKit + AVAssetWriter) and Windows (Windows Graphics Capture + Media Foundation H.264) backends, plus unsupported stubs for Linux, Android, iOS, OpenHarmony, and WASM.
  • Register IdTypeTag<CaptureSource> (30) and IdTypeTag<ScreenRecorder> (31).

Review Fixes Included

  • macOS dispatch_queue_t leak: release queue_ under !__has_feature(objc_arc) instead of !OS_OBJECT_USE_OBJC.
  • Atomic non-overwriting publish on macOS: use renameatx_np(..., RENAME_EXCL) so filesystems without hard-link support (exFAT, SMB) succeed without overwriting.
  • Post-publish state consistency: once destination_ is committed, best-effort temp directory cleanup failures no longer emit ScreenRecordingFailedEvent over a published file.
  • picker_busy & observer safety: RAII guard ensures picker_busy resets even if dispatcher teardown drops the callback; macOS SelectCaptureTarget cleans up observer/configuration on exception; macOS resize configuration updates are guarded under state->mutex.
  • Windows backend: reuse D3D11 staging texture across same-size frames instead of reallocating per frame; initialize COM as STA (RO_INIT_SINGLETHREADED) for the UI-thread GraphicsCapturePicker.

Verification

  • macOS cmake --build core/build --target nativeapi screen_capture_test screen_capture_macos_smoke passed.
  • ctest --test-dir core/build -R screen_capture_test passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant