fixes #843 - Update Dlna to respect user audio/subtitle language settings

This commit is contained in:
Luke Pulverenti 2014-06-14 14:24:20 -04:00
parent ffc4db4128
commit 0b60e7ca67
23 changed files with 118 additions and 101 deletions

View File

@ -1,5 +1,9 @@
using MediaBrowser.Model.Dto; using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace MediaBrowser.Controller.Entities namespace MediaBrowser.Controller.Entities
{ {
@ -12,4 +16,53 @@ namespace MediaBrowser.Controller.Entities
/// <returns>Task{IEnumerable{MediaSourceInfo}}.</returns> /// <returns>Task{IEnumerable{MediaSourceInfo}}.</returns>
IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution); IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution);
} }
public static class HasMediaSourceExtensions
{
public static IEnumerable<MediaSourceInfo> GetMediaSources(this IHasMediaSources item, bool enablePathSubstitution, User user)
{
if (item == null)
{
throw new ArgumentNullException("item");
}
if (!(item is Video))
{
return item.GetMediaSources(enablePathSubstitution);
}
if (user == null)
{
throw new ArgumentNullException("user");
}
var sources = item.GetMediaSources(enablePathSubstitution).ToList();
var preferredAudio = string.IsNullOrEmpty(user.Configuration.AudioLanguagePreference)
? new string[] { }
: new[] { user.Configuration.AudioLanguagePreference };
var preferredSubs = string.IsNullOrEmpty(user.Configuration.SubtitleLanguagePreference)
? new string[] { }
: new[] { user.Configuration.SubtitleLanguagePreference };
foreach (var source in sources)
{
source.DefaultAudioStreamIndex = MediaStreamSelector.GetDefaultAudioStreamIndex(
source.MediaStreams, preferredAudio, user.Configuration.PlayDefaultAudioTrack);
var defaultAudioIndex = source.DefaultAudioStreamIndex;
var audioLangage = defaultAudioIndex == null
? null
: source.MediaStreams.Where(i => i.Type == MediaStreamType.Audio && i.Index == defaultAudioIndex).Select(i => i.Language).FirstOrDefault();
source.DefaultSubtitleStreamIndex = MediaStreamSelector.GetDefaultSubtitleStreamIndex(source.MediaStreams,
preferredSubs,
user.Configuration.SubtitleMode,
audioLangage);
}
return sources;
}
}
} }

View File

@ -192,6 +192,7 @@
<Compile Include="MediaEncoding\IMediaEncoder.cs" /> <Compile Include="MediaEncoding\IMediaEncoder.cs" />
<Compile Include="MediaEncoding\InternalMediaInfoResult.cs" /> <Compile Include="MediaEncoding\InternalMediaInfoResult.cs" />
<Compile Include="MediaEncoding\ISubtitleEncoder.cs" /> <Compile Include="MediaEncoding\ISubtitleEncoder.cs" />
<Compile Include="MediaEncoding\MediaStreamSelector.cs" />
<Compile Include="MediaEncoding\VideoEncodingOptions.cs" /> <Compile Include="MediaEncoding\VideoEncodingOptions.cs" />
<Compile Include="Net\IHasResultFactory.cs" /> <Compile Include="Net\IHasResultFactory.cs" />
<Compile Include="Net\IHttpResultFactory.cs" /> <Compile Include="Net\IHttpResultFactory.cs" />

View File

@ -4,7 +4,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace MediaBrowser.Server.Implementations.Dto namespace MediaBrowser.Controller.MediaEncoding
{ {
public static class MediaStreamSelector public static class MediaStreamSelector
{ {

View File

@ -2,7 +2,6 @@
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Dlna.Service; using MediaBrowser.Dlna.Service;
@ -17,7 +16,6 @@ namespace MediaBrowser.Dlna.ContentDirectory
public class ContentDirectory : BaseService, IContentDirectory, IDisposable public class ContentDirectory : BaseService, IContentDirectory, IDisposable
{ {
private readonly ILibraryManager _libraryManager; private readonly ILibraryManager _libraryManager;
private readonly IDtoService _dtoService;
private readonly IImageProcessor _imageProcessor; private readonly IImageProcessor _imageProcessor;
private readonly IUserDataManager _userDataManager; private readonly IUserDataManager _userDataManager;
private readonly IDlnaManager _dlna; private readonly IDlnaManager _dlna;
@ -27,7 +25,6 @@ namespace MediaBrowser.Dlna.ContentDirectory
public ContentDirectory(IDlnaManager dlna, public ContentDirectory(IDlnaManager dlna,
IUserDataManager userDataManager, IUserDataManager userDataManager,
IImageProcessor imageProcessor, IImageProcessor imageProcessor,
IDtoService dtoService,
ILibraryManager libraryManager, ILibraryManager libraryManager,
IServerConfigurationManager config, IServerConfigurationManager config,
IUserManager userManager, IUserManager userManager,
@ -38,7 +35,6 @@ namespace MediaBrowser.Dlna.ContentDirectory
_dlna = dlna; _dlna = dlna;
_userDataManager = userDataManager; _userDataManager = userDataManager;
_imageProcessor = imageProcessor; _imageProcessor = imageProcessor;
_dtoService = dtoService;
_libraryManager = libraryManager; _libraryManager = libraryManager;
_config = config; _config = config;
_userManager = userManager; _userManager = userManager;
@ -73,7 +69,6 @@ namespace MediaBrowser.Dlna.ContentDirectory
_libraryManager, _libraryManager,
profile, profile,
serverAddress, serverAddress,
_dtoService,
_imageProcessor, _imageProcessor,
_userDataManager, _userDataManager,
user, user,

View File

@ -1,7 +1,6 @@
using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Entities.Movies;
@ -42,7 +41,7 @@ namespace MediaBrowser.Dlna.ContentDirectory
private readonly DeviceProfile _profile; private readonly DeviceProfile _profile;
public ControlHandler(ILogger logger, ILibraryManager libraryManager, DeviceProfile profile, string serverAddress, IDtoService dtoService, IImageProcessor imageProcessor, IUserDataManager userDataManager, User user, int systemUpdateId, IServerConfigurationManager config) public ControlHandler(ILogger logger, ILibraryManager libraryManager, DeviceProfile profile, string serverAddress, IImageProcessor imageProcessor, IUserDataManager userDataManager, User user, int systemUpdateId, IServerConfigurationManager config)
: base(config, logger) : base(config, logger)
{ {
_libraryManager = libraryManager; _libraryManager = libraryManager;
@ -51,7 +50,7 @@ namespace MediaBrowser.Dlna.ContentDirectory
_systemUpdateId = systemUpdateId; _systemUpdateId = systemUpdateId;
_profile = profile; _profile = profile;
_didlBuilder = new DidlBuilder(profile, imageProcessor, serverAddress, dtoService); _didlBuilder = new DidlBuilder(profile, user, imageProcessor, serverAddress);
} }
protected override IEnumerable<KeyValuePair<string, string>> GetResult(string methodName, Headers methodParams) protected override IEnumerable<KeyValuePair<string, string>> GetResult(string methodName, Headers methodParams)

View File

@ -1,7 +1,5 @@
using System.Collections.Generic; using MediaBrowser.Common.Net;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Entities.Movies;
@ -10,6 +8,7 @@ using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Drawing; using MediaBrowser.Model.Drawing;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using System; using System;
using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Xml; using System.Xml;
@ -28,14 +27,14 @@ namespace MediaBrowser.Dlna.Didl
private readonly DeviceProfile _profile; private readonly DeviceProfile _profile;
private readonly IImageProcessor _imageProcessor; private readonly IImageProcessor _imageProcessor;
private readonly string _serverAddress; private readonly string _serverAddress;
private readonly IDtoService _dtoService; private readonly User _user;
public DidlBuilder(DeviceProfile profile, IImageProcessor imageProcessor, string serverAddress, IDtoService dtoService) public DidlBuilder(DeviceProfile profile, User user, IImageProcessor imageProcessor, string serverAddress)
{ {
_profile = profile; _profile = profile;
_imageProcessor = imageProcessor; _imageProcessor = imageProcessor;
_serverAddress = serverAddress; _serverAddress = serverAddress;
_dtoService = dtoService; _user = user;
} }
public string GetItemDidl(BaseItem item, string deviceId, Filter filter) public string GetItemDidl(BaseItem item, string deviceId, Filter filter)
@ -99,9 +98,7 @@ namespace MediaBrowser.Dlna.Didl
{ {
var res = container.OwnerDocument.CreateElement(string.Empty, "res", NS_DIDL); var res = container.OwnerDocument.CreateElement(string.Empty, "res", NS_DIDL);
var sources = _dtoService.GetMediaSources(video); var sources = _user == null ? video.GetMediaSources(true).ToList() : video.GetMediaSources(true, _user).ToList();
int? maxBitrateSetting = null;
var streamInfo = new StreamBuilder().BuildVideoItem(new VideoOptions var streamInfo = new StreamBuilder().BuildVideoItem(new VideoOptions
{ {
@ -109,11 +106,11 @@ namespace MediaBrowser.Dlna.Didl
MediaSources = sources, MediaSources = sources,
Profile = _profile, Profile = _profile,
DeviceId = deviceId, DeviceId = deviceId,
MaxBitrate = maxBitrateSetting MaxBitrate = _profile.MaxBitrate
}); });
var url = streamInfo.ToDlnaUrl(_serverAddress); var url = streamInfo.ToDlnaUrl(_serverAddress);
//res.AppendChild(container.OwnerDocument.CreateCDataSection(url));
res.InnerText = url; res.InnerText = url;
var mediaSource = sources.First(i => string.Equals(i.Id, streamInfo.MediaSourceId)); var mediaSource = sources.First(i => string.Equals(i.Id, streamInfo.MediaSourceId));
@ -218,7 +215,7 @@ namespace MediaBrowser.Dlna.Didl
{ {
var res = container.OwnerDocument.CreateElement(string.Empty, "res", NS_DIDL); var res = container.OwnerDocument.CreateElement(string.Empty, "res", NS_DIDL);
var sources = _dtoService.GetMediaSources(audio); var sources = _user == null ? audio.GetMediaSources(true).ToList() : audio.GetMediaSources(true, _user).ToList();
var streamInfo = new StreamBuilder().BuildAudioItem(new AudioOptions var streamInfo = new StreamBuilder().BuildAudioItem(new AudioOptions
{ {
@ -229,7 +226,7 @@ namespace MediaBrowser.Dlna.Didl
}); });
var url = streamInfo.ToDlnaUrl(_serverAddress); var url = streamInfo.ToDlnaUrl(_serverAddress);
//res.AppendChild(container.OwnerDocument.CreateCDataSection(url));
res.InnerText = url; res.InnerText = url;
var mediaSource = sources.First(i => string.Equals(i.Id, streamInfo.MediaSourceId)); var mediaSource = sources.First(i => string.Equals(i.Id, streamInfo.MediaSourceId));

View File

@ -4,7 +4,6 @@ using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence; using MediaBrowser.Controller.Persistence;
using MediaBrowser.Controller.Plugins; using MediaBrowser.Controller.Plugins;
@ -32,7 +31,6 @@ namespace MediaBrowser.Dlna.Main
private readonly ILibraryManager _libraryManager; private readonly ILibraryManager _libraryManager;
private readonly IUserManager _userManager; private readonly IUserManager _userManager;
private readonly IDlnaManager _dlnaManager; private readonly IDlnaManager _dlnaManager;
private readonly IDtoService _dtoService;
private readonly IImageProcessor _imageProcessor; private readonly IImageProcessor _imageProcessor;
private SsdpHandler _ssdpHandler; private SsdpHandler _ssdpHandler;
@ -40,7 +38,7 @@ namespace MediaBrowser.Dlna.Main
private readonly List<Guid> _registeredServerIds = new List<Guid>(); private readonly List<Guid> _registeredServerIds = new List<Guid>();
private bool _dlnaServerStarted; private bool _dlnaServerStarted;
public DlnaEntryPoint(IServerConfigurationManager config, ILogManager logManager, IServerApplicationHost appHost, INetworkManager network, ISessionManager sessionManager, IHttpClient httpClient, IItemRepository itemRepo, ILibraryManager libraryManager, IUserManager userManager, IDlnaManager dlnaManager, IDtoService dtoService, IImageProcessor imageProcessor) public DlnaEntryPoint(IServerConfigurationManager config, ILogManager logManager, IServerApplicationHost appHost, INetworkManager network, ISessionManager sessionManager, IHttpClient httpClient, IItemRepository itemRepo, ILibraryManager libraryManager, IUserManager userManager, IDlnaManager dlnaManager, IImageProcessor imageProcessor)
{ {
_config = config; _config = config;
_appHost = appHost; _appHost = appHost;
@ -51,7 +49,6 @@ namespace MediaBrowser.Dlna.Main
_libraryManager = libraryManager; _libraryManager = libraryManager;
_userManager = userManager; _userManager = userManager;
_dlnaManager = dlnaManager; _dlnaManager = dlnaManager;
_dtoService = dtoService;
_imageProcessor = imageProcessor; _imageProcessor = imageProcessor;
_logger = logManager.GetLogger("Dlna"); _logger = logManager.GetLogger("Dlna");
} }
@ -197,7 +194,6 @@ namespace MediaBrowser.Dlna.Main
_userManager, _userManager,
_dlnaManager, _dlnaManager,
_appHost, _appHost,
_dtoService,
_imageProcessor, _imageProcessor,
_ssdpHandler); _ssdpHandler);

View File

@ -1,6 +1,5 @@
using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
@ -13,13 +12,13 @@ using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Session; using MediaBrowser.Model.Session;
using MediaBrowser.Model.System;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Model.System;
namespace MediaBrowser.Dlna.PlayTo namespace MediaBrowser.Dlna.PlayTo
{ {
@ -33,7 +32,6 @@ namespace MediaBrowser.Dlna.PlayTo
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IDlnaManager _dlnaManager; private readonly IDlnaManager _dlnaManager;
private readonly IUserManager _userManager; private readonly IUserManager _userManager;
private readonly IDtoService _dtoService;
private readonly IImageProcessor _imageProcessor; private readonly IImageProcessor _imageProcessor;
private readonly SsdpHandler _ssdpHandler; private readonly SsdpHandler _ssdpHandler;
@ -54,7 +52,7 @@ namespace MediaBrowser.Dlna.PlayTo
private Timer _updateTimer; private Timer _updateTimer;
public PlayToController(SessionInfo session, ISessionManager sessionManager, IItemRepository itemRepository, ILibraryManager libraryManager, ILogger logger, IDlnaManager dlnaManager, IUserManager userManager, IDtoService dtoService, IImageProcessor imageProcessor, SsdpHandler ssdpHandler, string serverAddress) public PlayToController(SessionInfo session, ISessionManager sessionManager, IItemRepository itemRepository, ILibraryManager libraryManager, ILogger logger, IDlnaManager dlnaManager, IUserManager userManager, IImageProcessor imageProcessor, SsdpHandler ssdpHandler, string serverAddress)
{ {
_session = session; _session = session;
_itemRepository = itemRepository; _itemRepository = itemRepository;
@ -62,7 +60,6 @@ namespace MediaBrowser.Dlna.PlayTo
_libraryManager = libraryManager; _libraryManager = libraryManager;
_dlnaManager = dlnaManager; _dlnaManager = dlnaManager;
_userManager = userManager; _userManager = userManager;
_dtoService = dtoService;
_imageProcessor = imageProcessor; _imageProcessor = imageProcessor;
_ssdpHandler = ssdpHandler; _ssdpHandler = ssdpHandler;
_serverAddress = serverAddress; _serverAddress = serverAddress;
@ -228,6 +225,8 @@ namespace MediaBrowser.Dlna.PlayTo
{ {
_logger.Debug("{0} - Received PlayRequest: {1}", this._session.DeviceName, command.PlayCommand); _logger.Debug("{0} - Received PlayRequest: {1}", this._session.DeviceName, command.PlayCommand);
var user = string.IsNullOrEmpty(command.ControllingUserId) ? null : _userManager.GetUserById(new Guid(command.ControllingUserId));
var items = new List<BaseItem>(); var items = new List<BaseItem>();
foreach (string id in command.ItemIds) foreach (string id in command.ItemIds)
{ {
@ -243,12 +242,12 @@ namespace MediaBrowser.Dlna.PlayTo
{ {
if (isFirst && command.StartPositionTicks.HasValue) if (isFirst && command.StartPositionTicks.HasValue)
{ {
playlist.Add(CreatePlaylistItem(item, command.StartPositionTicks.Value, serverAddress)); playlist.Add(CreatePlaylistItem(item, user, command.StartPositionTicks.Value, serverAddress));
isFirst = false; isFirst = false;
} }
else else
{ {
playlist.Add(CreatePlaylistItem(item, 0, serverAddress)); playlist.Add(CreatePlaylistItem(item, user, 0, serverAddress));
} }
} }
@ -267,10 +266,6 @@ namespace MediaBrowser.Dlna.PlayTo
if (!string.IsNullOrWhiteSpace(command.ControllingUserId)) if (!string.IsNullOrWhiteSpace(command.ControllingUserId))
{ {
var userId = new Guid(command.ControllingUserId);
var user = _userManager.GetUserById(userId);
await _sessionManager.LogSessionActivity(_session.Client, _session.ApplicationVersion, _session.DeviceId, await _sessionManager.LogSessionActivity(_session.Client, _session.ApplicationVersion, _session.DeviceId,
_session.DeviceName, _session.RemoteEndPoint, user).ConfigureAwait(false); _session.DeviceName, _session.RemoteEndPoint, user).ConfigureAwait(false);
} }
@ -388,15 +383,16 @@ namespace MediaBrowser.Dlna.PlayTo
} }
} }
private PlaylistItem CreatePlaylistItem(BaseItem item, long startPostionTicks, string serverAddress) private PlaylistItem CreatePlaylistItem(BaseItem item, User user, long startPostionTicks, string serverAddress)
{ {
var deviceInfo = _device.Properties; var deviceInfo = _device.Properties;
var profile = _dlnaManager.GetProfile(deviceInfo.ToDeviceIdentification()) ?? var profile = _dlnaManager.GetProfile(deviceInfo.ToDeviceIdentification()) ??
_dlnaManager.GetDefaultProfile(); _dlnaManager.GetDefaultProfile();
var mediaSources = item is Audio || item is Video var hasMediaSources = item as IHasMediaSources;
? _dtoService.GetMediaSources(item) var mediaSources = hasMediaSources != null
? (user == null ? hasMediaSources.GetMediaSources(true) : hasMediaSources.GetMediaSources(true, user)).ToList()
: new List<MediaSourceInfo>(); : new List<MediaSourceInfo>();
var playlistItem = GetPlaylistItem(item, mediaSources, profile, _session.DeviceId); var playlistItem = GetPlaylistItem(item, mediaSources, profile, _session.DeviceId);
@ -404,9 +400,7 @@ namespace MediaBrowser.Dlna.PlayTo
playlistItem.StreamUrl = playlistItem.StreamInfo.ToUrl(serverAddress); playlistItem.StreamUrl = playlistItem.StreamInfo.ToUrl(serverAddress);
var itemXml = var itemXml = new DidlBuilder(profile, user, _imageProcessor, serverAddress).GetItemDidl(item, _session.DeviceId, new Filter());
new DidlBuilder(profile, _imageProcessor, serverAddress, _dtoService).GetItemDidl(item, _session.DeviceId,
new Filter());
playlistItem.Didl = itemXml; playlistItem.Didl = itemXml;

View File

@ -3,7 +3,6 @@ using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence; using MediaBrowser.Controller.Persistence;
using MediaBrowser.Controller.Session; using MediaBrowser.Controller.Session;
@ -36,12 +35,11 @@ namespace MediaBrowser.Dlna.PlayTo
private readonly IDlnaManager _dlnaManager; private readonly IDlnaManager _dlnaManager;
private readonly IServerConfigurationManager _config; private readonly IServerConfigurationManager _config;
private readonly IServerApplicationHost _appHost; private readonly IServerApplicationHost _appHost;
private readonly IDtoService _dtoService;
private readonly IImageProcessor _imageProcessor; private readonly IImageProcessor _imageProcessor;
private readonly SsdpHandler _ssdpHandler; private readonly SsdpHandler _ssdpHandler;
public PlayToManager(ILogger logger, IServerConfigurationManager config, ISessionManager sessionManager, IHttpClient httpClient, IItemRepository itemRepository, ILibraryManager libraryManager, IUserManager userManager, IDlnaManager dlnaManager, IServerApplicationHost appHost, IDtoService dtoService, IImageProcessor imageProcessor, SsdpHandler ssdpHandler) public PlayToManager(ILogger logger, IServerConfigurationManager config, ISessionManager sessionManager, IHttpClient httpClient, IItemRepository itemRepository, ILibraryManager libraryManager, IUserManager userManager, IDlnaManager dlnaManager, IServerApplicationHost appHost, IImageProcessor imageProcessor, SsdpHandler ssdpHandler)
{ {
_tokenSource = new CancellationTokenSource(); _tokenSource = new CancellationTokenSource();
@ -53,7 +51,6 @@ namespace MediaBrowser.Dlna.PlayTo
_userManager = userManager; _userManager = userManager;
_dlnaManager = dlnaManager; _dlnaManager = dlnaManager;
_appHost = appHost; _appHost = appHost;
_dtoService = dtoService;
_imageProcessor = imageProcessor; _imageProcessor = imageProcessor;
_ssdpHandler = ssdpHandler; _ssdpHandler = ssdpHandler;
_config = config; _config = config;
@ -284,7 +281,6 @@ namespace MediaBrowser.Dlna.PlayTo
_logger, _logger,
_dlnaManager, _dlnaManager,
_userManager, _userManager,
_dtoService,
_imageProcessor, _imageProcessor,
_ssdpHandler, _ssdpHandler,
serverAddress); serverAddress);

View File

@ -21,7 +21,8 @@ namespace MediaBrowser.MediaEncoding.Subtitles
writer.WriteLine(@"{0:hh\:mm\:ss\.fff} --> {1:hh\:mm\:ss\.fff}", TimeSpan.FromTicks(trackEvent.StartPositionTicks), TimeSpan.FromTicks(trackEvent.EndPositionTicks)); writer.WriteLine(@"{0:hh\:mm\:ss\.fff} --> {1:hh\:mm\:ss\.fff}", TimeSpan.FromTicks(trackEvent.StartPositionTicks), TimeSpan.FromTicks(trackEvent.EndPositionTicks));
var text = Regex.Replace(trackEvent.Text, @"\\N", "<br />", RegexOptions.IgnoreCase); var text = trackEvent.Text;
//text = Regex.Replace(text, @"\\N", "<br />", RegexOptions.IgnoreCase);
writer.WriteLine(text); writer.WriteLine(text);
writer.WriteLine(string.Empty); writer.WriteLine(string.Empty);

View File

@ -49,6 +49,12 @@
<PropertyGroup> <PropertyGroup>
<RunPostBuildEvent>Always</RunPostBuildEvent> <RunPostBuildEvent>Always</RunPostBuildEvent>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>MediaBrowser.Model.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="..\SharedVersion.cs"> <Compile Include="..\SharedVersion.cs">
<Link>Properties\SharedVersion.cs</Link> <Link>Properties\SharedVersion.cs</Link>
@ -325,6 +331,7 @@
<Compile Include="Weather\WeatherUnits.cs" /> <Compile Include="Weather\WeatherUnits.cs" />
<None Include="Fody.targets" /> <None Include="Fody.targets" />
<None Include="FodyWeavers.xml" /> <None Include="FodyWeavers.xml" />
<None Include="MediaBrowser.Model.snk" />
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

Binary file not shown.

View File

@ -103,6 +103,22 @@ namespace MediaBrowser.Server.Implementations.Dto
AttachUserSpecificInfo(dto, item, user, fields); AttachUserSpecificInfo(dto, item, user, fields);
} }
var hasMediaSources = item as IHasMediaSources;
if (hasMediaSources != null)
{
if (fields.Contains(ItemFields.MediaSources))
{
if (user == null)
{
dto.MediaSources = hasMediaSources.GetMediaSources(true).ToList();
}
else
{
dto.MediaSources = hasMediaSources.GetMediaSources(true, user).ToList();
}
}
}
if (fields.Contains(ItemFields.Studios)) if (fields.Contains(ItemFields.Studios))
{ {
AttachStudios(dto, item); AttachStudios(dto, item);
@ -110,33 +126,6 @@ namespace MediaBrowser.Server.Implementations.Dto
AttachBasicFields(dto, item, owner, fields); AttachBasicFields(dto, item, owner, fields);
if (user != null && dto.MediaSources != null && item is Video)
{
var preferredAudio = string.IsNullOrEmpty(user.Configuration.AudioLanguagePreference)
? new string[] { }
: new[] { user.Configuration.AudioLanguagePreference };
var preferredSubs = string.IsNullOrEmpty(user.Configuration.SubtitleLanguagePreference)
? new string[] { }
: new[] { user.Configuration.SubtitleLanguagePreference };
foreach (var source in dto.MediaSources)
{
source.DefaultAudioStreamIndex = MediaStreamSelector.GetDefaultAudioStreamIndex(
source.MediaStreams, preferredAudio, user.Configuration.PlayDefaultAudioTrack);
var defaultAudioIndex = source.DefaultAudioStreamIndex;
var audioLangage = defaultAudioIndex == null
? null
: source.MediaStreams.Where(i => i.Type == MediaStreamType.Audio && i.Index == defaultAudioIndex).Select(i => i.Language).FirstOrDefault();
source.DefaultSubtitleStreamIndex = MediaStreamSelector.GetDefaultSubtitleStreamIndex(source.MediaStreams,
preferredSubs,
user.Configuration.SubtitleMode,
audioLangage);
}
}
if (fields.Contains(ItemFields.SoundtrackIds)) if (fields.Contains(ItemFields.SoundtrackIds))
{ {
var hasSoundtracks = item as IHasSoundtracks; var hasSoundtracks = item as IHasSoundtracks;
@ -926,11 +915,6 @@ namespace MediaBrowser.Server.Implementations.Dto
} }
dto.MediaSourceCount = 1; dto.MediaSourceCount = 1;
if (fields.Contains(ItemFields.MediaSources))
{
dto.MediaSources = GetMediaSources(audio);
}
} }
var album = item as MusicAlbum; var album = item as MusicAlbum;
@ -963,11 +947,6 @@ namespace MediaBrowser.Server.Implementations.Dto
dto.PartCount = video.AdditionalPartIds.Count + 1; dto.PartCount = video.AdditionalPartIds.Count + 1;
dto.MediaSourceCount = video.MediaSourceCount; dto.MediaSourceCount = video.MediaSourceCount;
if (fields.Contains(ItemFields.MediaSources))
{
dto.MediaSources = GetMediaSources(video);
}
if (fields.Contains(ItemFields.Chapters)) if (fields.Contains(ItemFields.Chapters))
{ {
List<ChapterInfoDto> chapters; List<ChapterInfoDto> chapters;

View File

@ -109,7 +109,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
if (liveTvItem != null) if (liveTvItem != null)
{ {
return !liveTvItem.HasImage(ImageType.Primary) && (liveTvItem.HasProviderImage ?? true) && (DateTime.UtcNow - date).TotalHours >= 6; return !liveTvItem.HasImage(ImageType.Primary) && (liveTvItem.HasProviderImage ?? true);
} }
return false; return false;
} }

View File

@ -109,7 +109,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
if (liveTvItem != null) if (liveTvItem != null)
{ {
return !liveTvItem.HasImage(ImageType.Primary) && (liveTvItem.HasProviderImage ?? true) && (DateTime.UtcNow - date).TotalHours >= 6; return !liveTvItem.HasImage(ImageType.Primary) && (liveTvItem.HasProviderImage ?? true);
} }
return false; return false;
} }

View File

@ -109,7 +109,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
if (liveTvItem != null) if (liveTvItem != null)
{ {
return !liveTvItem.HasImage(ImageType.Primary) && (liveTvItem.RecordingInfo.HasImage ?? true) && (DateTime.UtcNow - date).TotalHours >= 6; return !liveTvItem.HasImage(ImageType.Primary) && (liveTvItem.RecordingInfo.HasImage ?? true);
} }
return false; return false;
} }

View File

@ -112,7 +112,6 @@
<Compile Include="Drawing\PlayedIndicatorDrawer.cs" /> <Compile Include="Drawing\PlayedIndicatorDrawer.cs" />
<Compile Include="Drawing\UnplayedCountIndicator.cs" /> <Compile Include="Drawing\UnplayedCountIndicator.cs" />
<Compile Include="Dto\DtoService.cs" /> <Compile Include="Dto\DtoService.cs" />
<Compile Include="Dto\MediaStreamSelector.cs" />
<Compile Include="EntryPoints\AutomaticRestartEntryPoint.cs" /> <Compile Include="EntryPoints\AutomaticRestartEntryPoint.cs" />
<Compile Include="EntryPoints\ExternalPortForwarding.cs" /> <Compile Include="EntryPoints\ExternalPortForwarding.cs" />
<Compile Include="EntryPoints\LibraryChangedNotifier.cs" /> <Compile Include="EntryPoints\LibraryChangedNotifier.cs" />

View File

@ -521,7 +521,7 @@ namespace MediaBrowser.ServerApplication
var dlnaManager = new DlnaManager(XmlSerializer, FileSystemManager, ApplicationPaths, LogManager.GetLogger("Dlna"), JsonSerializer); var dlnaManager = new DlnaManager(XmlSerializer, FileSystemManager, ApplicationPaths, LogManager.GetLogger("Dlna"), JsonSerializer);
RegisterSingleInstance<IDlnaManager>(dlnaManager); RegisterSingleInstance<IDlnaManager>(dlnaManager);
var contentDirectory = new ContentDirectory(dlnaManager, UserDataManager, ImageProcessor, DtoService, LibraryManager, ServerConfigurationManager, UserManager, LogManager.GetLogger("UpnpContentDirectory"), HttpClient); var contentDirectory = new ContentDirectory(dlnaManager, UserDataManager, ImageProcessor, LibraryManager, ServerConfigurationManager, UserManager, LogManager.GetLogger("UpnpContentDirectory"), HttpClient);
RegisterSingleInstance<IContentDirectory>(contentDirectory); RegisterSingleInstance<IContentDirectory>(contentDirectory);
var connectionManager = new ConnectionManager(dlnaManager, ServerConfigurationManager, LogManager.GetLogger("UpnpConnectionManager"), HttpClient); var connectionManager = new ConnectionManager(dlnaManager, ServerConfigurationManager, LogManager.GetLogger("UpnpConnectionManager"), HttpClient);

View File

@ -61,14 +61,14 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="MediaBrowser.IsoMounter"> <Reference Include="MediaBrowser.IsoMounter">
<HintPath>..\packages\MediaBrowser.IsoMounting.3.0.65\lib\net45\MediaBrowser.IsoMounter.dll</HintPath> <HintPath>..\packages\MediaBrowser.IsoMounting.3.0.68\lib\net45\MediaBrowser.IsoMounter.dll</HintPath>
</Reference> </Reference>
<Reference Include="NLog, Version=3.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"> <Reference Include="NLog, Version=3.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NLog.3.0.0.0\lib\net45\NLog.dll</HintPath> <HintPath>..\packages\NLog.3.0.0.0\lib\net45\NLog.dll</HintPath>
</Reference> </Reference>
<Reference Include="pfmclrapi"> <Reference Include="pfmclrapi">
<HintPath>..\packages\MediaBrowser.IsoMounting.3.0.65\lib\net45\pfmclrapi.dll</HintPath> <HintPath>..\packages\MediaBrowser.IsoMounting.3.0.68\lib\net45\pfmclrapi.dll</HintPath>
</Reference> </Reference>
<Reference Include="ServiceStack.Interfaces"> <Reference Include="ServiceStack.Interfaces">
<HintPath>..\ThirdParty\ServiceStack\ServiceStack.Interfaces.dll</HintPath> <HintPath>..\ThirdParty\ServiceStack\ServiceStack.Interfaces.dll</HintPath>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="MediaBrowser.IsoMounting" version="3.0.65" targetFramework="net45" /> <package id="MediaBrowser.IsoMounting" version="3.0.68" targetFramework="net45" />
<package id="NLog" version="3.0.0.0" targetFramework="net45" /> <package id="NLog" version="3.0.0.0" targetFramework="net45" />
</packages> </packages>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Common.Internal</id> <id>MediaBrowser.Common.Internal</id>
<version>3.0.401</version> <version>3.0.405</version>
<title>MediaBrowser.Common.Internal</title> <title>MediaBrowser.Common.Internal</title>
<authors>Luke</authors> <authors>Luke</authors>
<owners>ebr,Luke,scottisafool</owners> <owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description> <description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
<copyright>Copyright © Media Browser 2013</copyright> <copyright>Copyright © Media Browser 2013</copyright>
<dependencies> <dependencies>
<dependency id="MediaBrowser.Common" version="3.0.401" /> <dependency id="MediaBrowser.Common" version="3.0.405" />
<dependency id="NLog" version="2.1.0" /> <dependency id="NLog" version="2.1.0" />
<dependency id="SimpleInjector" version="2.5.0" /> <dependency id="SimpleInjector" version="2.5.0" />
<dependency id="sharpcompress" version="0.10.2" /> <dependency id="sharpcompress" version="0.10.2" />

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Common</id> <id>MediaBrowser.Common</id>
<version>3.0.401</version> <version>3.0.405</version>
<title>MediaBrowser.Common</title> <title>MediaBrowser.Common</title>
<authors>Media Browser Team</authors> <authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners> <owners>ebr,Luke,scottisafool</owners>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Server.Core</id> <id>MediaBrowser.Server.Core</id>
<version>3.0.401</version> <version>3.0.405</version>
<title>Media Browser.Server.Core</title> <title>Media Browser.Server.Core</title>
<authors>Media Browser Team</authors> <authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners> <owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains core components required to build plugins for Media Browser Server.</description> <description>Contains core components required to build plugins for Media Browser Server.</description>
<copyright>Copyright © Media Browser 2013</copyright> <copyright>Copyright © Media Browser 2013</copyright>
<dependencies> <dependencies>
<dependency id="MediaBrowser.Common" version="3.0.401" /> <dependency id="MediaBrowser.Common" version="3.0.405" />
</dependencies> </dependencies>
</metadata> </metadata>
<files> <files>