Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creates a utility process that houses video encoding.
This CL changes where accelerated video encoding is done by decoupling it from the GPU process and putting it in an isolated utility process. The purpose for this is to ensure that malicious renderers cannot gain access to different parts of the GPU process that are unrelated to video encoding. For each renderer that needs accelerated video encoding, there should only be one utility process. Due to this, a new mojo interface was created that stores a UniqueReceiverSet of mojom::VideoEncodeAcceleratorProviders. This is required since the utility process can only have one mojom interface bound to it, but each renderer can have multiple video encoder providers. This interface is given to the utility process when it is launched. Each video encoder provider created on the renderer corresponding to it are added to the UniqueReceiverSet so that when calls are made to it, they are called from the utility process. For more information, refer to go/oop-vea Change-Id: I59979d58da93a52614922659e46a32ab5916e75b Bug: b:248540499 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3953577 Commit-Queue: Grayson LaFleur <graysonlafleur@google.com> Reviewed-by: Alex Gough <ajgo@chromium.org> Reviewed-by: Andres Calderon Jaramillo <andrescj@chromium.org> Reviewed-by: Alex Moshchuk <alexmos@chromium.org> Reviewed-by: Pilar Molina Lopez <pmolinalopez@chromium.org> Reviewed-by: Dan Sanders <sandersd@chromium.org> Cr-Commit-Position: refs/heads/main@{#1075405}
- Loading branch information
Grayson LaFleur
authored and
Chromium LUCI CQ
committed
Nov 24, 2022
1 parent
d11d6a5
commit d349535
Showing
12 changed files
with
232 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
18 changes: 18 additions & 0 deletions
18
content/browser/media/video_encode_accelerator_provider_launcher.cc
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2022 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "content/browser/media/video_encode_accelerator_provider_launcher.h" | ||
#include "content/public/browser/service_process_host.h" | ||
|
||
namespace content { | ||
|
||
void LaunchVideoEncodeAcceleratorProviderFactory( | ||
mojo::PendingReceiver<media::mojom::VideoEncodeAcceleratorProviderFactory> | ||
receiver) { | ||
ServiceProcessHost::Launch( | ||
std::move(receiver), | ||
ServiceProcessHost::Options().WithDisplayName("Video Encoder").Pass()); | ||
} | ||
|
||
} // namespace content |
22 changes: 22 additions & 0 deletions
22
content/browser/media/video_encode_accelerator_provider_launcher.h
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2022 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef CONTENT_BROWSER_MEDIA_VIDEO_ENCODE_ACCELERATOR_PROVIDER_LAUNCHER_H_ | ||
#define CONTENT_BROWSER_MEDIA_VIDEO_ENCODE_ACCELERATOR_PROVIDER_LAUNCHER_H_ | ||
|
||
#include "media/mojo/mojom/video_encode_accelerator.mojom.h" | ||
#include "mojo/public/cpp/bindings/pending_receiver.h" | ||
|
||
namespace content { | ||
|
||
// This method is used to create a utility process that hosts a | ||
// VideoEncodeAcceleratorProviderFactory implementation so that video | ||
// encode acceleration can be done outside of the GPU process. | ||
void LaunchVideoEncodeAcceleratorProviderFactory( | ||
mojo::PendingReceiver<media::mojom::VideoEncodeAcceleratorProviderFactory> | ||
receiver); | ||
|
||
} // namespace content | ||
|
||
#endif // CONTENT_BROWSER_MEDIA_VIDEO_ENCODE_ACCELERATOR_PROVIDER_LAUNCHER_H_ |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
49 changes: 49 additions & 0 deletions
49
media/mojo/services/mojo_video_encode_accelerator_provider_factory.cc
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2022 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "media/mojo/services/mojo_video_encode_accelerator_provider_factory.h" | ||
#include "gpu/config/gpu_driver_bug_workarounds.h" | ||
#include "gpu/config/gpu_info.h" | ||
#include "gpu/config/gpu_preferences.h" | ||
#include "media/base/media_log.h" | ||
#include "media/gpu/gpu_video_encode_accelerator_factory.h" | ||
#include "media/mojo/services/mojo_video_encode_accelerator_provider.h" | ||
|
||
namespace media { | ||
|
||
MojoVideoEncodeAcceleratorProviderFactory:: | ||
MojoVideoEncodeAcceleratorProviderFactory() | ||
: receiver_(this) { | ||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); | ||
} | ||
|
||
MojoVideoEncodeAcceleratorProviderFactory:: | ||
~MojoVideoEncodeAcceleratorProviderFactory() { | ||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); | ||
} | ||
|
||
void MojoVideoEncodeAcceleratorProviderFactory::BindReceiver( | ||
mojo::PendingReceiver<mojom::VideoEncodeAcceleratorProviderFactory> | ||
receiver) { | ||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); | ||
DCHECK(!receiver_.is_bound()); | ||
receiver_.Bind(std::move(receiver)); | ||
} | ||
|
||
void MojoVideoEncodeAcceleratorProviderFactory:: | ||
CreateVideoEncodeAcceleratorProvider( | ||
mojo::PendingReceiver<mojom::VideoEncodeAcceleratorProvider> receiver) { | ||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); | ||
// TODO(b/248540499): pass useful gpu::GpuPreferences, | ||
// gpu::GpuDriverBugWorkarounds, and gpu::GPUInfo::GPUDevice instances. | ||
std::unique_ptr<mojom::VideoEncodeAcceleratorProvider> provider = | ||
std::make_unique<MojoVideoEncodeAcceleratorProvider>( | ||
base::BindRepeating(&GpuVideoEncodeAcceleratorFactory::CreateVEA), | ||
gpu::GpuPreferences(), gpu::GpuDriverBugWorkarounds(), | ||
gpu::GPUInfo::GPUDevice()); | ||
|
||
video_encoder_providers_.Add(std::move(provider), std::move(receiver)); | ||
} | ||
|
||
} // namespace media |
51 changes: 51 additions & 0 deletions
51
media/mojo/services/mojo_video_encode_accelerator_provider_factory.h
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright 2022 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef MEDIA_MOJO_SERVICES_MOJO_VIDEO_ENCODE_ACCELERATOR_PROVIDER_FACTORY_H_ | ||
#define MEDIA_MOJO_SERVICES_MOJO_VIDEO_ENCODE_ACCELERATOR_PROVIDER_FACTORY_H_ | ||
|
||
#include "base/sequence_checker.h" | ||
#include "media/mojo/mojom/video_encode_accelerator.mojom.h" | ||
#include "media/mojo/services/media_mojo_export.h" | ||
#include "mojo/public/cpp/bindings/pending_receiver.h" | ||
#include "mojo/public/cpp/bindings/receiver.h" | ||
#include "mojo/public/cpp/bindings/unique_receiver_set.h" | ||
|
||
namespace media { | ||
|
||
// This class implements mojom::VideoEncodeAcceleratorProviderFactory and lives | ||
// in a utility process. This class houses a UniqueReceiverSet of | ||
// mojom::VideoEncodeAcceleratorProviders so that each utility process can have | ||
// multiple encoder providers. | ||
class MEDIA_MOJO_EXPORT MojoVideoEncodeAcceleratorProviderFactory | ||
: public mojom::VideoEncodeAcceleratorProviderFactory { | ||
public: | ||
MojoVideoEncodeAcceleratorProviderFactory(); | ||
MojoVideoEncodeAcceleratorProviderFactory( | ||
const MojoVideoEncodeAcceleratorProviderFactory&) = delete; | ||
MojoVideoEncodeAcceleratorProviderFactory& operator=( | ||
const MojoVideoEncodeAcceleratorProviderFactory&) = delete; | ||
~MojoVideoEncodeAcceleratorProviderFactory() override; | ||
|
||
void BindReceiver( | ||
mojo::PendingReceiver<mojom::VideoEncodeAcceleratorProviderFactory> | ||
receiver); | ||
|
||
// mojom::VideoEncodeAcceleratorProviderFactory implementation. | ||
void CreateVideoEncodeAcceleratorProvider( | ||
mojo::PendingReceiver<mojom::VideoEncodeAcceleratorProvider> receiver) | ||
override; | ||
|
||
private: | ||
mojo::Receiver<mojom::VideoEncodeAcceleratorProviderFactory> receiver_ | ||
GUARDED_BY_CONTEXT(sequence_checker_); | ||
mojo::UniqueReceiverSet<mojom::VideoEncodeAcceleratorProvider> | ||
video_encoder_providers_ GUARDED_BY_CONTEXT(sequence_checker_); | ||
|
||
SEQUENCE_CHECKER(sequence_checker_); | ||
}; | ||
|
||
} // namespace media | ||
|
||
#endif // MEDIA_MOJO_SERVICES_MOJO_VIDEO_ENCODE_ACCELERATOR_PROVIDER_FACTORY_H_ |