Compare commits
No commits in common. "4f9ebe2bce1e197d2aeec5f686183cac0824d759" and "a0e76633238c7dfb8bb7cf30ee65bbf09f454f80" have entirely different histories.
4f9ebe2bce
...
a0e7663323
@ -489,21 +489,18 @@ public class SRFPlayChannel : IChannel, IHasCacheKey
|
|||||||
var overview = chapter.Description ?? chapter.Lead;
|
var overview = chapter.Description ?? chapter.Lead;
|
||||||
|
|
||||||
// Get image URL - prefer chapter image, fall back to show image if available
|
// Get image URL - prefer chapter image, fall back to show image if available
|
||||||
var originalImageUrl = chapter.ImageUrl;
|
var imageUrl = chapter.ImageUrl;
|
||||||
if (string.IsNullOrEmpty(originalImageUrl) && mediaComposition.Show != null)
|
if (string.IsNullOrEmpty(imageUrl) && mediaComposition.Show != null)
|
||||||
{
|
{
|
||||||
originalImageUrl = mediaComposition.Show.ImageUrl;
|
imageUrl = mediaComposition.Show.ImageUrl;
|
||||||
_logger.LogDebug("URN {Urn}: Using show image as fallback", urn);
|
_logger.LogDebug("URN {Urn}: Using show image as fallback", urn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(originalImageUrl))
|
if (string.IsNullOrEmpty(imageUrl))
|
||||||
{
|
{
|
||||||
_logger.LogWarning("URN {Urn}: No image URL available for '{Title}'", urn, chapter.Title);
|
_logger.LogWarning("URN {Urn}: No image URL available for '{Title}'", urn, chapter.Title);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Proxy image URL to fix Content-Type headers from SRF CDN
|
|
||||||
var imageUrl = CreateProxiedImageUrl(originalImageUrl, serverUrl);
|
|
||||||
|
|
||||||
// Use ValidFrom for premiere date if this is a scheduled livestream, otherwise use Date
|
// Use ValidFrom for premiere date if this is a scheduled livestream, otherwise use Date
|
||||||
var premiereDate = chapter.Type == "SCHEDULED_LIVESTREAM" ? chapter.ValidFrom?.ToUniversalTime() : chapter.Date?.ToUniversalTime();
|
var premiereDate = chapter.Type == "SCHEDULED_LIVESTREAM" ? chapter.ValidFrom?.ToUniversalTime() : chapter.Date?.ToUniversalTime();
|
||||||
|
|
||||||
@ -620,24 +617,6 @@ public class SRFPlayChannel : IChannel, IHasCacheKey
|
|||||||
}
|
}
|
||||||
#pragma warning restore CA5351
|
#pragma warning restore CA5351
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a proxy URL for an image to fix Content-Type headers from SRF CDN.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="originalUrl">The original SRF image URL.</param>
|
|
||||||
/// <param name="serverUrl">The server base URL.</param>
|
|
||||||
/// <returns>The proxied image URL, or null if original is null.</returns>
|
|
||||||
private static string? CreateProxiedImageUrl(string? originalUrl, string serverUrl)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(originalUrl))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Encode the original URL as base64 for safe transport
|
|
||||||
var encodedUrl = Convert.ToBase64String(Encoding.UTF8.GetBytes(originalUrl));
|
|
||||||
return $"{serverUrl}/Plugins/SRFPlay/Proxy/Image?url={encodedUrl}";
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool IsEnabledFor(string userId)
|
public bool IsEnabledFor(string userId)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,11 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Net.Http;
|
|
||||||
using System.Net.Http.Headers;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Jellyfin.Plugin.SRFPlay.Services.Interfaces;
|
using Jellyfin.Plugin.SRFPlay.Services.Interfaces;
|
||||||
using MediaBrowser.Common.Net;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
@ -22,22 +19,16 @@ public class StreamProxyController : ControllerBase
|
|||||||
{
|
{
|
||||||
private readonly ILogger<StreamProxyController> _logger;
|
private readonly ILogger<StreamProxyController> _logger;
|
||||||
private readonly IStreamProxyService _proxyService;
|
private readonly IStreamProxyService _proxyService;
|
||||||
private readonly IHttpClientFactory _httpClientFactory;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="StreamProxyController"/> class.
|
/// Initializes a new instance of the <see cref="StreamProxyController"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="logger">The logger.</param>
|
/// <param name="logger">The logger.</param>
|
||||||
/// <param name="proxyService">The proxy service.</param>
|
/// <param name="proxyService">The proxy service.</param>
|
||||||
/// <param name="httpClientFactory">The HTTP client factory.</param>
|
public StreamProxyController(ILogger<StreamProxyController> logger, IStreamProxyService proxyService)
|
||||||
public StreamProxyController(
|
|
||||||
ILogger<StreamProxyController> logger,
|
|
||||||
IStreamProxyService proxyService,
|
|
||||||
IHttpClientFactory httpClientFactory)
|
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_proxyService = proxyService;
|
_proxyService = proxyService;
|
||||||
_httpClientFactory = httpClientFactory;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -325,117 +316,4 @@ public class StreamProxyController : ControllerBase
|
|||||||
|
|
||||||
return "application/octet-stream";
|
return "application/octet-stream";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Proxies image requests from SRF CDN, fixing Content-Type headers.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="url">The original image URL (base64 encoded).</param>
|
|
||||||
/// <param name="cancellationToken">Cancellation token.</param>
|
|
||||||
/// <returns>The image data with correct Content-Type.</returns>
|
|
||||||
[HttpGet("Image")]
|
|
||||||
[AllowAnonymous]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
public async Task<IActionResult> GetImage(
|
|
||||||
[FromQuery] string url,
|
|
||||||
CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(url))
|
|
||||||
{
|
|
||||||
return BadRequest("URL parameter is required");
|
|
||||||
}
|
|
||||||
|
|
||||||
string decodedUrl;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Decode base64 URL
|
|
||||||
var bytes = Convert.FromBase64String(url);
|
|
||||||
decodedUrl = System.Text.Encoding.UTF8.GetString(bytes);
|
|
||||||
}
|
|
||||||
catch (FormatException)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Invalid base64 URL parameter: {Url}", url);
|
|
||||||
return BadRequest("Invalid URL encoding");
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogDebug("Proxying image from: {Url}", decodedUrl);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var httpClient = _httpClientFactory.CreateClient(NamedClient.Default);
|
|
||||||
|
|
||||||
// Create request with proper headers
|
|
||||||
var request = new HttpRequestMessage(HttpMethod.Get, new Uri(decodedUrl));
|
|
||||||
request.Headers.UserAgent.ParseAdd(
|
|
||||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36");
|
|
||||||
request.Headers.Accept.ParseAdd("image/jpeg, image/png, image/webp, image/*;q=0.8");
|
|
||||||
|
|
||||||
var response = await httpClient.SendAsync(
|
|
||||||
request,
|
|
||||||
HttpCompletionOption.ResponseHeadersRead,
|
|
||||||
cancellationToken).ConfigureAwait(false);
|
|
||||||
|
|
||||||
if (!response.IsSuccessStatusCode)
|
|
||||||
{
|
|
||||||
_logger.LogWarning(
|
|
||||||
"Image fetch failed with status {StatusCode} for {Url}",
|
|
||||||
response.StatusCode,
|
|
||||||
decodedUrl);
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
var imageData = await response.Content.ReadAsByteArrayAsync(cancellationToken)
|
|
||||||
.ConfigureAwait(false);
|
|
||||||
|
|
||||||
// Determine correct content type
|
|
||||||
var contentType = GetImageContentType(decodedUrl);
|
|
||||||
|
|
||||||
_logger.LogDebug(
|
|
||||||
"Returning proxied image ({Length} bytes, {ContentType})",
|
|
||||||
imageData.Length,
|
|
||||||
contentType);
|
|
||||||
|
|
||||||
return File(imageData, contentType);
|
|
||||||
}
|
|
||||||
catch (HttpRequestException ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Error fetching image from {Url}", decodedUrl);
|
|
||||||
return StatusCode(StatusCodes.Status502BadGateway);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the content type for an image based on URL or file extension.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="url">The image URL.</param>
|
|
||||||
/// <returns>The MIME content type.</returns>
|
|
||||||
private static string GetImageContentType(string url)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(url))
|
|
||||||
{
|
|
||||||
return "image/jpeg";
|
|
||||||
}
|
|
||||||
|
|
||||||
var uri = new Uri(url);
|
|
||||||
var path = uri.AbsolutePath.ToLowerInvariant();
|
|
||||||
|
|
||||||
if (path.EndsWith(".png", StringComparison.Ordinal))
|
|
||||||
{
|
|
||||||
return "image/png";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (path.EndsWith(".gif", StringComparison.Ordinal))
|
|
||||||
{
|
|
||||||
return "image/gif";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (path.EndsWith(".webp", StringComparison.Ordinal))
|
|
||||||
{
|
|
||||||
return "image/webp";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default to JPEG for SRF images (most common)
|
|
||||||
return "image/jpeg";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -156,46 +156,26 @@ public class SRFImageProvider : IRemoteImageProvider, IHasOrder
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async Task<HttpResponseMessage> GetImageResponse(string url, CancellationToken cancellationToken)
|
public async Task<HttpResponseMessage> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
_logger.LogDebug("Fetching image from URL: {Url}", url);
|
|
||||||
|
|
||||||
var httpClient = _httpClientFactory.CreateClient(NamedClient.Default);
|
var httpClient = _httpClientFactory.CreateClient(NamedClient.Default);
|
||||||
|
|
||||||
// Create request with proper headers - SRF CDN requires User-Agent
|
// Create request with proper headers - SRF CDN requires User-Agent
|
||||||
var request = new HttpRequestMessage(HttpMethod.Get, new Uri(url));
|
var request = new HttpRequestMessage(HttpMethod.Get, new Uri(url));
|
||||||
request.Headers.UserAgent.ParseAdd("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36");
|
request.Headers.UserAgent.ParseAdd("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36");
|
||||||
request.Headers.Accept.ParseAdd("image/jpeg, image/png, image/webp, image/*;q=0.8");
|
request.Headers.Accept.ParseAdd("image/*");
|
||||||
|
|
||||||
var response = await httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
|
var response = await httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
var originalContentType = response.Content.Headers.ContentType?.MediaType;
|
// Fix Content-Type if it's binary/octet-stream - SRF CDN returns wrong content type
|
||||||
_logger.LogDebug(
|
|
||||||
"Image response status: {StatusCode}, Content-Type: {ContentType}, Content-Length: {Length}",
|
|
||||||
response.StatusCode,
|
|
||||||
originalContentType ?? "null",
|
|
||||||
response.Content.Headers.ContentLength);
|
|
||||||
|
|
||||||
// Fix Content-Type if it's not a proper image type - SRF CDN often returns wrong content type
|
|
||||||
// Jellyfin needs correct Content-Type to process images
|
// Jellyfin needs correct Content-Type to process images
|
||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode &&
|
||||||
|
response.Content.Headers.ContentType?.MediaType == "binary/octet-stream")
|
||||||
{
|
{
|
||||||
var needsContentTypeFix = string.IsNullOrEmpty(originalContentType) ||
|
// Determine correct content type from URL extension
|
||||||
originalContentType == "binary/octet-stream" ||
|
var contentType = GetContentTypeFromUrl(url);
|
||||||
originalContentType == "application/octet-stream" ||
|
if (!string.IsNullOrEmpty(contentType))
|
||||||
!originalContentType.StartsWith("image/", StringComparison.OrdinalIgnoreCase);
|
|
||||||
|
|
||||||
if (needsContentTypeFix)
|
|
||||||
{
|
{
|
||||||
// Determine correct content type from URL extension or default to JPEG
|
_logger.LogDebug("Fixing Content-Type from binary/octet-stream to {ContentType} for {Url}", contentType, url);
|
||||||
var contentType = GetContentTypeFromUrl(url);
|
response.Content.Headers.ContentType = new MediaTypeHeaderValue(contentType);
|
||||||
if (!string.IsNullOrEmpty(contentType))
|
|
||||||
{
|
|
||||||
_logger.LogInformation(
|
|
||||||
"Fixing Content-Type from '{OriginalType}' to '{NewType}' for {Url}",
|
|
||||||
originalContentType ?? "null",
|
|
||||||
contentType,
|
|
||||||
url);
|
|
||||||
response.Content.Headers.ContentType = new MediaTypeHeaderValue(contentType);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Jellyfin.Plugin.SRFPlay.Configuration;
|
using Jellyfin.Plugin.SRFPlay.Configuration;
|
||||||
@ -20,10 +22,12 @@ namespace Jellyfin.Plugin.SRFPlay.Providers;
|
|||||||
public class SRFMediaProvider : IMediaSourceProvider
|
public class SRFMediaProvider : IMediaSourceProvider
|
||||||
{
|
{
|
||||||
private readonly ILogger<SRFMediaProvider> _logger;
|
private readonly ILogger<SRFMediaProvider> _logger;
|
||||||
|
private readonly ILoggerFactory _loggerFactory;
|
||||||
private readonly IMediaCompositionFetcher _compositionFetcher;
|
private readonly IMediaCompositionFetcher _compositionFetcher;
|
||||||
private readonly IStreamUrlResolver _streamResolver;
|
private readonly IStreamUrlResolver _streamResolver;
|
||||||
private readonly IStreamProxyService _proxyService;
|
private readonly IStreamProxyService _proxyService;
|
||||||
private readonly IServerApplicationHost _appHost;
|
private readonly IServerApplicationHost _appHost;
|
||||||
|
private readonly Dictionary<string, string> _openTokenToItemId = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="SRFMediaProvider"/> class.
|
/// Initializes a new instance of the <see cref="SRFMediaProvider"/> class.
|
||||||
@ -40,6 +44,7 @@ public class SRFMediaProvider : IMediaSourceProvider
|
|||||||
IStreamProxyService proxyService,
|
IStreamProxyService proxyService,
|
||||||
IServerApplicationHost appHost)
|
IServerApplicationHost appHost)
|
||||||
{
|
{
|
||||||
|
_loggerFactory = loggerFactory;
|
||||||
_logger = loggerFactory.CreateLogger<SRFMediaProvider>();
|
_logger = loggerFactory.CreateLogger<SRFMediaProvider>();
|
||||||
_compositionFetcher = compositionFetcher;
|
_compositionFetcher = compositionFetcher;
|
||||||
_streamResolver = streamResolver;
|
_streamResolver = streamResolver;
|
||||||
@ -167,8 +172,14 @@ public class SRFMediaProvider : IMediaSourceProvider
|
|||||||
? config.PublicServerUrl.TrimEnd('/') // Use configured public URL (important for Android/remote clients)
|
? config.PublicServerUrl.TrimEnd('/') // Use configured public URL (important for Android/remote clients)
|
||||||
: _appHost.GetSmartApiUrl(string.Empty); // Fall back to Jellyfin's smart URL resolution
|
: _appHost.GetSmartApiUrl(string.Empty); // Fall back to Jellyfin's smart URL resolution
|
||||||
|
|
||||||
// Create proxy URL - item ID is all we need since proxy handles auth
|
// Generate an open token for this media source (used to track transcoding sessions)
|
||||||
var proxyUrl = $"{serverUrl}/Plugins/SRFPlay/Proxy/{itemIdStr}/master.m3u8";
|
var openToken = Guid.NewGuid().ToString("N");
|
||||||
|
_openTokenToItemId[openToken] = itemIdStr;
|
||||||
|
_logger.LogDebug("Created open token {OpenToken} for item {ItemId}", openToken, itemIdStr);
|
||||||
|
|
||||||
|
// Create proxy URL using token instead of item ID in path
|
||||||
|
// This prevents Jellyfin from rewriting the URL during transcoding
|
||||||
|
var proxyUrl = $"{serverUrl}/Plugins/SRFPlay/Proxy/{itemIdStr}/master.m3u8?token={openToken}";
|
||||||
|
|
||||||
_logger.LogInformation(
|
_logger.LogInformation(
|
||||||
"Using proxy URL for item {ItemId}: {ProxyUrl} (PublicServerUrl configured: {IsPublicConfigured})",
|
"Using proxy URL for item {ItemId}: {ProxyUrl} (PublicServerUrl configured: {IsPublicConfigured})",
|
||||||
@ -186,17 +197,36 @@ public class SRFMediaProvider : IMediaSourceProvider
|
|||||||
Container = "hls",
|
Container = "hls",
|
||||||
SupportsDirectStream = true,
|
SupportsDirectStream = true,
|
||||||
SupportsDirectPlay = true, // ✅ Enabled! Proxy handles auth
|
SupportsDirectPlay = true, // ✅ Enabled! Proxy handles auth
|
||||||
SupportsTranscoding = false, // Prefer DirectPlay - no transcoding needed for HLS
|
SupportsTranscoding = true,
|
||||||
IsRemote = false, // False because it's a local proxy endpoint
|
IsRemote = false, // False because it's a local proxy endpoint
|
||||||
Type = MediaSourceType.Default,
|
Type = MediaSourceType.Default,
|
||||||
RunTimeTicks = chapter.Duration > 0 ? TimeSpan.FromMilliseconds(chapter.Duration).Ticks : null,
|
RunTimeTicks = chapter.Duration > 0 ? TimeSpan.FromMilliseconds(chapter.Duration).Ticks : null,
|
||||||
VideoType = VideoType.VideoFile,
|
VideoType = VideoType.VideoFile,
|
||||||
IsInfiniteStream = isLiveStream, // True for live streams!
|
IsInfiniteStream = isLiveStream, // True for live streams!
|
||||||
RequiresOpening = false, // Proxy handles auth - no need for OpenMediaSource
|
RequiresOpening = true, // Enable to handle transcoding sessions
|
||||||
RequiresClosing = false,
|
RequiresClosing = false,
|
||||||
SupportsProbing = true, // Enable probing so Jellyfin can verify stream compatibility
|
SupportsProbing = false, // Disable probing for proxy URLs
|
||||||
ReadAtNativeFramerate = isLiveStream, // Read at native framerate for live streams
|
ReadAtNativeFramerate = isLiveStream, // Read at native framerate for live streams
|
||||||
MediaStreams = CreateMediaStreams(qualityPref)
|
OpenToken = openToken, // Token to identify this media source
|
||||||
|
MediaStreams = new List<MediaBrowser.Model.Entities.MediaStream>
|
||||||
|
{
|
||||||
|
new MediaBrowser.Model.Entities.MediaStream
|
||||||
|
{
|
||||||
|
Type = MediaStreamType.Video,
|
||||||
|
Codec = "h264",
|
||||||
|
Profile = "high",
|
||||||
|
IsInterlaced = false,
|
||||||
|
IsDefault = true,
|
||||||
|
Index = 0
|
||||||
|
},
|
||||||
|
new MediaBrowser.Model.Entities.MediaStream
|
||||||
|
{
|
||||||
|
Type = MediaStreamType.Audio,
|
||||||
|
Codec = "aac",
|
||||||
|
IsDefault = true,
|
||||||
|
Index = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
sources.Add(mediaSource);
|
sources.Add(mediaSource);
|
||||||
@ -241,57 +271,26 @@ public class SRFMediaProvider : IMediaSourceProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public Task<ILiveStream> OpenMediaSource(string openToken, List<ILiveStream> currentLiveStreams, CancellationToken cancellationToken)
|
public async Task<ILiveStream> OpenMediaSource(string openToken, List<ILiveStream> currentLiveStreams, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
// Not used - RequiresOpening is false, proxy handles authentication directly
|
_logger.LogInformation("OpenMediaSource called with openToken: {OpenToken}", openToken);
|
||||||
_logger.LogWarning("OpenMediaSource unexpectedly called with openToken: {OpenToken}", openToken);
|
|
||||||
throw new NotSupportedException("OpenMediaSource not supported - streams use direct proxy access");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
// Look up the original item ID from the open token
|
||||||
/// Creates MediaStream metadata based on quality preference.
|
if (!_openTokenToItemId.TryGetValue(openToken, out var originalItemId))
|
||||||
/// These are approximate values - HLS adaptive streaming will use actual stream qualities.
|
|
||||||
/// </summary>
|
|
||||||
private static List<MediaBrowser.Model.Entities.MediaStream> CreateMediaStreams(QualityPreference quality)
|
|
||||||
{
|
|
||||||
// Set resolution/bitrate based on quality preference
|
|
||||||
// These are typical values for SRF streams - actual HLS will adapt
|
|
||||||
var (width, height, videoBitrate) = quality switch
|
|
||||||
{
|
{
|
||||||
QualityPreference.SD => (1280, 720, 2500000),
|
_logger.LogError("Open token {OpenToken} not found in registry", openToken);
|
||||||
QualityPreference.HD => (1920, 1080, 5000000),
|
throw new InvalidOperationException($"Open token {openToken} not found");
|
||||||
_ => (1280, 720, 3000000)
|
}
|
||||||
};
|
|
||||||
|
|
||||||
return new List<MediaBrowser.Model.Entities.MediaStream>
|
_logger.LogInformation("Open token {OpenToken} maps to original item ID: {ItemId}", openToken, originalItemId);
|
||||||
{
|
|
||||||
new MediaBrowser.Model.Entities.MediaStream
|
// Create a live stream wrapper
|
||||||
{
|
var liveStream = new SRFLiveStream(
|
||||||
Type = MediaStreamType.Video,
|
_logger,
|
||||||
Codec = "h264",
|
_proxyService,
|
||||||
Profile = "high",
|
originalItemId,
|
||||||
Level = 40,
|
openToken);
|
||||||
Width = width,
|
|
||||||
Height = height,
|
return await Task.FromResult<ILiveStream>(liveStream).ConfigureAwait(false);
|
||||||
BitRate = videoBitrate,
|
|
||||||
BitDepth = 8,
|
|
||||||
IsInterlaced = false,
|
|
||||||
IsDefault = true,
|
|
||||||
Index = 0,
|
|
||||||
IsAVC = true,
|
|
||||||
PixelFormat = "yuv420p"
|
|
||||||
},
|
|
||||||
new MediaBrowser.Model.Entities.MediaStream
|
|
||||||
{
|
|
||||||
Type = MediaStreamType.Audio,
|
|
||||||
Codec = "aac",
|
|
||||||
Profile = "LC",
|
|
||||||
Channels = 2,
|
|
||||||
SampleRate = 48000,
|
|
||||||
BitRate = 128000,
|
|
||||||
IsDefault = true,
|
|
||||||
Index = 1
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user