aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2017-11-05 16:51:23 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2017-11-05 16:51:23 -0500
commit5cb74690284105db70a467ab77c2af3f44e42348 (patch)
tree0e37b05d34dbcbe3d08d0c74229287cd0cd6f496 /MediaBrowser.Controller
parentb9c1f61681de23d95de7c6b392eb3e55670991da (diff)
support track selection before playback
Diffstat (limited to 'MediaBrowser.Controller')
-rw-r--r--MediaBrowser.Controller/Entities/Audio/Audio.cs5
-rw-r--r--MediaBrowser.Controller/Entities/BaseItem.cs2
-rw-r--r--MediaBrowser.Controller/Entities/IHasMediaSources.cs1
-rw-r--r--MediaBrowser.Controller/Entities/Video.cs5
-rw-r--r--MediaBrowser.Controller/LiveTv/LiveTvChannel.cs5
-rw-r--r--MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs16
-rw-r--r--MediaBrowser.Controller/MediaEncoding/IEncodingManager.cs3
-rw-r--r--MediaBrowser.Controller/Providers/DirectoryService.cs52
-rw-r--r--MediaBrowser.Controller/Providers/IDirectoryService.cs3
9 files changed, 59 insertions, 33 deletions
diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs
index 16fd75d2e..8ef1060d1 100644
--- a/MediaBrowser.Controller/Entities/Audio/Audio.cs
+++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs
@@ -51,6 +51,11 @@ namespace MediaBrowser.Controller.Entities.Audio
return 1;
}
+ public bool SupportsMediaSourceSelection()
+ {
+ return false;
+ }
+
[IgnoreDataMember]
public override bool SupportsPlayedStatus
{
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs
index 7f6949feb..f6a8f1d5a 100644
--- a/MediaBrowser.Controller/Entities/BaseItem.cs
+++ b/MediaBrowser.Controller/Entities/BaseItem.cs
@@ -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
diff --git a/MediaBrowser.Controller/Entities/IHasMediaSources.cs b/MediaBrowser.Controller/Entities/IHasMediaSources.cs
index 54786134f..399fe9f5a 100644
--- a/MediaBrowser.Controller/Entities/IHasMediaSources.cs
+++ b/MediaBrowser.Controller/Entities/IHasMediaSources.cs
@@ -13,5 +13,6 @@ namespace MediaBrowser.Controller.Entities
/// <returns>Task{IEnumerable{MediaSourceInfo}}.</returns>
List<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution);
List<MediaStream> GetMediaStreams();
+ bool SupportsMediaSourceSelection();
}
}
diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs
index 52f1dd051..60db53f79 100644
--- a/MediaBrowser.Controller/Entities/Video.cs
+++ b/MediaBrowser.Controller/Entities/Video.cs
@@ -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>
diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs
index 16010b7f5..ac961d757 100644
--- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs
+++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs
@@ -24,6 +24,11 @@ namespace MediaBrowser.Controller.LiveTv
return list;
}
+ public bool SupportsMediaSourceSelection()
+ {
+ return false;
+ }
+
public override UnratedItem GetBlockUnratedType()
{
return UnratedItem.LiveTvChannel;
diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
index bddafe9a6..8f8791922 100644
--- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
+++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
@@ -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";
diff --git a/MediaBrowser.Controller/MediaEncoding/IEncodingManager.cs b/MediaBrowser.Controller/MediaEncoding/IEncodingManager.cs
index 81269fe3f..7d50efd5e 100644
--- a/MediaBrowser.Controller/MediaEncoding/IEncodingManager.cs
+++ b/MediaBrowser.Controller/MediaEncoding/IEncodingManager.cs
@@ -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);
}
}
diff --git a/MediaBrowser.Controller/Providers/DirectoryService.cs b/MediaBrowser.Controller/Providers/DirectoryService.cs
index d957470d3..d673198fd 100644
--- a/MediaBrowser.Controller/Providers/DirectoryService.cs
+++ b/MediaBrowser.Controller/Providers/DirectoryService.cs
@@ -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)
{
@@ -33,11 +33,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))
{
throw new ArgumentNullException("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,7 +54,8 @@ namespace MediaBrowser.Controller.Providers
entries = new FileSystemMetadata[] { };
}
- _cache.TryAdd(path, entries);
+ //_cache.TryAdd(path, entries);
+ _cache[path] = entries;
}
return entries;
@@ -74,13 +63,8 @@ namespace MediaBrowser.Controller.Providers
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;
+ }
+
}
}
diff --git a/MediaBrowser.Controller/Providers/IDirectoryService.cs b/MediaBrowser.Controller/Providers/IDirectoryService.cs
index 6f864f4be..0b4574f6e 100644
--- a/MediaBrowser.Controller/Providers/IDirectoryService.cs
+++ b/MediaBrowser.Controller/Providers/IDirectoryService.cs
@@ -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);
}
} \ No newline at end of file