[fix] add capture delivery diagnostics

This commit is contained in:
dijunkun
2026-09-16 12:54:06 +08:00
parent f3e67d7d6e
commit d8ccdbaa38
4 changed files with 106 additions and 3 deletions
@@ -33,6 +33,8 @@ namespace {
using Json = nlohmann::json;
thread_local bool current_frame_from_secure_desktop = false;
constexpr DWORD kSecureDesktopStatusIntervalMs = 250;
constexpr DWORD kSecureDesktopStatusPipeTimeoutMs = 500;
constexpr DWORD kSecureDesktopHelperPipeTimeoutMs = 120;
@@ -460,6 +462,10 @@ int ScreenCapturerWin::Destroy() {
return 0;
}
bool ScreenCapturerWin::CurrentFrameIsFromSecureDesktop() {
return current_frame_from_secure_desktop;
}
void ScreenCapturerWin::EmitCapturedFrame(
unsigned char* data, int size, int width, int height,
const char* stream_id, const MiniRtcNativeVideoFrame* native_frame,
@@ -473,6 +479,14 @@ void ScreenCapturerWin::EmitCapturedFrame(
return;
}
// Normal and helper callbacks can originate on different threads during
// desktop transitions. Keep diagnostics tied to this callback's source.
struct RestoreFrameSource {
bool previous;
~RestoreFrameSource() { current_frame_from_secure_desktop = previous; }
} restore_source{
std::exchange(current_frame_from_secure_desktop, from_secure_desktop)};
if (native_frame) {
if (!native_output_logged_.exchange(true, std::memory_order_relaxed)) {
LOG_INFO("Windows capturer native frame output enabled (type={})",
@@ -48,6 +48,9 @@ class ScreenCapturerWin : public ScreenCapturer {
void SetPrivacyController(PrivacyController* privacy) override { privacy_ = privacy; }
// Set before Init(), while capture is stopped.
void SetCaptureMethod(ScreenCaptureMethod method) { capture_method_ = method; }
// Query synchronously inside the frame callback, on the delivering thread.
// This describes the actual frame, independently of service status polling.
static bool CurrentFrameIsFromSecureDesktop();
private:
std::unique_ptr<ScreenCapturer> impl_;