#pragma once

#include <cstdint>
#include <vector>

struct Nv12Frame {
  uint32_t width{0};
  uint32_t height{0};
  // Packed NV12: Y (w*h) + UV interleaved (w*h/2)
  std::vector<uint8_t> data;
};

class MipiVflowBackend {
public:
  MipiVflowBackend();
  ~MipiVflowBackend();

  // Open one MIPI pipeline (host + PYM channel).
  // For your imx219 case, channel maps to PYM output (e.g. 0->1920x1080, 1->960x536).
  bool open(int mipi_host, int pym_channel, int sensor_id = 0);

  // Fill `out` with packed NV12. Returns false on timeout/failure.
  bool get_frame(Nv12Frame & out, int timeout_ms);

  void close();

  bool is_open() const;

private:
  struct Impl;
  Impl * impl_{nullptr};
};


