mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
core API: move Bitrate and PlayerConfig from core to playback
This commit is contained in:
parent
685c607c15
commit
191caca518
6 changed files with 48 additions and 45 deletions
|
@ -20,31 +20,6 @@ impl Default for SessionConfig {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Hash, PartialOrd, Ord, PartialEq, Eq)]
|
||||
pub enum Bitrate {
|
||||
Bitrate96,
|
||||
Bitrate160,
|
||||
Bitrate320,
|
||||
}
|
||||
|
||||
impl FromStr for Bitrate {
|
||||
type Err = ();
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s {
|
||||
"96" => Ok(Bitrate::Bitrate96),
|
||||
"160" => Ok(Bitrate::Bitrate160),
|
||||
"320" => Ok(Bitrate::Bitrate320),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Bitrate {
|
||||
fn default() -> Bitrate {
|
||||
Bitrate::Bitrate160
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Hash, PartialOrd, Ord, PartialEq, Eq)]
|
||||
pub enum DeviceType {
|
||||
Unknown = 0,
|
||||
|
@ -99,23 +74,6 @@ impl Default for DeviceType {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct PlayerConfig {
|
||||
pub bitrate: Bitrate,
|
||||
pub onstart: Option<String>,
|
||||
pub onstop: Option<String>,
|
||||
}
|
||||
|
||||
impl Default for PlayerConfig {
|
||||
fn default() -> PlayerConfig {
|
||||
PlayerConfig {
|
||||
bitrate: Bitrate::default(),
|
||||
onstart: None,
|
||||
onstop: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ConnectConfig {
|
||||
pub name: String,
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::env;
|
|||
use tokio_core::reactor::Core;
|
||||
|
||||
use librespot::core::authentication::Credentials;
|
||||
use librespot::core::config::{PlayerConfig, SessionConfig};
|
||||
use librespot::playback::config::{PlayerConfig, SessionConfig};
|
||||
use librespot::core::session::Session;
|
||||
use librespot::core::util::SpotifyId;
|
||||
|
||||
|
|
43
playback/src/config.rs
Normal file
43
playback/src/config.rs
Normal file
|
@ -0,0 +1,43 @@
|
|||
use std::str::FromStr;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Hash, PartialOrd, Ord, PartialEq, Eq)]
|
||||
pub enum Bitrate {
|
||||
Bitrate96,
|
||||
Bitrate160,
|
||||
Bitrate320,
|
||||
}
|
||||
|
||||
impl FromStr for Bitrate {
|
||||
type Err = ();
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s {
|
||||
"96" => Ok(Bitrate::Bitrate96),
|
||||
"160" => Ok(Bitrate::Bitrate160),
|
||||
"320" => Ok(Bitrate::Bitrate320),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Bitrate {
|
||||
fn default() -> Bitrate {
|
||||
Bitrate::Bitrate160
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct PlayerConfig {
|
||||
pub bitrate: Bitrate,
|
||||
pub onstart: Option<String>,
|
||||
pub onstop: Option<String>,
|
||||
}
|
||||
|
||||
impl Default for PlayerConfig {
|
||||
fn default() -> PlayerConfig {
|
||||
PlayerConfig {
|
||||
bitrate: Bitrate::default(),
|
||||
onstart: None,
|
||||
onstop: None,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,5 +22,6 @@ extern crate librespot_core as core;
|
|||
extern crate librespot_metadata as metadata;
|
||||
|
||||
pub mod audio_backend;
|
||||
pub mod config;
|
||||
pub mod mixer;
|
||||
pub mod player;
|
||||
|
|
|
@ -9,7 +9,7 @@ use std::sync::mpsc::{RecvError, TryRecvError, RecvTimeoutError};
|
|||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
use core::config::{Bitrate, PlayerConfig};
|
||||
use config::{Bitrate, PlayerConfig};
|
||||
use core::session::Session;
|
||||
use core::util::SpotifyId;
|
||||
|
||||
|
|
|
@ -20,11 +20,12 @@ use std::mem;
|
|||
|
||||
use librespot::core::authentication::{get_credentials, Credentials};
|
||||
use librespot::core::cache::Cache;
|
||||
use librespot::core::config::{Bitrate, DeviceType, PlayerConfig, SessionConfig, ConnectConfig};
|
||||
use librespot::core::config::{DeviceType, SessionConfig, ConnectConfig};
|
||||
use librespot::core::session::Session;
|
||||
use librespot::core::version;
|
||||
|
||||
use librespot::playback::audio_backend::{self, Sink, BACKENDS};
|
||||
use librespot::playback::config::{Bitrate, PlayerConfig};
|
||||
use librespot::discovery::discovery::{discovery, DiscoveryStream};
|
||||
use librespot::playback::mixer::{self, Mixer};
|
||||
use librespot::playback::player::Player;
|
||||
|
|
Loading…
Reference in a new issue