sync updates

This commit is contained in:
Luke Pulverenti
2015-03-31 12:24:16 -04:00
parent eaf70589ae
commit a025f4eefa
24 changed files with 366 additions and 133 deletions

View File

@@ -261,7 +261,7 @@ namespace MediaBrowser.Server.Implementations.Dto
{
if (user == null)
{
dto.MediaSources = hasMediaSources.GetMediaSources(true).ToList();
dto.MediaSources = _mediaSourceManager().GetStaticMediaSources(hasMediaSources, true).ToList();
}
else
{
@@ -269,7 +269,7 @@ namespace MediaBrowser.Server.Implementations.Dto
}
}
}
if (fields.Contains(ItemFields.Studios))
{
AttachStudios(dto, item);
@@ -1280,7 +1280,7 @@ namespace MediaBrowser.Server.Implementations.Dto
}
else
{
mediaStreams = iHasMediaSources.GetMediaSources(true).First().MediaStreams;
mediaStreams = _mediaSourceManager().GetStaticMediaSources(iHasMediaSources, true).First().MediaStreams;
}
dto.MediaStreams = mediaStreams;
@@ -1453,7 +1453,7 @@ namespace MediaBrowser.Server.Implementations.Dto
var tvChannel = item as LiveTvChannel;
if (tvChannel != null)
{
dto.MediaSources = tvChannel.GetMediaSources(true).ToList();
dto.MediaSources = _mediaSourceManager().GetStaticMediaSources(tvChannel, true).ToList();
}
var channelItem = item as IChannelItem;

View File

@@ -135,6 +135,7 @@ namespace MediaBrowser.Server.Implementations.Library
IEnumerable<MediaSourceInfo> mediaSources;
var hasMediaSources = (IHasMediaSources)item;
User user = null;
if (string.IsNullOrWhiteSpace(userId))
{
@@ -142,7 +143,7 @@ namespace MediaBrowser.Server.Implementations.Library
}
else
{
var user = _userManager.GetUserById(userId);
user = _userManager.GetUserById(userId);
mediaSources = GetStaticMediaSources(hasMediaSources, enablePathSubstitution, user);
}
@@ -154,6 +155,10 @@ namespace MediaBrowser.Server.Implementations.Library
foreach (var source in dynamicMediaSources)
{
if (user != null)
{
SetUserProperties(source, user);
}
if (source.Protocol == MediaProtocol.File)
{
source.SupportsDirectStream = File.Exists(source.Path);
@@ -225,6 +230,11 @@ namespace MediaBrowser.Server.Implementations.Library
return GetPlayackMediaSources(id, null, enablePathSubstitution, cancellationToken);
}
public MediaSourceInfo GetStaticMediaSource(IHasMediaSources item, string mediaSourceId, bool enablePathSubstitution)
{
return GetStaticMediaSources(item, enablePathSubstitution).FirstOrDefault(i => string.Equals(i.Id, mediaSourceId, StringComparison.OrdinalIgnoreCase));
}
public IEnumerable<MediaSourceInfo> GetStaticMediaSources(IHasMediaSources item, bool enablePathSubstitution)
{
if (item == null)
@@ -288,6 +298,9 @@ namespace MediaBrowser.Server.Implementations.Library
preferredSubs,
user.Configuration.SubtitleMode,
audioLangage);
MediaStreamSelector.SetSubtitleStreamScores(source.MediaStreams, preferredSubs,
user.Configuration.SubtitleMode, audioLangage);
}
private IEnumerable<MediaSourceInfo> SortMediaSources(IEnumerable<MediaSourceInfo> sources)
@@ -311,11 +324,6 @@ namespace MediaBrowser.Server.Implementations.Library
.ToList();
}
public MediaSourceInfo GetStaticMediaSource(IHasMediaSources item, string mediaSourceId, bool enablePathSubstitution)
{
return GetStaticMediaSources(item, enablePathSubstitution).FirstOrDefault(i => string.Equals(i.Id, mediaSourceId, StringComparison.OrdinalIgnoreCase));
}
private readonly ConcurrentDictionary<string, LiveStreamInfo> _openStreams = new ConcurrentDictionary<string, LiveStreamInfo>(StringComparer.OrdinalIgnoreCase);
private readonly SemaphoreSlim _liveStreamSemaphore = new SemaphoreSlim(1, 1);
@@ -428,9 +436,16 @@ namespace MediaBrowser.Server.Implementations.Library
try
{
var tuple = GetProvider(id);
LiveStreamInfo current;
if (_openStreams.TryGetValue(id, out current))
{
if (current.MediaSource.RequiresClosing)
{
var tuple = GetProvider(id);
await tuple.Item1.CloseMediaSource(tuple.Item2, cancellationToken).ConfigureAwait(false);
await tuple.Item1.CloseMediaSource(tuple.Item2, cancellationToken).ConfigureAwait(false);
}
}
LiveStreamInfo removed;
if (_openStreams.TryRemove(id, out removed))

View File

@@ -215,7 +215,7 @@ namespace MediaBrowser.Server.Implementations.Library
if (request.IsPlayed.HasValue)
{
var val = request.IsPlayed.Value;
if (i.IsPlayed(currentUser) != val)
if (i is Video && i.IsPlayed(currentUser) != val)
{
return false;
}

View File

@@ -17,11 +17,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv
private readonly ILiveTvManager _liveTvManager;
private readonly IJsonSerializer _jsonSerializer;
private readonly ILogger _logger;
private readonly IMediaSourceManager _mediaSourceManager;
public LiveTvMediaSourceProvider(ILiveTvManager liveTvManager, IJsonSerializer jsonSerializer, ILogManager logManager)
public LiveTvMediaSourceProvider(ILiveTvManager liveTvManager, IJsonSerializer jsonSerializer, ILogManager logManager, IMediaSourceManager mediaSourceManager)
{
_liveTvManager = liveTvManager;
_jsonSerializer = jsonSerializer;
_mediaSourceManager = mediaSourceManager;
_logger = logManager.GetLogger(GetType().Name);
}
@@ -63,7 +65,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
{
var hasMediaSources = (IHasMediaSources)item;
sources = hasMediaSources.GetMediaSources(false)
sources = _mediaSourceManager.GetStaticMediaSources(hasMediaSources, false)
.ToList();
}

View File

@@ -52,6 +52,7 @@
"HeaderAddUser": "Add User",
"LabelAddConnectSupporterHelp": "To add a user who isn't listed, you'll need to first link their account to Emby Connect from their user profile page.",
"LabelPinCode": "Pin code:",
"OptionHideWatchedContentFromLatestMedia": "Hide watched content from latest media",
"ButtonOk": "Ok",
"ButtonCancel": "Cancel",
"ButtonExit": "Exit",

View File

@@ -198,8 +198,7 @@ namespace MediaBrowser.Server.Implementations.Sync
var maxAudioChannels = supportsAc3 || supportsDca ? "5" : "2";
codecProfiles.Add(new CodecProfile
{
Type = CodecType.Audio,
Codec = "mpeg4",
Type = CodecType.VideoAudio,
Conditions = new[]
{
new ProfileCondition
@@ -207,7 +206,7 @@ namespace MediaBrowser.Server.Implementations.Sync
Condition = ProfileConditionType.LessThanEqual,
Property = ProfileConditionValue.AudioChannels,
Value = maxAudioChannels,
IsRequired = false
IsRequired = true
},
new ProfileCondition
{

View File

@@ -495,7 +495,7 @@ namespace MediaBrowser.Server.Implementations.Sync
// No sense creating external subs if we're already burning one into the video
var externalSubs = streamInfo.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode ?
new List<SubtitleStreamInfo>() :
streamInfo.GetExternalSubtitles(false, null, null);
streamInfo.GetExternalSubtitles(false, true, null, null);
// Mark as requiring conversion if transcoding the video, or if any subtitles need to be extracted
var requiresVideoTranscoding = streamInfo.PlayMethod == PlayMethod.Transcode && jobOptions.IsConverting;
@@ -823,7 +823,7 @@ namespace MediaBrowser.Server.Implementations.Sync
var hasMediaSources = item as IHasMediaSources;
var mediaSources = hasMediaSources.GetMediaSources(false).ToList();
var mediaSources = _mediaSourceManager.GetStaticMediaSources(hasMediaSources, false).ToList();
var preferredAudio = string.IsNullOrEmpty(user.Configuration.AudioLanguagePreference)
? new string[] { }