support track selection before playback

This commit is contained in:
Luke Pulverenti
2017-11-05 16:51:23 -05:00
parent b9c1f61681
commit 5cb7469028
41 changed files with 355 additions and 675 deletions

View File

@@ -51,6 +51,11 @@ namespace MediaBrowser.Controller.Entities.Audio
return 1;
}
public bool SupportsMediaSourceSelection()
{
return false;
}
[IgnoreDataMember]
public override bool SupportsPlayedStatus
{

View File

@@ -2040,7 +2040,7 @@ namespace MediaBrowser.Controller.Entities
.Where(i => i.IsLocalFile)
.Select(i => FileSystem.GetDirectoryName(i.Path))
.Distinct(StringComparer.OrdinalIgnoreCase)
.SelectMany(i => FileSystem.GetFilePaths(i))
.SelectMany(i => directoryService.GetFilePaths(i))
.ToList();
var deletedImages = ImageInfos

View File

@@ -13,5 +13,6 @@ namespace MediaBrowser.Controller.Entities
/// <returns>Task{IEnumerable{MediaSourceInfo}}.</returns>
List<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution);
List<MediaStream> GetMediaStreams();
bool SupportsMediaSourceSelection();
}
}

View File

@@ -109,6 +109,11 @@ namespace MediaBrowser.Controller.Entities
get { return true; }
}
public bool SupportsMediaSourceSelection()
{
return SourceType == SourceType.Library;
}
/// <summary>
/// Gets or sets the timestamp.
/// </summary>

View File

@@ -24,6 +24,11 @@ namespace MediaBrowser.Controller.LiveTv
return list;
}
public bool SupportsMediaSourceSelection()
{
return false;
}
public override UnratedItem GetBlockUnratedType()
{
return UnratedItem.LiveTvChannel;

View File

@@ -1325,6 +1325,8 @@ namespace MediaBrowser.Controller.MediaEncoding
if (state.VideoStream != null && state.VideoStream.Width.HasValue && state.VideoStream.Height.HasValue)
{
videoSizeParam = string.Format("scale={0}:{1}", state.VideoStream.Width.Value.ToString(_usCulture), state.VideoStream.Height.Value.ToString(_usCulture));
videoSizeParam += ":force_original_aspect_ratio=decrease";
}
var mapPrefix = state.SubtitleStream.IsExternal ?
@@ -1335,7 +1337,7 @@ namespace MediaBrowser.Controller.MediaEncoding
? 0
: state.SubtitleStream.Index;
return string.Format(" -filter_complex \"[{0}:{1}]{4}[sub] ; [0:{2}] [sub] overlay{3}\"",
return string.Format(" -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}][sub]overlay{3}\"",
mapPrefix.ToString(_usCulture),
subtitleStreamIndex.ToString(_usCulture),
state.VideoStream.Index.ToString(_usCulture),
@@ -2094,6 +2096,12 @@ namespace MediaBrowser.Controller.MediaEncoding
args += " -avoid_negative_ts disabled -start_at_zero";
}
// This is for internal graphical subs
if (hasGraphicalSubs)
{
args += GetGraphicalSubtitleParam(state, encodingOptions, videoCodec);
}
var qualityParam = GetVideoQualityParam(state, videoCodec, encodingOptions, defaultH264Preset);
if (!string.IsNullOrEmpty(qualityParam))
@@ -2101,12 +2109,6 @@ namespace MediaBrowser.Controller.MediaEncoding
args += " " + qualityParam.Trim();
}
// This is for internal graphical subs
if (hasGraphicalSubs)
{
args += GetGraphicalSubtitleParam(state, encodingOptions, videoCodec);
}
if (!state.RunTimeTicks.HasValue)
{
args += " -flags -global_header";

View File

@@ -3,6 +3,7 @@ using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Entities;
using MediaBrowser.Controller.Providers;
namespace MediaBrowser.Controller.MediaEncoding
{
@@ -11,6 +12,6 @@ namespace MediaBrowser.Controller.MediaEncoding
/// <summary>
/// Refreshes the chapter images.
/// </summary>
Task<bool> RefreshChapterImages(Video video, List<ChapterInfo> chapters, bool extractImages, bool saveChapters, CancellationToken cancellationToken);
Task<bool> RefreshChapterImages(Video video, IDirectoryService directoryService, List<ChapterInfo> chapters, bool extractImages, bool saveChapters, CancellationToken cancellationToken);
}
}

View File

@@ -14,11 +14,11 @@ namespace MediaBrowser.Controller.Providers
private readonly ILogger _logger;
private readonly IFileSystem _fileSystem;
private readonly ConcurrentDictionary<string, FileSystemMetadata[]> _cache =
new ConcurrentDictionary<string, FileSystemMetadata[]>(StringComparer.OrdinalIgnoreCase);
private readonly Dictionary<string, FileSystemMetadata[]> _cache = new Dictionary<string, FileSystemMetadata[]>(StringComparer.OrdinalIgnoreCase);
private readonly ConcurrentDictionary<string, FileSystemMetadata> _fileCache =
new ConcurrentDictionary<string, FileSystemMetadata>(StringComparer.OrdinalIgnoreCase);
private readonly Dictionary<string, FileSystemMetadata> _fileCache = new Dictionary<string, FileSystemMetadata>(StringComparer.OrdinalIgnoreCase);
private readonly Dictionary<string, List<string>> _filePathCache = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase);
public DirectoryService(ILogger logger, IFileSystem fileSystem)
{
@@ -32,11 +32,6 @@ namespace MediaBrowser.Controller.Providers
}
public FileSystemMetadata[] GetFileSystemEntries(string path)
{
return GetFileSystemEntries(path, false);
}
private FileSystemMetadata[] GetFileSystemEntries(string path, bool clearCache)
{
if (string.IsNullOrWhiteSpace(path))
{
@@ -45,13 +40,6 @@ namespace MediaBrowser.Controller.Providers
FileSystemMetadata[] entries;
if (clearCache)
{
FileSystemMetadata[] removed;
_cache.TryRemove(path, out removed);
}
if (!_cache.TryGetValue(path, out entries))
{
//_logger.Debug("Getting files for " + path);
@@ -66,21 +54,17 @@ namespace MediaBrowser.Controller.Providers
entries = new FileSystemMetadata[] { };
}
_cache.TryAdd(path, entries);
//_cache.TryAdd(path, entries);
_cache[path] = entries;
}
return entries;
}
public List<FileSystemMetadata> GetFiles(string path)
{
return GetFiles(path, false);
}
public List<FileSystemMetadata> GetFiles(string path, bool clearCache)
{
var list = new List<FileSystemMetadata>();
var items = GetFileSystemEntries(path, clearCache);
var items = GetFileSystemEntries(path);
foreach (var item in items)
{
if (!item.IsDirectory)
@@ -100,7 +84,8 @@ namespace MediaBrowser.Controller.Providers
if (file != null && file.Exists)
{
_fileCache.TryAdd(path, file);
//_fileCache.TryAdd(path, file);
_fileCache[path] = file;
}
else
{
@@ -111,5 +96,24 @@ namespace MediaBrowser.Controller.Providers
return file;
//return _fileSystem.GetFileInfo(path);
}
public List<string> GetFilePaths(string path)
{
return GetFilePaths(path, false);
}
public List<string> GetFilePaths(string path, bool clearCache)
{
List<string> result;
if (clearCache || !_filePathCache.TryGetValue(path, out result))
{
result = _fileSystem.GetFilePaths(path).ToList();
_filePathCache[path] = result;
}
return result;
}
}
}

View File

@@ -8,5 +8,8 @@ namespace MediaBrowser.Controller.Providers
FileSystemMetadata[] GetFileSystemEntries(string path);
List<FileSystemMetadata> GetFiles(string path);
FileSystemMetadata GetFile(string path);
List<string> GetFilePaths(string path);
List<string> GetFilePaths(string path, bool clearCache);
}
}