mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-06-23 15:30:56 -04:00
improve cancellation support of auto-organize
This commit is contained in:
parent
cb5c9333c5
commit
f641c501a7
@ -500,11 +500,7 @@ namespace Emby.Common.Implementations.Networking
|
|||||||
{
|
{
|
||||||
return IpAddressInfo.IPv6Loopback;
|
return IpAddressInfo.IPv6Loopback;
|
||||||
}
|
}
|
||||||
return new IpAddressInfo
|
return new IpAddressInfo(address.ToString(), address.AddressFamily == AddressFamily.InterNetworkV6 ? IpAddressFamily.InterNetworkV6 : IpAddressFamily.InterNetwork);
|
||||||
{
|
|
||||||
Address = address.ToString(),
|
|
||||||
AddressFamily = address.AddressFamily == AddressFamily.InterNetworkV6 ? IpAddressFamily.InterNetworkV6 : IpAddressFamily.InterNetwork
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IpAddressInfo[]> GetHostAddressesAsync(string host)
|
public async Task<IpAddressInfo[]> GetHostAddressesAsync(string host)
|
||||||
|
@ -72,17 +72,24 @@ namespace Emby.Server.Implementations.FileOrganization
|
|||||||
|
|
||||||
foreach (var file in eligibleFiles)
|
foreach (var file in eligibleFiles)
|
||||||
{
|
{
|
||||||
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
var organizer = new EpisodeFileOrganizer(_organizationService, _config, _fileSystem, _logger, _libraryManager,
|
var organizer = new EpisodeFileOrganizer(_organizationService, _config, _fileSystem, _logger, _libraryManager,
|
||||||
_libraryMonitor, _providerManager);
|
_libraryMonitor, _providerManager);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var result = await organizer.OrganizeEpisodeFile(file.FullName, options, options.TvOptions.OverwriteExistingEpisodes, cancellationToken).ConfigureAwait(false);
|
var result = await organizer.OrganizeEpisodeFile(file.FullName, options, options.TvOptions.OverwriteExistingEpisodes, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
if (result.Status == FileSortingStatus.Success && !processedFolders.Contains(file.DirectoryName, StringComparer.OrdinalIgnoreCase))
|
if (result.Status == FileSortingStatus.Success && !processedFolders.Contains(file.DirectoryName, StringComparer.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
processedFolders.Add(file.DirectoryName);
|
processedFolders.Add(file.DirectoryName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (OperationCanceledException)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.ErrorException("Error organizing episode {0}", ex, file.FullName);
|
_logger.ErrorException("Error organizing episode {0}", ex, file.FullName);
|
||||||
|
@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
|||||||
using MediaBrowser.Controller.MediaEncoding;
|
using MediaBrowser.Controller.MediaEncoding;
|
||||||
using MediaBrowser.Model.Dlna;
|
using MediaBrowser.Model.Dlna;
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
|
|
||||||
namespace Emby.Server.Implementations.LiveTv
|
namespace Emby.Server.Implementations.LiveTv
|
||||||
@ -29,6 +30,8 @@ namespace Emby.Server.Implementations.LiveTv
|
|||||||
|
|
||||||
var now = DateTime.UtcNow;
|
var now = DateTime.UtcNow;
|
||||||
|
|
||||||
|
var allowVideoStreamCopy = mediaSource.MediaStreams.Any(i => i.Type == MediaStreamType.Video && i.AllowStreamCopy);
|
||||||
|
|
||||||
var info = await _mediaEncoder.GetMediaInfo(new MediaInfoRequest
|
var info = await _mediaEncoder.GetMediaInfo(new MediaInfoRequest
|
||||||
{
|
{
|
||||||
InputPath = mediaSource.Path,
|
InputPath = mediaSource.Path,
|
||||||
@ -73,6 +76,8 @@ namespace Emby.Server.Implementations.LiveTv
|
|||||||
var videoStream = mediaSource.MediaStreams.FirstOrDefault(i => i.Type == MediaBrowser.Model.Entities.MediaStreamType.Video);
|
var videoStream = mediaSource.MediaStreams.FirstOrDefault(i => i.Type == MediaBrowser.Model.Entities.MediaStreamType.Video);
|
||||||
if (videoStream != null)
|
if (videoStream != null)
|
||||||
{
|
{
|
||||||
|
videoStream.AllowStreamCopy = allowVideoStreamCopy;
|
||||||
|
|
||||||
if (!videoStream.BitRate.HasValue)
|
if (!videoStream.BitRate.HasValue)
|
||||||
{
|
{
|
||||||
var width = videoStream.Width ?? 1920;
|
var width = videoStream.Width ?? 1920;
|
||||||
|
@ -261,7 +261,7 @@ namespace Emby.Server.Implementations.LiveTv
|
|||||||
return info.Item1;
|
return info.Item1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<Tuple<MediaSourceInfo, IDirectStreamProvider, bool>> GetChannelStream(string id, string mediaSourceId, CancellationToken cancellationToken)
|
public Task<Tuple<MediaSourceInfo, IDirectStreamProvider>> GetChannelStream(string id, string mediaSourceId, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
return GetLiveStream(id, mediaSourceId, true, cancellationToken);
|
return GetLiveStream(id, mediaSourceId, true, cancellationToken);
|
||||||
}
|
}
|
||||||
@ -323,7 +323,7 @@ namespace Emby.Server.Implementations.LiveTv
|
|||||||
return _services.FirstOrDefault(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase));
|
return _services.FirstOrDefault(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Tuple<MediaSourceInfo, IDirectStreamProvider, bool>> GetLiveStream(string id, string mediaSourceId, bool isChannel, CancellationToken cancellationToken)
|
private async Task<Tuple<MediaSourceInfo, IDirectStreamProvider>> GetLiveStream(string id, string mediaSourceId, bool isChannel, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (string.Equals(id, mediaSourceId, StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(id, mediaSourceId, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
@ -334,7 +334,6 @@ namespace Emby.Server.Implementations.LiveTv
|
|||||||
bool isVideo;
|
bool isVideo;
|
||||||
ILiveTvService service;
|
ILiveTvService service;
|
||||||
IDirectStreamProvider directStreamProvider = null;
|
IDirectStreamProvider directStreamProvider = null;
|
||||||
var assumeInterlaced = false;
|
|
||||||
|
|
||||||
if (isChannel)
|
if (isChannel)
|
||||||
{
|
{
|
||||||
@ -383,12 +382,7 @@ namespace Emby.Server.Implementations.LiveTv
|
|||||||
|
|
||||||
Normalize(info, service, isVideo);
|
Normalize(info, service, isVideo);
|
||||||
|
|
||||||
if (!(service is EmbyTV.EmbyTV))
|
return new Tuple<MediaSourceInfo, IDirectStreamProvider>(info, directStreamProvider);
|
||||||
{
|
|
||||||
assumeInterlaced = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Tuple<MediaSourceInfo, IDirectStreamProvider, bool>(info, directStreamProvider, assumeInterlaced);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Normalize(MediaSourceInfo mediaSource, ILiveTvService service, bool isVideo)
|
private void Normalize(MediaSourceInfo mediaSource, ILiveTvService service, bool isVideo)
|
||||||
@ -492,6 +486,12 @@ namespace Emby.Server.Implementations.LiveTv
|
|||||||
{
|
{
|
||||||
stream.NalLengthSize = "0";
|
stream.NalLengthSize = "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stream.Type == MediaStreamType.Video)
|
||||||
|
{
|
||||||
|
stream.IsInterlaced = true;
|
||||||
|
stream.AllowStreamCopy = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ namespace Emby.Server.Implementations.LiveTv
|
|||||||
{
|
{
|
||||||
if (!stream.SupportsProbing || stream.MediaStreams.Any(i => i.Index != -1))
|
if (!stream.SupportsProbing || stream.MediaStreams.Any(i => i.Index != -1))
|
||||||
{
|
{
|
||||||
await AddMediaInfo(stream, isAudio, cancellationToken).ConfigureAwait(false);
|
AddMediaInfo(stream, isAudio, cancellationToken);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -158,7 +158,7 @@ namespace Emby.Server.Implementations.LiveTv
|
|||||||
return new Tuple<MediaSourceInfo, IDirectStreamProvider>(stream, directStreamProvider);
|
return new Tuple<MediaSourceInfo, IDirectStreamProvider>(stream, directStreamProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task AddMediaInfo(MediaSourceInfo mediaSource, bool isAudio, CancellationToken cancellationToken)
|
private void AddMediaInfo(MediaSourceInfo mediaSource, bool isAudio, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
mediaSource.DefaultSubtitleStreamIndex = null;
|
mediaSource.DefaultSubtitleStreamIndex = null;
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ namespace MediaBrowser.Controller.LiveTv
|
|||||||
/// <param name="mediaSourceId">The media source identifier.</param>
|
/// <param name="mediaSourceId">The media source identifier.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task{StreamResponseInfo}.</returns>
|
/// <returns>Task{StreamResponseInfo}.</returns>
|
||||||
Task<Tuple<MediaSourceInfo, IDirectStreamProvider, bool>> GetChannelStream(string id, string mediaSourceId, CancellationToken cancellationToken);
|
Task<Tuple<MediaSourceInfo, IDirectStreamProvider>> GetChannelStream(string id, string mediaSourceId, CancellationToken cancellationToken);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the program.
|
/// Gets the program.
|
||||||
|
@ -743,6 +743,11 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
|
|
||||||
public bool CanStreamCopyVideo(EncodingJobInfo state, MediaStream videoStream)
|
public bool CanStreamCopyVideo(EncodingJobInfo state, MediaStream videoStream)
|
||||||
{
|
{
|
||||||
|
if (!videoStream.AllowStreamCopy)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var request = state.BaseRequest;
|
var request = state.BaseRequest;
|
||||||
|
|
||||||
if (videoStream.IsInterlaced)
|
if (videoStream.IsInterlaced)
|
||||||
@ -883,6 +888,11 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
|
|
||||||
public bool CanStreamCopyAudio(EncodingJobInfo state, MediaStream audioStream, List<string> supportedAudioCodecs)
|
public bool CanStreamCopyAudio(EncodingJobInfo state, MediaStream audioStream, List<string> supportedAudioCodecs)
|
||||||
{
|
{
|
||||||
|
if (!audioStream.AllowStreamCopy)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var request = state.BaseRequest;
|
var request = state.BaseRequest;
|
||||||
|
|
||||||
// Source and target codecs must match
|
// Source and target codecs must match
|
||||||
|
@ -13,6 +13,11 @@ namespace MediaBrowser.Model.Entities
|
|||||||
[DebuggerDisplay("StreamType = {Type}")]
|
[DebuggerDisplay("StreamType = {Type}")]
|
||||||
public class MediaStream
|
public class MediaStream
|
||||||
{
|
{
|
||||||
|
public MediaStream()
|
||||||
|
{
|
||||||
|
AllowStreamCopy = true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the codec.
|
/// Gets or sets the codec.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -153,6 +158,8 @@ namespace MediaBrowser.Model.Entities
|
|||||||
|
|
||||||
public bool? IsAVC { get; set; }
|
public bool? IsAVC { get; set; }
|
||||||
|
|
||||||
|
public bool AllowStreamCopy { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the channel layout.
|
/// Gets or sets the channel layout.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -12,13 +12,13 @@ namespace MediaBrowser.Model.Net
|
|||||||
public string Address { get; set; }
|
public string Address { get; set; }
|
||||||
public IpAddressFamily AddressFamily { get; set; }
|
public IpAddressFamily AddressFamily { get; set; }
|
||||||
|
|
||||||
public IpAddressInfo()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public IpAddressInfo(string address, IpAddressFamily addressFamily)
|
public IpAddressInfo(string address, IpAddressFamily addressFamily)
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(address))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("address");
|
||||||
|
}
|
||||||
|
|
||||||
Address = address;
|
Address = address;
|
||||||
AddressFamily = addressFamily;
|
AddressFamily = addressFamily;
|
||||||
}
|
}
|
||||||
|
@ -247,10 +247,7 @@ namespace Rssdp.Infrastructure
|
|||||||
{
|
{
|
||||||
await SendMessageIfSocketNotDisposed(messageData, new IpEndPointInfo
|
await SendMessageIfSocketNotDisposed(messageData, new IpEndPointInfo
|
||||||
{
|
{
|
||||||
IpAddress = new IpAddressInfo
|
IpAddress = new IpAddressInfo(SsdpConstants.MulticastLocalAdminAddress, IpAddressFamily.InterNetwork),
|
||||||
{
|
|
||||||
Address = SsdpConstants.MulticastLocalAdminAddress
|
|
||||||
},
|
|
||||||
Port = SsdpConstants.MulticastPort
|
Port = SsdpConstants.MulticastPort
|
||||||
|
|
||||||
}, cancellationToken).ConfigureAwait(false);
|
}, cancellationToken).ConfigureAwait(false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user