feat(core): shared external-stream asset resolver for Cast (Phase 0)
Add a frontend-agnostic API to resolve a track's bytes + MIME + actually-
delivered quality for an external renderer (Chromecast / DLNA), so the Slint
Cast port does not need an improvised downloader (ADR-006).
- qbz-models: ExternalStreamAsset { bytes, content_type, quality, duration,
origin }, StreamQualityInfo (kHz-normalized via from_raw, handles the
kHz-vs-Hz endpoint ambiguity), AssetOrigin.
- qbz-qobuz/cmaf: download_full_with_quality(_progress) returns the resolved
format_id/sampling_rate/bit_depth alongside the FLAC bytes; download_full is
now a thin wrapper (no duplicated segment assembly).
- qbz-player: Player::fetch_for_external_stream — CMAF-first (FLAC, accurate
quality) with legacy stream-URL fallback; never reads the local playback
cache (casting attempts the best tier and must report the real delivered
quality); never serves an empty content type (external_content_type helper).
- qbz-core: CoreBridge::fetch_for_external_stream_resolved wrapper.
Decision D3 (attempt UltraHiRes first + surface delivered quality) is satisfied
by passing Quality::UltraHiRes and returning StreamQualityInfo. Unit-tested:
content-type fallback by format id, sampling-rate unit normalization.
cc
This commit is contained in:
5 files changed
+278
-3
No files matched your search
@@ -7,6 +7,7 @@ use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
use qbz_models::{
|
||||
ExternalStreamAsset,
|
||||
Album, Artist, ArtistAlbums, CoreEvent, DiscoverAlbum, DiscoverData, DiscoverPlaylistsResponse,
|
||||
DiscoverResponse, FrontendAdapter, GenreInfo, LabelExploreResponse, LabelGetListResponse,
|
||||
LabelListPage, LabelPageData, LabelStoryResponse, PageArtistResponse,
|
||||
@@ -664,6 +665,23 @@ impl<A: FrontendAdapter + Send + Sync + 'static> QbzCore<A> {
|
||||
self.player.fetch_for_gapless(client, track_id, quality).await
|
||||
}
|
||||
|
||||
/// Resolve a fully-materialized audio asset (bytes + MIME + delivered
|
||||
/// quality) for an EXTERNAL renderer (Chromecast / DLNA). The Cast service
|
||||
/// hands the bytes to the local media server and the quality to the UI.
|
||||
/// Attempts the best tier first (pass `Quality::UltraHiRes`); the resolver
|
||||
/// falls back down the chain and reports what was actually delivered.
|
||||
pub async fn fetch_for_external_stream_resolved(
|
||||
&self,
|
||||
track_id: u64,
|
||||
quality: Quality,
|
||||
) -> Option<ExternalStreamAsset> {
|
||||
let guard = self.client.read().await;
|
||||
let client = guard.as_ref()?;
|
||||
self.player
|
||||
.fetch_for_external_stream(client, track_id, quality)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Advance to next track in queue
|
||||
pub async fn next_track(&self) -> Option<QueueTrack> {
|
||||
let queue = self.queue.write().await;
|
||||
|
||||
Reference in new issue
Block a user