diff options
Diffstat (limited to 'MediaBrowser.Model')
| -rw-r--r-- | MediaBrowser.Model/Dlna/ConditionProcessor.cs | 30 | ||||
| -rw-r--r-- | MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs | 6 | ||||
| -rw-r--r-- | MediaBrowser.Model/Dlna/DeviceProfile.cs | 5 | ||||
| -rw-r--r-- | MediaBrowser.Model/Dlna/ProfileConditionValue.cs | 27 | ||||
| -rw-r--r-- | MediaBrowser.Model/Dlna/StreamBuilder.cs | 6 | ||||
| -rw-r--r-- | MediaBrowser.Model/Dlna/StreamInfo.cs | 13 | ||||
| -rw-r--r-- | MediaBrowser.Model/Entities/MediaStream.cs | 10 | ||||
| -rw-r--r-- | MediaBrowser.Model/Extensions/DoubleHelper.cs | 14 |
8 files changed, 89 insertions, 22 deletions
diff --git a/MediaBrowser.Model/Dlna/ConditionProcessor.cs b/MediaBrowser.Model/Dlna/ConditionProcessor.cs index 64ce2aaba..61428e39b 100644 --- a/MediaBrowser.Model/Dlna/ConditionProcessor.cs +++ b/MediaBrowser.Model/Dlna/ConditionProcessor.cs @@ -17,7 +17,8 @@ namespace MediaBrowser.Model.Dlna double? videoLevel, double? videoFramerate, int? packetLength, - TransportStreamTimestamp? timestamp) + TransportStreamTimestamp? timestamp, + bool? isAnamorphic) { switch (condition.Property) { @@ -27,6 +28,8 @@ namespace MediaBrowser.Model.Dlna case ProfileConditionValue.Has64BitOffsets: // TODO: Implement return true; + case ProfileConditionValue.IsAnamorphic: + return IsConditionSatisfied(condition, isAnamorphic); case ProfileConditionValue.VideoFramerate: return IsConditionSatisfied(condition, videoFramerate); case ProfileConditionValue.VideoLevel: @@ -147,6 +150,31 @@ namespace MediaBrowser.Model.Dlna throw new InvalidOperationException("Unexpected ProfileConditionType"); } } + + private bool IsConditionSatisfied(ProfileCondition condition, bool? currentValue) + { + if (!currentValue.HasValue) + { + // If the value is unknown, it satisfies if not marked as required + return !condition.IsRequired; + } + + bool expected; + if (BoolHelper.TryParseCultureInvariant(condition.Value, out expected)) + { + switch (condition.Condition) + { + case ProfileConditionType.Equals: + return currentValue.Value == expected; + case ProfileConditionType.NotEquals: + return currentValue.Value != expected; + default: + throw new InvalidOperationException("Unexpected ProfileConditionType"); + } + } + + return false; + } private bool IsConditionSatisfied(ProfileCondition condition, double? currentValue) { diff --git a/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs b/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs index c97c06d34..55418e13b 100644 --- a/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs +++ b/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs @@ -108,7 +108,8 @@ namespace MediaBrowser.Model.Dlna double? videoLevel, double? videoFramerate, int? packetLength, - TranscodeSeekInfo transcodeSeekInfo) + TranscodeSeekInfo transcodeSeekInfo, + bool? isAnamorphic) { // first bit means Time based seek supported, second byte range seek supported (not sure about the order now), so 01 = only byte seek, 10 = time based, 11 = both, 00 = none string orgOp = ";DLNA.ORG_OP=" + DlnaMaps.GetOrgOpValue(runtimeTicks.HasValue, isDirectStream, transcodeSeekInfo); @@ -145,7 +146,8 @@ namespace MediaBrowser.Model.Dlna videoLevel, videoFramerate, packetLength, - timestamp); + timestamp, + isAnamorphic); string orgPn = mediaProfile == null ? null : mediaProfile.OrgPn; diff --git a/MediaBrowser.Model/Dlna/DeviceProfile.cs b/MediaBrowser.Model/Dlna/DeviceProfile.cs index 3cb3b383e..fb670a5de 100644 --- a/MediaBrowser.Model/Dlna/DeviceProfile.cs +++ b/MediaBrowser.Model/Dlna/DeviceProfile.cs @@ -269,7 +269,8 @@ namespace MediaBrowser.Model.Dlna double? videoLevel, double? videoFramerate, int? packetLength, - TransportStreamTimestamp timestamp) + TransportStreamTimestamp timestamp, + bool? isAnamorphic) { container = (container ?? string.Empty).TrimStart('.'); @@ -303,7 +304,7 @@ namespace MediaBrowser.Model.Dlna var anyOff = false; foreach (ProfileCondition c in i.Conditions) { - if (!conditionProcessor.IsVideoConditionSatisfied(c, audioBitrate, audioChannels, width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp)) + if (!conditionProcessor.IsVideoConditionSatisfied(c, audioBitrate, audioChannels, width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic)) { anyOff = true; break; diff --git a/MediaBrowser.Model/Dlna/ProfileConditionValue.cs b/MediaBrowser.Model/Dlna/ProfileConditionValue.cs index 56a322f5a..544a01184 100644 --- a/MediaBrowser.Model/Dlna/ProfileConditionValue.cs +++ b/MediaBrowser.Model/Dlna/ProfileConditionValue.cs @@ -2,18 +2,19 @@ { public enum ProfileConditionValue { - AudioChannels, - AudioBitrate, - AudioProfile, - Width, - Height, - Has64BitOffsets, - PacketLength, - VideoBitDepth, - VideoBitrate, - VideoFramerate, - VideoLevel, - VideoProfile, - VideoTimestamp + AudioChannels = 0, + AudioBitrate = 1, + AudioProfile = 2, + Width = 3, + Height = 4, + Has64BitOffsets = 5, + PacketLength = 6, + VideoBitDepth = 7, + VideoBitrate = 8, + VideoFramerate = 9, + VideoLevel = 10, + VideoProfile = 11, + VideoTimestamp = 12, + IsAnamorphic = 13 } }
\ No newline at end of file diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index 5828ded99..5e8ba3ff1 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -370,6 +370,7 @@ namespace MediaBrowser.Model.Dlna double? videoLevel = videoStream == null ? null : videoStream.Level; string videoProfile = videoStream == null ? null : videoStream.Profile; float? videoFramerate = videoStream == null ? null : videoStream.AverageFrameRate ?? videoStream.AverageFrameRate; + bool? isAnamorphic = videoStream == null ? null : videoStream.IsAnamorphic; int? audioBitrate = audioStream == null ? null : audioStream.BitRate; int? audioChannels = audioStream == null ? null : audioStream.Channels; @@ -381,7 +382,7 @@ namespace MediaBrowser.Model.Dlna // Check container conditions foreach (ProfileCondition i in conditions) { - if (!conditionProcessor.IsVideoConditionSatisfied(i, audioBitrate, audioChannels, width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp)) + if (!conditionProcessor.IsVideoConditionSatisfied(i, audioBitrate, audioChannels, width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic)) { return null; } @@ -403,7 +404,7 @@ namespace MediaBrowser.Model.Dlna foreach (ProfileCondition i in conditions) { - if (!conditionProcessor.IsVideoConditionSatisfied(i, audioBitrate, audioChannels, width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp)) + if (!conditionProcessor.IsVideoConditionSatisfied(i, audioBitrate, audioChannels, width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic)) { return null; } @@ -520,6 +521,7 @@ namespace MediaBrowser.Model.Dlna break; } case ProfileConditionValue.AudioProfile: + case ProfileConditionValue.IsAnamorphic: case ProfileConditionValue.Has64BitOffsets: case ProfileConditionValue.PacketLength: case ProfileConditionValue.VideoTimestamp: diff --git a/MediaBrowser.Model/Dlna/StreamInfo.cs b/MediaBrowser.Model/Dlna/StreamInfo.cs index b5aded684..9d23597fa 100644 --- a/MediaBrowser.Model/Dlna/StreamInfo.cs +++ b/MediaBrowser.Model/Dlna/StreamInfo.cs @@ -348,6 +348,19 @@ namespace MediaBrowser.Model.Dlna } } + public bool? IsTargetAnamorphic + { + get + { + if (IsDirectStream) + { + return TargetVideoStream == null ? null : TargetVideoStream.IsAnamorphic; + } + + return false; + } + } + public int? TargetWidth { get diff --git a/MediaBrowser.Model/Entities/MediaStream.cs b/MediaBrowser.Model/Entities/MediaStream.cs index 838095832..7be8a64b7 100644 --- a/MediaBrowser.Model/Entities/MediaStream.cs +++ b/MediaBrowser.Model/Entities/MediaStream.cs @@ -33,7 +33,7 @@ namespace MediaBrowser.Model.Entities /// </summary> /// <value>The channel layout.</value> public string ChannelLayout { get; set; } - + /// <summary> /// Gets or sets the bit rate. /// </summary> @@ -155,11 +155,17 @@ namespace MediaBrowser.Model.Entities /// </summary> /// <value>The pixel format.</value> public string PixelFormat { get; set; } - + /// <summary> /// Gets or sets the level. /// </summary> /// <value>The level.</value> public double? Level { get; set; } + + /// <summary> + /// Gets a value indicating whether this instance is anamorphic. + /// </summary> + /// <value><c>true</c> if this instance is anamorphic; otherwise, <c>false</c>.</value> + public bool? IsAnamorphic { get; set; } } } diff --git a/MediaBrowser.Model/Extensions/DoubleHelper.cs b/MediaBrowser.Model/Extensions/DoubleHelper.cs index bcaf2d780..00e3bc624 100644 --- a/MediaBrowser.Model/Extensions/DoubleHelper.cs +++ b/MediaBrowser.Model/Extensions/DoubleHelper.cs @@ -18,4 +18,18 @@ namespace MediaBrowser.Model.Extensions return double.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out result); } } + + public static class BoolHelper + { + /// <summary> + /// Tries the parse culture invariant. + /// </summary> + /// <param name="s">The s.</param> + /// <param name="result">The result.</param> + /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> + public static bool TryParseCultureInvariant(string s, out bool result) + { + return bool.TryParse(s, out result); + } + } } |
