#pragma once

#include <string>

struct FrameSize
{
	unsigned width = 0;
	unsigned height = 0;

	bool IsEmpty() const { return width == 0 || height == 0; }
};

inline bool operator==(const FrameSize& left, const FrameSize& right)
{
	return left.width == right.width && left.height == right.height;
}

inline bool operator!=(const FrameSize& left, const FrameSize& right)
{
	return !(left == right);
}

struct VideoFormat
{
	std::string formatName = "1080p";
	std::string frameRate = "59.94";
	std::string displayName = "1080p59.94";
	FrameSize frameSize = { 1920, 1080 };
	double frameDurationMilliseconds = 1000.0 / 59.94;
};

struct VideoFormatSelection
{
	VideoFormat input;
	VideoFormat output;
};

std::string NormalizeModeToken(const std::string& value);
double FrameDurationMillisecondsFromRateString(const std::string& rateText, double fallbackRate = 59.94);
void VideoFormatDimensions(const std::string& formatName, unsigned& width, unsigned& height);
bool ResolveConfiguredVideoFormat(const std::string& videoFormat, const std::string& frameRate, VideoFormat& videoMode);
bool ResolveConfiguredVideoFormats(
	const std::string& inputVideoFormat,
	const std::string& inputFrameRate,
	const std::string& outputVideoFormat,
	const std::string& outputFrameRate,
	VideoFormatSelection& videoModes,
	std::string& error);
