From 48220310ae84f667792eaf43da51383c3fe85da7 Mon Sep 17 00:00:00 2001 From: Salman Date: Mon, 30 Jan 2023 15:53:06 +0000 Subject: [PATCH] shared_screencast_stream: Set WL capturer id For frames captured and sent to the callback immediately, we are not sending the capturer ID as we used to do in base capturer pipewire. Adding the capturer id as well as the frame capture time so as to keep the sent frame to be in sync with the non-immediate-frame-send implementation. Bug: chromium:1291247 Change-Id: I02693907928b9e770ea56f89b46c37f17f4bc4a3 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/291680 Reviewed-by: Alexander Cooper Commit-Queue: Alexander Cooper Auto-Submit: Salman Malik Cr-Commit-Position: refs/heads/main@{#39228} --- .../linux/wayland/shared_screencast_stream.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc index c9b1f8dee5..d31f86772e 100644 --- a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc +++ b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc @@ -26,6 +26,7 @@ #include "rtc_base/logging.h" #include "rtc_base/sanitizer.h" #include "rtc_base/synchronization/mutex.h" +#include "rtc_base/time_utils.h" namespace webrtc { @@ -690,6 +691,7 @@ void SharedScreenCastStreamPrivate::NotifyCallbackOfNewFrame( RTC_NO_SANITIZE("cfi-icall") void SharedScreenCastStreamPrivate::ProcessBuffer(pw_buffer* buffer) { + int64_t capture_start_time_nanos = rtc::TimeNanos(); if (callback_) { callback_->OnFrameCaptureStart(); } @@ -941,7 +943,11 @@ void SharedScreenCastStreamPrivate::ProcessBuffer(pw_buffer* buffer) { queue_.current_frame()->set_may_contain_cursor(is_cursor_embedded_); if (callback_) { - NotifyCallbackOfNewFrame(queue_.current_frame()->Share()); + std::unique_ptr frame = queue_.current_frame()->Share(); + frame->set_capturer_id(DesktopCapturerId::kWaylandCapturerLinux); + frame->set_capture_time_ms((rtc::TimeNanos() - capture_start_time_nanos) / + rtc::kNumNanosecsPerMillisec); + NotifyCallbackOfNewFrame(std::move(frame)); } }