diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-06-22 12:25:47 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-06-22 12:25:47 -0400 |
| commit | 3b30a2aee09bb045e466486fc0fff8a11cc6de74 (patch) | |
| tree | 051b157b6509631e077cf3c83153bead3a851ea3 /MediaBrowser.Model/Dlna | |
| parent | 414b1251c791dd914e51a5cfd7afeeaaf912e8a3 (diff) | |
detect anamorphic video
Diffstat (limited to 'MediaBrowser.Model/Dlna')
| -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 |
6 files changed, 67 insertions, 20 deletions
diff --git a/MediaBrowser.Model/Dlna/ConditionProcessor.cs b/MediaBrowser.Model/Dlna/ConditionProcessor.cs index 64ce2aabac..61428e39b1 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 c97c06d34a..55418e13b1 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 3cb3b383eb..fb670a5de1 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 56a322f5ad..544a011846 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 5828ded99a..5e8ba3ff12 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 b5aded6842..9d23597fae 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 |
