mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-02 20:32:52 +01:00
implement modular media sources
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using MediaBrowser.Controller.LiveTv;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Model.Dlna;
|
||||
using MediaBrowser.Model.Drawing;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Logging;
|
||||
@@ -17,7 +18,7 @@ namespace MediaBrowser.Api.Playback
|
||||
public class StreamState : IDisposable
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILiveTvManager _liveTvManager;
|
||||
private readonly IMediaSourceManager _mediaSourceManager;
|
||||
|
||||
public string RequestedUrl { get; set; }
|
||||
|
||||
@@ -39,7 +40,7 @@ namespace MediaBrowser.Api.Playback
|
||||
|
||||
public string InputContainer { get; set; }
|
||||
|
||||
public List<MediaStream> AllMediaStreams { get; set; }
|
||||
public MediaSourceInfo MediaSource { get; set; }
|
||||
|
||||
public MediaStream AudioStream { get; set; }
|
||||
public MediaStream VideoStream { get; set; }
|
||||
@@ -64,8 +65,6 @@ namespace MediaBrowser.Api.Playback
|
||||
|
||||
public List<string> PlayableStreamFileNames { get; set; }
|
||||
|
||||
public string LiveTvStreamId { get; set; }
|
||||
|
||||
public int SegmentLength = 3;
|
||||
public bool EnableGenericHlsSegmenter = false;
|
||||
public int HlsListSize
|
||||
@@ -86,14 +85,13 @@ namespace MediaBrowser.Api.Playback
|
||||
|
||||
public List<string> SupportedAudioCodecs { get; set; }
|
||||
|
||||
public StreamState(ILiveTvManager liveTvManager, ILogger logger)
|
||||
public StreamState(IMediaSourceManager mediaSourceManager, ILogger logger)
|
||||
{
|
||||
_liveTvManager = liveTvManager;
|
||||
_mediaSourceManager = mediaSourceManager;
|
||||
_logger = logger;
|
||||
SupportedAudioCodecs = new List<string>();
|
||||
PlayableStreamFileNames = new List<string>();
|
||||
RemoteHttpHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
AllMediaStreams = new List<MediaStream>();
|
||||
}
|
||||
|
||||
public string InputAudioSync { get; set; }
|
||||
@@ -113,9 +111,6 @@ namespace MediaBrowser.Api.Playback
|
||||
|
||||
public long? EncodingDurationTicks { get; set; }
|
||||
|
||||
public string ItemType { get; set; }
|
||||
public string ItemId { get; set; }
|
||||
|
||||
public string GetMimeType(string outputPath)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(MimeType))
|
||||
@@ -187,15 +182,15 @@ namespace MediaBrowser.Api.Playback
|
||||
|
||||
private async void DisposeLiveStream()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(LiveTvStreamId))
|
||||
if (MediaSource.RequiresClosing)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _liveTvManager.CloseLiveStream(LiveTvStreamId, CancellationToken.None).ConfigureAwait(false);
|
||||
await _mediaSourceManager.CloseMediaSource(MediaSource.CloseKey, CancellationToken.None).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error closing live tv stream", ex);
|
||||
_logger.ErrorException("Error closing media source", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user