Fix a couple bugs in Fuchsia screen capture.

1. Use ComponentContext::Create instead of

   ComponentContext::CreateAndServeOutgoingDirectory. We're not
   actually serving an outgoing directory here, and trying to causes
   conflicts when this code is linked into a Fuchsia component.
2. Mark the whole screen as having been updated on each frame. Some
   codecs were assuming that nothing on the screen was changing, and
   so only the first frame would be shared.

Change-Id: Icb02a2cc097947b85cceddec49291e666257ed81
Bug: webrtc:14681
Bug: webrtc:14682
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/283920
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Reviewed-by: Sarah Pham <smpham@google.com>
Commit-Queue: Hunter Freyer <hjfreyer@google.com>
Cr-Commit-Position: refs/heads/main@{#38682}
This commit is contained in:
Hunter Freyer 2022-11-17 19:05:36 +00:00 committed by WebRTC LUCI CQ
parent 5c297eb7a9
commit 1571258ca6

View File

@ -65,8 +65,7 @@ std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawScreenCapturer(
}
ScreenCapturerFuchsia::ScreenCapturerFuchsia()
: component_context_(
sys::ComponentContext::CreateAndServeOutgoingDirectory()) {
: component_context_(sys::ComponentContext::Create()) {
RTC_DCHECK(CheckRequirements());
}
@ -86,7 +85,7 @@ ScreenCapturerFuchsia::~ScreenCapturerFuchsia() {
// TODO(fxbug.dev/100303): Remove this function when Flatland is the only API.
bool ScreenCapturerFuchsia::CheckRequirements() {
std::unique_ptr<sys::ComponentContext> component_context =
sys::ComponentContext::CreateAndServeOutgoingDirectory();
sys::ComponentContext::Create();
fuchsia::ui::scenic::ScenicSyncPtr scenic;
zx_status_t status = component_context->svc()->Connect(scenic.NewRequest());
if (status != ZX_OK) {
@ -163,6 +162,9 @@ void ScreenCapturerFuchsia::CaptureFrame() {
uint32_t stride = kFuchsiaBytesPerPixel * pixels_per_row;
frame->CopyPixelsFrom(virtual_memory_mapped_addrs_[buffer_index], stride,
DesktopRect::MakeWH(width_, height_));
// Mark the whole screen as having been updated.
frame->mutable_updated_region()->SetRect(
DesktopRect::MakeWH(width_, height_));
fuchsia::ui::composition::ScreenCapture_ReleaseFrame_Result release_result;
screen_capture_->ReleaseFrame(buffer_index, &release_result);