config.rs 971 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. use std::str::FromStr;
  2. #[derive(Clone, Copy, Debug, Hash, PartialOrd, Ord, PartialEq, Eq)]
  3. pub enum Bitrate {
  4. Bitrate96,
  5. Bitrate160,
  6. Bitrate320,
  7. }
  8. impl FromStr for Bitrate {
  9. type Err = ();
  10. fn from_str(s: &str) -> Result<Self, Self::Err> {
  11. match s {
  12. "96" => Ok(Bitrate::Bitrate96),
  13. "160" => Ok(Bitrate::Bitrate160),
  14. "320" => Ok(Bitrate::Bitrate320),
  15. _ => Err(()),
  16. }
  17. }
  18. }
  19. impl Default for Bitrate {
  20. fn default() -> Bitrate {
  21. Bitrate::Bitrate160
  22. }
  23. }
  24. #[derive(Clone, Debug)]
  25. pub struct PlayerConfig {
  26. pub bitrate: Bitrate,
  27. pub normalisation: bool,
  28. pub normalisation_pregain: f32,
  29. pub gapless: bool,
  30. }
  31. impl Default for PlayerConfig {
  32. fn default() -> PlayerConfig {
  33. PlayerConfig {
  34. bitrate: Bitrate::default(),
  35. normalisation: false,
  36. normalisation_pregain: 0.0,
  37. gapless: true,
  38. }
  39. }
  40. }