// Copyright (c) Meta Platforms, Inc. and affiliates.
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.

// See test_third_party_interface.py for context.
#include "DeviceInterface.h"
#include "FilterGraph.h"

namespace facebook::torchcodec {

class DummyDeviceInterface : public DeviceInterface {
 public:
  DummyDeviceInterface(const StableDevice& device) : DeviceInterface(device) {}

  virtual ~DummyDeviceInterface() {}

  void initialize(const SharedAVCodecContext& codecContext) override {
    // Access to CPU device interface is essential for CPU fallback
    // implementation
    std::unique_ptr<DeviceInterface> cpuInterface =
        createDeviceInterface(kStableCPU);
  }

  void convertAVFrameToFrameOutput(
      UniqueAVFrame& avFrame,
      FrameOutput& frameOutput,
      std::optional<torch::stable::Tensor> preAllocatedOutputTensor =
          std::nullopt) override {}

 private:
  std::unique_ptr<FilterGraph> filterGraphContext_;
};

namespace {
static bool g_dummy = registerDeviceInterface(
    DeviceInterfaceKey(StableDeviceType::PrivateUse1),
    [](const StableDevice& device) {
      return new DummyDeviceInterface(device);
    });
} // namespace
} // namespace facebook::torchcodec
