feat(stream): add stream quality selection and update stream URL handling
This commit is contained in:
@@ -14,7 +14,7 @@ pub mod value_objects;
|
||||
// Re-export commonly used types
|
||||
pub use entities::*;
|
||||
pub use errors::{DomainError, DomainResult};
|
||||
pub use ports::{Collection, IMediaProvider, ProviderCapabilities, SeriesSummary, StreamingProtocol};
|
||||
pub use ports::{Collection, IMediaProvider, ProviderCapabilities, SeriesSummary, StreamingProtocol, StreamQuality};
|
||||
pub use repositories::*;
|
||||
pub use iptv::{generate_m3u, generate_xmltv};
|
||||
pub use services::{ChannelService, ScheduleEngineService, UserService};
|
||||
|
||||
@@ -12,6 +12,19 @@ use crate::entities::MediaItem;
|
||||
use crate::errors::{DomainError, DomainResult};
|
||||
use crate::value_objects::{ContentType, MediaFilter, MediaItemId};
|
||||
|
||||
// ============================================================================
|
||||
// Stream quality
|
||||
// ============================================================================
|
||||
|
||||
/// Requested stream quality for `get_stream_url`.
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum StreamQuality {
|
||||
/// Try direct stream via PlaybackInfo; fall back to HLS at 8 Mbps.
|
||||
Direct,
|
||||
/// Force HLS transcode at this bitrate (bits per second).
|
||||
Transcode(u32),
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Provider capabilities
|
||||
// ============================================================================
|
||||
@@ -113,7 +126,7 @@ pub trait IMediaProvider: Send + Sync {
|
||||
///
|
||||
/// URLs are intentionally *not* stored in the schedule because they may be
|
||||
/// short-lived (signed URLs, session tokens) or depend on client context.
|
||||
async fn get_stream_url(&self, item_id: &MediaItemId) -> DomainResult<String>;
|
||||
async fn get_stream_url(&self, item_id: &MediaItemId, quality: &StreamQuality) -> DomainResult<String>;
|
||||
|
||||
/// List top-level collections (libraries/sections) available in this provider.
|
||||
///
|
||||
|
||||
@@ -10,7 +10,7 @@ use crate::entities::{
|
||||
ScheduledSlot,
|
||||
};
|
||||
use crate::errors::{DomainError, DomainResult};
|
||||
use crate::ports::IMediaProvider;
|
||||
use crate::ports::{IMediaProvider, StreamQuality};
|
||||
use crate::repositories::{ChannelRepository, ScheduleRepository};
|
||||
use crate::value_objects::{
|
||||
BlockId, ChannelId, FillStrategy, MediaFilter, MediaItemId, RecyclePolicy,
|
||||
@@ -224,8 +224,8 @@ impl ScheduleEngineService {
|
||||
}
|
||||
|
||||
/// Delegate stream URL resolution to the configured media provider.
|
||||
pub async fn get_stream_url(&self, item_id: &MediaItemId) -> DomainResult<String> {
|
||||
self.media_provider.get_stream_url(item_id).await
|
||||
pub async fn get_stream_url(&self, item_id: &MediaItemId, quality: &StreamQuality) -> DomainResult<String> {
|
||||
self.media_provider.get_stream_url(item_id, quality).await
|
||||
}
|
||||
|
||||
/// Return all slots that overlap the given time window — the EPG data.
|
||||
|
||||
Reference in New Issue
Block a user