// Copyright 2023 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_CLIENTS_MOJO_VIDEO_ENCODER_METRICS_PROVIDER_H_ #define MEDIA_MOJO_CLIENTS_MOJO_VIDEO_ENCODER_METRICS_PROVIDER_H_ #include <atomic> #include "base/memory/scoped_refptr.h" #include "base/sequence_checker.h" #include "base/thread_annotations.h" #include "media/base/video_encoder_metrics_provider.h" #include "media/mojo/mojom/video_encoder_metrics_provider.mojom.h" #include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/remote.h" namespace media { // MojoVideoEncoderMetricsProviderFactory creates VideoEncoderMetricsProvider // that records encoder statistics in browser process via mojo call. // MojoVideoEncoderMetricsProviderFactory constructor can be called on any // sequence. CreateVideoEncoderMetricsProvider() must be called on the same // specific sequence. // The created VideoEncoderMetricsProviders must be operated and destroyed on a // specific sequence and MojoVideoEncoderMetricsProviderFactory needs to be // destroyed on the sequence. // If MojoVideoEncoderMetricsProviderFactory is created one-off, it is // guaranteed that the factory is destroyed with VideoEncoderMetricsProvider. // For example, |factory| below will be destroyed when |metrics_provider| is // destroyed. // ``` // auto factory = base::MakeRefCounted< // MojoVideoEncoderMetricsProviderFactory>(kCastMirroring, pending_remote); // auto metrics_provider = // std::move(factory).CreateVideoEncoderMetricsProvider(); // ``` // If MojoVideoEncoderMetricsProviderFactory is held by some class, then it // needs to ensure it is destroyed on the same sequence as one destroying // created VideoEncoderMetricsProviders. class MojoVideoEncoderMetricsProviderFactory : public base::RefCountedThreadSafe< MojoVideoEncoderMetricsProviderFactory> { … }; } // namespace media #endif // MEDIA_MOJO_CLIENTS_MOJO_VIDEO_ENCODER_METRICS_PROVIDER_H_