diff --git a/MediaBrowser.Controller/Dlna/CodecProfile.cs b/MediaBrowser.Controller/Dlna/CodecProfile.cs new file mode 100644 index 000000000..f17805654 --- /dev/null +++ b/MediaBrowser.Controller/Dlna/CodecProfile.cs @@ -0,0 +1,51 @@ +using System.Collections.Generic; + +namespace MediaBrowser.Controller.Dlna +{ + public class CodecProfile + { + public CodecType Type { get; set; } + public List Conditions { get; set; } + public string[] Codecs { get; set; } + + public CodecProfile() + { + Conditions = new List(); + Codecs = new string[] { }; + } + } + + public enum CodecType + { + VideoCodec = 0, + VideoAudioCodec = 1, + AudioCodec = 2 + } + + public class ProfileCondition + { + public ProfileConditionType Condition { get; set; } + public ProfileConditionValue Property { get; set; } + public string Value { get; set; } + } + + public enum ProfileConditionType + { + Equals = 0, + NotEquals = 1, + LessThanEqual = 2, + GreaterThanEqual = 3 + } + + public enum ProfileConditionValue + { + AudioChannels, + AudioBitrate, + Filesize, + Width, + Height, + VideoBitrate, + VideoFramerate, + VideoLevel + } +} diff --git a/MediaBrowser.Controller/Dlna/DeviceProfile.cs b/MediaBrowser.Controller/Dlna/DeviceProfile.cs index bdcfc009a..179321a53 100644 --- a/MediaBrowser.Controller/Dlna/DeviceProfile.cs +++ b/MediaBrowser.Controller/Dlna/DeviceProfile.cs @@ -56,12 +56,14 @@ namespace MediaBrowser.Controller.Dlna public string ProtocolInfo { get; set; } public MediaProfile[] MediaProfiles { get; set; } + public CodecProfile[] CodecProfiles { get; set; } public DeviceProfile() { DirectPlayProfiles = new DirectPlayProfile[] { }; TranscodingProfiles = new TranscodingProfile[] { }; MediaProfiles = new MediaProfile[] { }; + CodecProfiles = new CodecProfile[] { }; } } } diff --git a/MediaBrowser.Controller/Dlna/DirectPlayProfile.cs b/MediaBrowser.Controller/Dlna/DirectPlayProfile.cs index c11180aeb..29665cbec 100644 --- a/MediaBrowser.Controller/Dlna/DirectPlayProfile.cs +++ b/MediaBrowser.Controller/Dlna/DirectPlayProfile.cs @@ -22,37 +22,10 @@ namespace MediaBrowser.Controller.Dlna } } - public class ProfileCondition - { - public ProfileConditionType Condition { get; set; } - public ProfileConditionValue Property { get; set; } - public string Value { get; set; } - } - public enum DlnaProfileType { Audio = 0, Video = 1, Photo = 2 } - - public enum ProfileConditionType - { - Equals = 0, - NotEquals = 1, - LessThanEqual = 2, - GreaterThanEqual = 3 - } - - public enum ProfileConditionValue - { - AudioChannels, - AudioBitrate, - Filesize, - VideoWidth, - VideoHeight, - VideoBitrate, - VideoFramerate, - VideoLevel - } } diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 778abadb1..b51824bdb 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -78,6 +78,7 @@ + diff --git a/MediaBrowser.Dlna/DlnaManager.cs b/MediaBrowser.Dlna/DlnaManager.cs index d073c8316..fd74ba24a 100644 --- a/MediaBrowser.Dlna/DlnaManager.cs +++ b/MediaBrowser.Dlna/DlnaManager.cs @@ -657,7 +657,7 @@ namespace MediaBrowser.Dlna { new DirectPlayProfile { - Containers = new[]{"mp3", "flac", "m4a", "wma"}, + Containers = new[]{"mp3", "flac", "m4a", "wma", "aac"}, Type = DlnaProfileType.Audio }, @@ -665,6 +665,54 @@ namespace MediaBrowser.Dlna { Containers = new[]{"avi", "mp4", "mkv", "ts"}, Type = DlnaProfileType.Video + }, + + new DirectPlayProfile + { + Type = DlnaProfileType.Photo, + + Conditions = new List + { + new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.Width, Value = "1920"}, + new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.Height, Value = "1080"} + } + } + }, + + MediaProfiles = new[] + { + new MediaProfile + { + Container ="ts", + OrgPn = "MPEG_TS_SD_NA", + Type = DlnaProfileType.Video + } + }, + + CodecProfiles = new[] + { + new CodecProfile + { + Type = CodecType.VideoCodec, + Codecs = new[]{"h264"}, + + Conditions = new List + { + new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.Width, Value = "1920"}, + new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.Height, Value = "1080"}, + new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.VideoLevel, Value = "41"} + } + }, + + new CodecProfile + { + Type = CodecType.VideoAudioCodec, + Codecs = new[]{"aac"}, + + Conditions = new List + { + new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.AudioChannels, Value = "2"} + } } } }); diff --git a/MediaBrowser.Dlna/PlayTo/PlaylistItemFactory.cs b/MediaBrowser.Dlna/PlayTo/PlaylistItemFactory.cs index 817dfb86f..968f7643a 100644 --- a/MediaBrowser.Dlna/PlayTo/PlaylistItemFactory.cs +++ b/MediaBrowser.Dlna/PlayTo/PlaylistItemFactory.cs @@ -171,11 +171,14 @@ namespace MediaBrowser.Dlna.PlayTo { var mediaPath = item.Path; - // Check container type - var mediaContainer = Path.GetExtension(mediaPath); - if (!profile.Containers.Any(i => string.Equals("." + i.TrimStart('.'), mediaContainer, StringComparison.OrdinalIgnoreCase))) + if (profile.Containers.Length > 0) { - return false; + // Check container type + var mediaContainer = Path.GetExtension(mediaPath); + if (!profile.Containers.Any(i => string.Equals("." + i.TrimStart('.'), mediaContainer, StringComparison.OrdinalIgnoreCase))) + { + return false; + } } // Check additional conditions @@ -191,11 +194,14 @@ namespace MediaBrowser.Dlna.PlayTo { var mediaPath = item.Path; - // Check container type - var mediaContainer = Path.GetExtension(mediaPath); - if (!profile.Containers.Any(i => string.Equals("." + i.TrimStart('.'), mediaContainer, StringComparison.OrdinalIgnoreCase))) + if (profile.Containers.Length > 0) { - return false; + // Check container type + var mediaContainer = Path.GetExtension(mediaPath); + if (!profile.Containers.Any(i => string.Equals("." + i.TrimStart('.'), mediaContainer, StringComparison.OrdinalIgnoreCase))) + { + return false; + } } // Check additional conditions @@ -216,11 +222,14 @@ namespace MediaBrowser.Dlna.PlayTo var mediaPath = item.Path; - // Check container type - var mediaContainer = Path.GetExtension(mediaPath); - if (!profile.Containers.Any(i => string.Equals("." + i.TrimStart('.'), mediaContainer, StringComparison.OrdinalIgnoreCase))) + if (profile.Containers.Length > 0) { - return false; + // Check container type + var mediaContainer = Path.GetExtension(mediaPath); + if (!profile.Containers.Any(i => string.Equals("." + i.TrimStart('.'), mediaContainer, StringComparison.OrdinalIgnoreCase))) + { + return false; + } } // Check video codec @@ -330,9 +339,9 @@ namespace MediaBrowser.Dlna.PlayTo return videoStream == null ? null : videoStream.BitRate; case ProfileConditionValue.VideoFramerate: return videoStream == null ? null : (ConvertToLong(videoStream.AverageFrameRate ?? videoStream.RealFrameRate)); - case ProfileConditionValue.VideoHeight: + case ProfileConditionValue.Height: return videoStream == null ? null : videoStream.Height; - case ProfileConditionValue.VideoWidth: + case ProfileConditionValue.Width: return videoStream == null ? null : videoStream.Width; case ProfileConditionValue.VideoLevel: return videoStream == null ? null : ConvertToLong(videoStream.Level);