/// <summary> /// Generates a set of qualities from a given DefaultQuality level. /// </summary> /// <param name="q"></param> /// <param name="preset"></param> /// <returns></returns> public static IEnumerable <IQuality> GenerateDefaultQualities(DefaultQuality q, H264Preset preset) { switch (q) { case DefaultQuality.potato: return(new List <Quality>() { new Quality(1280, 720, 1600, preset), new Quality(854, 480, 800, preset), new Quality(640, 360, 500, preset) }); case DefaultQuality.low: return(new List <Quality>() { new Quality(1280, 720, 2400, preset), new Quality(1280, 720, 1600, preset), new Quality(640, 360, 700, preset), }); case DefaultQuality.high: return(new List <Quality>() { new Quality(1920, 1080, 6000, preset), new Quality(1920, 1080, 4000, preset), new Quality(1280, 720, 2000, preset), }); case DefaultQuality.ultra: return(new List <Quality>() { new Quality(1920, 1080, 8000, preset), new Quality(1920, 1080, 6000, preset), new Quality(1280, 720, 2000, preset), }); default: break; } // Medium/default return(new List <Quality>() { new Quality(1920, 1080, 3400, preset), new Quality(1280, 720, 1800, preset), new Quality(640, 360, 800, preset), }); }
public Quality Create(string name) { Quality quality; if (name == AgedBrie) { quality = new AgedBrieQuality(); } else if (name == BackstagePass) { quality = new BackStagePassQuality(); } else if (name == Sulfuras) { quality = new SulfurasQuality(); } else { quality = new DefaultQuality(); } return(quality); }
private TwitchVideoQuality GetSelectedQuality(List <TwitchVideoQuality> qualities, DefaultQuality defaultQuality) { TwitchVideoQuality sourceQuality = qualities.Find(q => q.IsSource); if (defaultQuality.IsSource) { return(sourceQuality); } if (defaultQuality.IsAudioOnly) { TwitchVideoQuality audioOnlyQuality = qualities.FirstOrDefault(q => q.IsAudioOnly); if (audioOnlyQuality != null) { return(audioOnlyQuality); } else { return(sourceQuality); } } IEnumerable <TwitchVideoQuality> visualQualities = qualities.Where(q => !q.IsAudioOnly); int defaultRes = defaultQuality.VerticalResolution; TwitchVideoQuality selectedQuality = null; foreach (TwitchVideoQuality quality in visualQualities) { if (quality.VerticalResolution <= defaultRes && (selectedQuality == null || selectedQuality.VerticalResolution < quality.VerticalResolution)) { selectedQuality = quality; } } if (selectedQuality != null) { return(selectedQuality); } foreach (TwitchVideoQuality quality in visualQualities) { if (quality.VerticalResolution >= defaultRes && (selectedQuality == null || selectedQuality.VerticalResolution > quality.VerticalResolution)) { selectedQuality = quality; } } if (selectedQuality != null) { return(selectedQuality); } return(sourceQuality); }