The Free Software Media System - Server Backend & API
updated dlna profiles
Luke Pulverentia748c660cb3b
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.csindex 93f3e2d9f9..a4abb129b3 100644--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs@@ -1665,8 +1665,21 @@ namespace MediaBrowser.Api.Playback}var mediaProfile = state.VideoRequest == null ?- profile.GetAudioMediaProfile(state.OutputContainer, audioCodec) :- profile.GetVideoMediaProfile(state.OutputContainer, audioCodec, videoCodec);+ profile.GetAudioMediaProfile(state.OutputContainer, audioCodec, state.OutputAudioChannels, state.OutputAudioBitrate) :+ profile.GetVideoMediaProfile(state.OutputContainer,+ audioCodec,+ videoCodec,+ state.OutputAudioBitrate,+ state.OutputAudioChannels,+ state.OutputWidth,+ state.OutputHeight,+ state.TargetVideoBitDepth,+ state.OutputVideoBitrate,+ state.TargetVideoProfile,+ state.TargetVideoLevel,+ state.TargetFramerate,+ state.TargetPacketLength,+ state.TargetTimestamp);if (mediaProfile != null){@@ -1752,10 +1765,17 @@ namespace MediaBrowser.Api.PlaybackaudioCodec,state.OutputWidth,state.OutputHeight,- state.TotalOutputBitrate,- TransportStreamTimestamp.VALID,+ state.TargetVideoBitDepth,+ state.OutputVideoBitrate,+ state.OutputAudioBitrate,+ state.OutputAudioChannels,+ state.TargetTimestamp,isStaticallyStreamed,state.RunTimeTicks,+ state.TargetVideoProfile,+ state.TargetVideoLevel,+ state.TargetFramerate,+ state.TargetPacketLength,state.TranscodeSeekInfo);}diff --git a/MediaBrowser.Api/Playback/StreamState.cs b/MediaBrowser.Api/Playback/StreamState.csindex 8a8246b69d..fe9199244b 100644--- a/MediaBrowser.Api/Playback/StreamState.cs+++ b/MediaBrowser.Api/Playback/StreamState.cs@@ -1,4 +1,5 @@-using MediaBrowser.Common.Net;+using System.Globalization;+using MediaBrowser.Common.Net;using MediaBrowser.Controller.LiveTv;using MediaBrowser.Model.Dlna;using MediaBrowser.Model.Drawing;@@ -221,5 +222,88 @@ namespace MediaBrowser.Api.Playbackreturn VideoRequest.MaxHeight ?? VideoRequest.Height;}}++ /// <summary>+ /// Predicts the audio sample rate that will be in the output stream+ /// </summary>+ public int? TargetVideoBitDepth+ {+ get+ {+ var stream = VideoStream;+ return stream == null || !Request.Static ? null : stream.BitDepth;+ }+ }++ /// <summary>+ /// Predicts the audio sample rate that will be in the output stream+ /// </summary>+ public double? TargetFramerate+ {+ get+ {+ var stream = VideoStream;+ var requestedFramerate = VideoRequest.MaxFramerate ?? VideoRequest.Framerate;++ return requestedFramerate.HasValue && !Request.Static+ ? requestedFramerate+ : stream == null ? null : stream.AverageFrameRate ?? stream.RealFrameRate;+ }+ }++ /// <summary>+ /// Predicts the audio sample rate that will be in the output stream+ /// </summary>+ public double? TargetVideoLevel+ {+ get+ {+ var stream = VideoStream;+ return !string.IsNullOrEmpty(VideoRequest.Level) && !Request.Static+ ? double.Parse(VideoRequest.Level, CultureInfo.InvariantCulture)+ : stream == null ? null : stream.Level;+ }+ }++ public TransportStreamTimestamp TargetTimestamp+ {+ get+ {+ var stream = VideoStream;++ return !Request.Static+ ? TransportStreamTimestamp.VALID+ : stream == null ? TransportStreamTimestamp.VALID : stream.Timestamp;+ }+ }++ /// <summary>+ /// Predicts the audio sample rate that will be in the output stream+ /// </summary>+ public int? TargetPacketLength+ {+ get+ {+ var stream = VideoStream;+ return !Request.Static+ ? null+ : stream == null ? null : stream.PacketLength;+ }+ }++ /// <summary>+ /// Predicts the audio sample rate that will be in the output stream+ /// </summary>+ public string TargetVideoProfile+ {+ get+ {+ var stream = VideoStream;+ return !string.IsNullOrEmpty(VideoRequest.Profile) && !Request.Static+ ? VideoRequest.Profile+ : stream == null ? null : stream.Profile;+ }+ }+}}diff --git a/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs b/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.csindex 6ef22ef5b8..521bf7a817 100644--- a/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs+++ b/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs@@ -195,6 +195,8 @@ namespace MediaBrowser.Controller.MediaEncodingstream.AverageFrameRate = GetFrameRate(streamInfo.avg_frame_rate);stream.RealFrameRate = GetFrameRate(streamInfo.r_frame_rate);++ stream.BitDepth = GetBitDepth(stream.PixelFormat);}else{@@ -232,6 +234,34 @@ namespace MediaBrowser.Controller.MediaEncodingreturn stream;}+ private static int? GetBitDepth(string pixelFormat)+ {+ var eightBit = new List<string>+ {+ "yuv420p",+ "yuv411p",+ "yuvj420p",+ "uyyvyy411",+ "nv12",+ "nv21",+ "rgb444le",+ "rgb444be",+ "bgr444le",+ "bgr444be",+ "yuvj411p"+ };++ if (!string.IsNullOrEmpty(pixelFormat))+ {+ if (eightBit.Contains(pixelFormat, StringComparer.OrdinalIgnoreCase))+ {+ return 8;+ }+ }++ return null;+ }+/// <summary>/// Gets a string from an FFProbeResult tags dictionary/// </summary>diff --git a/MediaBrowser.Dlna/Didl/DidlBuilder.cs b/MediaBrowser.Dlna/Didl/DidlBuilder.csindex 27aae7d9c1..4209e0f156 100644--- a/MediaBrowser.Dlna/Didl/DidlBuilder.cs+++ b/MediaBrowser.Dlna/Didl/DidlBuilder.cs@@ -9,7 +9,6 @@ using MediaBrowser.Model.Dlna;using MediaBrowser.Model.Drawing;using MediaBrowser.Model.Entities;using System;-using System.Collections.Generic;using System.Globalization;using System.Linq;using System.Xml;@@ -47,6 +46,12 @@ namespace MediaBrowser.Dlna.Didldidl.SetAttribute("xmlns:dlna", NS_DLNA);didl.SetAttribute("xmlns:upnp", NS_UPNP);//didl.SetAttribute("xmlns:sec", NS_SEC);++ foreach (var att in _profile.ContentDirectoryRootAttributes)+ {+ didl.SetAttribute(att.Name, att.Value);+ }+result.AppendChild(didl);result.DocumentElement.AppendChild(GetItemElement(result, item, deviceId, filter));@@ -130,7 +135,7 @@ namespace MediaBrowser.Dlna.Didl}}- var totalBitrate = streamInfo.TotalOutputBitrate;+ var totalBitrate = streamInfo.TargetTotalBitrate;var targetSampleRate = streamInfo.TargetAudioSampleRate;var targetChannels = streamInfo.TargetAudioChannels;@@ -162,7 +167,18 @@ namespace MediaBrowser.Dlna.Didlvar mediaProfile = _profile.GetVideoMediaProfile(streamInfo.Container,streamInfo.AudioCodec,- streamInfo.VideoCodec);+ streamInfo.VideoCodec,+ streamInfo.TargetAudioBitrate,+ targetChannels,+ targetWidth,+ targetHeight,+ streamInfo.TargetVideoBitDepth,+ streamInfo.TargetVideoBitrate,+ streamInfo.TargetVideoProfile,+ streamInfo.TargetVideoLevel,+ streamInfo.TargetFramerate,+ streamInfo.TargetPacketLength,+ streamInfo.TargetTimestamp);var filename = url.Substring(0, url.IndexOf('?'));@@ -175,10 +191,17 @@ namespace MediaBrowser.Dlna.DidlstreamInfo.AudioCodec,targetWidth,targetHeight,- totalBitrate,+ streamInfo.TargetVideoBitDepth,+ streamInfo.TargetVideoBitrate,+ streamInfo.TargetAudioChannels,+ streamInfo.TargetAudioBitrate,streamInfo.TargetTimestamp,streamInfo.IsDirectStream,streamInfo.RunTimeTicks,+ streamInfo.TargetVideoProfile,+ streamInfo.TargetVideoLevel,+ streamInfo.TargetFramerate,+ streamInfo.TargetPacketLength,streamInfo.TranscodeSeekInfo);res.SetAttribute("protocolInfo", String.Format(@@ -248,7 +271,9 @@ namespace MediaBrowser.Dlna.Didl}var mediaProfile = _profile.GetAudioMediaProfile(streamInfo.Container,- streamInfo.AudioCodec);+ streamInfo.AudioCodec,+ targetChannels,+ targetAudioBitrate);var filename = url.Substring(0, url.IndexOf('?'));@@ -541,15 +566,12 @@ namespace MediaBrowser.Dlna.Didlvar width = albumartUrlInfo.Width;var height = albumartUrlInfo.Height;- var mediaProfile = new MediaFormatProfileResolver().ResolveImageFormat("jpg", width, height);-- var orgPn = mediaProfile.HasValue ? "DLNA.ORG_PN=:" + mediaProfile.Value + ";" : string.Empty;+ var contentFeatures = new ContentFeatureBuilder(_profile).BuildImageHeader("jpg", width, height);- res.SetAttribute("protocolInfo", string.Format(- "http-get:*:{1}:{0}DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS={2}",- orgPn,+ res.SetAttribute("protocolInfo", String.Format(+ "http-get:*:{0}:{1}","image/jpeg",- DlnaMaps.DefaultStreaming+ contentFeatures));if (width.HasValue && height.HasValue)diff --git a/MediaBrowser.Dlna/PlayTo/DlnaController.cs b/MediaBrowser.Dlna/PlayTo/DlnaController.csindex 28fc4474e9..6b6152d85a 100644--- a/MediaBrowser.Dlna/PlayTo/DlnaController.cs+++ b/MediaBrowser.Dlna/PlayTo/DlnaController.cs@@ -428,10 +428,17 @@ namespace MediaBrowser.Dlna.PlayTostreamInfo.AudioCodec,streamInfo.TargetWidth,streamInfo.TargetHeight,- streamInfo.TotalOutputBitrate,+ streamInfo.TargetVideoBitDepth,+ streamInfo.TargetVideoBitrate,+ streamInfo.TargetAudioChannels,+ streamInfo.TargetAudioBitrate,streamInfo.TargetTimestamp,streamInfo.IsDirectStream,streamInfo.RunTimeTicks,+ streamInfo.TargetVideoProfile,+ streamInfo.TargetVideoLevel,+ streamInfo.TargetFramerate,+ streamInfo.TargetPacketLength,streamInfo.TranscodeSeekInfo);}diff --git a/MediaBrowser.Dlna/Profiles/PanasonicVieraProfile.cs b/MediaBrowser.Dlna/Profiles/PanasonicVieraProfile.csindex 178207fc6a..2968bcd5fa 100644--- a/MediaBrowser.Dlna/Profiles/PanasonicVieraProfile.cs+++ b/MediaBrowser.Dlna/Profiles/PanasonicVieraProfile.cs@@ -1,6 +1,5 @@-using System.Xml.Serialization;-using MediaBrowser.Controller.Dlna;-using MediaBrowser.Model.Dlna;+using MediaBrowser.Model.Dlna;+using System.Xml.Serialization;namespace MediaBrowser.Dlna.Profiles{@@ -27,6 +26,15 @@ namespace MediaBrowser.Dlna.Profiles}};+ ContentDirectoryRootAttributes = new[]+ {+ new XmlAttribute+ {+ Name = "xmlns:pv",+ Value = "http://www.pv.com/pvns/"+ }+ };+TimelineOffsetSeconds = 10;TranscodingProfiles = new[]diff --git a/MediaBrowser.Dlna/Profiles/SamsungSmartTvProfile.cs b/MediaBrowser.Dlna/Profiles/SamsungSmartTvProfile.csindex 9b113b6c66..69203f3425 100644--- a/MediaBrowser.Dlna/Profiles/SamsungSmartTvProfile.cs+++ b/MediaBrowser.Dlna/Profiles/SamsungSmartTvProfile.cs@@ -17,6 +17,15 @@ namespace MediaBrowser.Dlna.ProfilesModelUrl = "samsung.com"};+ ContentDirectoryRootAttributes = new[]+ {+ new XmlAttribute+ {+ Name = "xmlns:sec",+ Value = "http://www.sec.co.kr/"+ }+ };+TranscodingProfiles = new[]{new TranscodingProfilediff --git a/MediaBrowser.Dlna/Profiles/SonyBlurayPlayer2013Profile.cs b/MediaBrowser.Dlna/Profiles/SonyBlurayPlayer2013Profile.csindex 833f623bf4..bc6ac98ca5 100644--- a/MediaBrowser.Dlna/Profiles/SonyBlurayPlayer2013Profile.cs+++ b/MediaBrowser.Dlna/Profiles/SonyBlurayPlayer2013Profile.cs@@ -18,6 +18,15 @@ namespace MediaBrowser.Dlna.ProfilesModelNumber = "BDP-2013"};+ ContentDirectoryRootAttributes = new[]+ {+ new XmlAttribute+ {+ Name = "xmlns:av",+ Value = "urn:schemas-sony-com:av"+ }+ };+ModelName = "Windows Media Player Sharing";ModelNumber = "3.0";Manufacturer = "Microsoft Corporation";diff --git a/MediaBrowser.Dlna/Profiles/SonyBlurayPlayerProfile.cs b/MediaBrowser.Dlna/Profiles/SonyBlurayPlayerProfile.csindex 970c57319a..bb5a109da2 100644--- a/MediaBrowser.Dlna/Profiles/SonyBlurayPlayerProfile.cs+++ b/MediaBrowser.Dlna/Profiles/SonyBlurayPlayerProfile.cs@@ -33,6 +33,15 @@ namespace MediaBrowser.Dlna.Profiles}};+ ContentDirectoryRootAttributes = new[]+ {+ new XmlAttribute+ {+ Name = "xmlns:av",+ Value = "urn:schemas-sony-com:av"+ }+ };+ModelName = "Windows Media Player Sharing";ModelNumber = "3.0";Manufacturer = "Microsoft Corporation";diff --git a/MediaBrowser.Dlna/Profiles/SonyBravia2010Profile.cs b/MediaBrowser.Dlna/Profiles/SonyBravia2010Profile.csindex 6639e18763..d3c0ae7a78 100644--- a/MediaBrowser.Dlna/Profiles/SonyBravia2010Profile.cs+++ b/MediaBrowser.Dlna/Profiles/SonyBravia2010Profile.cs@@ -27,6 +27,15 @@ namespace MediaBrowser.Dlna.Profiles}};+ ContentDirectoryRootAttributes = new[]+ {+ new XmlAttribute+ {+ Name = "xmlns:av",+ Value = "urn:schemas-sony-com:av"+ }+ };+ModelName = "Windows Media Player Sharing";ModelNumber = "3.0";ModelUrl = "http://www.microsoft.com/";@@ -99,7 +108,23 @@ namespace MediaBrowser.Dlna.ProfilesAudioCodec="ac3,aac,mp3",MimeType = "video/vnd.dlna.mpeg-tts",OrgPn="AVC_TS_HD_24_AC3_T,AVC_TS_HD_50_AC3_T,AVC_TS_HD_60_AC3_T,AVC_TS_HD_EU_T",- Type = DlnaProfileType.Video+ Type = DlnaProfileType.Video,++ Conditions = new []+ {+ new ProfileCondition+ {+ Condition = ProfileConditionType.Equals,+ Property = ProfileConditionValue.PacketLength,+ Value = "192"+ },+ new ProfileCondition+ {+ Condition = ProfileConditionType.Equals,+ Property = ProfileConditionValue.VideoTimestamp,+ Value = "Valid"+ }+ }},new ResponseProfile@@ -109,7 +134,17 @@ namespace MediaBrowser.Dlna.ProfilesAudioCodec="ac3,aac,mp3",MimeType = "video/mpeg",OrgPn="AVC_TS_HD_24_AC3_ISO,AVC_TS_HD_50_AC3_ISO,AVC_TS_HD_60_AC3_ISO,AVC_TS_HD_EU_ISO",- Type = DlnaProfileType.Video+ Type = DlnaProfileType.Video,++ Conditions = new []+ {+ new ProfileCondition+ {+ Condition = ProfileConditionType.Equals,+ Property = ProfileConditionValue.PacketLength,+ Value = "188"+ }+ }},new ResponseProfilediff --git a/MediaBrowser.Dlna/Profiles/SonyBravia2011Profile.cs b/MediaBrowser.Dlna/Profiles/SonyBravia2011Profile.csindex 8665b892ab..65a3cdb0dc 100644--- a/MediaBrowser.Dlna/Profiles/SonyBravia2011Profile.cs+++ b/MediaBrowser.Dlna/Profiles/SonyBravia2011Profile.cs@@ -1,6 +1,5 @@-using System.Xml.Serialization;-using MediaBrowser.Controller.Dlna;-using MediaBrowser.Model.Dlna;+using MediaBrowser.Model.Dlna;+using System.Xml.Serialization;namespace MediaBrowser.Dlna.Profiles{@@ -27,6 +26,15 @@ namespace MediaBrowser.Dlna.Profiles}};+ ContentDirectoryRootAttributes = new[]+ {+ new XmlAttribute+ {+ Name = "xmlns:av",+ Value = "urn:schemas-sony-com:av"+ }+ };+ModelName = "Windows Media Player Sharing";ModelNumber = "3.0";ModelUrl = "http://www.microsoft.com/";@@ -141,7 +149,23 @@ namespace MediaBrowser.Dlna.ProfilesAudioCodec="ac3,aac,mp3",MimeType = "video/vnd.dlna.mpeg-tts",OrgPn="AVC_TS_HD_24_AC3_T,AVC_TS_HD_50_AC3_T,AVC_TS_HD_60_AC3_T,AVC_TS_HD_EU_T",- Type = DlnaProfileType.Video+ Type = DlnaProfileType.Video,++ Conditions = new []+ {+ new ProfileCondition+ {+ Condition = ProfileConditionType.Equals,+ Property = ProfileConditionValue.PacketLength,+ Value = "192"+ },+ new ProfileCondition+ {+ Condition = ProfileConditionType.Equals,+ Property = ProfileConditionValue.VideoTimestamp,+ Value = "Valid"+ }+ }},new ResponseProfile@@ -151,7 +175,17 @@ namespace MediaBrowser.Dlna.ProfilesAudioCodec="ac3,aac,mp3",MimeType = "video/mpeg",OrgPn="AVC_TS_HD_24_AC3_ISO,AVC_TS_HD_50_AC3_ISO,AVC_TS_HD_60_AC3_ISO,AVC_TS_HD_EU_ISO",- Type = DlnaProfileType.Video+ Type = DlnaProfileType.Video,++ Conditions = new []+ {+ new ProfileCondition+ {+ Condition = ProfileConditionType.Equals,+ Property = ProfileConditionValue.PacketLength,+ Value = "188"+ }+ }},new ResponseProfilediff --git a/MediaBrowser.Dlna/Profiles/SonyBravia2012Profile.cs b/MediaBrowser.Dlna/Profiles/SonyBravia2012Profile.csindex 5becc6752a..5a818d0adc 100644--- a/MediaBrowser.Dlna/Profiles/SonyBravia2012Profile.cs+++ b/MediaBrowser.Dlna/Profiles/SonyBravia2012Profile.cs@@ -27,6 +27,15 @@ namespace MediaBrowser.Dlna.Profiles}};+ ContentDirectoryRootAttributes = new[]+ {+ new XmlAttribute+ {+ Name = "xmlns:av",+ Value = "urn:schemas-sony-com:av"+ }+ };+ModelName = "Windows Media Player Sharing";ModelNumber = "3.0";ModelUrl = "http://www.microsoft.com/";@@ -129,7 +138,23 @@ namespace MediaBrowser.Dlna.ProfilesAudioCodec="ac3,aac,mp3",MimeType = "video/vnd.dlna.mpeg-tts",OrgPn="AVC_TS_HD_24_AC3_T,AVC_TS_HD_50_AC3_T,AVC_TS_HD_60_AC3_T,AVC_TS_HD_EU_T",- Type = DlnaProfileType.Video+ Type = DlnaProfileType.Video,++ Conditions = new []+ {+ new ProfileCondition+ {+ Condition = ProfileConditionType.Equals,+ Property = ProfileConditionValue.PacketLength,+ Value = "192"+ },+ new ProfileCondition+ {+ Condition = ProfileConditionType.Equals,+ Property = ProfileConditionValue.VideoTimestamp,+ Value = "Valid"+ }+ }},new ResponseProfile@@ -139,7 +164,17 @@ namespace MediaBrowser.Dlna.ProfilesAudioCodec="ac3,aac,mp3",MimeType = "video/mpeg",OrgPn="AVC_TS_HD_24_AC3_ISO,AVC_TS_HD_50_AC3_ISO,AVC_TS_HD_60_AC3_ISO,AVC_TS_HD_EU_ISO",- Type = DlnaProfileType.Video+ Type = DlnaProfileType.Video,++ Conditions = new []+ {+ new ProfileCondition+ {+ Condition = ProfileConditionType.Equals,+ Property = ProfileConditionValue.PacketLength,+ Value = "188"+ }+ }},new ResponseProfilediff --git a/MediaBrowser.Dlna/Profiles/SonyBravia2013Profile.cs b/MediaBrowser.Dlna/Profiles/SonyBravia2013Profile.csindex 51ded765eb..5923bce4cf 100644--- a/MediaBrowser.Dlna/Profiles/SonyBravia2013Profile.cs+++ b/MediaBrowser.Dlna/Profiles/SonyBravia2013Profile.cs@@ -26,6 +26,15 @@ namespace MediaBrowser.Dlna.Profiles}};+ ContentDirectoryRootAttributes = new[]+ {+ new XmlAttribute+ {+ Name = "xmlns:av",+ Value = "urn:schemas-sony-com:av"+ }+ };+ModelName = "Windows Media Player Sharing";ModelNumber = "3.0";ModelUrl = "http://www.microsoft.com/";@@ -184,7 +193,23 @@ namespace MediaBrowser.Dlna.ProfilesAudioCodec="ac3,aac,mp3",MimeType = "video/vnd.dlna.mpeg-tts",OrgPn="AVC_TS_HD_24_AC3_T,AVC_TS_HD_50_AC3_T,AVC_TS_HD_60_AC3_T,AVC_TS_HD_EU_T",- Type = DlnaProfileType.Video+ Type = DlnaProfileType.Video,++ Conditions = new []+ {+ new ProfileCondition+ {+ Condition = ProfileConditionType.Equals,+ Property = ProfileConditionValue.PacketLength,+ Value = "192"+ },+ new ProfileCondition+ {+ Condition = ProfileConditionType.Equals,+ Property = ProfileConditionValue.VideoTimestamp,+ Value = "Valid"+ }+ }},new ResponseProfile@@ -194,7 +219,17 @@ namespace MediaBrowser.Dlna.ProfilesAudioCodec="ac3,aac,mp3",MimeType = "video/mpeg",OrgPn="AVC_TS_HD_24_AC3_ISO,AVC_TS_HD_50_AC3_ISO,AVC_TS_HD_60_AC3_ISO,AVC_TS_HD_EU_ISO",- Type = DlnaProfileType.Video+ Type = DlnaProfileType.Video,++ Conditions = new []+ {+ new ProfileCondition+ {+ Condition = ProfileConditionType.Equals,+ Property = ProfileConditionValue.PacketLength,+ Value = "188"+ }+ }},new ResponseProfilediff --git a/MediaBrowser.Dlna/Profiles/Xml/Default.xml b/MediaBrowser.Dlna/Profiles/Xml/Default.xmlindex dcc8ede744..e9b920d171 100644--- a/MediaBrowser.Dlna/Profiles/Xml/Default.xml+++ b/MediaBrowser.Dlna/Profiles/Xml/Default.xml@@ -22,6 +22,7 @@<TimelineOffsetSeconds>0</TimelineOffsetSeconds><RequiresPlainVideoItems>false</RequiresPlainVideoItems><RequiresPlainFolders>false</RequiresPlainFolders>+ <ContentDirectoryRootAttributes /><DirectPlayProfiles><DirectPlayProfile container="mp3,wma" type="Audio" /><DirectPlayProfile container="avi,mp4" type="Video" />diff --git a/MediaBrowser.Dlna/Profiles/Xml/Denon AVR.xml b/MediaBrowser.Dlna/Profiles/Xml/Denon AVR.xmlindex 3b7f3f74d4..7ee3abdde1 100644--- a/MediaBrowser.Dlna/Profiles/Xml/Denon AVR.xml+++ b/MediaBrowser.Dlna/Profiles/Xml/Denon AVR.xml@@ -27,6 +27,7 @@<TimelineOffsetSeconds>0</TimelineOffsetSeconds><RequiresPlainVideoItems>false</RequiresPlainVideoItems><RequiresPlainFolders>false</RequiresPlainFolders>+ <ContentDirectoryRootAttributes /><DirectPlayProfiles><DirectPlayProfile container="mp3,flac,m4a,wma" type="Audio" /></DirectPlayProfiles>diff --git a/MediaBrowser.Dlna/Profiles/Xml/LG Smart TV.xml b/MediaBrowser.Dlna/Profiles/Xml/LG Smart TV.xmlindex 92a107c6e4..aec6d2cc1b 100644--- a/MediaBrowser.Dlna/Profiles/Xml/LG Smart TV.xml+++ b/MediaBrowser.Dlna/Profiles/Xml/LG Smart TV.xml@@ -28,6 +28,7 @@<TimelineOffsetSeconds>10</TimelineOffsetSeconds><RequiresPlainVideoItems>false</RequiresPlainVideoItems><RequiresPlainFolders>false</RequiresPlainFolders>+ <ContentDirectoryRootAttributes /><DirectPlayProfiles><DirectPlayProfile container="ts" audioCodec="aac,ac3,mp3" videoCodec="h264" type="Video" /><DirectPlayProfile container="mkv" audioCodec="aac,ac3,mp3" videoCodec="h264" type="Video" />diff --git a/MediaBrowser.Dlna/Profiles/Xml/Linksys DMA2100.xml b/MediaBrowser.Dlna/Profiles/Xml/Linksys DMA2100.xmlindex 00d3d3a09e..a0a4f502cf 100644--- a/MediaBrowser.Dlna/Profiles/Xml/Linksys DMA2100.xml+++ b/MediaBrowser.Dlna/Profiles/Xml/Linksys DMA2100.xml@@ -26,6 +26,7 @@<TimelineOffsetSeconds>0</TimelineOffsetSeconds><RequiresPlainVideoItems>false</RequiresPlainVideoItems><RequiresPlainFolders>false</RequiresPlainFolders>+ <ContentDirectoryRootAttributes /><DirectPlayProfiles><DirectPlayProfile container="mp3,flac,m4a,wma" type="Audio" /><DirectPlayProfile container="avi,mp4,mkv,ts" type="Video" />diff --git a/MediaBrowser.Dlna/Profiles/Xml/Panasonic Viera.xml b/MediaBrowser.Dlna/Profiles/Xml/Panasonic Viera.xmlindex dfb95c036a..4f8ae88e35 100644--- a/MediaBrowser.Dlna/Profiles/Xml/Panasonic Viera.xml+++ b/MediaBrowser.Dlna/Profiles/Xml/Panasonic Viera.xml@@ -29,6 +29,9 @@<TimelineOffsetSeconds>10</TimelineOffsetSeconds><RequiresPlainVideoItems>false</RequiresPlainVideoItems><RequiresPlainFolders>false</RequiresPlainFolders>+ <ContentDirectoryRootAttributes>+ <XmlAttribute name="xmlns:pv" value="http://www.pv.com/pvns/" />+ </ContentDirectoryRootAttributes><DirectPlayProfiles><DirectPlayProfile container="mpeg" audioCodec="ac3,mp3" videoCodec="mpeg2video,mpeg4" type="Video" /><DirectPlayProfile container="mkv" audioCodec="aac,ac3,mp3,pcm" videoCodec="h264" type="Video" />diff --git a/MediaBrowser.Dlna/Profiles/Xml/Samsung Smart TV.xml b/MediaBrowser.Dlna/Profiles/Xml/Samsung Smart TV.xmlindex 4e0f5e623c..1371710cc7 100644--- a/MediaBrowser.Dlna/Profiles/Xml/Samsung Smart TV.xml+++ b/MediaBrowser.Dlna/Profiles/Xml/Samsung Smart TV.xml@@ -26,6 +26,9 @@<TimelineOffsetSeconds>0</TimelineOffsetSeconds><RequiresPlainVideoItems>false</RequiresPlainVideoItems><RequiresPlainFolders>false</RequiresPlainFolders>+ <ContentDirectoryRootAttributes>+ <XmlAttribute name="xmlns:sec" value="http://www.sec.co.kr/" />+ </ContentDirectoryRootAttributes><DirectPlayProfiles><DirectPlayProfile container="asf" audioCodec="mp3,ac3,wmav2,wmapro,wmavoice" videoCodec="h264,mpeg4,mjpeg" type="Video" /><DirectPlayProfile container="avi" audioCodec="mp3,ac3,dca" videoCodec="h264,mpeg4,mjpeg" type="Video" />diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player 2013.xml b/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player 2013.xmlindex c9463225c4..86ced11506 100644--- a/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player 2013.xml+++ b/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player 2013.xml@@ -28,6 +28,9 @@<TimelineOffsetSeconds>0</TimelineOffsetSeconds><RequiresPlainVideoItems>false</RequiresPlainVideoItems><RequiresPlainFolders>false</RequiresPlainFolders>+ <ContentDirectoryRootAttributes>+ <XmlAttribute name="xmlns:av" value="urn:schemas-sony-com:av" />+ </ContentDirectoryRootAttributes><DirectPlayProfiles><DirectPlayProfile container="ts" audioCodec="ac3,aac,mp3,pcm" videoCodec="mpeg1video,mpeg2video,h264" type="Video" /><DirectPlayProfile container="mpeg" audioCodec="ac3,mp3,mp2,pcm" videoCodec="mpeg1video,mpeg2video" type="Video" />diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player.xml b/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player.xmlindex 1805d81b44..22b3b2ce50 100644--- a/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player.xml+++ b/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player.xml@@ -30,6 +30,9 @@<TimelineOffsetSeconds>0</TimelineOffsetSeconds><RequiresPlainVideoItems>false</RequiresPlainVideoItems><RequiresPlainFolders>false</RequiresPlainFolders>+ <ContentDirectoryRootAttributes>+ <XmlAttribute name="xmlns:av" value="urn:schemas-sony-com:av" />+ </ContentDirectoryRootAttributes><DirectPlayProfiles><DirectPlayProfile container="ts" audioCodec="ac3,aac,mp3,pcm" videoCodec="mpeg1video,mpeg2video,h264" type="Video" /><DirectPlayProfile container="mpeg" audioCodec="ac3,mp3,pcm" videoCodec="mpeg1video,mpeg2video" type="Video" />diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2010).xml b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2010).xmlindex 42b866bd32..40605bc4e2 100644--- a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2010).xml+++ b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2010).xml@@ -30,6 +30,9 @@<TimelineOffsetSeconds>0</TimelineOffsetSeconds><RequiresPlainVideoItems>false</RequiresPlainVideoItems><RequiresPlainFolders>false</RequiresPlainFolders>+ <ContentDirectoryRootAttributes>+ <XmlAttribute name="xmlns:av" value="urn:schemas-sony-com:av" />+ </ContentDirectoryRootAttributes><DirectPlayProfiles><DirectPlayProfile container="ts" audioCodec="ac3,aac,mp3" videoCodec="h264" type="Video" /><DirectPlayProfile container="ts" audioCodec="mp3,mp2" videoCodec="mpeg1video,mpeg2video" type="Video" />@@ -83,10 +86,15 @@</CodecProfiles><ResponseProfiles><ResponseProfile container="ts" audioCodec="ac3,aac,mp3" videoCodec="h264" type="Video" orgPn="AVC_TS_HD_24_AC3_T,AVC_TS_HD_50_AC3_T,AVC_TS_HD_60_AC3_T,AVC_TS_HD_EU_T" mimeType="video/vnd.dlna.mpeg-tts">- <Conditions />+ <Conditions>+ <ProfileCondition condition="Equals" property="PacketLength" value="192" isRequired="true" />+ <ProfileCondition condition="Equals" property="VideoTimestamp" value="Valid" isRequired="true" />+ </Conditions></ResponseProfile><ResponseProfile container="ts" audioCodec="ac3,aac,mp3" videoCodec="h264" type="Video" orgPn="AVC_TS_HD_24_AC3_ISO,AVC_TS_HD_50_AC3_ISO,AVC_TS_HD_60_AC3_ISO,AVC_TS_HD_EU_ISO" mimeType="video/mpeg">- <Conditions />+ <Conditions>+ <ProfileCondition condition="Equals" property="PacketLength" value="188" isRequired="true" />+ </Conditions></ResponseProfile><ResponseProfile container="ts" audioCodec="ac3,aac,mp3" videoCodec="h264" type="Video" orgPn="AVC_TS_HD_24_AC3,AVC_TS_HD_50_AC3,AVC_TS_HD_60_AC3,AVC_TS_HD_EU" mimeType="video/vnd.dlna.mpeg-tts"><Conditions />diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2011).xml b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2011).xmlindex 073996ccbf..561bd2c00e 100644--- a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2011).xml+++ b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2011).xml@@ -30,6 +30,9 @@<TimelineOffsetSeconds>0</TimelineOffsetSeconds><RequiresPlainVideoItems>false</RequiresPlainVideoItems><RequiresPlainFolders>false</RequiresPlainFolders>+ <ContentDirectoryRootAttributes>+ <XmlAttribute name="xmlns:av" value="urn:schemas-sony-com:av" />+ </ContentDirectoryRootAttributes><DirectPlayProfiles><DirectPlayProfile container="ts" audioCodec="ac3,aac,mp3" videoCodec="h264" type="Video" /><DirectPlayProfile container="ts" audioCodec="mp3,mp2" videoCodec="mpeg2video" type="Video" />@@ -86,10 +89,15 @@</CodecProfiles><ResponseProfiles><ResponseProfile container="ts" audioCodec="ac3,aac,mp3" videoCodec="h264" type="Video" orgPn="AVC_TS_HD_24_AC3_T,AVC_TS_HD_50_AC3_T,AVC_TS_HD_60_AC3_T,AVC_TS_HD_EU_T" mimeType="video/vnd.dlna.mpeg-tts">- <Conditions />+ <Conditions>+ <ProfileCondition condition="Equals" property="PacketLength" value="192" isRequired="true" />+ <ProfileCondition condition="Equals" property="VideoTimestamp" value="Valid" isRequired="true" />+ </Conditions></ResponseProfile><ResponseProfile container="ts" audioCodec="ac3,aac,mp3" videoCodec="h264" type="Video" orgPn="AVC_TS_HD_24_AC3_ISO,AVC_TS_HD_50_AC3_ISO,AVC_TS_HD_60_AC3_ISO,AVC_TS_HD_EU_ISO" mimeType="video/mpeg">- <Conditions />+ <Conditions>+ <ProfileCondition condition="Equals" property="PacketLength" value="188" isRequired="true" />+ </Conditions></ResponseProfile><ResponseProfile container="ts" audioCodec="ac3,aac,mp3" videoCodec="h264" type="Video" orgPn="AVC_TS_HD_24_AC3,AVC_TS_HD_50_AC3,AVC_TS_HD_60_AC3,AVC_TS_HD_EU" mimeType="video/vnd.dlna.mpeg-tts"><Conditions />diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2012).xml b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2012).xmlindex d1bf59991d..b62b60a66b 100644--- a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2012).xml+++ b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2012).xml@@ -30,6 +30,9 @@<TimelineOffsetSeconds>0</TimelineOffsetSeconds><RequiresPlainVideoItems>false</RequiresPlainVideoItems><RequiresPlainFolders>false</RequiresPlainFolders>+ <ContentDirectoryRootAttributes>+ <XmlAttribute name="xmlns:av" value="urn:schemas-sony-com:av" />+ </ContentDirectoryRootAttributes><DirectPlayProfiles><DirectPlayProfile container="ts" audioCodec="ac3,aac,mp3" videoCodec="h264" type="Video" /><DirectPlayProfile container="ts" audioCodec="mp3,mp2" videoCodec="mpeg2video" type="Video" />@@ -69,10 +72,15 @@</CodecProfiles><ResponseProfiles><ResponseProfile container="ts" audioCodec="ac3,aac,mp3" videoCodec="h264" type="Video" orgPn="AVC_TS_HD_24_AC3_T,AVC_TS_HD_50_AC3_T,AVC_TS_HD_60_AC3_T,AVC_TS_HD_EU_T" mimeType="video/vnd.dlna.mpeg-tts">- <Conditions />+ <Conditions>+ <ProfileCondition condition="Equals" property="PacketLength" value="192" isRequired="true" />+ <ProfileCondition condition="Equals" property="VideoTimestamp" value="Valid" isRequired="true" />+ </Conditions></ResponseProfile><ResponseProfile container="ts" audioCodec="ac3,aac,mp3" videoCodec="h264" type="Video" orgPn="AVC_TS_HD_24_AC3_ISO,AVC_TS_HD_50_AC3_ISO,AVC_TS_HD_60_AC3_ISO,AVC_TS_HD_EU_ISO" mimeType="video/mpeg">- <Conditions />+ <Conditions>+ <ProfileCondition condition="Equals" property="PacketLength" value="188" isRequired="true" />+ </Conditions></ResponseProfile><ResponseProfile container="ts" audioCodec="ac3,aac,mp3" videoCodec="h264" type="Video" orgPn="AVC_TS_HD_24_AC3,AVC_TS_HD_50_AC3,AVC_TS_HD_60_AC3,AVC_TS_HD_EU" mimeType="video/vnd.dlna.mpeg-tts"><Conditions />diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2013).xml b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2013).xmlindex 4dc1d9a741..ea78552c68 100644--- a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2013).xml+++ b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2013).xml@@ -30,6 +30,9 @@<TimelineOffsetSeconds>0</TimelineOffsetSeconds><RequiresPlainVideoItems>false</RequiresPlainVideoItems><RequiresPlainFolders>false</RequiresPlainFolders>+ <ContentDirectoryRootAttributes>+ <XmlAttribute name="xmlns:av" value="urn:schemas-sony-com:av" />+ </ContentDirectoryRootAttributes><DirectPlayProfiles><DirectPlayProfile container="ts" audioCodec="ac3,eac3,aac,mp3" videoCodec="h264" type="Video" /><DirectPlayProfile container="ts" audioCodec="mp3,mp2" videoCodec="mpeg2video" type="Video" />@@ -69,10 +72,15 @@</CodecProfiles><ResponseProfiles><ResponseProfile container="ts" audioCodec="ac3,aac,mp3" videoCodec="h264" type="Video" orgPn="AVC_TS_HD_24_AC3_T,AVC_TS_HD_50_AC3_T,AVC_TS_HD_60_AC3_T,AVC_TS_HD_EU_T" mimeType="video/vnd.dlna.mpeg-tts">- <Conditions />+ <Conditions>+ <ProfileCondition condition="Equals" property="PacketLength" value="192" isRequired="true" />+ <ProfileCondition condition="Equals" property="VideoTimestamp" value="Valid" isRequired="true" />+ </Conditions></ResponseProfile><ResponseProfile container="ts" audioCodec="ac3,aac,mp3" videoCodec="h264" type="Video" orgPn="AVC_TS_HD_24_AC3_ISO,AVC_TS_HD_50_AC3_ISO,AVC_TS_HD_60_AC3_ISO,AVC_TS_HD_EU_ISO" mimeType="video/mpeg">- <Conditions />+ <Conditions>+ <ProfileCondition condition="Equals" property="PacketLength" value="188" isRequired="true" />+ </Conditions></ResponseProfile><ResponseProfile container="ts" audioCodec="ac3,aac,mp3" videoCodec="h264" type="Video" orgPn="AVC_TS_HD_24_AC3,AVC_TS_HD_50_AC3,AVC_TS_HD_60_AC3,AVC_TS_HD_EU" mimeType="video/vnd.dlna.mpeg-tts"><Conditions />diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony PlayStation 3.xml b/MediaBrowser.Dlna/Profiles/Xml/Sony PlayStation 3.xmlindex fed31fec0e..f27f5aa4a6 100644--- a/MediaBrowser.Dlna/Profiles/Xml/Sony PlayStation 3.xml+++ b/MediaBrowser.Dlna/Profiles/Xml/Sony PlayStation 3.xml@@ -30,6 +30,7 @@<TimelineOffsetSeconds>0</TimelineOffsetSeconds><RequiresPlainVideoItems>false</RequiresPlainVideoItems><RequiresPlainFolders>false</RequiresPlainFolders>+ <ContentDirectoryRootAttributes /><DirectPlayProfiles><DirectPlayProfile container="mp3,wma" type="Audio" /><DirectPlayProfile container="avi,mp4" type="Video" />diff --git a/MediaBrowser.Dlna/Profiles/Xml/WDTV Live.xml b/MediaBrowser.Dlna/Profiles/Xml/WDTV Live.xmlindex 0936a6ced2..bee389b69f 100644--- a/MediaBrowser.Dlna/Profiles/Xml/WDTV Live.xml+++ b/MediaBrowser.Dlna/Profiles/Xml/WDTV Live.xml@@ -29,6 +29,7 @@<TimelineOffsetSeconds>5</TimelineOffsetSeconds><RequiresPlainVideoItems>false</RequiresPlainVideoItems><RequiresPlainFolders>false</RequiresPlainFolders>+ <ContentDirectoryRootAttributes /><DirectPlayProfiles><DirectPlayProfile container="avi" audioCodec="ac3,dca,mp2,mp3,pcm" videoCodec="mpeg1video,mpeg2video,mpeg4,h264,vc1" type="Video" /><DirectPlayProfile container="mpeg" audioCodec="ac3,dca,mp2,mp3,pcm" videoCodec="mpeg1video,mpeg2video" type="Video" />diff --git a/MediaBrowser.Dlna/Profiles/Xml/Xbox 360.xml b/MediaBrowser.Dlna/Profiles/Xml/Xbox 360.xmlindex cf12b26405..c72f404396 100644--- a/MediaBrowser.Dlna/Profiles/Xml/Xbox 360.xml+++ b/MediaBrowser.Dlna/Profiles/Xml/Xbox 360.xml@@ -29,6 +29,7 @@<TimelineOffsetSeconds>40</TimelineOffsetSeconds><RequiresPlainVideoItems>true</RequiresPlainVideoItems><RequiresPlainFolders>true</RequiresPlainFolders>+ <ContentDirectoryRootAttributes /><DirectPlayProfiles><DirectPlayProfile container="avi" audioCodec="ac3,mp3" videoCodec="mpeg4" type="Video" /><DirectPlayProfile container="avi" audioCodec="aac" videoCodec="h264" type="Video" />diff --git a/MediaBrowser.Dlna/Profiles/Xml/Xbox One.xml b/MediaBrowser.Dlna/Profiles/Xml/Xbox One.xmlindex a1d3ed428e..c2aae9ef4b 100644--- a/MediaBrowser.Dlna/Profiles/Xml/Xbox One.xml+++ b/MediaBrowser.Dlna/Profiles/Xml/Xbox One.xml@@ -27,6 +27,7 @@<TimelineOffsetSeconds>0</TimelineOffsetSeconds><RequiresPlainVideoItems>false</RequiresPlainVideoItems><RequiresPlainFolders>false</RequiresPlainFolders>+ <ContentDirectoryRootAttributes /><DirectPlayProfiles><DirectPlayProfile container="ts" audioCodec="ac3" videoCodec="h264" type="Video" /><DirectPlayProfile container="avi" audioCodec="ac3,mp3" videoCodec="mpeg4" type="Video" />diff --git a/MediaBrowser.Dlna/Profiles/Xml/foobar2000.xml b/MediaBrowser.Dlna/Profiles/Xml/foobar2000.xmlindex 2269af5d46..a80dff73e9 100644--- a/MediaBrowser.Dlna/Profiles/Xml/foobar2000.xml+++ b/MediaBrowser.Dlna/Profiles/Xml/foobar2000.xml@@ -28,6 +28,7 @@<TimelineOffsetSeconds>0</TimelineOffsetSeconds><RequiresPlainVideoItems>false</RequiresPlainVideoItems><RequiresPlainFolders>false</RequiresPlainFolders>+ <ContentDirectoryRootAttributes /><DirectPlayProfiles><DirectPlayProfile container="mp3,wma" type="Audio" /><DirectPlayProfile container="avi,mp4" type="Video" />diff --git a/MediaBrowser.Dlna/Server/ControlHandler.cs b/MediaBrowser.Dlna/Server/ControlHandler.csindex 734adf7952..b28ec010e8 100644--- a/MediaBrowser.Dlna/Server/ControlHandler.cs+++ b/MediaBrowser.Dlna/Server/ControlHandler.cs@@ -40,6 +40,8 @@ namespace MediaBrowser.Dlna.Serverprivate readonly DidlBuilder _didlBuilder;+ private readonly DeviceProfile _profile;+public ControlHandler(ILogger logger, ILibraryManager libraryManager, DeviceProfile profile, string serverAddress, IDtoService dtoService, IImageProcessor imageProcessor, IUserDataManager userDataManager, User user, int systemUpdateId){_logger = logger;@@ -47,6 +49,7 @@ namespace MediaBrowser.Dlna.Server_userDataManager = userDataManager;_user = user;_systemUpdateId = systemUpdateId;+ _profile = profile;_didlBuilder = new DidlBuilder(profile, imageProcessor, serverAddress, dtoService);}@@ -314,7 +317,6 @@ namespace MediaBrowser.Dlna.Server// sort example: dc:title, dc:date- var provided = 0;var requested = 0;var start = 0;@@ -334,7 +336,12 @@ namespace MediaBrowser.Dlna.Serverdidl.SetAttribute("xmlns:dc", NS_DC);didl.SetAttribute("xmlns:dlna", NS_DLNA);didl.SetAttribute("xmlns:upnp", NS_UPNP);- //didl.SetAttribute("xmlns:sec", NS_SEC);++ foreach (var att in _profile.ContentDirectoryRootAttributes)+ {+ didl.SetAttribute(att.Name, att.Value);+ }+result.AppendChild(didl);var folder = (Folder)GetItemFromObjectId(sparams["ContainerID"], user);@@ -352,7 +359,7 @@ namespace MediaBrowser.Dlna.Serverchildren = children.Take(requested).ToList();}- provided = children.Count;+ var provided = children.Count;foreach (var i in children){diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csprojindex fe2fe20917..56baaec0a6 100644--- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj+++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj@@ -104,6 +104,9 @@<Compile Include="..\MediaBrowser.Model\Dlna\CodecProfile.cs"><Link>Dlna\CodecProfile.cs</Link></Compile>+ <Compile Include="..\MediaBrowser.Model\Dlna\ConditionProcessor.cs">+ <Link>Dlna\ConditionProcessor.cs</Link>+ </Compile><Compile Include="..\MediaBrowser.Model\Dlna\ContainerProfile.cs"><Link>Dlna\ContainerProfile.cs</Link></Compile>diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csprojindex b833a19a70..37fb68ad6d 100644--- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj+++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj@@ -91,6 +91,9 @@<Compile Include="..\MediaBrowser.Model\Dlna\CodecProfile.cs"><Link>Dlna\CodecProfile.cs</Link></Compile>+ <Compile Include="..\MediaBrowser.Model\Dlna\ConditionProcessor.cs">+ <Link>Dlna\ConditionProcessor.cs</Link>+ </Compile><Compile Include="..\MediaBrowser.Model\Dlna\ContainerProfile.cs"><Link>Dlna\ContainerProfile.cs</Link></Compile>diff --git a/MediaBrowser.Model/Dlna/CodecProfile.cs b/MediaBrowser.Model/Dlna/CodecProfile.csindex b15dfc809e..2b04b7fdb7 100644--- a/MediaBrowser.Model/Dlna/CodecProfile.cs+++ b/MediaBrowser.Model/Dlna/CodecProfile.cs@@ -76,10 +76,12 @@ namespace MediaBrowser.Model.DlnaWidth,Height,Has64BitOffsets,+ PacketLength,VideoBitDepth,VideoBitrate,VideoFramerate,VideoLevel,- VideoProfile+ VideoProfile,+ VideoTimestamp}}diff --git a/MediaBrowser.Model/Dlna/ConditionProcessor.cs b/MediaBrowser.Model/Dlna/ConditionProcessor.csnew file mode 100644index 0000000000..292ca21487--- /dev/null+++ b/MediaBrowser.Model/Dlna/ConditionProcessor.cs@@ -0,0 +1,192 @@+using System;+using System.Globalization;++namespace MediaBrowser.Model.Dlna+{+ public class ConditionProcessor+ {+ public bool IsVideoConditionSatisfied(ProfileCondition condition,+ int? audioBitrate,+ int? audioChannels,+ int? width,+ int? height,+ int? bitDepth,+ int? videoBitrate,+ string videoProfile,+ double? videoLevel,+ double? videoFramerate,+ int? packetLength,+ TransportStreamTimestamp timestamp)+ {+ switch (condition.Property)+ {+ case ProfileConditionValue.AudioProfile:+ // TODO: Implement+ return true;+ case ProfileConditionValue.Has64BitOffsets:+ // TODO: Implement+ return true;+ case ProfileConditionValue.VideoFramerate:+ return IsConditionSatisfied(condition, videoFramerate);+ case ProfileConditionValue.VideoLevel:+ return IsConditionSatisfied(condition, videoLevel);+ case ProfileConditionValue.VideoProfile:+ return IsConditionSatisfied(condition, videoProfile);+ case ProfileConditionValue.PacketLength:+ return IsConditionSatisfied(condition, packetLength);+ case ProfileConditionValue.AudioBitrate:+ return IsConditionSatisfied(condition, audioBitrate);+ case ProfileConditionValue.AudioChannels:+ return IsConditionSatisfied(condition, audioChannels);+ case ProfileConditionValue.VideoBitDepth:+ return IsConditionSatisfied(condition, bitDepth);+ case ProfileConditionValue.VideoBitrate:+ return IsConditionSatisfied(condition, videoBitrate);+ case ProfileConditionValue.Height:+ return IsConditionSatisfied(condition, height);+ case ProfileConditionValue.Width:+ return IsConditionSatisfied(condition, width);+ case ProfileConditionValue.VideoTimestamp:+ return IsConditionSatisfied(condition, timestamp);+ default:+ throw new ArgumentException("Unexpected condition on video file: " + condition.Property);+ }+ }++ public bool IsImageConditionSatisfied(ProfileCondition condition, int? width, int? height)+ {+ switch (condition.Property)+ {+ case ProfileConditionValue.Height:+ return IsConditionSatisfied(condition, height);+ case ProfileConditionValue.Width:+ return IsConditionSatisfied(condition, width);+ default:+ throw new ArgumentException("Unexpected condition on image file: " + condition.Property);+ }+ }++ public bool IsAudioConditionSatisfied(ProfileCondition condition, int? audioChannels, int? audioBitrate)+ {+ switch (condition.Property)+ {+ case ProfileConditionValue.AudioBitrate:+ return IsConditionSatisfied(condition, audioBitrate);+ case ProfileConditionValue.AudioChannels:+ return IsConditionSatisfied(condition, audioChannels);+ default:+ throw new ArgumentException("Unexpected condition on audio file: " + condition.Property);+ }+ }++ public bool IsVideoAudioConditionSatisfied(ProfileCondition condition,+ int? audioChannels,+ int? audioBitrate)+ {+ switch (condition.Property)+ {+ case ProfileConditionValue.AudioBitrate:+ return IsConditionSatisfied(condition, audioBitrate);+ case ProfileConditionValue.AudioChannels:+ return IsConditionSatisfied(condition, audioChannels);+ default:+ throw new ArgumentException("Unexpected condition on audio file: " + condition.Property);+ }+ }++ private static readonly CultureInfo UsCulture = new CultureInfo("en-US");+ private bool IsConditionSatisfied(ProfileCondition condition, int? currentValue)+ {+ if (!currentValue.HasValue)+ {+ // If the value is unknown, it satisfies if not marked as required+ return !condition.IsRequired;+ }++ int expected;+ if (int.TryParse(condition.Value, NumberStyles.Any, UsCulture, out expected))+ {+ switch (condition.Condition)+ {+ case ProfileConditionType.Equals:+ return currentValue.Value.Equals(expected);+ case ProfileConditionType.GreaterThanEqual:+ return currentValue.Value >= expected;+ case ProfileConditionType.LessThanEqual:+ return currentValue.Value <= expected;+ case ProfileConditionType.NotEquals:+ return !currentValue.Value.Equals(expected);+ default:+ throw new InvalidOperationException("Unexpected ProfileConditionType");+ }+ }++ return false;+ }++ private bool IsConditionSatisfied(ProfileCondition condition, string currentValue)+ {+ if (string.IsNullOrEmpty(currentValue))+ {+ // If the value is unknown, it satisfies if not marked as required+ return !condition.IsRequired;+ }++ var expected = condition.Value;++ switch (condition.Condition)+ {+ case ProfileConditionType.Equals:+ return string.Equals(currentValue, expected, StringComparison.OrdinalIgnoreCase);+ case ProfileConditionType.NotEquals:+ return !string.Equals(currentValue, expected, StringComparison.OrdinalIgnoreCase);+ default:+ throw new InvalidOperationException("Unexpected ProfileConditionType");+ }+ }++ private bool IsConditionSatisfied(ProfileCondition condition, double? currentValue)+ {+ if (!currentValue.HasValue)+ {+ // If the value is unknown, it satisfies if not marked as required+ return !condition.IsRequired;+ }++ double expected;+ if (double.TryParse(condition.Value, NumberStyles.Any, UsCulture, out expected))+ {+ switch (condition.Condition)+ {+ case ProfileConditionType.Equals:+ return currentValue.Value.Equals(expected);+ case ProfileConditionType.GreaterThanEqual:+ return currentValue.Value >= expected;+ case ProfileConditionType.LessThanEqual:+ return currentValue.Value <= expected;+ case ProfileConditionType.NotEquals:+ return !currentValue.Value.Equals(expected);+ default:+ throw new InvalidOperationException("Unexpected ProfileConditionType");+ }+ }++ return false;+ }++ private bool IsConditionSatisfied(ProfileCondition condition, TransportStreamTimestamp timestamp)+ {+ var expected = (TransportStreamTimestamp)Enum.Parse(typeof(TransportStreamTimestamp), condition.Value, true);++ switch (condition.Condition)+ {+ case ProfileConditionType.Equals:+ return timestamp == expected;+ case ProfileConditionType.NotEquals:+ return timestamp != expected;+ default:+ throw new InvalidOperationException("Unexpected ProfileConditionType");+ }+ }+ }+}diff --git a/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs b/MediaBrowser.Model/Dlna/ContentFeatureBuilder.csindex 351eca5be0..b2bbe3b14c 100644--- a/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs+++ b/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs@@ -1,4 +1,6 @@using System;+using System.Collections.Generic;+using System.Linq;namespace MediaBrowser.Model.Dlna{@@ -11,13 +13,45 @@ namespace MediaBrowser.Model.Dlna_profile = profile;}- public string BuildAudioHeader(string container,+ public string BuildImageHeader(string container,+ int? width,+ int? height)+ {+ var orgOp = ";DLNA.ORG_OP=" + DlnaMaps.GetImageOrgOpValue();++ // 0 = native, 1 = transcoded+ const string orgCi = ";DLNA.ORG_CI=0";++ var flagValue = DlnaFlags.StreamingTransferMode |+ DlnaFlags.BackgroundTransferMode |+ DlnaFlags.DlnaV15;++ var dlnaflags = string.Format(";DLNA.ORG_FLAGS={0}",+ FlagsToString(flagValue));++ var mediaProfile = _profile.GetImageMediaProfile(container,+ width,+ height);++ var orgPn = mediaProfile == null ? null : mediaProfile.OrgPn;++ if (string.IsNullOrEmpty(orgPn))+ {+ orgPn = GetImageOrgPnValue(container, width, height);+ }++ var contentFeatures = string.IsNullOrEmpty(orgPn) ? string.Empty : "DLNA.ORG_PN=" + orgPn;++ return (contentFeatures + orgOp + orgCi + dlnaflags).Trim(';');+ }++ public string BuildAudioHeader(string container,string audioCodec,- int? audioBitrate,- int? audioSampleRate,- int? audioChannels,- bool isDirectStream,- long? runtimeTicks,+ int? audioBitrate,+ int? audioSampleRate,+ int? audioChannels,+ bool isDirectStream,+ long? runtimeTicks,TranscodeSeekInfo transcodeSeekInfo){// 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@@ -42,7 +76,10 @@ namespace MediaBrowser.Model.Dlnavar dlnaflags = string.Format(";DLNA.ORG_FLAGS={0}",FlagsToString(flagValue));- var mediaProfile = _profile.GetAudioMediaProfile(container, audioCodec);+ var mediaProfile = _profile.GetAudioMediaProfile(container,+ audioCodec,+ audioChannels,+ audioBitrate);var orgPn = mediaProfile == null ? null : mediaProfile.OrgPn;@@ -62,15 +99,22 @@ namespace MediaBrowser.Model.Dlnareturn string.Format("{0:X8}{1:D24}", (ulong)flags, 0);}- public string BuildVideoHeader(string container,- string videoCodec,- string audioCodec,- int? width,- int? height,- int? bitrate,- TransportStreamTimestamp timestamp,- bool isDirectStream,- long? runtimeTicks,+ public string BuildVideoHeader(string container,+ string videoCodec,+ string audioCodec,+ int? width,+ int? height,+ int? bitDepth,+ int? videoBitrate,+ int? audioChannels,+ int? audioBitrate,+ TransportStreamTimestamp timestamp,+ bool isDirectStream,+ long? runtimeTicks,+ string videoProfile,+ double? videoLevel,+ double? videoFramerate,+ int? packetLength,TranscodeSeekInfo transcodeSeekInfo){// 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@@ -95,12 +139,30 @@ namespace MediaBrowser.Model.Dlnavar dlnaflags = string.Format(";DLNA.ORG_FLAGS={0}000000000000000000000000",Enum.Format(typeof(DlnaFlags), flagValue, "x"));- var mediaProfile = _profile.GetVideoMediaProfile(container, audioCodec, videoCodec);+ var mediaProfile = _profile.GetVideoMediaProfile(container,+ audioCodec,+ videoCodec,+ audioBitrate,+ audioChannels,+ width,+ height,+ bitDepth,+ videoBitrate,+ videoProfile,+ videoLevel,+ videoFramerate,+ packetLength,+ timestamp);+var orgPn = mediaProfile == null ? null : mediaProfile.OrgPn;-+if (string.IsNullOrEmpty(orgPn)){- orgPn = GetVideoOrgPnValue(container, videoCodec, audioCodec, width, height, bitrate, timestamp);+ orgPn = GetVideoOrgPnValue(container, videoCodec, audioCodec, width, height, timestamp)+ .FirstOrDefault();++ // TODO: Support multiple values and return multiple headers?+ orgPn = (orgPn ?? string.Empty).Split(',').FirstOrDefault();}var contentFeatures = string.IsNullOrEmpty(orgPn) ? string.Empty : "DLNA.ORG_PN=" + orgPn;@@ -108,6 +170,16 @@ namespace MediaBrowser.Model.Dlnareturn (contentFeatures + orgOp + orgCi + dlnaflags).Trim(';');}+ private string GetImageOrgPnValue(string container, int? width, int? height)+ {+ var format = new MediaFormatProfileResolver()+ .ResolveImageFormat(container,+ width,+ height);++ return format.HasValue ? format.Value.ToString() : null;+ }+private string GetAudioOrgPnValue(string container, int? audioBitrate, int? audioSampleRate, int? audioChannels){var format = new MediaFormatProfileResolver()@@ -119,18 +191,16 @@ namespace MediaBrowser.Model.Dlnareturn format.HasValue ? format.Value.ToString() : null;}- private string GetVideoOrgPnValue(string container, string videoCodec, string audioCodec, int? width, int? height, int? bitrate, TransportStreamTimestamp timestamp)+ private IEnumerable<string> GetVideoOrgPnValue(string container, string videoCodec, string audioCodec, int? width, int? height, TransportStreamTimestamp timestamp){- var videoFormat = new MediaFormatProfileResolver()+ return new MediaFormatProfileResolver().ResolveVideoFormat(container,videoCodec,audioCodec,width,height,- bitrate,- timestamp);-- return videoFormat.HasValue ? videoFormat.Value.ToString() : null;+ timestamp)+ .Select(i => i.ToString());}}}diff --git a/MediaBrowser.Model/Dlna/DeviceProfile.cs b/MediaBrowser.Model/Dlna/DeviceProfile.csindex 106ba75b08..96ff108962 100644--- a/MediaBrowser.Model/Dlna/DeviceProfile.cs+++ b/MediaBrowser.Model/Dlna/DeviceProfile.cs@@ -1,5 +1,4 @@-using MediaBrowser.Model.Entities;-using System;+using System;using System.Collections.Generic;using System.Linq;using System.Xml.Serialization;@@ -71,6 +70,8 @@ namespace MediaBrowser.Model.Dlnapublic bool RequiresPlainVideoItems { get; set; }public bool RequiresPlainFolders { get; set; }+ public XmlAttribute[] ContentDirectoryRootAttributes { get; set; }+/// <summary>/// Gets or sets the direct play profiles./// </summary>@@ -96,6 +97,8 @@ namespace MediaBrowser.Model.DlnaCodecProfiles = new CodecProfile[] { };ContainerProfiles = new ContainerProfile[] { };+ ContentDirectoryRootAttributes = new XmlAttribute[] { };+SupportedMediaTypes = "Audio,Photo,Video";}@@ -159,7 +162,7 @@ namespace MediaBrowser.Model.Dlna});}- public ResponseProfile GetAudioMediaProfile(string container, string audioCodec)+ public ResponseProfile GetAudioMediaProfile(string container, string audioCodec, int? audioChannels, int? audioBitrate){container = (container ?? string.Empty).TrimStart('.');@@ -182,11 +185,51 @@ namespace MediaBrowser.Model.Dlnareturn false;}- return true;+ var conditionProcessor = new ConditionProcessor();+ return i.Conditions.All(c => conditionProcessor.IsAudioConditionSatisfied(c,+ audioChannels,+ audioBitrate));});}- public ResponseProfile GetVideoMediaProfile(string container, string audioCodec, string videoCodec)+ public ResponseProfile GetImageMediaProfile(string container, int? width, int? height)+ {+ container = (container ?? string.Empty).TrimStart('.');++ return ResponseProfiles.FirstOrDefault(i =>+ {+ if (i.Type != DlnaProfileType.Photo)+ {+ return false;+ }++ var containers = i.GetContainers().ToList();+ if (containers.Count > 0 && !containers.Contains(container))+ {+ return false;+ }++ var conditionProcessor = new ConditionProcessor();+ return i.Conditions.All(c => conditionProcessor.IsImageConditionSatisfied(c,+ width,+ height));+ });+ }++ public ResponseProfile GetVideoMediaProfile(string container,+ string audioCodec,+ string videoCodec,+ int? audioBitrate,+ int? audioChannels,+ int? width,+ int? height,+ int? bitDepth,+ int? videoBitrate,+ string videoProfile,+ double? videoLevel,+ double? videoFramerate,+ int? packetLength,+ TransportStreamTimestamp timestamp){container = (container ?? string.Empty).TrimStart('.');@@ -215,11 +258,23 @@ namespace MediaBrowser.Model.Dlnareturn false;}- return true;+ var conditionProcessor = new ConditionProcessor();+ return i.Conditions.All(c => conditionProcessor.IsVideoConditionSatisfied(c,+ audioBitrate,+ audioChannels,+ width,+ height,+ bitDepth,+ videoBitrate,+ videoProfile,+ videoLevel,+ videoFramerate,+ packetLength,+ timestamp));});}- public ResponseProfile GetPhotoMediaProfile(string container)+ public ResponseProfile GetPhotoMediaProfile(string container, int? width, int? height){container = (container ?? string.Empty).TrimStart('.');@@ -236,7 +291,10 @@ namespace MediaBrowser.Model.Dlnareturn false;}- return true;+ var conditionProcessor = new ConditionProcessor();+ return i.Conditions.All(c => conditionProcessor.IsImageConditionSatisfied(c,+ width,+ height));});}}diff --git a/MediaBrowser.Model/Dlna/DirectPlayProfile.cs b/MediaBrowser.Model/Dlna/DirectPlayProfile.csindex c7ecdc908b..e195c94507 100644--- a/MediaBrowser.Model/Dlna/DirectPlayProfile.cs+++ b/MediaBrowser.Model/Dlna/DirectPlayProfile.cs@@ -34,6 +34,15 @@ namespace MediaBrowser.Model.Dlna}}+ public class XmlAttribute+ {+ [XmlAttribute("name")]+ public string Name { get; set; }++ [XmlAttribute("value")]+ public string Value { get; set; }+ }+public enum DlnaProfileType{Audio = 0,diff --git a/MediaBrowser.Model/Dlna/DlnaMaps.cs b/MediaBrowser.Model/Dlna/DlnaMaps.csindex eb0c333154..d2871474ad 100644--- a/MediaBrowser.Model/Dlna/DlnaMaps.cs+++ b/MediaBrowser.Model/Dlna/DlnaMaps.cs@@ -41,6 +41,19 @@ namespace MediaBrowser.Model.Dlna// No seeking is available if we don't know the content runtimereturn "00";}++ public static string GetImageOrgOpValue()+ {+ var orgOp = string.Empty;++ // Time-based seeking currently only possible when transcoding+ orgOp += "0";++ // Byte-based seeking only possible when not transcoding+ orgOp += "1";++ return orgOp;+ }}[Flags]diff --git a/MediaBrowser.Model/Dlna/MediaFormatProfile.cs b/MediaBrowser.Model/Dlna/MediaFormatProfile.csindex e686fe932d..596985bdc0 100644--- a/MediaBrowser.Model/Dlna/MediaFormatProfile.cs+++ b/MediaBrowser.Model/Dlna/MediaFormatProfile.cs@@ -1,6 +1,4 @@-using System;-namespace MediaBrowser.Model.Dlna{public enum MediaFormatProfilediff --git a/MediaBrowser.Model/Dlna/MediaFormatProfileResolver.cs b/MediaBrowser.Model/Dlna/MediaFormatProfileResolver.csindex 02400a7ff3..9337a6c95f 100644--- a/MediaBrowser.Model/Dlna/MediaFormatProfileResolver.cs+++ b/MediaBrowser.Model/Dlna/MediaFormatProfileResolver.cs@@ -1,57 +1,62 @@using System;using System.Collections.Generic;-using System.Linq;namespace MediaBrowser.Model.Dlna{public class MediaFormatProfileResolver{- public MediaFormatProfile? ResolveVideoFormat(string container, string videoCodec, string audioCodec, int? width, int? height, int? bitrate, TransportStreamTimestamp timestampType)+ public IEnumerable<MediaFormatProfile> ResolveVideoFormat(string container, string videoCodec, string audioCodec, int? width, int? height, TransportStreamTimestamp timestampType){if (string.Equals(container, "asf", StringComparison.OrdinalIgnoreCase))- return ResolveVideoASFFormat(videoCodec, audioCodec, width, height);+ {+ var val = ResolveVideoASFFormat(videoCodec, audioCodec, width, height);+ return val.HasValue ? new List<MediaFormatProfile> { val.Value } : new List<MediaFormatProfile>();+ }if (string.Equals(container, "mp4", StringComparison.OrdinalIgnoreCase))- return ResolveVideoMP4Format(videoCodec, audioCodec, width, height, bitrate);+ {+ var val = ResolveVideoMP4Format(videoCodec, audioCodec, width, height);+ return val.HasValue ? new List<MediaFormatProfile> { val.Value } : new List<MediaFormatProfile>();+ }if (string.Equals(container, "avi", StringComparison.OrdinalIgnoreCase))- return MediaFormatProfile.AVI;+ return new[] { MediaFormatProfile.AVI };if (string.Equals(container, "mkv", StringComparison.OrdinalIgnoreCase))- return MediaFormatProfile.MATROSKA;+ return new[] { MediaFormatProfile.MATROSKA };if (string.Equals(container, "mpeg2ps", StringComparison.OrdinalIgnoreCase) ||string.Equals(container, "ts", StringComparison.OrdinalIgnoreCase))- // MediaFormatProfile.MPEG_PS_PAL, MediaFormatProfile.MPEG_PS_NTSC- return MediaFormatProfile.MPEG_PS_NTSC;++ return new[] { MediaFormatProfile.MPEG_PS_NTSC, MediaFormatProfile.MPEG_PS_PAL };if (string.Equals(container, "mpeg1video", StringComparison.OrdinalIgnoreCase))- return MediaFormatProfile.MPEG1;+ return new[] { MediaFormatProfile.MPEG1 };if (string.Equals(container, "mpeg2ts", StringComparison.OrdinalIgnoreCase) ||string.Equals(container, "mpegts", StringComparison.OrdinalIgnoreCase) ||string.Equals(container, "m2ts", StringComparison.OrdinalIgnoreCase)){- var list = ResolveVideoMPEG2TSFormat(videoCodec, audioCodec, width, height, timestampType)- .ToList();-- return list.Count > 0 ? list[0] : (MediaFormatProfile?)null;+ return ResolveVideoMPEG2TSFormat(videoCodec, audioCodec, width, height, timestampType);}if (string.Equals(container, "flv", StringComparison.OrdinalIgnoreCase))- return MediaFormatProfile.FLV;+ return new[] { MediaFormatProfile.FLV };if (string.Equals(container, "wtv", StringComparison.OrdinalIgnoreCase))- return MediaFormatProfile.WTV;+ return new[] { MediaFormatProfile.WTV };if (string.Equals(container, "3gp", StringComparison.OrdinalIgnoreCase))- return ResolveVideo3GPFormat(videoCodec, audioCodec);+ {+ var val = ResolveVideo3GPFormat(videoCodec, audioCodec);+ return val.HasValue ? new List<MediaFormatProfile> { val.Value } : new List<MediaFormatProfile>();+ }if (string.Equals(container, "ogv", StringComparison.OrdinalIgnoreCase) || string.Equals(container, "ogg", StringComparison.OrdinalIgnoreCase))- return MediaFormatProfile.OGV;+ return new[] { MediaFormatProfile.OGV };- return null;+ return new List<MediaFormatProfile>();}private IEnumerable<MediaFormatProfile> ResolveVideoMPEG2TSFormat(string videoCodec, string audioCodec, int? width, int? height, TransportStreamTimestamp timestampType)@@ -132,11 +137,16 @@ namespace MediaBrowser.Model.Dlna}return new[] { MediaFormatProfile.VC1_TS_AP_L1_AC3_ISO };}- // if (audioCodec == AudioCodec.DTS) {- // suffix = suffix.equals("_ISO") ? suffix : "_T";- // return Collections.singletonList(MediaFormatProfile.valueOf(String.format("VC1_TS_HD_DTS%s", cast(Object[])[ suffix ])));- // }- //} else if ((videoCodec == VideoCodec.MPEG4) || (videoCodec == VideoCodec.MSMPEG4)) {+ if (string.Equals(audioCodec, "dts", StringComparison.OrdinalIgnoreCase))+ {+ suffix = string.Equals(suffix, "_ISO") ? suffix : "_T";++ return new[] { ValueOf(string.Format("VC1_TS_HD_DTS{0}", suffix)) };+ }++ }+ else if (string.Equals(videoCodec, "mpeg4", StringComparison.OrdinalIgnoreCase) || string.Equals(videoCodec, "msmpeg4", StringComparison.OrdinalIgnoreCase))+ {// if (audioCodec == AudioCodec.AAC)// return Collections.singletonList(MediaFormatProfile.valueOf(String.format("MPEG4_P2_TS_ASP_AAC%s", cast(Object[])[ suffix ])));// if (audioCodec == AudioCodec.MP3)@@ -145,7 +155,6 @@ namespace MediaBrowser.Model.Dlna// return Collections.singletonList(MediaFormatProfile.valueOf(String.format("MPEG4_P2_TS_ASP_MPEG2_L2%s", cast(Object[])[ suffix ])));// if ((audioCodec is null) || (audioCodec == AudioCodec.AC3)) {// return Collections.singletonList(MediaFormatProfile.valueOf(String.format("MPEG4_P2_TS_ASP_AC3%s", cast(Object[])[ suffix ])));- // }}return new List<MediaFormatProfile>();@@ -156,7 +165,7 @@ namespace MediaBrowser.Model.Dlnareturn (MediaFormatProfile)Enum.Parse(typeof(MediaFormatProfile), value, true);}- private MediaFormatProfile? ResolveVideoMP4Format(string videoCodec, string audioCodec, int? width, int? height, int? bitrate)+ private MediaFormatProfile? ResolveVideoMP4Format(string videoCodec, string audioCodec, int? width, int? height){if (string.Equals(videoCodec, "h264", StringComparison.OrdinalIgnoreCase)){diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.csindex 2127af34ae..f3425d2027 100644--- a/MediaBrowser.Model/Dlna/StreamBuilder.cs+++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs@@ -100,13 +100,23 @@ namespace MediaBrowser.Model.Dlnavar audioCodec = audioStream == null ? null : audioStream.Codec;// Make sure audio codec profiles are satisfied- if (!string.IsNullOrEmpty(audioCodec) && options.Profile.CodecProfiles.Where(i => i.Type == CodecType.Audio && i.ContainsCodec(audioCodec))- .All(i => AreConditionsSatisfied(i.Conditions, item.Path, null, audioStream)))+ if (!string.IsNullOrEmpty(audioCodec)){- playlistItem.IsDirectStream = true;- playlistItem.Container = item.Container;+ var conditionProcessor = new ConditionProcessor();- return playlistItem;+ var conditions = options.Profile.CodecProfiles.Where(i => i.Type == CodecType.Audio && i.ContainsCodec(audioCodec))+ .SelectMany(i => i.Conditions);++ var audioChannels = audioStream == null ? null : audioStream.Channels;+ var audioBitrate = audioStream == null ? null : audioStream.BitRate;++ if (conditions.All(c => conditionProcessor.IsAudioConditionSatisfied(c, audioChannels, audioBitrate)))+ {+ playlistItem.IsDirectStream = true;+ playlistItem.Container = item.Container;++ return playlistItem;+ }}}}@@ -168,29 +178,14 @@ namespace MediaBrowser.Model.Dlnaif (IsEligibleForDirectPlay(item, options, maxBitrateSetting)){// See if it can be direct played- var directPlay = options.Profile.DirectPlayProfiles- .FirstOrDefault(i => i.Type == playlistItem.MediaType && IsVideoDirectPlaySupported(i, item, videoStream, audioStream));+ var directPlay = GetVideoDirectPlayProfile(options.Profile, item, videoStream, audioStream);if (directPlay != null){- var videoCodec = videoStream == null ? null : videoStream.Codec;-- // Make sure video codec profiles are satisfied- if (!string.IsNullOrEmpty(videoCodec) && options.Profile.CodecProfiles.Where(i => i.Type == CodecType.Video && i.ContainsCodec(videoCodec))- .All(i => AreConditionsSatisfied(i.Conditions, item.Path, videoStream, audioStream)))- {- var audioCodec = audioStream == null ? null : audioStream.Codec;-- // Make sure audio codec profiles are satisfied- if (string.IsNullOrEmpty(audioCodec) || options.Profile.CodecProfiles.Where(i => i.Type == CodecType.VideoAudio && i.ContainsCodec(audioCodec))- .All(i => AreConditionsSatisfied(i.Conditions, item.Path, videoStream, audioStream)))- {- playlistItem.IsDirectStream = true;- playlistItem.Container = item.Container;+ playlistItem.IsDirectStream = true;+ playlistItem.Container = item.Container;- return playlistItem;- }- }+ return playlistItem;}}@@ -257,6 +252,110 @@ namespace MediaBrowser.Model.Dlnareturn playlistItem;}+ private DirectPlayProfile GetVideoDirectPlayProfile(DeviceProfile profile,+ MediaSourceInfo mediaSource,+ MediaStream videoStream,+ MediaStream audioStream)+ {+ // See if it can be direct played+ var directPlay = profile.DirectPlayProfiles+ .FirstOrDefault(i => i.Type == DlnaProfileType.Video && IsVideoDirectPlaySupported(i, mediaSource, videoStream, audioStream));++ if (directPlay == null)+ {+ return null;+ }++ var container = mediaSource.Container;++ var conditions = profile.ContainerProfiles+ .Where(i => i.Type == DlnaProfileType.Video && i.GetContainers().Contains(container, StringComparer.OrdinalIgnoreCase))+ .SelectMany(i => i.Conditions);++ var conditionProcessor = new ConditionProcessor();++ var width = videoStream == null ? null : videoStream.Width;+ var height = videoStream == null ? null : videoStream.Height;+ var bitDepth = videoStream == null ? null : videoStream.BitDepth;+ var videoBitrate = videoStream == null ? null : videoStream.BitRate;+ var videoLevel = videoStream == null ? null : videoStream.Level;+ var videoProfile = videoStream == null ? null : videoStream.Profile;+ var videoFramerate = videoStream == null ? null : videoStream.AverageFrameRate ?? videoStream.AverageFrameRate;++ var audioBitrate = audioStream == null ? null : audioStream.BitRate;+ var audioChannels = audioStream == null ? null : audioStream.Channels;++ var timestamp = videoStream == null ? TransportStreamTimestamp.NONE : videoStream.Timestamp;+ var packetLength = videoStream == null ? null : videoStream.PacketLength;++ // Check container conditions+ if (!conditions.All(i => conditionProcessor.IsVideoConditionSatisfied(i,+ audioBitrate,+ audioChannels,+ width,+ height,+ bitDepth,+ videoBitrate,+ videoProfile,+ videoLevel,+ videoFramerate,+ packetLength,+ timestamp)))+ {+ return null;+ }++ var videoCodec = videoStream == null ? null : videoStream.Codec;++ if (string.IsNullOrEmpty(videoCodec))+ {+ return null;+ }++ conditions = profile.CodecProfiles+ .Where(i => i.Type == CodecType.Video && i.ContainsCodec(videoCodec))+ .SelectMany(i => i.Conditions);++ if (!conditions.All(i => conditionProcessor.IsVideoConditionSatisfied(i,+ audioBitrate,+ audioChannels,+ width,+ height,+ bitDepth,+ videoBitrate,+ videoProfile,+ videoLevel,+ videoFramerate,+ packetLength,+ timestamp)))+ {+ return null;+ }++ if (audioStream != null)+ {+ var audioCodec = audioStream.Codec;++ if (string.IsNullOrEmpty(audioCodec))+ {+ return null;+ }++ conditions = profile.CodecProfiles+ .Where(i => i.Type == CodecType.VideoAudio && i.ContainsCodec(audioCodec))+ .SelectMany(i => i.Conditions);++ if (!conditions.All(i => conditionProcessor.IsVideoAudioConditionSatisfied(i,+ audioChannels,+ audioBitrate)))+ {+ return null;+ }+ }++ return directPlay;+ }+private bool IsEligibleForDirectPlay(MediaSourceInfo item, VideoOptions options, int? maxBitrate){if (options.SubtitleStreamIndex.HasValue)@@ -343,12 +442,18 @@ namespace MediaBrowser.Model.Dlna}case ProfileConditionValue.AudioProfile:case ProfileConditionValue.Has64BitOffsets:+ case ProfileConditionValue.PacketLength:+ case ProfileConditionValue.VideoTimestamp:case ProfileConditionValue.VideoBitDepth:- case ProfileConditionValue.VideoProfile:{// Not supported yetbreak;}+ case ProfileConditionValue.VideoProfile:+ {+ item.VideoProfile = value;+ break;+ }case ProfileConditionValue.Height:{int num;@@ -457,155 +562,5 @@ namespace MediaBrowser.Model.Dlnareturn true;}-- private bool AreConditionsSatisfied(IEnumerable<ProfileCondition> conditions, string mediaPath, MediaStream videoStream, MediaStream audioStream)- {- return conditions.All(i => IsConditionSatisfied(i, mediaPath, videoStream, audioStream));- }-- /// <summary>- /// Determines whether [is condition satisfied] [the specified condition].- /// </summary>- /// <param name="condition">The condition.</param>- /// <param name="mediaPath">The media path.</param>- /// <param name="videoStream">The video stream.</param>- /// <param name="audioStream">The audio stream.</param>- /// <returns><c>true</c> if [is condition satisfied] [the specified condition]; otherwise, <c>false</c>.</returns>- /// <exception cref="System.InvalidOperationException">Unexpected ProfileConditionType</exception>- private bool IsConditionSatisfied(ProfileCondition condition, string mediaPath, MediaStream videoStream, MediaStream audioStream)- {- if (condition.Property == ProfileConditionValue.Has64BitOffsets)- {- // TODO: Determine how to evaluate this- }-- if (condition.Property == ProfileConditionValue.VideoProfile)- {- var profile = videoStream == null ? null : videoStream.Profile;-- if (!string.IsNullOrEmpty(profile))- {- switch (condition.Condition)- {- case ProfileConditionType.Equals:- return string.Equals(profile, condition.Value, StringComparison.OrdinalIgnoreCase);- case ProfileConditionType.NotEquals:- return !string.Equals(profile, condition.Value, StringComparison.OrdinalIgnoreCase);- default:- throw new InvalidOperationException("Unexpected ProfileConditionType");- }- }- }-- else if (condition.Property == ProfileConditionValue.AudioProfile)- {- var profile = audioStream == null ? null : audioStream.Profile;-- if (!string.IsNullOrEmpty(profile))- {- switch (condition.Condition)- {- case ProfileConditionType.Equals:- return string.Equals(profile, condition.Value, StringComparison.OrdinalIgnoreCase);- case ProfileConditionType.NotEquals:- return !string.Equals(profile, condition.Value, StringComparison.OrdinalIgnoreCase);- default:- throw new InvalidOperationException("Unexpected ProfileConditionType");- }- }- }-- else- {- var actualValue = GetConditionValue(condition, mediaPath, videoStream, audioStream);-- if (actualValue.HasValue)- {- double expected;- if (double.TryParse(condition.Value, NumberStyles.Any, _usCulture, out expected))- {- switch (condition.Condition)- {- case ProfileConditionType.Equals:- return actualValue.Value.Equals(expected);- case ProfileConditionType.GreaterThanEqual:- return actualValue.Value >= expected;- case ProfileConditionType.LessThanEqual:- return actualValue.Value <= expected;- case ProfileConditionType.NotEquals:- return !actualValue.Value.Equals(expected);- default:- throw new InvalidOperationException("Unexpected ProfileConditionType");- }- }- }- }-- // Value doesn't exist in metadata. Fail it if required.- return !condition.IsRequired;- }-- /// <summary>- /// Gets the condition value.- /// </summary>- /// <param name="condition">The condition.</param>- /// <param name="mediaPath">The media path.</param>- /// <param name="videoStream">The video stream.</param>- /// <param name="audioStream">The audio stream.</param>- /// <returns>System.Nullable{System.Int64}.</returns>- /// <exception cref="System.InvalidOperationException">Unexpected Property</exception>- private double? GetConditionValue(ProfileCondition condition, string mediaPath, MediaStream videoStream, MediaStream audioStream)- {- switch (condition.Property)- {- case ProfileConditionValue.AudioBitrate:- return audioStream == null ? null : audioStream.BitRate;- case ProfileConditionValue.AudioChannels:- return audioStream == null ? null : audioStream.Channels;- case ProfileConditionValue.VideoBitrate:- return videoStream == null ? null : videoStream.BitRate;- case ProfileConditionValue.VideoFramerate:- return videoStream == null ? null : (videoStream.AverageFrameRate ?? videoStream.RealFrameRate);- case ProfileConditionValue.Height:- return videoStream == null ? null : videoStream.Height;- case ProfileConditionValue.Width:- return videoStream == null ? null : videoStream.Width;- case ProfileConditionValue.VideoLevel:- return videoStream == null ? null : videoStream.Level;- case ProfileConditionValue.VideoBitDepth:- return videoStream == null ? null : GetBitDepth(videoStream);- default:- throw new InvalidOperationException("Unexpected Property");- }- }-- private int? GetBitDepth(MediaStream videoStream)- {- var eightBit = new List<string>- {- "yuv420p",- "yuv411p",- "yuvj420p",- "uyyvyy411",- "nv12",- "nv21",- "rgb444le",- "rgb444be",- "bgr444le",- "bgr444be",- "yuvj411p"- };-- if (!string.IsNullOrEmpty(videoStream.PixelFormat))- {- if (eightBit.Contains(videoStream.PixelFormat, StringComparer.OrdinalIgnoreCase))- {- return 8;- }- }-- return null;- }}-}diff --git a/MediaBrowser.Model/Dlna/StreamInfo.cs b/MediaBrowser.Model/Dlna/StreamInfo.csindex c5589322d8..0ab6805e3b 100644--- a/MediaBrowser.Model/Dlna/StreamInfo.cs+++ b/MediaBrowser.Model/Dlna/StreamInfo.cs@@ -26,6 +26,7 @@ namespace MediaBrowser.Model.Dlnapublic long StartPositionTicks { get; set; }public string VideoCodec { get; set; }+ public string VideoProfile { get; set; }public string AudioCodec { get; set; }@@ -57,8 +58,6 @@ namespace MediaBrowser.Model.Dlnapublic MediaSourceInfo MediaSource { get; set; }- public TransportStreamTimestamp TargetTimestamp { get; set; }-public string MediaSourceId{get@@ -177,6 +176,74 @@ namespace MediaBrowser.Model.Dlna}}+ /// <summary>+ /// Predicts the audio sample rate that will be in the output stream+ /// </summary>+ public int? TargetVideoBitDepth+ {+ get+ {+ var stream = TargetVideoStream;+ return stream == null || !IsDirectStream ? null : stream.BitDepth;+ }+ }++ /// <summary>+ /// Predicts the audio sample rate that will be in the output stream+ /// </summary>+ public double? TargetFramerate+ {+ get+ {+ var stream = TargetVideoStream;+ return MaxFramerate.HasValue && !IsDirectStream+ ? MaxFramerate+ : stream == null ? null : stream.AverageFrameRate ?? stream.RealFrameRate;+ }+ }++ /// <summary>+ /// Predicts the audio sample rate that will be in the output stream+ /// </summary>+ public double? TargetVideoLevel+ {+ get+ {+ var stream = TargetVideoStream;+ return VideoLevel.HasValue && !IsDirectStream+ ? VideoLevel+ : stream == null ? null : stream.Level;+ }+ }++ /// <summary>+ /// Predicts the audio sample rate that will be in the output stream+ /// </summary>+ public int? TargetPacketLength+ {+ get+ {+ var stream = TargetVideoStream;+ return !IsDirectStream+ ? null+ : stream == null ? null : stream.PacketLength;+ }+ }++ /// <summary>+ /// Predicts the audio sample rate that will be in the output stream+ /// </summary>+ public string TargetVideoProfile+ {+ get+ {+ var stream = TargetVideoStream;+ return !string.IsNullOrEmpty(VideoProfile) && !IsDirectStream+ ? VideoProfile+ : stream == null ? null : stream.Profile;+ }+ }+/// <summary>/// Predicts the audio bitrate that will be in the output stream/// </summary>@@ -256,11 +323,35 @@ namespace MediaBrowser.Model.Dlna}}- public int? TotalOutputBitrate+ public int? TargetVideoBitrate+ {+ get+ {+ var stream = TargetVideoStream;++ return VideoBitrate.HasValue && !IsDirectStream+ ? VideoBitrate+ : stream == null ? null : stream.BitRate;+ }+ }++ public TransportStreamTimestamp TargetTimestamp+ {+ get+ {+ var stream = TargetVideoStream;++ return !IsDirectStream+ ? TransportStreamTimestamp.VALID+ : stream == null ? TransportStreamTimestamp.VALID : stream.Timestamp;+ }+ }++ public int? TargetTotalBitrate{get{- return (TargetAudioBitrate ?? 0) + (VideoBitrate ?? 0);+ return (TargetAudioBitrate ?? 0) + (TargetVideoBitrate ?? 0);}}diff --git a/MediaBrowser.Model/Entities/MediaStream.cs b/MediaBrowser.Model/Entities/MediaStream.csindex cdfdd19c84..920112d02e 100644--- a/MediaBrowser.Model/Entities/MediaStream.cs+++ b/MediaBrowser.Model/Entities/MediaStream.cs@@ -1,5 +1,6 @@using System.Collections.Generic;using System.Diagnostics;+using MediaBrowser.Model.Dlna;namespace MediaBrowser.Model.Entities{@@ -39,6 +40,24 @@ namespace MediaBrowser.Model.Entities/// <value>The bit rate.</value>public int? BitRate { get; set; }+ /// <summary>+ /// Gets or sets the bit depth.+ /// </summary>+ /// <value>The bit depth.</value>+ public int? BitDepth { get; set; }++ /// <summary>+ /// Gets or sets the length of the packet.+ /// </summary>+ /// <value>The length of the packet.</value>+ public int? PacketLength { get; set; }++ /// <summary>+ /// Gets or sets the timestamp.+ /// </summary>+ /// <value>The timestamp.</value>+ public TransportStreamTimestamp Timestamp { get; set; }+/// <summary>/// Gets or sets the channels./// </summary>diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csprojindex 4d0214eb86..1ae0833fb7 100644--- a/MediaBrowser.Model/MediaBrowser.Model.csproj+++ b/MediaBrowser.Model/MediaBrowser.Model.csproj@@ -67,6 +67,7 @@<Compile Include="Configuration\MetadataOptions.cs" /><Compile Include="Configuration\ServerConfiguration.cs" /><Compile Include="Dlna\CodecProfile.cs" />+ <Compile Include="Dlna\ConditionProcessor.cs" /><Compile Include="Dlna\ContainerProfile.cs" /><Compile Include="Dlna\ContentFeatureBuilder.cs" /><Compile Include="Dlna\DeviceIdentification.cs" />diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteMediaStreamsRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteMediaStreamsRepository.csindex 3a8aeb6e69..58ca432bbd 100644--- a/MediaBrowser.Server.Implementations/Persistence/SqliteMediaStreamsRepository.cs+++ b/MediaBrowser.Server.Implementations/Persistence/SqliteMediaStreamsRepository.cs@@ -1,11 +1,11 @@-using System.Text;-using MediaBrowser.Controller.Persistence;+using MediaBrowser.Controller.Persistence;using MediaBrowser.Model.Entities;using MediaBrowser.Model.Logging;using System;using System.Collections.Generic;using System.Data;using System.Linq;+using System.Text;using System.Threading;using System.Threading.Tasks;@@ -40,7 +40,7 @@ namespace MediaBrowser.Server.Implementations.Persistence// Add PixelFormat column- createTableCommand += "(ItemId GUID, StreamIndex INT, StreamType TEXT, Codec TEXT, Language TEXT, ChannelLayout TEXT, Profile TEXT, AspectRatio TEXT, Path TEXT, IsInterlaced BIT, BitRate INT NULL, Channels INT NULL, SampleRate INT NULL, IsDefault BIT, IsForced BIT, IsExternal BIT, Height INT NULL, Width INT NULL, AverageFrameRate FLOAT NULL, RealFrameRate FLOAT NULL, Level FLOAT NULL, PixelFormat TEXT, PRIMARY KEY (ItemId, StreamIndex))";+ createTableCommand += "(ItemId GUID, StreamIndex INT, StreamType TEXT, Codec TEXT, Language TEXT, ChannelLayout TEXT, Profile TEXT, AspectRatio TEXT, Path TEXT, IsInterlaced BIT, BitRate INT NULL, Channels INT NULL, SampleRate INT NULL, IsDefault BIT, IsForced BIT, IsExternal BIT, Height INT NULL, Width INT NULL, AverageFrameRate FLOAT NULL, RealFrameRate FLOAT NULL, Level FLOAT NULL, PixelFormat TEXT, BitDepth INT NULL, PRIMARY KEY (ItemId, StreamIndex))";string[] queries = {@@ -57,6 +57,7 @@ namespace MediaBrowser.Server.Implementations.Persistence_connection.RunQueries(queries, _logger);AddPixelFormatColumnCommand();+ AddBitDepthCommand();PrepareStatements();@@ -94,6 +95,37 @@ namespace MediaBrowser.Server.Implementations.Persistence_connection.RunQueries(new[] { builder.ToString() }, _logger);}+ private void AddBitDepthCommand()+ {+ using (var cmd = _connection.CreateCommand())+ {+ cmd.CommandText = "PRAGMA table_info(mediastreams)";++ using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult))+ {+ while (reader.Read())+ {+ if (!reader.IsDBNull(1))+ {+ var name = reader.GetString(1);++ if (string.Equals(name, "BitDepth", StringComparison.OrdinalIgnoreCase))+ {+ return;+ }+ }+ }+ }+ }++ var builder = new StringBuilder();++ builder.AppendLine("alter table mediastreams");+ builder.AppendLine("add column BitDepth INT NULL");++ _connection.RunQueries(new[] { builder.ToString() }, _logger);+ }+private readonly string[] _saveColumns ={"ItemId",@@ -117,7 +149,8 @@ namespace MediaBrowser.Server.Implementations.Persistence"AverageFrameRate","RealFrameRate","Level",- "PixelFormat"+ "PixelFormat",+ "BitDepth"};/// <summary>@@ -281,6 +314,11 @@ namespace MediaBrowser.Server.Implementations.Persistenceitem.PixelFormat = reader.GetString(21);}+ if (!reader.IsDBNull(22))+ {+ item.BitDepth = reader.GetInt32(22);+ }+return item;}@@ -343,6 +381,7 @@ namespace MediaBrowser.Server.Implementations.Persistence_saveStreamCommand.GetParameter(19).Value = stream.RealFrameRate;_saveStreamCommand.GetParameter(20).Value = stream.Level;_saveStreamCommand.GetParameter(21).Value = stream.PixelFormat;+ _saveStreamCommand.GetParameter(22).Value = stream.BitDepth;_saveStreamCommand.Transaction = transaction;_saveStreamCommand.ExecuteNonQuery();