using UnityEngine; namespace Funique { public struct MediaChannel { public MediaType mediaType; public string inf; public string path; public string v_codec; public string a_codec; public float framerate; public int width; public int height; public long bandwidth; public long average; public string Bitrate_Simplify { get { long target = bandwidth; char[] code = new char[] { 'K', 'M', 'G', 'T' }; int digit = target.ToString().Length; char c = target.ToString()[0]; string r = string.Empty; if(digit <= 3) { r = target.ToString(); } else { r += c; int total = (digit - 1) % 3; for (int i = 0; i < total; i++) r += '0'; int code_index = Mathf.FloorToInt((digit - 4) / 3); r += code[code_index]; } return r; } } public string GetOptionTitle(ABRDisplayType DisplayFormat) { switch (DisplayFormat) { case ABRDisplayType.Resolution: return $"{width}x{height}"; case ABRDisplayType.ScanLine: return $"{height}p"; default: case ABRDisplayType.ScanLine_Bitrate: return $"{height}p {Bitrate_Simplify}"; case ABRDisplayType.Bitrate: return $"{Bitrate_Simplify}"; case ABRDisplayType.URL: return path; case ABRDisplayType.Simple_Bitrate: return $"{SimpleTransform(width, height)} {Bitrate_Simplify}"; case ABRDisplayType.Simple: return $"{SimpleTransform(width, height)}"; } } private string SimpleTransform(int w, int h) { Vector2Int v = new Vector2Int(w, h); if (v == new Vector2Int(7680, 7680)) return "8K"; else if (v == new Vector2Int(7680, 3840)) return "8K"; else if (v == new Vector2Int(5760, 5760)) return "6K"; else if (v == new Vector2Int(5760, 3240)) return "6K"; else if (v == new Vector2Int(5760, 2880)) return "6K"; else if (v == new Vector2Int(3840, 3840)) return "4K"; else if (v == new Vector2Int(3840, 2160)) return "4K"; else if (v == new Vector2Int(1920, 1080)) return "HD"; else return "Other"; } } }