From 820b4873fb669b5a273817d68f3fbfc216b6610e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 4 Jun 2017 16:28:27 -0400 Subject: move methods to base class --- .../MediaEncoding/EncodingJobInfo.cs | 267 ++++++++++++++++++++- 1 file changed, 266 insertions(+), 1 deletion(-) (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs index 9b89e8f5aa..57c81ddf76 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs @@ -8,6 +8,7 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; using MediaBrowser.Model.Logging; using MediaBrowser.Model.MediaInfo; +using MediaBrowser.Model.Drawing; namespace MediaBrowser.Controller.MediaEncoding { @@ -134,7 +135,6 @@ namespace MediaBrowser.Controller.MediaEncoding public int? OutputAudioBitrate; public int? OutputAudioChannels; - public int? OutputAudioSampleRate; public bool DeInterlace { get; set; } public bool IsVideoRequest { get; set; } public TranscodingJobType TranscodingType { get; set; } @@ -173,6 +173,97 @@ namespace MediaBrowser.Controller.MediaEncoding return false; } + public int? TotalOutputBitrate + { + get + { + return (OutputAudioBitrate ?? 0) + (OutputVideoBitrate ?? 0); + } + } + + public int? OutputWidth + { + get + { + if (VideoStream != null && VideoStream.Width.HasValue && VideoStream.Height.HasValue) + { + var size = new ImageSize + { + Width = VideoStream.Width.Value, + Height = VideoStream.Height.Value + }; + + var newSize = DrawingUtils.Resize(size, + BaseRequest.Width, + BaseRequest.Height, + BaseRequest.MaxWidth, + BaseRequest.MaxHeight); + + return Convert.ToInt32(newSize.Width); + } + + if (!IsVideoRequest) + { + return null; + } + + return BaseRequest.MaxWidth ?? BaseRequest.Width; + } + } + + public int? OutputHeight + { + get + { + if (VideoStream != null && VideoStream.Width.HasValue && VideoStream.Height.HasValue) + { + var size = new ImageSize + { + Width = VideoStream.Width.Value, + Height = VideoStream.Height.Value + }; + + var newSize = DrawingUtils.Resize(size, + BaseRequest.Width, + BaseRequest.Height, + BaseRequest.MaxWidth, + BaseRequest.MaxHeight); + + return Convert.ToInt32(newSize.Height); + } + + if (!IsVideoRequest) + { + return null; + } + + return BaseRequest.MaxHeight ?? BaseRequest.Height; + } + } + + public int? OutputAudioSampleRate + { + get + { + if (BaseRequest.Static || string.Equals(OutputAudioCodec, "copy", StringComparison.OrdinalIgnoreCase)) + { + if (AudioStream != null) + { + return AudioStream.SampleRate; + } + } + + else if (BaseRequest.AudioSampleRate.HasValue) + { + // Don't exceed what the encoder supports + // Seeing issues of attempting to encode to 88200 + return Math.Min(44100, BaseRequest.AudioSampleRate.Value); + } + + return null; + } + } + /// /// Predicts the audio sample rate that will be in the output stream /// @@ -189,6 +280,180 @@ namespace MediaBrowser.Controller.MediaEncoding } } + /// + /// Predicts the audio sample rate that will be in the output stream + /// + public int? TargetVideoBitDepth + { + get + { + var stream = VideoStream; + return stream == null || !BaseRequest.Static ? null : stream.BitDepth; + } + } + + /// + /// Gets the target reference frames. + /// + /// The target reference frames. + public int? TargetRefFrames + { + get + { + var stream = VideoStream; + return stream == null || !BaseRequest.Static ? null : stream.RefFrames; + } + } + + /// + /// Predicts the audio sample rate that will be in the output stream + /// + public float? TargetFramerate + { + get + { + var stream = VideoStream; + var requestedFramerate = BaseRequest.MaxFramerate ?? BaseRequest.Framerate; + + return requestedFramerate.HasValue && !BaseRequest.Static + ? requestedFramerate + : stream == null ? null : stream.AverageFrameRate ?? stream.RealFrameRate; + } + } + + public TransportStreamTimestamp TargetTimestamp + { + get + { + var defaultValue = string.Equals(OutputContainer, "m2ts", StringComparison.OrdinalIgnoreCase) ? + TransportStreamTimestamp.Valid : + TransportStreamTimestamp.None; + + return !BaseRequest.Static + ? defaultValue + : InputTimestamp; + } + } + + /// + /// Predicts the audio sample rate that will be in the output stream + /// + public int? TargetPacketLength + { + get + { + var stream = VideoStream; + return !BaseRequest.Static + ? null + : stream == null ? null : stream.PacketLength; + } + } + + /// + /// Predicts the audio sample rate that will be in the output stream + /// + public string TargetVideoProfile + { + get + { + var stream = VideoStream; + return !string.IsNullOrEmpty(BaseRequest.Profile) && !BaseRequest.Static + ? BaseRequest.Profile + : stream == null ? null : stream.Profile; + } + } + + public string TargetVideoCodecTag + { + get + { + var stream = VideoStream; + return !BaseRequest.Static + ? null + : stream == null ? null : stream.CodecTag; + } + } + + public bool? IsTargetAnamorphic + { + get + { + if (BaseRequest.Static) + { + return VideoStream == null ? null : VideoStream.IsAnamorphic; + } + + return false; + } + } + + public bool? IsTargetInterlaced + { + get + { + if (BaseRequest.Static) + { + return VideoStream == null ? (bool?)null : VideoStream.IsInterlaced; + } + + if (DeInterlace) + { + return false; + } + + return VideoStream == null ? (bool?)null : VideoStream.IsInterlaced; + } + } + + public bool? IsTargetAVC + { + get + { + if (BaseRequest.Static) + { + return VideoStream == null ? null : VideoStream.IsAVC; + } + + return false; + } + } + + public int? TargetVideoStreamCount + { + get + { + if (BaseRequest.Static) + { + return GetMediaStreamCount(MediaStreamType.Video, int.MaxValue); + } + return GetMediaStreamCount(MediaStreamType.Video, 1); + } + } + + public int? TargetAudioStreamCount + { + get + { + if (BaseRequest.Static) + { + return GetMediaStreamCount(MediaStreamType.Audio, int.MaxValue); + } + return GetMediaStreamCount(MediaStreamType.Audio, 1); + } + } + + private int? GetMediaStreamCount(MediaStreamType type, int limit) + { + var count = MediaSource.GetStreamCount(type); + + if (count.HasValue) + { + count = Math.Min(count.Value, limit); + } + + return count; + } + protected void DisposeIsoMount() { if (IsoMount != null) -- cgit v1.2.3 From 42d0b070b48c9be4e11d3913d48d50f634cfd078 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 4 Jun 2017 17:08:56 -0400 Subject: update project files --- BDInfo/BDInfo.csproj | 4 ---- BDInfo/project.json | 17 ----------------- DvdLib/DvdLib.csproj | 4 ---- DvdLib/project.json | 17 ----------------- Emby.Dlna/project.json | 17 ----------------- Emby.Drawing/project.json | 17 ----------------- Emby.Photos/project.json | 17 ----------------- MediaBrowser.Api/Playback/MediaInfoService.cs | 13 +++++++++++++ MediaBrowser.Api/project.json | 17 ----------------- MediaBrowser.Common/MediaBrowser.Common.csproj | 3 --- MediaBrowser.Common/project.json | 17 ----------------- MediaBrowser.Controller/MediaBrowser.Controller.csproj | 4 ---- MediaBrowser.Controller/project.json | 17 ----------------- .../Images/EpisodeLocalImageProvider.cs | 2 +- MediaBrowser.LocalMetadata/project.json | 17 ----------------- MediaBrowser.MediaEncoding/project.json | 17 ----------------- MediaBrowser.Model/MediaBrowser.Model.csproj | 4 ---- MediaBrowser.Model/project.json | 17 ----------------- MediaBrowser.Providers/project.json | 17 ----------------- MediaBrowser.Server.Implementations/project.json | 17 ----------------- MediaBrowser.WebDashboard/project.json | 17 ----------------- MediaBrowser.XbmcMetadata/project.json | 17 ----------------- OpenSubtitlesHandler/OpenSubtitlesHandler.csproj | 3 --- OpenSubtitlesHandler/project.json | 17 ----------------- RSSDP/project.json | 17 ----------------- 25 files changed, 14 insertions(+), 312 deletions(-) delete mode 100644 BDInfo/project.json delete mode 100644 DvdLib/project.json delete mode 100644 Emby.Dlna/project.json delete mode 100644 Emby.Drawing/project.json delete mode 100644 Emby.Photos/project.json delete mode 100644 MediaBrowser.Api/project.json delete mode 100644 MediaBrowser.Common/project.json delete mode 100644 MediaBrowser.Controller/project.json delete mode 100644 MediaBrowser.LocalMetadata/project.json delete mode 100644 MediaBrowser.MediaEncoding/project.json delete mode 100644 MediaBrowser.Model/project.json delete mode 100644 MediaBrowser.Providers/project.json delete mode 100644 MediaBrowser.Server.Implementations/project.json delete mode 100644 MediaBrowser.WebDashboard/project.json delete mode 100644 MediaBrowser.XbmcMetadata/project.json delete mode 100644 OpenSubtitlesHandler/project.json delete mode 100644 RSSDP/project.json (limited to 'MediaBrowser.Controller') diff --git a/BDInfo/BDInfo.csproj b/BDInfo/BDInfo.csproj index e7013f341b..97abe74846 100644 --- a/BDInfo/BDInfo.csproj +++ b/BDInfo/BDInfo.csproj @@ -33,10 +33,6 @@ prompt 4 - - - - diff --git a/BDInfo/project.json b/BDInfo/project.json deleted file mode 100644 index fbbe9eaf32..0000000000 --- a/BDInfo/project.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "frameworks":{ - "netstandard1.6":{ - "dependencies":{ - "NETStandard.Library":"1.6.0", - } - }, - ".NETPortable,Version=v4.5,Profile=Profile7":{ - "buildOptions": { - "define": [ ] - }, - "frameworkAssemblies":{ - - } - } - } -} \ No newline at end of file diff --git a/DvdLib/DvdLib.csproj b/DvdLib/DvdLib.csproj index ba63e77f0f..9ed197c591 100644 --- a/DvdLib/DvdLib.csproj +++ b/DvdLib/DvdLib.csproj @@ -33,10 +33,6 @@ prompt 4 - - - - diff --git a/DvdLib/project.json b/DvdLib/project.json deleted file mode 100644 index fbbe9eaf32..0000000000 --- a/DvdLib/project.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "frameworks":{ - "netstandard1.6":{ - "dependencies":{ - "NETStandard.Library":"1.6.0", - } - }, - ".NETPortable,Version=v4.5,Profile=Profile7":{ - "buildOptions": { - "define": [ ] - }, - "frameworkAssemblies":{ - - } - } - } -} \ No newline at end of file diff --git a/Emby.Dlna/project.json b/Emby.Dlna/project.json deleted file mode 100644 index fbbe9eaf32..0000000000 --- a/Emby.Dlna/project.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "frameworks":{ - "netstandard1.6":{ - "dependencies":{ - "NETStandard.Library":"1.6.0", - } - }, - ".NETPortable,Version=v4.5,Profile=Profile7":{ - "buildOptions": { - "define": [ ] - }, - "frameworkAssemblies":{ - - } - } - } -} \ No newline at end of file diff --git a/Emby.Drawing/project.json b/Emby.Drawing/project.json deleted file mode 100644 index fbbe9eaf32..0000000000 --- a/Emby.Drawing/project.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "frameworks":{ - "netstandard1.6":{ - "dependencies":{ - "NETStandard.Library":"1.6.0", - } - }, - ".NETPortable,Version=v4.5,Profile=Profile7":{ - "buildOptions": { - "define": [ ] - }, - "frameworkAssemblies":{ - - } - } - } -} \ No newline at end of file diff --git a/Emby.Photos/project.json b/Emby.Photos/project.json deleted file mode 100644 index fbbe9eaf32..0000000000 --- a/Emby.Photos/project.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "frameworks":{ - "netstandard1.6":{ - "dependencies":{ - "NETStandard.Library":"1.6.0", - } - }, - ".NETPortable,Version=v4.5,Profile=Profile7":{ - "buildOptions": { - "define": [ ] - }, - "frameworkAssemblies":{ - - } - } - } -} \ No newline at end of file diff --git a/MediaBrowser.Api/Playback/MediaInfoService.cs b/MediaBrowser.Api/Playback/MediaInfoService.cs index 911d925554..bba8094b64 100644 --- a/MediaBrowser.Api/Playback/MediaInfoService.cs +++ b/MediaBrowser.Api/Playback/MediaInfoService.cs @@ -357,6 +357,19 @@ namespace MediaBrowser.Api.Playback mediaSource.SupportsTranscoding = false; } + if (item is Audio) + { + Logger.Info("User policy for {0}. EnableAudioPlaybackTranscoding: {1}", user.Name, user.Policy.EnableAudioPlaybackTranscoding); + } + else + { + Logger.Info("User policy for {0}. EnablePlaybackRemuxing: {1} EnableVideoPlaybackTranscoding: {2} EnableAudioPlaybackTranscoding: {3}", + user.Name, + user.Policy.EnablePlaybackRemuxing, + user.Policy.EnableVideoPlaybackTranscoding, + user.Policy.EnableAudioPlaybackTranscoding); + } + if (mediaSource.SupportsDirectPlay) { if (mediaSource.IsRemote && forceDirectPlayRemoteMediaSource) diff --git a/MediaBrowser.Api/project.json b/MediaBrowser.Api/project.json deleted file mode 100644 index fbbe9eaf32..0000000000 --- a/MediaBrowser.Api/project.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "frameworks":{ - "netstandard1.6":{ - "dependencies":{ - "NETStandard.Library":"1.6.0", - } - }, - ".NETPortable,Version=v4.5,Profile=Profile7":{ - "buildOptions": { - "define": [ ] - }, - "frameworkAssemblies":{ - - } - } - } -} \ No newline at end of file diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csproj index b24975dbab..d561b634ec 100644 --- a/MediaBrowser.Common/MediaBrowser.Common.csproj +++ b/MediaBrowser.Common/MediaBrowser.Common.csproj @@ -72,9 +72,6 @@ MediaBrowser.Model - - - diff --git a/MediaBrowser.Common/project.json b/MediaBrowser.Common/project.json deleted file mode 100644 index fbbe9eaf32..0000000000 --- a/MediaBrowser.Common/project.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "frameworks":{ - "netstandard1.6":{ - "dependencies":{ - "NETStandard.Library":"1.6.0", - } - }, - ".NETPortable,Version=v4.5,Profile=Profile7":{ - "buildOptions": { - "define": [ ] - }, - "frameworkAssemblies":{ - - } - } - } -} \ No newline at end of file diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index e15b58e77a..348cfd343f 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -36,10 +36,6 @@ Always - - - - Properties\SharedVersion.cs diff --git a/MediaBrowser.Controller/project.json b/MediaBrowser.Controller/project.json deleted file mode 100644 index fbbe9eaf32..0000000000 --- a/MediaBrowser.Controller/project.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "frameworks":{ - "netstandard1.6":{ - "dependencies":{ - "NETStandard.Library":"1.6.0", - } - }, - ".NETPortable,Version=v4.5,Profile=Profile7":{ - "buildOptions": { - "define": [ ] - }, - "frameworkAssemblies":{ - - } - } - } -} \ No newline at end of file diff --git a/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs b/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs index 033c38420d..2b5858aec4 100644 --- a/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs +++ b/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs @@ -40,7 +40,7 @@ namespace MediaBrowser.LocalMetadata.Images { var parentPath = _fileSystem.GetDirectoryName(item.Path); - var parentPathFiles = directoryService.GetFileSystemEntries(parentPath) + var parentPathFiles = directoryService.GetFiles(parentPath) .ToList(); var nameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(item.Path); diff --git a/MediaBrowser.LocalMetadata/project.json b/MediaBrowser.LocalMetadata/project.json deleted file mode 100644 index fbbe9eaf32..0000000000 --- a/MediaBrowser.LocalMetadata/project.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "frameworks":{ - "netstandard1.6":{ - "dependencies":{ - "NETStandard.Library":"1.6.0", - } - }, - ".NETPortable,Version=v4.5,Profile=Profile7":{ - "buildOptions": { - "define": [ ] - }, - "frameworkAssemblies":{ - - } - } - } -} \ No newline at end of file diff --git a/MediaBrowser.MediaEncoding/project.json b/MediaBrowser.MediaEncoding/project.json deleted file mode 100644 index fbbe9eaf32..0000000000 --- a/MediaBrowser.MediaEncoding/project.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "frameworks":{ - "netstandard1.6":{ - "dependencies":{ - "NETStandard.Library":"1.6.0", - } - }, - ".NETPortable,Version=v4.5,Profile=Profile7":{ - "buildOptions": { - "define": [ ] - }, - "frameworkAssemblies":{ - - } - } - } -} \ No newline at end of file diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index 67a04c5a19..354fd38ead 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -33,10 +33,6 @@ prompt 4 - - - - Properties\SharedVersion.cs diff --git a/MediaBrowser.Model/project.json b/MediaBrowser.Model/project.json deleted file mode 100644 index fbbe9eaf32..0000000000 --- a/MediaBrowser.Model/project.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "frameworks":{ - "netstandard1.6":{ - "dependencies":{ - "NETStandard.Library":"1.6.0", - } - }, - ".NETPortable,Version=v4.5,Profile=Profile7":{ - "buildOptions": { - "define": [ ] - }, - "frameworkAssemblies":{ - - } - } - } -} \ No newline at end of file diff --git a/MediaBrowser.Providers/project.json b/MediaBrowser.Providers/project.json deleted file mode 100644 index fbbe9eaf32..0000000000 --- a/MediaBrowser.Providers/project.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "frameworks":{ - "netstandard1.6":{ - "dependencies":{ - "NETStandard.Library":"1.6.0", - } - }, - ".NETPortable,Version=v4.5,Profile=Profile7":{ - "buildOptions": { - "define": [ ] - }, - "frameworkAssemblies":{ - - } - } - } -} \ No newline at end of file diff --git a/MediaBrowser.Server.Implementations/project.json b/MediaBrowser.Server.Implementations/project.json deleted file mode 100644 index fbbe9eaf32..0000000000 --- a/MediaBrowser.Server.Implementations/project.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "frameworks":{ - "netstandard1.6":{ - "dependencies":{ - "NETStandard.Library":"1.6.0", - } - }, - ".NETPortable,Version=v4.5,Profile=Profile7":{ - "buildOptions": { - "define": [ ] - }, - "frameworkAssemblies":{ - - } - } - } -} \ No newline at end of file diff --git a/MediaBrowser.WebDashboard/project.json b/MediaBrowser.WebDashboard/project.json deleted file mode 100644 index fbbe9eaf32..0000000000 --- a/MediaBrowser.WebDashboard/project.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "frameworks":{ - "netstandard1.6":{ - "dependencies":{ - "NETStandard.Library":"1.6.0", - } - }, - ".NETPortable,Version=v4.5,Profile=Profile7":{ - "buildOptions": { - "define": [ ] - }, - "frameworkAssemblies":{ - - } - } - } -} \ No newline at end of file diff --git a/MediaBrowser.XbmcMetadata/project.json b/MediaBrowser.XbmcMetadata/project.json deleted file mode 100644 index fbbe9eaf32..0000000000 --- a/MediaBrowser.XbmcMetadata/project.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "frameworks":{ - "netstandard1.6":{ - "dependencies":{ - "NETStandard.Library":"1.6.0", - } - }, - ".NETPortable,Version=v4.5,Profile=Profile7":{ - "buildOptions": { - "define": [ ] - }, - "frameworkAssemblies":{ - - } - } - } -} \ No newline at end of file diff --git a/OpenSubtitlesHandler/OpenSubtitlesHandler.csproj b/OpenSubtitlesHandler/OpenSubtitlesHandler.csproj index e546830273..d70f729625 100644 --- a/OpenSubtitlesHandler/OpenSubtitlesHandler.csproj +++ b/OpenSubtitlesHandler/OpenSubtitlesHandler.csproj @@ -107,9 +107,6 @@ - - -