#pragma once

#include <cstdint>
#include <optional>
#include <string>
#include <vector>

#include "core/device_discovery.h"

namespace aptt {

inline constexpr std::uint32_t kMmeWaveMapperId = 0xFFFFFFFFu;

struct MmeFormatProbeRequest {
  std::uint32_t device_id = kMmeWaveMapperId;
  std::vector<FormatDescriptor> candidate_formats;
};

FormatDescriptor MmePcmCandidate(std::uint32_t sample_rate_hz,
                                 SampleType sample_type,
                                 std::uint32_t channel_count);
std::vector<FormatDescriptor> MmeDefaultPcmCandidates();

std::string MmeDeviceStableId(std::uint32_t device_id);
std::optional<std::uint32_t> MmeDeviceIdFromStableId(const std::string& stable_id);
std::string MmeResultSymbol(std::uint32_t result);
CapabilitySupport MmeSupportFromWaveOutOpenResult(std::uint32_t result);

DeviceCapabilitySnapshot MakeMmeWaveOutDeviceSnapshot(
    std::uint32_t device_id,
    std::string product_name,
    std::uint32_t formats_mask,
    std::uint16_t channel_count,
    bool is_mapper);

CapabilityProbeRecord MakeMmeFormatProbeRecord(
    const FormatDescriptor& requested,
    std::uint32_t result);

DeviceCapabilitySnapshot ProbeMmeWaveOutFormats(
    const MmeFormatProbeRequest& request);
DiscoverySnapshot EnumerateMmeWaveOutDevices();

}  // namespace aptt
