aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Controller')
-rw-r--r--MediaBrowser.Controller/Channels/ChannelAudioItem.cs16
-rw-r--r--MediaBrowser.Controller/Channels/ChannelMediaInfo.cs6
-rw-r--r--MediaBrowser.Controller/Channels/ChannelVideoItem.cs16
-rw-r--r--MediaBrowser.Controller/Channels/IChannelManager.cs6
-rw-r--r--MediaBrowser.Controller/Entities/Video.cs3
-rw-r--r--MediaBrowser.Controller/Library/IMediaSourceManager.cs42
-rw-r--r--MediaBrowser.Controller/Library/IMediaSourceProvider.cs16
-rw-r--r--MediaBrowser.Controller/LiveTv/ILiveTvItem.cs4
-rw-r--r--MediaBrowser.Controller/LiveTv/ILiveTvManager.cs16
-rw-r--r--MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs21
-rw-r--r--MediaBrowser.Controller/LiveTv/LiveTvChannel.cs11
-rw-r--r--MediaBrowser.Controller/LiveTv/LiveTvProgram.cs6
-rw-r--r--MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs23
-rw-r--r--MediaBrowser.Controller/MediaBrowser.Controller.csproj3
-rw-r--r--MediaBrowser.Controller/MediaEncoding/ISubtitleEncoder.cs8
-rw-r--r--MediaBrowser.Controller/MediaEncoding/MediaStreamSelector.cs77
-rw-r--r--MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs7
-rw-r--r--MediaBrowser.Controller/Sync/IHasDynamicAccess.cs18
-rw-r--r--MediaBrowser.Controller/Sync/IServerSyncProvider.cs11
-rw-r--r--MediaBrowser.Controller/Sync/ISyncDataProvider.cs16
-rw-r--r--MediaBrowser.Controller/Sync/SyncedFileInfo.cs (renamed from MediaBrowser.Controller/Sync/SendFileResult.cs)13
21 files changed, 294 insertions, 45 deletions
diff --git a/MediaBrowser.Controller/Channels/ChannelAudioItem.cs b/MediaBrowser.Controller/Channels/ChannelAudioItem.cs
index 91b2407be..8d9024676 100644
--- a/MediaBrowser.Controller/Channels/ChannelAudioItem.cs
+++ b/MediaBrowser.Controller/Channels/ChannelAudioItem.cs
@@ -75,17 +75,23 @@ namespace MediaBrowser.Controller.Channels
public override IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution)
{
- var list = base.GetMediaSources(enablePathSubstitution).ToList();
-
- var sources = ChannelManager.GetChannelItemMediaSources(Id.ToString("N"), false, CancellationToken.None)
- .Result.ToList();
+ var sources = ChannelManager.GetStaticMediaSources(this, false, CancellationToken.None)
+ .Result.ToList();
if (sources.Count > 0)
{
return sources;
}
- list.InsertRange(0, sources);
+ var list = base.GetMediaSources(enablePathSubstitution).ToList();
+
+ foreach (var mediaSource in list)
+ {
+ if (string.IsNullOrWhiteSpace(mediaSource.Path))
+ {
+ mediaSource.Type = MediaSourceType.Placeholder;
+ }
+ }
return list;
}
diff --git a/MediaBrowser.Controller/Channels/ChannelMediaInfo.cs b/MediaBrowser.Controller/Channels/ChannelMediaInfo.cs
index 0c2e30923..1672b75fa 100644
--- a/MediaBrowser.Controller/Channels/ChannelMediaInfo.cs
+++ b/MediaBrowser.Controller/Channels/ChannelMediaInfo.cs
@@ -38,6 +38,7 @@ namespace MediaBrowser.Controller.Channels
public string Id { get; set; }
public bool ReadAtNativeFramerate { get; set; }
+ public bool SupportsDirectPlay { get; set; }
public ChannelMediaInfo()
{
@@ -45,6 +46,7 @@ namespace MediaBrowser.Controller.Channels
// This is most common
Protocol = MediaProtocol.Http;
+ SupportsDirectPlay = true;
}
public MediaSourceInfo ToMediaSource()
@@ -62,7 +64,9 @@ namespace MediaBrowser.Controller.Channels
RunTimeTicks = RunTimeTicks,
Name = id,
Id = id,
- ReadAtNativeFramerate = ReadAtNativeFramerate
+ ReadAtNativeFramerate = ReadAtNativeFramerate,
+ SupportsDirectStream = Protocol == MediaProtocol.File || Protocol == MediaProtocol.Http,
+ SupportsDirectPlay = SupportsDirectPlay
};
var bitrate = (AudioBitrate ?? 0) + (VideoBitrate ?? 0);
diff --git a/MediaBrowser.Controller/Channels/ChannelVideoItem.cs b/MediaBrowser.Controller/Channels/ChannelVideoItem.cs
index d7d4483cd..8eec2021b 100644
--- a/MediaBrowser.Controller/Channels/ChannelVideoItem.cs
+++ b/MediaBrowser.Controller/Channels/ChannelVideoItem.cs
@@ -90,17 +90,23 @@ namespace MediaBrowser.Controller.Channels
public override IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution)
{
- var list = base.GetMediaSources(enablePathSubstitution).ToList();
-
- var sources = ChannelManager.GetChannelItemMediaSources(Id.ToString("N"), false, CancellationToken.None)
- .Result.ToList();
+ var sources = ChannelManager.GetStaticMediaSources(this, false, CancellationToken.None)
+ .Result.ToList();
if (sources.Count > 0)
{
return sources;
}
- list.InsertRange(0, sources);
+ var list = base.GetMediaSources(enablePathSubstitution).ToList();
+
+ foreach (var mediaSource in list)
+ {
+ if (string.IsNullOrWhiteSpace(mediaSource.Path))
+ {
+ mediaSource.Type = MediaSourceType.Placeholder;
+ }
+ }
return list;
}
diff --git a/MediaBrowser.Controller/Channels/IChannelManager.cs b/MediaBrowser.Controller/Channels/IChannelManager.cs
index 05015da37..f5c4ab373 100644
--- a/MediaBrowser.Controller/Channels/IChannelManager.cs
+++ b/MediaBrowser.Controller/Channels/IChannelManager.cs
@@ -112,11 +112,11 @@ namespace MediaBrowser.Controller.Channels
/// <summary>
/// Gets the channel item media sources.
/// </summary>
- /// <param name="id">The identifier.</param>
- /// <param name="includeDynamicSources">if set to <c>true</c> [include dynamic sources].</param>
+ /// <param name="item">The item.</param>
+ /// <param name="includeCachedVersions">if set to <c>true</c> [include cached versions].</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task{IEnumerable{MediaSourceInfo}}.</returns>
- Task<IEnumerable<MediaSourceInfo>> GetChannelItemMediaSources(string id, bool includeDynamicSources, CancellationToken cancellationToken);
+ Task<IEnumerable<MediaSourceInfo>> GetStaticMediaSources(IChannelMediaItem item, bool includeCachedVersions, CancellationToken cancellationToken);
/// <summary>
/// Gets the channel folder.
diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs
index ba84beca3..00dc5dc67 100644
--- a/MediaBrowser.Controller/Entities/Video.cs
+++ b/MediaBrowser.Controller/Entities/Video.cs
@@ -501,7 +501,8 @@ namespace MediaBrowser.Controller.Entities
Formats = (i.FormatName ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(),
Timestamp = i.Timestamp,
Type = type,
- PlayableStreamFileNames = i.PlayableStreamFileNames.ToList()
+ PlayableStreamFileNames = i.PlayableStreamFileNames.ToList(),
+ SupportsDirectStream = i.VideoType == VideoType.VideoFile
};
if (i.IsShortcut)
diff --git a/MediaBrowser.Controller/Library/IMediaSourceManager.cs b/MediaBrowser.Controller/Library/IMediaSourceManager.cs
index c21fed6fc..9cbbabc8d 100644
--- a/MediaBrowser.Controller/Library/IMediaSourceManager.cs
+++ b/MediaBrowser.Controller/Library/IMediaSourceManager.cs
@@ -2,6 +2,7 @@
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
+using MediaBrowser.Model.MediaInfo;
using System;
using System.Collections.Generic;
using System.Threading;
@@ -65,6 +66,14 @@ namespace MediaBrowser.Controller.Library
IEnumerable<MediaSourceInfo> GetStaticMediaSources(IHasMediaSources item, bool enablePathSubstitution, User user);
/// <summary>
+ /// Gets the static media sources.
+ /// </summary>
+ /// <param name="item">The item.</param>
+ /// <param name="enablePathSubstitution">if set to <c>true</c> [enable path substitution].</param>
+ /// <returns>IEnumerable&lt;MediaSourceInfo&gt;.</returns>
+ IEnumerable<MediaSourceInfo> GetStaticMediaSources(IHasMediaSources item, bool enablePathSubstitution);
+
+ /// <summary>
/// Gets the static media source.
/// </summary>
/// <param name="item">The item.</param>
@@ -72,5 +81,38 @@ namespace MediaBrowser.Controller.Library
/// <param name="enablePathSubstitution">if set to <c>true</c> [enable path substitution].</param>
/// <returns>MediaSourceInfo.</returns>
MediaSourceInfo GetStaticMediaSource(IHasMediaSources item, string mediaSourceId, bool enablePathSubstitution);
+
+ /// <summary>
+ /// Opens the media source.
+ /// </summary>
+ /// <param name="request">The request.</param>
+ /// <param name="enableAutoClose">if set to <c>true</c> [enable automatic close].</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
+ /// <returns>Task&lt;MediaSourceInfo&gt;.</returns>
+ Task<LiveStreamResponse> OpenLiveStream(LiveStreamRequest request, bool enableAutoClose, CancellationToken cancellationToken);
+
+ /// <summary>
+ /// Gets the live stream.
+ /// </summary>
+ /// <param name="id">The identifier.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
+ /// <returns>Task&lt;MediaSourceInfo&gt;.</returns>
+ Task<MediaSourceInfo> GetLiveStream(string id, CancellationToken cancellationToken);
+
+ /// <summary>
+ /// Pings the media source.
+ /// </summary>
+ /// <param name="id">The live stream identifier.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
+ /// <returns>Task.</returns>
+ Task PingLiveStream(string id, CancellationToken cancellationToken);
+
+ /// <summary>
+ /// Closes the media source.
+ /// </summary>
+ /// <param name="id">The live stream identifier.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
+ /// <returns>Task.</returns>
+ Task CloseLiveStream(string id, CancellationToken cancellationToken);
}
}
diff --git a/MediaBrowser.Controller/Library/IMediaSourceProvider.cs b/MediaBrowser.Controller/Library/IMediaSourceProvider.cs
index 461285d6c..5b033af4a 100644
--- a/MediaBrowser.Controller/Library/IMediaSourceProvider.cs
+++ b/MediaBrowser.Controller/Library/IMediaSourceProvider.cs
@@ -15,5 +15,21 @@ namespace MediaBrowser.Controller.Library
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task&lt;IEnumerable&lt;MediaSourceInfo&gt;&gt;.</returns>
Task<IEnumerable<MediaSourceInfo>> GetMediaSources(IHasMediaSources item, CancellationToken cancellationToken);
+
+ /// <summary>
+ /// Opens the media source.
+ /// </summary>
+ /// <param name="openToken">The open token.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
+ /// <returns>Task&lt;MediaSourceInfo&gt;.</returns>
+ Task<MediaSourceInfo> OpenMediaSource(string openToken, CancellationToken cancellationToken);
+
+ /// <summary>
+ /// Closes the media source.
+ /// </summary>
+ /// <param name="liveStreamId">The live stream identifier.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
+ /// <returns>Task.</returns>
+ Task CloseMediaSource(string liveStreamId, CancellationToken cancellationToken);
}
}
diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvItem.cs b/MediaBrowser.Controller/LiveTv/ILiveTvItem.cs
index d3334e8ea..6c277a2e1 100644
--- a/MediaBrowser.Controller/LiveTv/ILiveTvItem.cs
+++ b/MediaBrowser.Controller/LiveTv/ILiveTvItem.cs
@@ -1,8 +1,10 @@
-
+using System;
+
namespace MediaBrowser.Controller.LiveTv
{
public interface ILiveTvItem
{
+ Guid Id { get; }
string ServiceName { get; set; }
}
}
diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
index 0b58a9232..d5b5d92a6 100644
--- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
+++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
@@ -301,5 +301,21 @@ namespace MediaBrowser.Controller.LiveTv
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task&lt;QueryResult&lt;BaseItem&gt;&gt;.</returns>
Task<QueryResult<BaseItem>> GetInternalRecordings(RecordingQuery query, CancellationToken cancellationToken);
+
+ /// <summary>
+ /// Gets the recording media sources.
+ /// </summary>
+ /// <param name="id">The identifier.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
+ /// <returns>Task&lt;IEnumerable&lt;MediaSourceInfo&gt;&gt;.</returns>
+ Task<IEnumerable<MediaSourceInfo>> GetRecordingMediaSources(string id, CancellationToken cancellationToken);
+
+ /// <summary>
+ /// Gets the channel media sources.
+ /// </summary>
+ /// <param name="id">The identifier.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
+ /// <returns>Task&lt;IEnumerable&lt;MediaSourceInfo&gt;&gt;.</returns>
+ Task<IEnumerable<MediaSourceInfo>> GetChannelMediaSources(string id, CancellationToken cancellationToken);
}
}
diff --git a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs
index 9815066ef..0dc296d5a 100644
--- a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs
+++ b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs
@@ -1,10 +1,12 @@
-using System.Runtime.Serialization;
-using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Model.Configuration;
+using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Users;
+using System.Collections.Generic;
using System.Linq;
+using System.Runtime.Serialization;
namespace MediaBrowser.Controller.LiveTv
{
@@ -99,5 +101,20 @@ namespace MediaBrowser.Controller.LiveTv
{
return user.Policy.EnableLiveTvManagement;
}
+
+ public override IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution)
+ {
+ var list = base.GetMediaSources(enablePathSubstitution).ToList();
+
+ foreach (var mediaSource in list)
+ {
+ if (string.IsNullOrWhiteSpace(mediaSource.Path))
+ {
+ mediaSource.Type = MediaSourceType.Placeholder;
+ }
+ }
+
+ return list;
+ }
}
}
diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs
index 75e418bcc..cb10003ed 100644
--- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs
+++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs
@@ -82,6 +82,15 @@ namespace MediaBrowser.Controller.LiveTv
/// <value><c>null</c> if [has image] contains no value, <c>true</c> if [has image]; otherwise, <c>false</c>.</value>
public bool? HasProviderImage { get; set; }
+ public override LocationType LocationType
+ {
+ get
+ {
+ // TODO: This should be removed
+ return LocationType.Remote;
+ }
+ }
+
protected override string CreateSortName()
{
double number = 0;
@@ -127,7 +136,7 @@ namespace MediaBrowser.Controller.LiveTv
Name = Name,
Path = Path,
RunTimeTicks = RunTimeTicks,
- Type = MediaSourceType.Default
+ Type = MediaSourceType.Placeholder
};
list.Add(info);
diff --git a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs
index 0b07d8b6d..0609df4c6 100644
--- a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs
+++ b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs
@@ -35,6 +35,12 @@ namespace MediaBrowser.Controller.LiveTv
public string ExternalChannelId { get; set; }
/// <summary>
+ /// Gets or sets the original air date.
+ /// </summary>
+ /// <value>The original air date.</value>
+ public DateTime? OriginalAirDate { get; set; }
+
+ /// <summary>
/// Gets or sets the type of the channel.
/// </summary>
/// <value>The type of the channel.</value>
diff --git a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs
index 207684d55..3669f9440 100644
--- a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs
+++ b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs
@@ -1,9 +1,11 @@
-using System.Runtime.Serialization;
-using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Configuration;
+using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
-using System.Linq;
using MediaBrowser.Model.Users;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
namespace MediaBrowser.Controller.LiveTv
{
@@ -97,5 +99,20 @@ namespace MediaBrowser.Controller.LiveTv
{
return user.Policy.EnableLiveTvManagement;
}
+
+ public override IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution)
+ {
+ var list = base.GetMediaSources(enablePathSubstitution).ToList();
+
+ foreach (var mediaSource in list)
+ {
+ if (string.IsNullOrWhiteSpace(mediaSource.Path))
+ {
+ mediaSource.Type = MediaSourceType.Placeholder;
+ }
+ }
+
+ return list;
+ }
}
}
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index d7a69ceb2..2fa62f79f 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -393,12 +393,13 @@
<Compile Include="Subtitles\SubtitleDownloadEventArgs.cs" />
<Compile Include="Subtitles\SubtitleResponse.cs" />
<Compile Include="Subtitles\SubtitleSearchRequest.cs" />
+ <Compile Include="Sync\IHasDynamicAccess.cs" />
<Compile Include="Sync\IServerSyncProvider.cs" />
<Compile Include="Sync\ISyncDataProvider.cs" />
<Compile Include="Sync\ISyncManager.cs" />
<Compile Include="Sync\ISyncProvider.cs" />
<Compile Include="Sync\ISyncRepository.cs" />
- <Compile Include="Sync\SendFileResult.cs" />
+ <Compile Include="Sync\SyncedFileInfo.cs" />
<Compile Include="Themes\IAppThemeManager.cs" />
<Compile Include="Themes\InternalThemeImage.cs" />
<Compile Include="TV\ITVSeriesManager.cs" />
diff --git a/MediaBrowser.Controller/MediaEncoding/ISubtitleEncoder.cs b/MediaBrowser.Controller/MediaEncoding/ISubtitleEncoder.cs
index 37c2bf4d2..e4a2cd007 100644
--- a/MediaBrowser.Controller/MediaEncoding/ISubtitleEncoder.cs
+++ b/MediaBrowser.Controller/MediaEncoding/ISubtitleEncoder.cs
@@ -1,4 +1,5 @@
-using System.IO;
+using MediaBrowser.Model.MediaInfo;
+using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -47,8 +48,9 @@ namespace MediaBrowser.Controller.MediaEncoding
/// Gets the subtitle language encoding parameter.
/// </summary>
/// <param name="path">The path.</param>
+ /// <param name="protocol">The protocol.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>System.String.</returns>
- string GetSubtitleFileCharacterSet(string path);
-
+ Task<string> GetSubtitleFileCharacterSet(string path, MediaProtocol protocol, CancellationToken cancellationToken);
}
}
diff --git a/MediaBrowser.Controller/MediaEncoding/MediaStreamSelector.cs b/MediaBrowser.Controller/MediaEncoding/MediaStreamSelector.cs
index 57fddb2b1..a006a1723 100644
--- a/MediaBrowser.Controller/MediaEncoding/MediaStreamSelector.cs
+++ b/MediaBrowser.Controller/MediaEncoding/MediaStreamSelector.cs
@@ -41,8 +41,6 @@ namespace MediaBrowser.Controller.MediaEncoding
streams = GetSortedStreams(streams, MediaStreamType.Subtitle, preferredLanguages)
.ToList();
- var full = streams.Where(s => !s.IsForced);
-
MediaStream stream = null;
if (mode == SubtitlePlaybackMode.None)
@@ -55,13 +53,13 @@ namespace MediaBrowser.Controller.MediaEncoding
// if the audio language is not understood by the user, load their preferred subs, if there are any
if (!ContainsOrdinal(preferredLanguages, audioTrackLanguage))
{
- stream = full.FirstOrDefault(s => ContainsOrdinal(preferredLanguages, s.Language));
+ stream = streams.Where(s => !s.IsForced).FirstOrDefault(s => ContainsOrdinal(preferredLanguages, s.Language));
}
}
else if (mode == SubtitlePlaybackMode.Always)
{
// always load the most suitable full subtitles
- stream = full.FirstOrDefault();
+ stream = streams.FirstOrDefault(s => !s.IsForced);
}
// load forced subs if we have found no suitable full subtitles
@@ -97,6 +95,77 @@ namespace MediaBrowser.Controller.MediaEncoding
.ThenBy(i => i.Index);
}
+ public static void SetSubtitleStreamScores(List<MediaStream> streams,
+ List<string> preferredLanguages,
+ SubtitlePlaybackMode mode,
+ string audioTrackLanguage)
+ {
+ if (mode == SubtitlePlaybackMode.None)
+ {
+ return;
+ }
+
+ streams = GetSortedStreams(streams, MediaStreamType.Subtitle, preferredLanguages)
+ .ToList();
+
+ var filteredStreams = new List<MediaStream>();
+
+ if (mode == SubtitlePlaybackMode.Default)
+ {
+ // if the audio language is not understood by the user, load their preferred subs, if there are any
+ if (!ContainsOrdinal(preferredLanguages, audioTrackLanguage))
+ {
+ filteredStreams = streams.Where(s => !s.IsForced && ContainsOrdinal(preferredLanguages, s.Language))
+ .ToList();
+ }
+ }
+ else if (mode == SubtitlePlaybackMode.Always)
+ {
+ // always load the most suitable full subtitles
+ filteredStreams = streams.Where(s => !s.IsForced)
+ .ToList();
+ }
+
+ // load forced subs if we have found no suitable full subtitles
+ if (filteredStreams.Count == 0)
+ {
+ filteredStreams = streams
+ .Where(s => s.IsForced && string.Equals(s.Language, audioTrackLanguage, StringComparison.OrdinalIgnoreCase))
+ .ToList();
+ }
+
+ foreach (var stream in filteredStreams)
+ {
+ stream.Score = GetSubtitleScore(stream, preferredLanguages);
+ }
+ }
+
+ private static int GetSubtitleScore(MediaStream stream, List<string> languagePreferences)
+ {
+ var values = new List<int>();
+
+ var index = languagePreferences.FindIndex(l => string.Equals(stream.Language, l, StringComparison.OrdinalIgnoreCase));
+
+ values.Add(index == -1 ? 0 : 100 - index);
+
+ values.Add(stream.IsDefault ? 1 : 0);
+ values.Add(stream.SupportsExternalStream ? 1 : 0);
+ values.Add(stream.IsTextSubtitleStream ? 1 : 0);
+ values.Add(stream.IsExternal ? 1 : 0);
+
+ values.Reverse();
+ var scale = 1;
+ var score = 0;
+
+ foreach (var value in values)
+ {
+ score += scale * (value + 1);
+ scale *= 10;
+ }
+
+ return score;
+ }
+
private static int GetBooleanOrderBy(bool value)
{
return value ? 0 : 1;
diff --git a/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs b/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs
index 0afaf955e..3756f1d93 100644
--- a/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs
+++ b/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs
@@ -1,5 +1,4 @@
-using MediaBrowser.Common.Net;
-using MediaBrowser.Model.Logging;
+using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Net;
using System;
using System.Collections.Generic;
@@ -75,12 +74,12 @@ namespace MediaBrowser.Controller.Net
throw new ArgumentNullException("message");
}
- if (message.MessageType.Equals(Name + "Start", StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(message.MessageType, Name + "Start", StringComparison.OrdinalIgnoreCase))
{
Start(message);
}
- if (message.MessageType.Equals(Name + "Stop", StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(message.MessageType, Name + "Stop", StringComparison.OrdinalIgnoreCase))
{
Stop(message);
}
diff --git a/MediaBrowser.Controller/Sync/IHasDynamicAccess.cs b/MediaBrowser.Controller/Sync/IHasDynamicAccess.cs
new file mode 100644
index 000000000..f907de729
--- /dev/null
+++ b/MediaBrowser.Controller/Sync/IHasDynamicAccess.cs
@@ -0,0 +1,18 @@
+using MediaBrowser.Model.Sync;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace MediaBrowser.Controller.Sync
+{
+ public interface IHasDynamicAccess
+ {
+ /// <summary>
+ /// Gets the synced file information.
+ /// </summary>
+ /// <param name="remotePath">The remote path.</param>
+ /// <param name="target">The target.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
+ /// <returns>Task&lt;SyncedFileInfo&gt;.</returns>
+ Task<SyncedFileInfo> GetSyncedFileInfo(string remotePath, SyncTarget target, CancellationToken cancellationToken);
+ }
+}
diff --git a/MediaBrowser.Controller/Sync/IServerSyncProvider.cs b/MediaBrowser.Controller/Sync/IServerSyncProvider.cs
index abf884e9d..46bbbd329 100644
--- a/MediaBrowser.Controller/Sync/IServerSyncProvider.cs
+++ b/MediaBrowser.Controller/Sync/IServerSyncProvider.cs
@@ -18,7 +18,7 @@ namespace MediaBrowser.Controller.Sync
/// <param name="progress">The progress.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
- Task<SendFileResult> SendFile(Stream stream, string remotePath, SyncTarget target, IProgress<double> progress, CancellationToken cancellationToken);
+ Task<SyncedFileInfo> SendFile(Stream stream, string remotePath, SyncTarget target, IProgress<double> progress, CancellationToken cancellationToken);
/// <summary>
/// Deletes the file.
@@ -54,14 +54,5 @@ namespace MediaBrowser.Controller.Sync
/// <param name="target">The target.</param>
/// <returns>System.String.</returns>
string GetParentDirectoryPath(string path, SyncTarget target);
-
- /// <summary>
- /// Gets the file system entries.
- /// </summary>
- /// <param name="path">The path.</param>
- /// <param name="target">The target.</param>
- /// <param name="cancellationToken">The cancellation token.</param>
- /// <returns>Task&lt;List&lt;DeviceFileInfo&gt;&gt;.</returns>
- Task<List<DeviceFileInfo>> GetFileSystemEntries(string path, SyncTarget target, CancellationToken cancellationToken);
}
}
diff --git a/MediaBrowser.Controller/Sync/ISyncDataProvider.cs b/MediaBrowser.Controller/Sync/ISyncDataProvider.cs
index f84748b97..04101fd46 100644
--- a/MediaBrowser.Controller/Sync/ISyncDataProvider.cs
+++ b/MediaBrowser.Controller/Sync/ISyncDataProvider.cs
@@ -15,6 +15,14 @@ namespace MediaBrowser.Controller.Sync
Task<List<string>> GetServerItemIds(SyncTarget target, string serverId);
/// <summary>
+ /// Gets the synchronize job item ids.
+ /// </summary>
+ /// <param name="target">The target.</param>
+ /// <param name="serverId">The server identifier.</param>
+ /// <returns>Task&lt;List&lt;System.String&gt;&gt;.</returns>
+ Task<List<string>> GetSyncJobItemIds(SyncTarget target, string serverId);
+
+ /// <summary>
/// Adds the or update.
/// </summary>
/// <param name="target">The target.</param>
@@ -46,5 +54,13 @@ namespace MediaBrowser.Controller.Sync
/// <param name="itemId">The item identifier.</param>
/// <returns>Task&lt;LocalItem&gt;.</returns>
Task<List<LocalItem>> GetCachedItems(SyncTarget target, string serverId, string itemId);
+ /// <summary>
+ /// Gets the cached items by synchronize job item identifier.
+ /// </summary>
+ /// <param name="target">The target.</param>
+ /// <param name="serverId">The server identifier.</param>
+ /// <param name="syncJobItemId">The synchronize job item identifier.</param>
+ /// <returns>Task&lt;List&lt;LocalItem&gt;&gt;.</returns>
+ Task<List<LocalItem>> GetCachedItemsBySyncJobItemId(SyncTarget target, string serverId, string syncJobItemId);
}
}
diff --git a/MediaBrowser.Controller/Sync/SendFileResult.cs b/MediaBrowser.Controller/Sync/SyncedFileInfo.cs
index 62753444a..550af2d55 100644
--- a/MediaBrowser.Controller/Sync/SendFileResult.cs
+++ b/MediaBrowser.Controller/Sync/SyncedFileInfo.cs
@@ -1,8 +1,9 @@
using MediaBrowser.Model.MediaInfo;
+using System.Collections.Generic;
namespace MediaBrowser.Controller.Sync
{
- public class SendFileResult
+ public class SyncedFileInfo
{
/// <summary>
/// Gets or sets the path.
@@ -14,5 +15,15 @@ namespace MediaBrowser.Controller.Sync
/// </summary>
/// <value>The protocol.</value>
public MediaProtocol Protocol { get; set; }
+ /// <summary>
+ /// Gets or sets the required HTTP headers.
+ /// </summary>
+ /// <value>The required HTTP headers.</value>
+ public Dictionary<string, string> RequiredHttpHeaders { get; set; }
+
+ public SyncedFileInfo()
+ {
+ RequiredHttpHeaders = new Dictionary<string, string>();
+ }
}
}