1
0
Fork 0
mirror of https://github.com/librespot-org/librespot.git synced 2025-10-04 02:09:26 +02:00

Lay groundwork for new Spotify API client (#805)

Lay groundwork for new Spotify API before removing `spirc`

* Add token provider
* Introduce HTTP client
* Introduce caching `ApResolver` component
* Remove `keymaster` and update example
* Use `PacketType` instead of hex identifiers
* Document new unknown packet 0xb6
This commit is contained in:
Roderick van Domburg 2021-06-28 20:58:58 +02:00 committed by GitHub
parent 113ac94c07
commit 39bf40bcc7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
62 changed files with 3101 additions and 1837 deletions

View file

@ -1,7 +1,8 @@
use super::{Open, Sink, SinkAsBytes};
use crate::config::AudioFormat;
use crate::convert::Converter;
use crate::decoder::AudioPacket;
use crate::player::{NUM_CHANNELS, SAMPLE_RATE};
use crate::{NUM_CHANNELS, SAMPLE_RATE};
use gstreamer as gst;
use gstreamer_app as gst_app;
@ -33,11 +34,17 @@ impl Open for GstreamerSink {
let sample_size = format.size();
let gst_bytes = 2048 * sample_size;
#[cfg(target_endian = "little")]
const ENDIANNESS: &str = "LE";
#[cfg(target_endian = "big")]
const ENDIANNESS: &str = "BE";
let pipeline_str_preamble = format!(
"appsrc caps=\"audio/x-raw,format={}LE,layout=interleaved,channels={},rate={}\" block=true max-bytes={} name=appsrc0 ",
gst_format, NUM_CHANNELS, SAMPLE_RATE, gst_bytes
"appsrc caps=\"audio/x-raw,format={}{},layout=interleaved,channels={},rate={}\" block=true max-bytes={} name=appsrc0 ",
gst_format, ENDIANNESS, NUM_CHANNELS, SAMPLE_RATE, gst_bytes
);
let pipeline_str_rest = r#" ! audioconvert ! autoaudiosink"#;
// no need to dither twice; use librespot dithering instead
let pipeline_str_rest = r#" ! audioconvert dithering=none ! autoaudiosink"#;
let pipeline_str: String = match device {
Some(x) => format!("{}{}", pipeline_str_preamble, x),
None => format!("{}{}", pipeline_str_preamble, pipeline_str_rest),
@ -120,7 +127,6 @@ impl Open for GstreamerSink {
}
impl Sink for GstreamerSink {
start_stop_noop!();
sink_as_bytes!();
}
@ -133,3 +139,7 @@ impl SinkAsBytes for GstreamerSink {
Ok(())
}
}
impl GstreamerSink {
pub const NAME: &'static str = "gstreamer";
}