private bool IsConditionSatisfied(ProfileCondition condition, double?currentValue) { if (!currentValue.HasValue) { // If the value is unknown, it satisfies if not marked as required return(!condition.IsRequired); } double expected; if (DoubleHelper.TryParseCultureInvariant(condition.Value, out expected)) { switch (condition.Condition) { case ProfileConditionType.Equals: return(currentValue.Value.Equals(expected)); case ProfileConditionType.GreaterThanEqual: return(currentValue.Value >= expected); case ProfileConditionType.LessThanEqual: return(currentValue.Value <= expected); case ProfileConditionType.NotEquals: return(!currentValue.Value.Equals(expected)); default: throw new InvalidOperationException("Unexpected ProfileConditionType"); } } return(false); }
private void ParseValue(string value) { if (!string.IsNullOrEmpty(value)) { string[] parts = value.Split('-'); if (parts.Length == 2) { double val; if (DoubleHelper.TryParseCultureInvariant(parts[0], out val)) { _width = val; } if (DoubleHelper.TryParseCultureInvariant(parts[1], out val)) { _height = val; } } } }
private void ApplyTranscodingConditions(StreamInfo item, IEnumerable <ProfileCondition> conditions) { foreach (ProfileCondition condition in conditions) { string value = condition.Value; if (string.IsNullOrEmpty(value)) { continue; } switch (condition.Property) { case ProfileConditionValue.AudioBitrate: { int num; if (IntHelper.TryParseCultureInvariant(value, out num)) { item.AudioBitrate = num; } break; } case ProfileConditionValue.AudioChannels: { int num; if (IntHelper.TryParseCultureInvariant(value, out num)) { item.MaxAudioChannels = num; } break; } case ProfileConditionValue.AudioProfile: case ProfileConditionValue.Has64BitOffsets: case ProfileConditionValue.PacketLength: case ProfileConditionValue.VideoTimestamp: case ProfileConditionValue.VideoBitDepth: { // Not supported yet break; } case ProfileConditionValue.VideoProfile: { item.VideoProfile = value; break; } case ProfileConditionValue.Height: { int num; if (IntHelper.TryParseCultureInvariant(value, out num)) { item.MaxHeight = num; } break; } case ProfileConditionValue.VideoBitrate: { int num; if (IntHelper.TryParseCultureInvariant(value, out num)) { item.VideoBitrate = num; } break; } case ProfileConditionValue.VideoFramerate: { double num; if (DoubleHelper.TryParseCultureInvariant(value, out num)) { item.MaxFramerate = num; } break; } case ProfileConditionValue.VideoLevel: { int num; if (IntHelper.TryParseCultureInvariant(value, out num)) { item.VideoLevel = num; } break; } case ProfileConditionValue.Width: { int num; if (IntHelper.TryParseCultureInvariant(value, out num)) { item.MaxWidth = num; } break; } default: throw new ArgumentException("Unrecognized ProfileConditionValue"); } } }