diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 9d54458a6e..b77c6fd015 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -806,6 +806,8 @@ namespace MediaBrowser.Api.Playback if (string.IsNullOrEmpty(state.MediaPath)) { + var checkCodecs = false; + if (string.Equals(state.ItemType, typeof(LiveTvChannel).Name)) { var streamInfo = await LiveTvManager.GetChannelStream(state.Request.Id, cancellationTokenSource.Token).ConfigureAwait(false); @@ -824,6 +826,9 @@ namespace MediaBrowser.Api.Playback state.MediaPath = streamInfo.Url; state.InputProtocol = MediaProtocol.Http; } + + AttachMediaStreamInfo(state, streamInfo.MediaStreams, state.VideoRequest, state.RequestedUrl); + checkCodecs = true; } else if (string.Equals(state.ItemType, typeof(LiveTvVideoRecording).Name) || @@ -845,6 +850,24 @@ namespace MediaBrowser.Api.Playback state.MediaPath = streamInfo.Url; state.InputProtocol = MediaProtocol.Http; } + + AttachMediaStreamInfo(state, streamInfo.MediaStreams, state.VideoRequest, state.RequestedUrl); + checkCodecs = true; + } + + var videoRequest = state.VideoRequest; + + if (videoRequest != null && checkCodecs) + { + if (state.VideoStream != null && CanStreamCopyVideo(videoRequest, state.VideoStream)) + { + state.OutputVideoCodec = "copy"; + } + + if (state.AudioStream != null && CanStreamCopyAudio(videoRequest, state.AudioStream, state.SupportedAudioCodecs)) + { + state.OutputAudioCodec = "copy"; + } } } } diff --git a/MediaBrowser.Api/UserService.cs b/MediaBrowser.Api/UserService.cs index 4ffe5b3911..6fe428274a 100644 --- a/MediaBrowser.Api/UserService.cs +++ b/MediaBrowser.Api/UserService.cs @@ -225,46 +225,6 @@ namespace MediaBrowser.Api //return ToOptimizedResult(new List()); } - private bool IsInLocalNetwork(string remoteEndpoint) - { - if (string.IsNullOrWhiteSpace(remoteEndpoint)) - { - throw new ArgumentNullException("remoteEndpoint"); - } - - IPAddress address; - if (!IPAddress.TryParse(remoteEndpoint, out address)) - { - return true; - } - - const int lengthMatch = 4; - - if (remoteEndpoint.Length >= lengthMatch) - { - var prefix = remoteEndpoint.Substring(0, lengthMatch); - - if (_networkManager.GetLocalIpAddresses() - .Any(i => i.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))) - { - return true; - } - } - - // Private address space: - // http://en.wikipedia.org/wiki/Private_network - - return - - // If url was requested with computer name, we may see this - remoteEndpoint.IndexOf("::", StringComparison.OrdinalIgnoreCase) != -1 || - - remoteEndpoint.StartsWith("10.", StringComparison.OrdinalIgnoreCase) || - remoteEndpoint.StartsWith("192.", StringComparison.OrdinalIgnoreCase) || - remoteEndpoint.StartsWith("172.", StringComparison.OrdinalIgnoreCase) || - remoteEndpoint.StartsWith("169.", StringComparison.OrdinalIgnoreCase); - } - /// /// Gets the specified request. /// @@ -283,10 +243,10 @@ namespace MediaBrowser.Api { users = users.Where(i => i.Configuration.IsHidden == request.IsHidden.Value); } - + var result = users .OrderBy(u => u.Name) - .Select(_dtoService.GetUserDto) + .Select(i => _userManager.GetUserDto(i, Request.RemoteIp)) .ToList(); return ToOptimizedSerializedResultUsingCache(result); @@ -306,7 +266,7 @@ namespace MediaBrowser.Api throw new ResourceNotFoundException("User not found"); } - var result = _dtoService.GetUserDto(user); + var result = _userManager.GetUserDto(user, Request.RemoteIp); return ToOptimizedSerializedResultUsingCache(result); } @@ -410,7 +370,7 @@ namespace MediaBrowser.Api } else { - var success = _userManager.AuthenticateUser(user.Name, request.CurrentPassword).Result; + var success = _userManager.AuthenticateUser(user.Name, request.CurrentPassword, Request.RemoteIp).Result; if (!success) { @@ -488,7 +448,7 @@ namespace MediaBrowser.Api newUser.UpdateConfiguration(dtoUser.Configuration); - var result = _dtoService.GetUserDto(newUser); + var result = _userManager.GetUserDto(newUser, Request.RemoteIp); return ToOptimizedResult(result); } diff --git a/MediaBrowser.Common/Net/INetworkManager.cs b/MediaBrowser.Common/Net/INetworkManager.cs index b5f1c82941..979dae49c9 100644 --- a/MediaBrowser.Common/Net/INetworkManager.cs +++ b/MediaBrowser.Common/Net/INetworkManager.cs @@ -44,5 +44,12 @@ namespace MediaBrowser.Common.Net /// The endpointstring. /// IPEndPoint. IPEndPoint Parse(string endpointstring); + + /// + /// Determines whether [is in local network] [the specified endpoint]. + /// + /// The endpoint. + /// true if [is in local network] [the specified endpoint]; otherwise, false. + bool IsInLocalNetwork(string endpoint); } } \ No newline at end of file diff --git a/MediaBrowser.Controller/Dto/IDtoService.cs b/MediaBrowser.Controller/Dto/IDtoService.cs index 434e896dad..fc15eedf04 100644 --- a/MediaBrowser.Controller/Dto/IDtoService.cs +++ b/MediaBrowser.Controller/Dto/IDtoService.cs @@ -2,6 +2,7 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Querying; +using System; using System.Collections.Generic; namespace MediaBrowser.Controller.Dto @@ -16,6 +17,7 @@ namespace MediaBrowser.Controller.Dto /// /// The user. /// UserDto. + [Obsolete] UserDto GetUserDto(User user); /// diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 96a8c579e2..79c96dd5e4 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -934,19 +934,50 @@ namespace MediaBrowser.Controller.Entities public IEnumerable GetLinkedChildren(User user) { - if (!FilterLinkedChildrenPerUser) + if (!FilterLinkedChildrenPerUser || user == null) { return GetLinkedChildren(); } var locations = user.RootFolder - .Children + .GetChildren(user, true) .OfType() .SelectMany(i => i.PhysicalLocations) .ToList(); - return LinkedChildren.Where(i => string.IsNullOrWhiteSpace(i.Path) || locations.Any(l => FileSystem.ContainsSubPath(l, i.Path))) - .Select(GetLinkedChild) + return LinkedChildren + .Select(i => + { + var requiresPostFilter = true; + + if (!string.IsNullOrWhiteSpace(i.Path)) + { + requiresPostFilter = false; + + if (!locations.Any(l => FileSystem.ContainsSubPath(l, i.Path))) + { + return null; + } + } + + var child = GetLinkedChild(i); + + if (requiresPostFilter && child != null) + { + if (string.IsNullOrWhiteSpace(child.Path)) + { + Logger.Debug("Found LinkedChild with null path: {0}", child.Name); + return child; + } + + if (!locations.Any(l => FileSystem.ContainsSubPath(l, child.Path))) + { + return null; + } + } + + return child; + }) .Where(i => i != null); } diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs index 5d8fff38f4..705cf90575 100644 --- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs +++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs @@ -1,6 +1,4 @@ -using System.Runtime.Serialization; -using MediaBrowser.Common.Progress; -using MediaBrowser.Controller.Playlists; +using MediaBrowser.Common.Progress; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; @@ -8,6 +6,7 @@ using MediaBrowser.Model.Querying; using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; using System.Threading; using System.Threading.Tasks; @@ -81,8 +80,6 @@ namespace MediaBrowser.Controller.Entities.Movies { var children = base.GetChildren(user, includeLinkedChildren); - children = Playlist.FilterInaccessibleItems(children, user); - if (string.Equals(DisplayOrder, ItemSortBy.SortName, StringComparison.OrdinalIgnoreCase)) { // Sort by name @@ -99,12 +96,6 @@ namespace MediaBrowser.Controller.Entities.Movies return LibraryManager.Sort(children, user, new[] { ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName }, SortOrder.Ascending); } - public override IEnumerable GetRecursiveChildren(User user, bool includeLinkedChildren = true) - { - var children = base.GetRecursiveChildren(user, includeLinkedChildren); - return Playlist.FilterInaccessibleItems(children, user); - } - public BoxSetInfo GetLookupInfo() { return GetItemLookupInfo(); diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index b9c419722d..e4fd929ffd 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -24,6 +24,7 @@ namespace MediaBrowser.Controller.Entities /// /// The password. public string Password { get; set; } + public string LocalPassword { get; set; } /// /// Gets or sets the path. diff --git a/MediaBrowser.Controller/Library/IUserManager.cs b/MediaBrowser.Controller/Library/IUserManager.cs index c6bbf02ae7..a5d949c8a2 100644 --- a/MediaBrowser.Controller/Library/IUserManager.cs +++ b/MediaBrowser.Controller/Library/IUserManager.cs @@ -1,5 +1,6 @@ using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Configuration; +using MediaBrowser.Model.Dto; using MediaBrowser.Model.Events; using System; using System.Collections.Generic; @@ -53,10 +54,11 @@ namespace MediaBrowser.Controller.Library /// /// The username. /// The password. + /// The remote end point. /// Task{System.Boolean}. /// user - Task AuthenticateUser(string username, string password); - + Task AuthenticateUser(string username, string password, string remoteEndPoint); + /// /// Refreshes metadata for each user /// @@ -114,5 +116,13 @@ namespace MediaBrowser.Controller.Library /// The new password. /// Task. Task ChangePassword(User user, string newPassword); + + /// + /// Gets the user dto. + /// + /// The user. + /// The remote end point. + /// UserDto. + UserDto GetUserDto(User user, string remoteEndPoint = null); } } diff --git a/MediaBrowser.Controller/Playlists/Playlist.cs b/MediaBrowser.Controller/Playlists/Playlist.cs index 7822623a97..05a894223e 100644 --- a/MediaBrowser.Controller/Playlists/Playlist.cs +++ b/MediaBrowser.Controller/Playlists/Playlist.cs @@ -72,30 +72,7 @@ namespace MediaBrowser.Controller.Playlists }).Where(m => string.Equals(m.MediaType, playlistMediaType, StringComparison.OrdinalIgnoreCase)); - return FilterInaccessibleItems(inputItems, user); - } - - public static IEnumerable FilterInaccessibleItems(IEnumerable items, User user) - { - return items; - //var locations = user.RootFolder.Children.OfType().SelectMany(i => i.PhysicalLocations).ToList(); - - //return items.Where(i => - //{ - // var parent = i.Parent; - - // while (parent != null) - // { - // parent = parent.Parent; - - // if (parent != null && parent.Parent is AggregateFolder) - // { - // break; - // } - // } - - // return parent == null || locations.Contains(parent.Path, StringComparer.OrdinalIgnoreCase); - //}); + return inputItems; } [IgnoreDataMember] diff --git a/MediaBrowser.Dlna/DlnaManager.cs b/MediaBrowser.Dlna/DlnaManager.cs index 29bd21407b..2dd863c801 100644 --- a/MediaBrowser.Dlna/DlnaManager.cs +++ b/MediaBrowser.Dlna/DlnaManager.cs @@ -79,6 +79,7 @@ namespace MediaBrowser.Dlna //new WindowsMediaCenterProfile(), new WindowsPhoneProfile(), new AndroidProfile(), + new DirectTvProfile(), new DefaultProfile() }; diff --git a/MediaBrowser.Dlna/MediaBrowser.Dlna.csproj b/MediaBrowser.Dlna/MediaBrowser.Dlna.csproj index 962c2a211e..466c990092 100644 --- a/MediaBrowser.Dlna/MediaBrowser.Dlna.csproj +++ b/MediaBrowser.Dlna/MediaBrowser.Dlna.csproj @@ -73,6 +73,7 @@ + @@ -188,6 +189,9 @@ + + +