refactor: replace get_stream_url with get_source_uri per ADR-0002
Providers now expose a source URI (for FFmpeg) instead of a viewer-facing stream URL. Playout Service will own transcoding. - Add SourceUri value object (NetworkUrl | FilePath) - Remove StreamQuality, StreamingProtocol from domain - Simplify ProviderCapabilities (drop streaming_protocol, transcode) - Jellyfin: return static direct stream URL - Local files: return absolute file path - Rename use case get_stream_url -> get_source - Stream endpoint returns JSON SourceUri instead of 307 redirect
This commit is contained in:
@@ -3,20 +3,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::errors::{DomainError, DomainResult};
|
||||
use crate::models::MediaItem;
|
||||
use crate::value_objects::{ContentType, MediaFilter, MediaItemId};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum StreamQuality {
|
||||
Direct,
|
||||
Transcode(u32),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum StreamingProtocol {
|
||||
Hls,
|
||||
DirectFile,
|
||||
}
|
||||
use crate::value_objects::{ContentType, MediaFilter, MediaItemId, SourceUri};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ProviderCapabilities {
|
||||
@@ -26,9 +13,7 @@ pub struct ProviderCapabilities {
|
||||
pub tags: bool,
|
||||
pub decade: bool,
|
||||
pub search: bool,
|
||||
pub streaming_protocol: StreamingProtocol,
|
||||
pub rescan: bool,
|
||||
pub transcode: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
@@ -55,11 +40,7 @@ pub trait IMediaProvider: Send + Sync {
|
||||
|
||||
async fn fetch_by_id(&self, item_id: &MediaItemId) -> DomainResult<Option<MediaItem>>;
|
||||
|
||||
async fn get_stream_url(
|
||||
&self,
|
||||
item_id: &MediaItemId,
|
||||
quality: &StreamQuality,
|
||||
) -> DomainResult<String>;
|
||||
async fn get_source_uri(&self, item_id: &MediaItemId) -> DomainResult<SourceUri>;
|
||||
|
||||
async fn list_collections(&self) -> DomainResult<Vec<Collection>> {
|
||||
Err(DomainError::InfrastructureError(
|
||||
@@ -95,11 +76,7 @@ pub trait IProviderRegistry: Send + Sync {
|
||||
|
||||
async fn fetch_by_id(&self, item_id: &MediaItemId) -> DomainResult<Option<MediaItem>>;
|
||||
|
||||
async fn get_stream_url(
|
||||
&self,
|
||||
item_id: &MediaItemId,
|
||||
quality: &StreamQuality,
|
||||
) -> DomainResult<String>;
|
||||
async fn get_source_uri(&self, item_id: &MediaItemId) -> DomainResult<SourceUri>;
|
||||
|
||||
fn provider_ids(&self) -> Vec<String>;
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ pub use events::{DomainEvent, EventConsumer, EventEnvelope, EventHandler, EventP
|
||||
pub use library::{LibraryCommand, LibraryQuery, LibrarySyncAdapter};
|
||||
pub use media::{
|
||||
Collection, IMediaProvider, IProviderRegistry, ProviderCapabilities, SeriesSummary,
|
||||
StreamQuality, StreamingProtocol,
|
||||
};
|
||||
pub use provider_config::{ProviderConfigCommand, ProviderConfigQuery};
|
||||
pub use schedule::{ScheduleCommand, ScheduleQuery};
|
||||
|
||||
@@ -7,9 +7,9 @@ use crate::models::{
|
||||
};
|
||||
use crate::ports::{
|
||||
ActivityLogCommand, ActivityLogQuery, EventConsumer, EventPublisher, IMediaProvider,
|
||||
LibrarySyncAdapter, ProviderCapabilities, StreamQuality, StreamingProtocol,
|
||||
LibrarySyncAdapter, ProviderCapabilities,
|
||||
};
|
||||
use crate::value_objects::{ChannelId, MediaFilter, MediaItemId};
|
||||
use crate::value_objects::{ChannelId, MediaFilter, MediaItemId, SourceUri};
|
||||
|
||||
pub struct NoopEventPublisher;
|
||||
|
||||
@@ -85,9 +85,7 @@ impl IMediaProvider for NoopMediaProvider {
|
||||
tags: false,
|
||||
decade: false,
|
||||
search: false,
|
||||
streaming_protocol: StreamingProtocol::Hls,
|
||||
rescan: false,
|
||||
transcode: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,11 +97,7 @@ impl IMediaProvider for NoopMediaProvider {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
async fn get_stream_url(
|
||||
&self,
|
||||
_item_id: &MediaItemId,
|
||||
_quality: &StreamQuality,
|
||||
) -> DomainResult<String> {
|
||||
async fn get_source_uri(&self, _item_id: &MediaItemId) -> DomainResult<SourceUri> {
|
||||
Err(crate::errors::DomainError::InfrastructureError(
|
||||
"NoopMediaProvider does not support streaming".into(),
|
||||
))
|
||||
|
||||
@@ -3,9 +3,11 @@ pub mod channel;
|
||||
pub mod ids;
|
||||
pub mod scheduling;
|
||||
pub mod search;
|
||||
pub mod streaming;
|
||||
|
||||
pub use auth::*;
|
||||
pub use channel::*;
|
||||
pub use ids::*;
|
||||
pub use scheduling::*;
|
||||
pub use search::*;
|
||||
pub use streaming::*;
|
||||
|
||||
8
crates/domain/src/value_objects/streaming.rs
Normal file
8
crates/domain/src/value_objects/streaming.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(tag = "type", rename_all = "snake_case")]
|
||||
pub enum SourceUri {
|
||||
NetworkUrl { url: String },
|
||||
FilePath { path: String },
|
||||
}
|
||||
Reference in New Issue
Block a user