diff options
Diffstat (limited to 'MediaBrowser.Model/Dlna')
| -rw-r--r-- | MediaBrowser.Model/Dlna/ContainerProfile.cs | 8 | ||||
| -rw-r--r-- | MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs | 3 | ||||
| -rw-r--r-- | MediaBrowser.Model/Dlna/ResolutionNormalizer.cs | 37 | ||||
| -rw-r--r-- | MediaBrowser.Model/Dlna/StreamBuilder.cs | 14 | ||||
| -rw-r--r-- | MediaBrowser.Model/Dlna/StreamInfo.cs | 8 | ||||
| -rw-r--r-- | MediaBrowser.Model/Dlna/SubtitleProfile.cs | 4 |
6 files changed, 33 insertions, 41 deletions
diff --git a/MediaBrowser.Model/Dlna/ContainerProfile.cs b/MediaBrowser.Model/Dlna/ContainerProfile.cs index 3fb0682b0..ccad4cead 100644 --- a/MediaBrowser.Model/Dlna/ContainerProfile.cs +++ b/MediaBrowser.Model/Dlna/ContainerProfile.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.Xml.Serialization; -using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Extensions; namespace MediaBrowser.Model.Dlna @@ -17,7 +15,7 @@ namespace MediaBrowser.Model.Dlna public ContainerProfile() { - Conditions = new ProfileCondition[] { }; + Conditions = Array.Empty<ProfileCondition>(); } public string[] GetContainers() @@ -25,13 +23,11 @@ namespace MediaBrowser.Model.Dlna return SplitValue(Container); } - private static readonly string[] EmptyStringArray = Array.Empty<string>(); - public static string[] SplitValue(string value) { if (string.IsNullOrEmpty(value)) { - return EmptyStringArray; + return Array.Empty<string>(); } return value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); diff --git a/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs b/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs index 966c4a8ce..88d7573e6 100644 --- a/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs +++ b/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs @@ -1,7 +1,6 @@ using MediaBrowser.Model.MediaInfo; using System; using System.Collections.Generic; -using System.Linq; namespace MediaBrowser.Model.Dlna { @@ -28,7 +27,7 @@ namespace MediaBrowser.Model.Dlna DlnaFlags flagValue = DlnaFlags.BackgroundTransferMode | DlnaFlags.InteractiveTransferMode | DlnaFlags.DlnaV15; - + string dlnaflags = string.Format(";DLNA.ORG_FLAGS={0}", DlnaMaps.FlagsToString(flagValue)); diff --git a/MediaBrowser.Model/Dlna/ResolutionNormalizer.cs b/MediaBrowser.Model/Dlna/ResolutionNormalizer.cs index 4fdf4972f..4cde26a03 100644 --- a/MediaBrowser.Model/Dlna/ResolutionNormalizer.cs +++ b/MediaBrowser.Model/Dlna/ResolutionNormalizer.cs @@ -1,13 +1,12 @@ using System; -using System.Collections.Generic; using MediaBrowser.Model.Extensions; namespace MediaBrowser.Model.Dlna { public class ResolutionNormalizer { - private static readonly ResolutionConfiguration[] Configurations = - new [] + private static readonly ResolutionConfiguration[] Configurations = + new[] { new ResolutionConfiguration(426, 320000), new ResolutionConfiguration(640, 400000), @@ -20,24 +19,24 @@ namespace MediaBrowser.Model.Dlna public static ResolutionOptions Normalize(int? inputBitrate, int? unused1, int? unused2, - int outputBitrate, - string inputCodec, + int outputBitrate, + string inputCodec, string outputCodec, int? maxWidth, int? maxHeight) { - // If the bitrate isn't changing, then don't downlscale the resolution - if (inputBitrate.HasValue && outputBitrate >= inputBitrate.Value) - { - if (maxWidth.HasValue || maxHeight.HasValue) - { - return new ResolutionOptions - { - MaxWidth = maxWidth, - MaxHeight = maxHeight - }; - } - } + // If the bitrate isn't changing, then don't downlscale the resolution + if (inputBitrate.HasValue && outputBitrate >= inputBitrate.Value) + { + if (maxWidth.HasValue || maxHeight.HasValue) + { + return new ResolutionOptions + { + MaxWidth = maxWidth, + MaxHeight = maxHeight + }; + } + } var resolutionConfig = GetResolutionConfiguration(outputBitrate); if (resolutionConfig != null) @@ -90,8 +89,8 @@ namespace MediaBrowser.Model.Dlna { var inputScaleFactor = GetVideoBitrateScaleFactor(inputVideoCodec); var outputScaleFactor = GetVideoBitrateScaleFactor(outputVideoCodec); - var scaleFactor = outputScaleFactor/inputScaleFactor; - var newBitrate = scaleFactor*bitrate; + var scaleFactor = outputScaleFactor / inputScaleFactor; + var newBitrate = scaleFactor * bitrate; return Convert.ToInt32(newBitrate); } diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index 840abf618..41306b4c3 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -1,7 +1,7 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Extensions; -using MediaBrowser.Model.Logging; +using Microsoft.Extensions.Logging; using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.Session; using System; @@ -528,7 +528,7 @@ namespace MediaBrowser.Model.Dlna { transcodeReasons.InsertRange(0, GetTranscodeReasonsFromDirectPlayProfile(item, null, audioStream, options.Profile.DirectPlayProfiles)); - _logger.Info("Profile: {0}, No direct play profiles found for Path: {1}", + _logger.LogInformation("Profile: {0}, No direct play profiles found for Path: {1}", options.Profile.Name ?? "Unknown Profile", item.Path ?? "Unknown path"); } @@ -732,7 +732,7 @@ namespace MediaBrowser.Model.Dlna bool isEligibleForDirectPlay = options.EnableDirectPlay && (options.ForceDirectPlay || directPlayEligibilityResult.Item1); bool isEligibleForDirectStream = options.EnableDirectStream && (options.ForceDirectStream || directStreamEligibilityResult.Item1); - _logger.Info("Profile: {0}, Path: {1}, isEligibleForDirectPlay: {2}, isEligibleForDirectStream: {3}", + _logger.LogInformation("Profile: {0}, Path: {1}, isEligibleForDirectPlay: {2}, isEligibleForDirectStream: {3}", options.Profile.Name ?? "Unknown Profile", item.Path ?? "Unknown path", isEligibleForDirectPlay, @@ -1022,7 +1022,7 @@ namespace MediaBrowser.Model.Dlna if (directPlay == null) { - _logger.Info("Profile: {0}, No direct play profiles found for Path: {1}", + _logger.LogInformation("Profile: {0}, No direct play profiles found for Path: {1}", profile.Name ?? "Unknown Profile", mediaSource.Path ?? "Unknown path"); @@ -1188,7 +1188,7 @@ namespace MediaBrowser.Model.Dlna private void LogConditionFailure(DeviceProfile profile, string type, ProfileCondition condition, MediaSourceInfo mediaSource) { - _logger.Info("Profile: {0}, DirectPlay=false. Reason={1}.{2} Condition: {3}. ConditionValue: {4}. IsRequired: {5}. Path: {6}", + _logger.LogInformation("Profile: {0}, DirectPlay=false. Reason={1}.{2} Condition: {3}. ConditionValue: {4}. IsRequired: {5}. Path: {6}", type, profile.Name ?? "Unknown Profile", condition.Property, @@ -1210,7 +1210,7 @@ namespace MediaBrowser.Model.Dlna if (subtitleProfile.Method != SubtitleDeliveryMethod.External && subtitleProfile.Method != SubtitleDeliveryMethod.Embed) { - _logger.Info("Not eligible for {0} due to unsupported subtitles", playMethod); + _logger.LogInformation("Not eligible for {0} due to unsupported subtitles", playMethod); return new ValueTuple<bool, TranscodeReason?>(false, TranscodeReason.SubtitleCodecNotSupported); } } @@ -1397,7 +1397,7 @@ namespace MediaBrowser.Model.Dlna if (itemBitrate > requestedMaxBitrate) { - _logger.Info("Bitrate exceeds " + playMethod + " limit: media bitrate: {0}, max bitrate: {1}", itemBitrate.ToString(CultureInfo.InvariantCulture), requestedMaxBitrate.ToString(CultureInfo.InvariantCulture)); + _logger.LogInformation("Bitrate exceeds " + playMethod + " limit: media bitrate: {0}, max bitrate: {1}", itemBitrate.ToString(CultureInfo.InvariantCulture), requestedMaxBitrate.ToString(CultureInfo.InvariantCulture)); return false; } diff --git a/MediaBrowser.Model/Dlna/StreamInfo.cs b/MediaBrowser.Model/Dlna/StreamInfo.cs index c927cd31c..ba0ac0486 100644 --- a/MediaBrowser.Model/Dlna/StreamInfo.cs +++ b/MediaBrowser.Model/Dlna/StreamInfo.cs @@ -18,10 +18,10 @@ namespace MediaBrowser.Model.Dlna { public StreamInfo() { - AudioCodecs = new string[] { }; - VideoCodecs = new string[] { }; - SubtitleCodecs = new string[] { }; - TranscodeReasons = new TranscodeReason[] { }; + AudioCodecs = Array.Empty<string>(); + VideoCodecs = Array.Empty<string>(); + SubtitleCodecs = Array.Empty<string>(); + TranscodeReasons = Array.Empty<TranscodeReason>(); StreamOptions = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); } diff --git a/MediaBrowser.Model/Dlna/SubtitleProfile.cs b/MediaBrowser.Model/Dlna/SubtitleProfile.cs index a7e61e69a..f85ba4a7a 100644 --- a/MediaBrowser.Model/Dlna/SubtitleProfile.cs +++ b/MediaBrowser.Model/Dlna/SubtitleProfile.cs @@ -1,7 +1,5 @@ using MediaBrowser.Model.Extensions; -using System.Collections.Generic; using System.Xml.Serialization; -using MediaBrowser.Model.Dlna; namespace MediaBrowser.Model.Dlna { @@ -43,4 +41,4 @@ namespace MediaBrowser.Model.Dlna return languages.Length == 0 || ListHelper.ContainsIgnoreCase(languages, subLanguage); } } -}
\ No newline at end of file +} |
