From 24cdfddc4f3beafc43f45c6f5fdc1f22d5263ccb Mon Sep 17 00:00:00 2001 From: 7illusions Date: Wed, 12 Mar 2014 14:08:24 +0100 Subject: Fixes the PlayTo Profile detection --- MediaBrowser.Dlna/PlayTo/Configuration/TranscodeSetting.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'MediaBrowser.Dlna/PlayTo/Configuration/TranscodeSetting.cs') diff --git a/MediaBrowser.Dlna/PlayTo/Configuration/TranscodeSetting.cs b/MediaBrowser.Dlna/PlayTo/Configuration/TranscodeSetting.cs index f5cceaaaa..ddf6f2187 100644 --- a/MediaBrowser.Dlna/PlayTo/Configuration/TranscodeSetting.cs +++ b/MediaBrowser.Dlna/PlayTo/Configuration/TranscodeSetting.cs @@ -1,4 +1,5 @@ using System; +using System.Text.RegularExpressions; namespace MediaBrowser.Dlna.PlayTo.Configuration { @@ -19,6 +20,8 @@ namespace MediaBrowser.Dlna.PlayTo.Configuration /// The target container. /// public string TargetContainer { get; set; } + + public string MimeType { get; set; } /// /// The default transcoding settings @@ -46,19 +49,19 @@ namespace MediaBrowser.Dlna.PlayTo.Configuration { if (!string.IsNullOrEmpty(profile.FriendlyName)) { - if (!string.Equals(deviceProperties.Name, profile.FriendlyName, StringComparison.OrdinalIgnoreCase)) + if (!Regex.IsMatch(deviceProperties.Name, profile.FriendlyName)) continue; } if (!string.IsNullOrEmpty(profile.ModelNumber)) { - if (!string.Equals(deviceProperties.ModelNumber, profile.ModelNumber, StringComparison.OrdinalIgnoreCase)) + if (!Regex.IsMatch(deviceProperties.ModelNumber, profile.ModelNumber)) continue; } if (!string.IsNullOrEmpty(profile.ModelName)) { - if (!string.Equals(deviceProperties.ModelName, profile.ModelName, StringComparison.OrdinalIgnoreCase)) + if (!Regex.IsMatch(deviceProperties.ModelName, profile.ModelName)) continue; } -- cgit v1.2.3 From 438b0078ccd07e39cbf95b737d676a39192d064c Mon Sep 17 00:00:00 2001 From: 7illusions Date: Wed, 12 Mar 2014 21:01:19 +0100 Subject: Added MimeType to PlayTo profile --- MediaBrowser.Dlna/MediaBrowser.Dlna.csproj | 2 +- .../PlayTo/Configuration/PlayToConfiguration.cs | 134 +++++++++++++++++++++ .../PlayTo/Configuration/PluginConfiguration.cs | 119 ------------------ .../PlayTo/Configuration/TranscodeSetting.cs | 8 +- MediaBrowser.Dlna/PlayTo/PlaylistItem.cs | 15 ++- MediaBrowser.Dlna/PlayTo/StreamHelper.cs | 14 ++- 6 files changed, 165 insertions(+), 127 deletions(-) create mode 100644 MediaBrowser.Dlna/PlayTo/Configuration/PlayToConfiguration.cs delete mode 100644 MediaBrowser.Dlna/PlayTo/Configuration/PluginConfiguration.cs (limited to 'MediaBrowser.Dlna/PlayTo/Configuration/TranscodeSetting.cs') diff --git a/MediaBrowser.Dlna/MediaBrowser.Dlna.csproj b/MediaBrowser.Dlna/MediaBrowser.Dlna.csproj index 59420c5a1..622ccefbc 100644 --- a/MediaBrowser.Dlna/MediaBrowser.Dlna.csproj +++ b/MediaBrowser.Dlna/MediaBrowser.Dlna.csproj @@ -53,7 +53,7 @@ - + diff --git a/MediaBrowser.Dlna/PlayTo/Configuration/PlayToConfiguration.cs b/MediaBrowser.Dlna/PlayTo/Configuration/PlayToConfiguration.cs new file mode 100644 index 000000000..d3fcb24ad --- /dev/null +++ b/MediaBrowser.Dlna/PlayTo/Configuration/PlayToConfiguration.cs @@ -0,0 +1,134 @@ +namespace MediaBrowser.Dlna.PlayTo.Configuration +{ + public class PlayToConfiguration + { + private static readonly string[] _supportedStaticFormats = { "mp3", "flac", "m4a", "wma", "avi", "mp4", "mkv", "ts" }; + public static string[] SupportedStaticFormats + { + get + { + return _supportedStaticFormats; + } + } + + private static readonly DlnaProfile[] _profiles = GetDefaultProfiles(); + public static DlnaProfile[] Profiles + { + get + { + return _profiles; + } + } + + private static DlnaProfile[] GetDefaultProfiles() + { + var profile0 = new DlnaProfile + { + Name = "Samsung TV (B Series) [Profile]", + ClientType = "DLNA", + FriendlyName = "^TV$", + ModelNumber = @"1\.0", + ModelName = "Samsung DTV DMR", + TranscodeSettings = new[] + { + new TranscodeSettings {Container = "mkv", MimeType = "x-mkv"}, + new TranscodeSettings {Container = "flac", TargetContainer = "mp3"}, + new TranscodeSettings {Container = "m4a", TargetContainer = "mp3"} + } + }; + + var profile1 = new DlnaProfile + { + Name = "Samsung TV (E/F-series) [Profile]", + ClientType = "DLNA", + FriendlyName = @"(^\[TV\][A-Z]{2}\d{2}(E|F)[A-Z]?\d{3,4}.*)|^\[TV\] Samsung", + ModelNumber = @"(1\.0)|(AllShare1\.0)", + TranscodeSettings = new[] + { + new TranscodeSettings {Container = "mkv", MimeType = "x-mkv"}, + new TranscodeSettings {Container = "flac", TargetContainer = "mp3"}, + new TranscodeSettings {Container = "m4a", TargetContainer = "mp3"} + } + }; + + var profile2 = new DlnaProfile + { + Name = "Samsung TV (C/D-series) [Profile]", + ClientType = "DLNA", + FriendlyName = @"(^TV-\d{2}C\d{3}.*)|(^\[TV\][A-Z]{2}\d{2}(D)[A-Z]?\d{3,4}.*)|^\[TV\] Samsung", + ModelNumber = @"(1\.0)|(AllShare1\.0)", + TranscodeSettings = new[] + { + new TranscodeSettings {Container = "mkv", MimeType = "x-mkv"}, + new TranscodeSettings {Container = "flac", TargetContainer = "mp3"}, + new TranscodeSettings {Container = "m4a", TargetContainer = "mp3"} + } + }; + + var profile3 = new DlnaProfile + { + Name = "Xbox 360 [Profile]", + ClientType = "DLNA", + ModelName = "Xbox 360", + TranscodeSettings = new[] + { + new TranscodeSettings {Container = "mkv", TargetContainer = "ts"}, + new TranscodeSettings {Container = "flac", TargetContainer = "mp3"}, + new TranscodeSettings {Container = "m4a", TargetContainer = "mp3"} + } + }; + + var profile4 = new DlnaProfile + { + Name = "Xbox One [Profile]", + ModelName = "Xbox One", + ClientType = "DLNA", + FriendlyName = "Xbox-SystemOS", + TranscodeSettings = new[] + { + new TranscodeSettings {Container = "mkv", TargetContainer = "ts"}, + new TranscodeSettings {Container = "flac", TargetContainer = "mp3"}, + new TranscodeSettings {Container = "m4a", TargetContainer = "mp3"} + } + }; + + var profile5 = new DlnaProfile + { + Name = "Sony Bravia TV (2012)", + ClientType = "TV", + FriendlyName = @"BRAVIA KDL-\d{2}[A-Z]X\d5(\d|G).*", + TranscodeSettings = TranscodeSettings.GetDefaultTranscodingSettings() + }; + + //WDTV does not need any transcoding of the formats we support statically + var profile6 = new DlnaProfile + { + Name = "WDTV Live [Profile]", + ClientType = "DLNA", + ModelName = "WD TV HD Live", + TranscodeSettings = new TranscodeSettings[] { } + }; + + var profile7 = new DlnaProfile + { + //Linksys DMA2100us does not need any transcoding of the formats we support statically + Name = "Linksys DMA2100 [Profile]", + ClientType = "DLNA", + ModelName = "DMA2100us", + TranscodeSettings = new TranscodeSettings[] { } + }; + + return new[] + { + profile0, + profile1, + profile2, + profile3, + profile4, + profile5, + profile6, + profile7 + }; + } + } +} diff --git a/MediaBrowser.Dlna/PlayTo/Configuration/PluginConfiguration.cs b/MediaBrowser.Dlna/PlayTo/Configuration/PluginConfiguration.cs deleted file mode 100644 index 1bd8781bb..000000000 --- a/MediaBrowser.Dlna/PlayTo/Configuration/PluginConfiguration.cs +++ /dev/null @@ -1,119 +0,0 @@ -namespace MediaBrowser.Dlna.PlayTo.Configuration -{ - public class PlayToConfiguration - { - private static readonly string[] _supportedStaticFormats = { "mp3", "flac", "m4a", "wma", "avi", "mp4", "mkv", "ts" }; - public static string[] SupportedStaticFormats - { - get - { - return _supportedStaticFormats; - } - } - - private static readonly DlnaProfile[] _profiles = GetDefaultProfiles(); - public static DlnaProfile[] Profiles - { - get - { - return _profiles; - } - } - - private static DlnaProfile[] GetDefaultProfiles() - { - var profile0 = new DlnaProfile - { - Name = "Samsung TV (B Series) [Profile]", - ClientType = "DLNA", - FriendlyName = "^TV$", - ModelNumber = @"1\.0", - ModelName = "Samsung DTV DMR", - TranscodeSettings = TranscodeSettings.GetDefaultTranscodingSettings() - }; - - var profile1 = new DlnaProfile - { - Name = "Samsung TV (E/F-series) [Profile]", - ClientType = "DLNA", - FriendlyName = @"(^\[TV\][A-Z]{2}\d{2}(E|F)[A-Z]?\d{3,4}.*)|^\[TV\] Samsung", - ModelNumber = @"(1\.0)|(AllShare1\.0)", - TranscodeSettings = TranscodeSettings.GetDefaultTranscodingSettings() - }; - - var profile2 = new DlnaProfile - { - Name = "Samsung TV (C/D-series) [Profile]", - ClientType = "DLNA", - FriendlyName = @"(^TV-\d{2}C\d{3}.*)|(^\[TV\][A-Z]{2}\d{2}(D)[A-Z]?\d{3,4}.*)|^\[TV\] Samsung", - ModelNumber = @"(1\.0)|(AllShare1\.0)", - TranscodeSettings = TranscodeSettings.GetDefaultTranscodingSettings() - }; - - var profile3 = new DlnaProfile - { - Name = "Xbox 360 [Profile]", - ClientType = "DLNA", - ModelName = "Xbox 360", - TranscodeSettings = new[] - { - new TranscodeSettings {Container = "mkv", TargetContainer = "ts"}, - new TranscodeSettings {Container = "flac", TargetContainer = "mp3"}, - new TranscodeSettings {Container = "m4a", TargetContainer = "mp3"} - } - }; - - var profile4 = new DlnaProfile - { - Name = "Xbox One [Profile]", - ModelName = "Xbox One", - ClientType = "DLNA", - FriendlyName = "Xbox-SystemOS", - TranscodeSettings = new[] - { - new TranscodeSettings {Container = "mkv", TargetContainer = "ts"}, - new TranscodeSettings {Container = "flac", TargetContainer = "mp3"}, - new TranscodeSettings {Container = "m4a", TargetContainer = "mp3"} - } - }; - - var profile5 = new DlnaProfile - { - Name = "Sony Bravia TV (2012)", - ClientType = "TV", - FriendlyName = @"BRAVIA KDL-\d{2}[A-Z]X\d5(\d|G).*", - TranscodeSettings = TranscodeSettings.GetDefaultTranscodingSettings() - }; - - //WDTV does not need any transcoding of the formats we support statically - var profile6 = new DlnaProfile - { - Name = "WDTV Live [Profile]", - ClientType = "DLNA", - ModelName = "WD TV HD Live", - TranscodeSettings = new TranscodeSettings[] { } - }; - - var profile7 = new DlnaProfile - { - //Linksys DMA2100us does not need any transcoding of the formats we support statically - Name = "Linksys DMA2100 [Profile]", - ClientType = "DLNA", - ModelName = "DMA2100us", - TranscodeSettings = new TranscodeSettings[] { } - }; - - return new[] - { - profile0, - profile1, - profile2, - profile3, - profile4, - profile5, - profile6, - profile7 - }; - } - } -} diff --git a/MediaBrowser.Dlna/PlayTo/Configuration/TranscodeSetting.cs b/MediaBrowser.Dlna/PlayTo/Configuration/TranscodeSetting.cs index ddf6f2187..4713dc385 100644 --- a/MediaBrowser.Dlna/PlayTo/Configuration/TranscodeSetting.cs +++ b/MediaBrowser.Dlna/PlayTo/Configuration/TranscodeSetting.cs @@ -20,7 +20,13 @@ namespace MediaBrowser.Dlna.PlayTo.Configuration /// The target container. /// public string TargetContainer { get; set; } - + + /// + /// Gets or sets the Mimetype to enforce + /// + /// + /// The MimeType. + /// public string MimeType { get; set; } /// diff --git a/MediaBrowser.Dlna/PlayTo/PlaylistItem.cs b/MediaBrowser.Dlna/PlayTo/PlaylistItem.cs index d2d04c4a8..6523eb9f5 100644 --- a/MediaBrowser.Dlna/PlayTo/PlaylistItem.cs +++ b/MediaBrowser.Dlna/PlayTo/PlaylistItem.cs @@ -16,6 +16,8 @@ namespace MediaBrowser.Dlna.PlayTo public string FileFormat { get; set; } + public string MimeType { get; set; } + public int PlayState { get; set; } public string StreamUrl { get; set; } @@ -51,10 +53,21 @@ namespace MediaBrowser.Dlna.PlayTo { if (string.IsNullOrWhiteSpace(transcodeSetting.Container)) continue; - if (path.EndsWith(transcodeSetting.Container)) + if (path.EndsWith(transcodeSetting.Container) && !string.IsNullOrWhiteSpace(transcodeSetting.TargetContainer)) { playlistItem.Transcode = true; playlistItem.FileFormat = transcodeSetting.TargetContainer; + + if (string.IsNullOrWhiteSpace(transcodeSetting.MimeType)) + playlistItem.MimeType = transcodeSetting.MimeType; + + return playlistItem; + } + if (path.EndsWith(transcodeSetting.Container) && !string.IsNullOrWhiteSpace(transcodeSetting.MimeType)) + { + playlistItem.Transcode = false; + playlistItem.FileFormat = transcodeSetting.Container; + playlistItem.MimeType = transcodeSetting.MimeType; return playlistItem; } } diff --git a/MediaBrowser.Dlna/PlayTo/StreamHelper.cs b/MediaBrowser.Dlna/PlayTo/StreamHelper.cs index eed0bb7d7..3492ed182 100644 --- a/MediaBrowser.Dlna/PlayTo/StreamHelper.cs +++ b/MediaBrowser.Dlna/PlayTo/StreamHelper.cs @@ -96,9 +96,12 @@ namespace MediaBrowser.Dlna.PlayTo /// The url to send to the device internal static string GetVideoUrl(DeviceProperties deviceProperties, PlaylistItem item, List streams, string serverAddress) { + string dlnaCommand = string.Empty; if (!item.Transcode) - return string.Format("{0}/Videos/{1}/stream.{2}?Static=True", serverAddress, item.ItemId, item.FileFormat); - + { + dlnaCommand = BuildDlnaUrl(deviceProperties.UUID, !item.Transcode, null, null, null, null, null, null, null, null, null, null, item.MimeType); + return string.Format("{0}/Videos/{1}/stream.{2}?{3}", serverAddress, item.ItemId, item.FileFormat, dlnaCommand); + } var videostream = streams.Where(m => m.Type == MediaStreamType.Video).OrderBy(m => m.IsDefault).FirstOrDefault(); var audiostream = streams.Where(m => m.Type == MediaStreamType.Audio).OrderBy(m => m.IsDefault).FirstOrDefault(); @@ -117,7 +120,7 @@ namespace MediaBrowser.Dlna.PlayTo audioChannels = 2; } - string dlnaCommand = BuildDlnaUrl(deviceProperties.UUID, videoCodec, audioCodec, null, null, videoBitrate, audioChannels, audioBitrate, item.StartPositionTicks, "baseline", "3"); + dlnaCommand = BuildDlnaUrl(deviceProperties.UUID, !item.Transcode, videoCodec, audioCodec, null, null, videoBitrate, audioChannels, audioBitrate, item.StartPositionTicks, "baseline", "3", item.MimeType); return string.Format("{0}/Videos/{1}/stream.{2}?{3}", serverAddress, item.ItemId, item.FileFormat, dlnaCommand); } @@ -162,12 +165,12 @@ namespace MediaBrowser.Dlna.PlayTo /// /// Builds the dlna URL. /// - private static string BuildDlnaUrl(string deviceID, VideoCodecs? videoCodec, AudioCodecs? audioCodec, int? subtitleIndex, int? audiostreamIndex, int? videoBitrate, int? audiochannels, int? audioBitrate, long? startPositionTicks, string profile, string videoLevel) + private static string BuildDlnaUrl(string deviceID, bool isStatic, VideoCodecs? videoCodec, AudioCodecs? audioCodec, int? subtitleIndex, int? audiostreamIndex, int? videoBitrate, int? audiochannels, int? audioBitrate, long? startPositionTicks, string profile, string videoLevel, string mimeType) { var usCulture = new CultureInfo("en-US"); var dlnaparam = string.Format("Params={0};", deviceID); - + dlnaparam += isStatic ? "true;" : "false;"; dlnaparam += videoCodec.HasValue ? videoCodec.Value + ";" : ";"; dlnaparam += audioCodec.HasValue ? audioCodec.Value + ";" : ";"; dlnaparam += audiostreamIndex.HasValue ? audiostreamIndex.Value.ToString(usCulture) + ";" : ";"; @@ -178,6 +181,7 @@ namespace MediaBrowser.Dlna.PlayTo dlnaparam += startPositionTicks.HasValue ? startPositionTicks.Value.ToString(usCulture) + ";" : ";"; dlnaparam += profile + ";"; dlnaparam += videoLevel + ";"; + dlnaparam += mimeType + ";"; return dlnaparam; } -- cgit v1.2.3