chromium/chromeos/ash/components/kiosk/vision/internal/detection_processor.h

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROMEOS_ASH_COMPONENTS_KIOSK_VISION_INTERNAL_DETECTION_PROCESSOR_H_
#define CHROMEOS_ASH_COMPONENTS_KIOSK_VISION_INTERNAL_DETECTION_PROCESSOR_H_

#include <vector>

#include "base/memory/raw_ptr.h"
#include "media/capture/video/chromeos/mojom/cros_camera_service.mojom-forward.h"

namespace ash::kiosk_vision {

// Implementations of this interface receive `KioskVisionDetection` events,
// transform them into relevant events, and make them available to consumers.
//
// This is similar to `KioskVisionObserver` as it receives detection events. But
// it differs fundamentally in that it's geared towards needs of processors, not
// of `CrosCameraService` concerns. Some key differences are:
//   * Errors here are a superset of `KioskVisionObserver`, as there are more
//   error conditions besides what camera service reports.
//   * The interface generated by mojo requires ownership of the
//   `KioskVisionDetection` struct. Here a `const &` is preferred to avoid
//   copies between different implementations.
//   * Implementations are used within Ash and don't need the usual mojo
//   machinery like receivers and remotes.
class DetectionProcessor {
 public:
  virtual ~DetectionProcessor() = default;

  virtual void OnFrameProcessed(
      const cros::mojom::KioskVisionDetection& detection) = 0;

  virtual void OnTrackCompleted(const cros::mojom::KioskVisionTrack& track) = 0;

  virtual void OnError(cros::mojom::KioskVisionError error) = 0;
};

// Helper to define a collection of `DetectionProcessor` instances.
//
// `DetectionProcessor` implementations can be enabled and disabled by policies.
// This is generally used to describe the set of processors that are currently
// enabled.
//
// `DetectionProcessor` entries are not owned and must outlive the vector.
using DetectionProcessors = std::vector<raw_ptr<DetectionProcessor>>;

}  // namespace ash::kiosk_vision

#endif  // CHROMEOS_ASH_COMPONENTS_KIOSK_VISION_INTERNAL_DETECTION_PROCESSOR_H_