SyncHelper.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using System.Globalization;
  3. namespace MediaBrowser.Server.Implementations.Sync
  4. {
  5. public class SyncHelper
  6. {
  7. public static int? AdjustBitrate(int? profileBitrate, string quality)
  8. {
  9. if (profileBitrate.HasValue)
  10. {
  11. if (string.Equals(quality, "medium", StringComparison.OrdinalIgnoreCase))
  12. {
  13. profileBitrate = Convert.ToInt32(profileBitrate.Value * .75);
  14. }
  15. else if (string.Equals(quality, "low", StringComparison.OrdinalIgnoreCase))
  16. {
  17. profileBitrate = Convert.ToInt32(profileBitrate.Value*.5);
  18. }
  19. else
  20. {
  21. int value;
  22. if (int.TryParse(quality, NumberStyles.Any, CultureInfo.InvariantCulture, out value))
  23. {
  24. profileBitrate = value;
  25. }
  26. }
  27. }
  28. return profileBitrate;
  29. }
  30. }
  31. }