#ifndef CAMERA_HAL_TYPES_H
#define CAMERA_HAL_TYPES_H

#include <cstdint>
#include <cstddef>

// AIDL Camera HAL v4 common types
// These mirror the AIDL interface types from hardware/interfaces/camera/

namespace camera_hal {

// Stream format constants (matching AIDL CameraMetadata)
enum StreamFormat : int32_t {
    FORMAT_YUV_420_888 = 32,
    FORMAT_IMPLEMENTATION_DEFINED = 35,
    FORMAT_BLOB_JPEG = 37,
    FORMAT_RAW16 = 38,
    FORMAT_RAW_PRIVATE = 39,
    FORMAT_RAW10 = 40,
    FORMAT_RAW12 = 41,
    FORMAT_DEPTH16 = 42,
    FORMAT_DEPTH_POINT_CLOUD = 43,
    FORMAT_PRIVATE = 50,
};

// Stream direction
enum StreamDirection : int32_t {
    STREAM_OUTPUT = 0,
    STREAM_INPUT = 1,
};

// Stream configuration
struct Stream {
    int32_t id;
    int32_t width;
    int32_t height;
    StreamFormat format;
    StreamDirection direction;
    int32_t usage;
    int32_t rotation;
    int32_t data_space;
    void* physical_camera_id; // nullable
};

// Buffer status
enum BufferStatus : int32_t {
    BUFFER_STATUS_OK = 0,
    BUFFER_STATUS_ERROR = 1,
    BUFFER_STATUS_NO_BUFFER = 2,
};

// Camera buffer descriptor (wraps AHardwareBuffer / GraphicBuffer)
struct CameraBuffer {
    int32_t stream_id;
    int64_t buffer_id;
    void* handle; // AHardwareBuffer* or native_handle_t*
    int32_t status;
    int64_t timestamp;
    void* acquire_fence;
    void* release_fence;
};

// Capture request
struct CaptureRequest {
    int32_t frame_number;
    int32_t settings_count;
    void* settings; // CameraMetadata*
    int32_t input_buffer_present;
    CameraBuffer* input_buffer;
    int32_t output_buffer_count;
    CameraBuffer* output_buffers;
    int32_t physical_camera_id_count;
    void* physical_camera_ids;
    void* physical_camera_settings;
};

// Capture result
struct CaptureResult {
    int32_t frame_number;
    void* result; // CameraMetadata*
    int32_t output_buffer_count;
    CameraBuffer* output_buffers;
    int32_t physical_camera_metadata_count;
    void* physical_camera_ids;
    void* physical_camera_metadata;
};

// Stream configuration mode
enum StreamConfigurationMode : int32_t {
    NORMAL_MODE = 0,
    CONSTRAINED_HIGH_SPEED_MODE = 1,
};

// HalStreamConfiguration (result of configureStreams)
struct HalStreamConfiguration {
    int32_t stream_count;
    Stream* streams;
    StreamConfigurationMode mode;
};

} // namespace camera_hal

#endif // CAMERA_HAL_TYPES_H
