Publish file/device quality updates to sync app state
This commit is contained in:
25
src/api.rs
25
src/api.rs
@@ -17,11 +17,17 @@ type Aes128CbcDec = cbc::Decryptor<Aes128>;
|
||||
pub enum TrackStream {
|
||||
DirectUrl {
|
||||
url: String,
|
||||
sampling_rate_hz: Option<u32>,
|
||||
bit_depth: Option<u32>,
|
||||
channels: Option<u32>,
|
||||
},
|
||||
Segmented {
|
||||
url_template: String,
|
||||
n_segments: u32,
|
||||
encryption_key_hex: Option<String>,
|
||||
sampling_rate_hz: Option<u32>,
|
||||
bit_depth: Option<u32>,
|
||||
channels: Option<u32>,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -482,7 +488,12 @@ impl QobuzApi {
|
||||
}
|
||||
|
||||
if let Some(url) = file.url {
|
||||
return Ok(TrackStream::DirectUrl { url });
|
||||
return Ok(TrackStream::DirectUrl {
|
||||
url,
|
||||
sampling_rate_hz: file.sampling_rate.map(|v| v.round() as u32),
|
||||
bit_depth: file.bit_depth.map(|v| v as u32),
|
||||
channels: Some(2),
|
||||
});
|
||||
}
|
||||
|
||||
if let (Some(url_template), Some(n_segments)) = (file.url_template, file.n_segments) {
|
||||
@@ -490,6 +501,9 @@ impl QobuzApi {
|
||||
url_template,
|
||||
n_segments,
|
||||
encryption_key_hex: file.key,
|
||||
sampling_rate_hz: file.sampling_rate.map(|v| v.round() as u32),
|
||||
bit_depth: file.bit_depth.map(|v| v as u32),
|
||||
channels: Some(2),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -566,7 +580,12 @@ impl QobuzApi {
|
||||
let url = self
|
||||
.get_track_url_legacy(access_token, track_id, format_id)
|
||||
.await?;
|
||||
Ok(TrackStream::DirectUrl { url })
|
||||
Ok(TrackStream::DirectUrl {
|
||||
url,
|
||||
sampling_rate_hz: None,
|
||||
bit_depth: None,
|
||||
channels: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -581,7 +600,7 @@ impl QobuzApi {
|
||||
.get_track_stream(access_token, track_id, format_id)
|
||||
.await?
|
||||
{
|
||||
TrackStream::DirectUrl { url } => Ok(url),
|
||||
TrackStream::DirectUrl { url, .. } => Ok(url),
|
||||
TrackStream::Segmented { .. } => Err(QobuzError::ApiError(
|
||||
"Track uses segmented stream; use get_track_stream instead".to_string(),
|
||||
)),
|
||||
|
||||
Reference in New Issue
Block a user