From ff328fefc57461bd999210b3059b997e7f9842ac Mon Sep 17 00:00:00 2001 From: cvium Date: Fri, 10 Sep 2021 12:53:45 +0200 Subject: [PATCH] Replace GetDirectStreamProviderByUniqueId with GetLiveStreamInfoByUniqueId --- .../Library/MediaSourceManager.cs | 13 ++++++------- Jellyfin.Api/Controllers/LiveTvController.cs | 2 +- .../Library/IMediaSourceManager.cs | 9 +++++++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Emby.Server.Implementations/Library/MediaSourceManager.cs b/Emby.Server.Implementations/Library/MediaSourceManager.cs index d6d67fcf4b..16231c73fc 100644 --- a/Emby.Server.Implementations/Library/MediaSourceManager.cs +++ b/Emby.Server.Implementations/Library/MediaSourceManager.cs @@ -587,13 +587,6 @@ namespace Emby.Server.Implementations.Library mediaSource.InferTotalBitrate(); } - public Task GetDirectStreamProviderByUniqueId(string uniqueId, CancellationToken cancellationToken) - { - var info = _openStreams.FirstOrDefault(i => i.Value != null && string.Equals(i.Value.UniqueId, uniqueId, StringComparison.OrdinalIgnoreCase)); - - return Task.FromResult(info.Value as IDirectStreamProvider); - } - public async Task OpenLiveStream(LiveStreamRequest request, CancellationToken cancellationToken) { var result = await OpenLiveStreamInternal(request, cancellationToken).ConfigureAwait(false); @@ -799,6 +792,12 @@ namespace Emby.Server.Implementations.Library return null; } + /// + public ILiveStream GetLiveStreamInfoByUniqueId(string uniqueId) + { + return _openStreams.Values.FirstOrDefault(stream => string.Equals(uniqueId, stream?.UniqueId, StringComparison.OrdinalIgnoreCase)); + } + public async Task GetLiveStream(string id, CancellationToken cancellationToken) { var result = await GetLiveStreamWithDirectStreamProvider(id, cancellationToken).ConfigureAwait(false); diff --git a/Jellyfin.Api/Controllers/LiveTvController.cs b/Jellyfin.Api/Controllers/LiveTvController.cs index 3f68b267f3..b131530c93 100644 --- a/Jellyfin.Api/Controllers/LiveTvController.cs +++ b/Jellyfin.Api/Controllers/LiveTvController.cs @@ -1201,7 +1201,7 @@ namespace Jellyfin.Api.Controllers [ProducesVideoFile] public ActionResult GetLiveStreamFile([FromRoute, Required] string streamId, [FromRoute, Required] string container) { - var liveStreamInfo = _mediaSourceManager.GetLiveStreamInfo(streamId); + var liveStreamInfo = _mediaSourceManager.GetLiveStreamInfoByUniqueId(streamId); if (liveStreamInfo == null) { return NotFound(); diff --git a/MediaBrowser.Controller/Library/IMediaSourceManager.cs b/MediaBrowser.Controller/Library/IMediaSourceManager.cs index 0de3ccf3f0..e802796d34 100644 --- a/MediaBrowser.Controller/Library/IMediaSourceManager.cs +++ b/MediaBrowser.Controller/Library/IMediaSourceManager.cs @@ -116,6 +116,13 @@ namespace MediaBrowser.Controller.Library /// An instance of . public ILiveStream GetLiveStreamInfo(string id); + /// + /// Gets the live stream info using the stream's unique id. + /// + /// The unique identifier. + /// An instance of . + public ILiveStream GetLiveStreamInfoByUniqueId(string uniqueId); + /// /// Closes the media source. /// @@ -132,7 +139,5 @@ namespace MediaBrowser.Controller.Library void SetDefaultAudioAndSubtitleStreamIndexes(BaseItem item, MediaSourceInfo source, User user); Task AddMediaInfoWithProbe(MediaSourceInfo mediaSource, bool isAudio, string cacheKey, bool addProbeDelay, bool isLiveStream, CancellationToken cancellationToken); - - Task GetDirectStreamProviderByUniqueId(string uniqueId, CancellationToken cancellationToken); } }