diff options
Diffstat (limited to 'MediaBrowser.Api')
| -rw-r--r-- | MediaBrowser.Api/ApiEntryPoint.cs | 15 | ||||
| -rw-r--r-- | MediaBrowser.Api/MediaBrowser.Api.csproj | 7 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/BaseStreamingService.cs | 79 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs | 4 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/StreamState.cs | 44 | ||||
| -rw-r--r-- | MediaBrowser.Api/UserService.cs | 9 |
6 files changed, 93 insertions, 65 deletions
diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.cs index 7c655ef88e..d386373d4b 100644 --- a/MediaBrowser.Api/ApiEntryPoint.cs +++ b/MediaBrowser.Api/ApiEntryPoint.cs @@ -172,19 +172,8 @@ namespace MediaBrowser.Api if (!string.IsNullOrWhiteSpace(deviceId)) { - var audioCodec = state.Request.AudioCodec; - var videoCodec = state.VideoRequest == null ? null : state.VideoRequest.VideoCodec; - - if (string.Equals(state.OutputAudioCodec, "copy", StringComparison.OrdinalIgnoreCase) || - string.IsNullOrEmpty(audioCodec)) - { - audioCodec = state.OutputAudioCodec; - } - if (string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase) || - string.IsNullOrEmpty(videoCodec)) - { - videoCodec = state.OutputVideoCodec; - } + var audioCodec = state.ActualOutputVideoCodec; + var videoCodec = state.ActualOutputVideoCodec; _sessionManager.ReportTranscodingInfo(deviceId, new TranscodingInfo { diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csproj index 5d8a24f9ab..b233629e1f 100644 --- a/MediaBrowser.Api/MediaBrowser.Api.csproj +++ b/MediaBrowser.Api/MediaBrowser.Api.csproj @@ -172,13 +172,6 @@ <PostBuildEvent> </PostBuildEvent> </PropertyGroup> - <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" /> - <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> - <PropertyGroup> - <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> - </PropertyGroup> - <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" /> - </Target> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index dccf459eb8..ec6ca7737b 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -830,23 +830,6 @@ namespace MediaBrowser.Api.Playback return MediaEncoder.GetInputArgument(inputPath, protocol); } - private MediaProtocol GetProtocol(string path) - { - if (path.StartsWith("Http", StringComparison.OrdinalIgnoreCase)) - { - return MediaProtocol.Http; - } - if (path.StartsWith("Rtsp", StringComparison.OrdinalIgnoreCase)) - { - return MediaProtocol.Rtsp; - } - if (path.StartsWith("Rtmp", StringComparison.OrdinalIgnoreCase)) - { - return MediaProtocol.Rtmp; - } - return MediaProtocol.File; - } - private async Task AcquireResources(StreamState state, CancellationTokenSource cancellationTokenSource) { if (state.VideoType == VideoType.Iso && state.IsoType.HasValue && IsoManager.CanMount(state.MediaPath)) @@ -1788,9 +1771,23 @@ namespace MediaBrowser.Api.Playback } // If client is requesting a specific video profile, it must match the source - if (!string.IsNullOrEmpty(request.Profile) && !string.Equals(request.Profile, videoStream.Profile, StringComparison.OrdinalIgnoreCase)) + if (!string.IsNullOrEmpty(request.Profile)) { - return false; + if (string.IsNullOrEmpty(videoStream.Profile)) + { + return false; + } + + if (!string.Equals(request.Profile, videoStream.Profile, StringComparison.OrdinalIgnoreCase)) + { + var currentScore = GetVideoProfileScore(videoStream.Profile); + var requestedScore = GetVideoProfileScore(request.Profile); + + if (currentScore == -1 || currentScore > requestedScore) + { + return false; + } + } } // Video width must fall within requested value @@ -1870,6 +1867,22 @@ namespace MediaBrowser.Api.Playback return request.EnableAutoStreamCopy; } + private int GetVideoProfileScore(string profile) + { + var list = new List<string> + { + "Constrained Baseline", + "Baseline", + "Extended", + "Main", + "High", + "Progressive High", + "Constrained High" + }; + + return Array.FindIndex(list.ToArray(), t => string.Equals(t, profile, StringComparison.OrdinalIgnoreCase)); + } + private bool CanStreamCopyAudio(VideoStreamRequest request, MediaStream audioStream, List<string> supportedAudioCodecs) { // Source and target codecs must match @@ -1942,19 +1955,9 @@ namespace MediaBrowser.Api.Playback return; } - var audioCodec = state.OutputAudioCodec; - - if (string.Equals(audioCodec, "copy", StringComparison.OrdinalIgnoreCase) && state.AudioStream != null) - { - audioCodec = state.AudioStream.Codec; - } - - var videoCodec = state.OutputVideoCodec; + var audioCodec = state.ActualOutputAudioCodec; - if (string.Equals(videoCodec, "copy", StringComparison.OrdinalIgnoreCase) && state.VideoStream != null) - { - videoCodec = state.VideoStream.Codec; - } + var videoCodec = state.ActualOutputVideoCodec; var mediaProfile = state.VideoRequest == null ? profile.GetAudioMediaProfile(state.OutputContainer, audioCodec, state.OutputAudioChannels, state.OutputAudioBitrate) : @@ -2022,12 +2025,7 @@ namespace MediaBrowser.Api.Playback profile = DlnaManager.GetDefaultProfile(); } - var audioCodec = state.OutputAudioCodec; - - if (string.Equals(audioCodec, "copy", StringComparison.OrdinalIgnoreCase) && state.AudioStream != null) - { - audioCodec = state.AudioStream.Codec; - } + var audioCodec = state.ActualOutputAudioCodec; if (state.VideoRequest == null) { @@ -2045,12 +2043,7 @@ namespace MediaBrowser.Api.Playback } else { - var videoCodec = state.OutputVideoCodec; - - if (string.Equals(videoCodec, "copy", StringComparison.OrdinalIgnoreCase) && state.VideoStream != null) - { - videoCodec = state.VideoStream.Codec; - } + var videoCodec = state.ActualOutputVideoCodec; responseHeaders["contentFeatures.dlna.org"] = new ContentFeatureBuilder(profile) .BuildVideoHeader( diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index b41686cb6c..bea4ba37ed 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -605,7 +605,7 @@ namespace MediaBrowser.Api.Playback.Hls { var codec = state.OutputAudioCodec; - if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase)) + if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase)) { return "-codec:a:0 copy"; } @@ -636,7 +636,7 @@ namespace MediaBrowser.Api.Playback.Hls var codec = state.OutputVideoCodec; // See if we can save come cpu cycles by avoiding encoding - if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase)) + if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase)) { return IsH264(state.VideoStream) ? "-codec:v:0 copy -bsf:v h264_mp4toannexb" : "-codec:v:0 copy"; } diff --git a/MediaBrowser.Api/Playback/StreamState.cs b/MediaBrowser.Api/Playback/StreamState.cs index de803037df..24b2bebd3a 100644 --- a/MediaBrowser.Api/Playback/StreamState.cs +++ b/MediaBrowser.Api/Playback/StreamState.cs @@ -188,6 +188,50 @@ namespace MediaBrowser.Api.Playback public int? OutputAudioBitrate; public int? OutputVideoBitrate; + public string ActualOutputVideoCodec + { + get + { + var codec = OutputVideoCodec; + + if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase)) + { + var stream = VideoStream; + + if (stream != null) + { + return stream.Codec; + } + + return null; + } + + return codec; + } + } + + public string ActualOutputAudioCodec + { + get + { + var codec = OutputAudioCodec; + + if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase)) + { + var stream = AudioStream; + + if (stream != null) + { + return stream.Codec; + } + + return null; + } + + return codec; + } + } + public string OutputContainer { get; set; } public DeviceProfile DeviceProfile { get; set; } diff --git a/MediaBrowser.Api/UserService.cs b/MediaBrowser.Api/UserService.cs index fede6caafe..48bd2fc1ea 100644 --- a/MediaBrowser.Api/UserService.cs +++ b/MediaBrowser.Api/UserService.cs @@ -29,6 +29,9 @@ namespace MediaBrowser.Api [ApiMember(Name = "IsDisabled", Description = "Optional filter by IsDisabled=true or false", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] public bool? IsDisabled { get; set; } + + [ApiMember(Name = "IsGuest", Description = "Optional filter by IsGuest=true or false", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] + public bool? IsGuest { get; set; } } [Route("/Users/Public", "GET", Summary = "Gets a list of publicly visible users for display on a login screen.")] @@ -255,6 +258,12 @@ namespace MediaBrowser.Api users = users.Where(i => i.Configuration.IsHidden == request.IsHidden.Value); } + if (request.IsGuest.HasValue) + { + + users = users.Where(i => (i.ConnectLinkType.HasValue && i.ConnectLinkType.Value == UserLinkType.Guest) == request.IsGuest.Value); + } + var result = users .OrderBy(u => u.Name) .Select(i => _userManager.GetUserDto(i, Request.RemoteIp)) |
