diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-03-13 15:08:02 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-03-13 15:08:02 -0400 |
| commit | 0db3588529e1602f3f974cf3ffabc34ee5b4b214 (patch) | |
| tree | e79b97cbfa4e6aab9a5bf20c7adf57aeac34e401 /MediaBrowser.Dlna/PlayTo/Configuration | |
| parent | bd53ddc67ce56d1ea5a12ee5706a21ead8720c4f (diff) | |
expand on dlna profiles
Diffstat (limited to 'MediaBrowser.Dlna/PlayTo/Configuration')
3 files changed, 0 insertions, 337 deletions
diff --git a/MediaBrowser.Dlna/PlayTo/Configuration/DlnaProfile.cs b/MediaBrowser.Dlna/PlayTo/Configuration/DlnaProfile.cs deleted file mode 100644 index 70bda72387..0000000000 --- a/MediaBrowser.Dlna/PlayTo/Configuration/DlnaProfile.cs +++ /dev/null @@ -1,53 +0,0 @@ -namespace MediaBrowser.Dlna.PlayTo.Configuration -{ - public class DlnaProfile - { - /// <summary> - /// Gets or sets the name to be displayed. - /// </summary> - /// <value> - /// The name. - /// </value> - public string Name { get; set; } - - /// <summary> - /// Gets or sets the type of the client. - /// </summary> - /// <value> - /// The type of the client. - /// </value> - public string ClientType { get; set; } - - /// <summary> - /// Gets or sets the name of the friendly. - /// </summary> - /// <value> - /// The name of the friendly. - /// </value> - public string FriendlyName { get; set; } - - /// <summary> - /// Gets or sets the model number. - /// </summary> - /// <value> - /// The model number. - /// </value> - public string ModelNumber { get; set; } - - /// <summary> - /// Gets or sets the name of the model. - /// </summary> - /// <value> - /// The name of the model. - /// </value> - public string ModelName { get; set; } - - /// <summary> - /// Gets or sets the transcode settings. - /// </summary> - /// <value> - /// The transcode settings. - /// </value> - public TranscodeSetting[] TranscodeSettings { get; set; } - } -} diff --git a/MediaBrowser.Dlna/PlayTo/Configuration/PlayToConfiguration.cs b/MediaBrowser.Dlna/PlayTo/Configuration/PlayToConfiguration.cs deleted file mode 100644 index 927d8805b4..0000000000 --- a/MediaBrowser.Dlna/PlayTo/Configuration/PlayToConfiguration.cs +++ /dev/null @@ -1,198 +0,0 @@ -using MediaBrowser.Model.Logging; -using System; -using System.IO; -using System.Xml.Serialization; -namespace MediaBrowser.Dlna.PlayTo.Configuration -{ - public class PlayToConfiguration - { - [XmlIgnore] - public static PlayToConfiguration Instance - { - get; - private set; - } - - private static readonly string[] _supportedStaticFormats = { "mp3", "flac", "m4a", "wma", "avi", "mp4", "mkv", "ts" }; - - [XmlIgnore] - public string[] SupportedStaticFormats - { - get - { - return _supportedStaticFormats; - } - } - - public DlnaProfile[] Profiles - { get; set; } - - public 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 TranscodeSetting {Container = "mkv", MimeType = "x-mkv"}, - new TranscodeSetting {Container = "flac", TargetContainer = "mp3"}, - new TranscodeSetting {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 TranscodeSetting {Container = "mkv", MimeType = "x-mkv"}, - new TranscodeSetting {Container = "flac", TargetContainer = "mp3"}, - new TranscodeSetting {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 TranscodeSetting {Container = "mkv", MimeType = "x-mkv"}, - new TranscodeSetting {Container = "flac", TargetContainer = "mp3"}, - new TranscodeSetting {Container = "m4a", TargetContainer = "mp3"} - } - }; - - var profile3 = new DlnaProfile - { - Name = "Xbox 360 [Profile]", - ClientType = "DLNA", - ModelName = "Xbox 360", - TranscodeSettings = new[] - { - new TranscodeSetting {Container = "mkv", TargetContainer = "ts"}, - new TranscodeSetting {Container = "flac", TargetContainer = "mp3"}, - new TranscodeSetting {Container = "m4a", TargetContainer = "mp3"} - } - }; - - var profile4 = new DlnaProfile - { - Name = "Xbox One [Profile]", - ModelName = "Xbox One", - ClientType = "DLNA", - FriendlyName = "Xbox-SystemOS", - TranscodeSettings = new[] - { - new TranscodeSetting {Container = "mkv", TargetContainer = "ts"}, - new TranscodeSetting {Container = "flac", TargetContainer = "mp3"}, - new TranscodeSetting {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 = TranscodeSetting.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 TranscodeSetting[] { } - }; - - 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 TranscodeSetting[] { } - }; - - return new[] - { - profile0, - profile1, - profile2, - profile3, - profile4, - profile5, - profile6, - profile7 - }; - } - - public static void Load(string path, ILogger logger) - { - if (!File.Exists(path)) - { - Instance = CreateNewSettingsFile(path, logger); - - } - else - { - try - { - XmlSerializer deserializer = new XmlSerializer(typeof(PlayToConfiguration)); - using (var textReader = new StreamReader(path)) - { - var configuration = (PlayToConfiguration)deserializer.Deserialize(textReader); - Instance = configuration; - textReader.Close(); - } - } - catch (Exception e) - { - // Something went wrong with the loading of the file - // Maybe a user created a faulty config? - // Delete the file and use default settings - logger.ErrorException("Error loading PlayTo configuration", e); - Instance = CreateNewSettingsFile(path, logger); - } - } - } - - private static PlayToConfiguration CreateNewSettingsFile(string path, ILogger logger) - { - var defaultConfig = new PlayToConfiguration(); - defaultConfig.Profiles = PlayToConfiguration.GetDefaultProfiles(); - - try - { - if (File.Exists(path)) - File.Delete(path); - - XmlSerializer serializer = new XmlSerializer(typeof(PlayToConfiguration)); - - using (var fileStream = new StreamWriter(path)) - { - serializer.Serialize(fileStream, defaultConfig); - fileStream.Close(); - } - } - catch(Exception e) - { - //Something went wrong deleting or creating the file, Log and continue with the default profile unsaved - logger.ErrorException("Error creating default PlayTo configuration", e); - } - return defaultConfig; - } - - } -} diff --git a/MediaBrowser.Dlna/PlayTo/Configuration/TranscodeSetting.cs b/MediaBrowser.Dlna/PlayTo/Configuration/TranscodeSetting.cs deleted file mode 100644 index 83ff92154f..0000000000 --- a/MediaBrowser.Dlna/PlayTo/Configuration/TranscodeSetting.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Text.RegularExpressions; - - -namespace MediaBrowser.Dlna.PlayTo.Configuration -{ - public class TranscodeSetting - { - /// <summary> - /// Gets or sets the container. - /// </summary> - /// <value> - /// The container. - /// </value> - public string Container { get; set; } - - /// <summary> - /// Gets or sets the target container. - /// </summary> - /// <value> - /// The target container. - /// </value> - public string TargetContainer { get; set; } - - /// <summary> - /// Gets or sets the Mimetype to enforce - /// </summary> - /// <value> - /// The MimeType. - /// </value> - public string MimeType { get; set; } - - /// <summary> - /// The default transcoding settings - /// </summary> - private static readonly TranscodeSetting[] DefaultTranscodingSettings = - { - new TranscodeSetting { Container = "mkv", TargetContainer = "ts" }, - new TranscodeSetting { Container = "flac", TargetContainer = "mp3" }, - new TranscodeSetting { Container = "m4a", TargetContainer = "mp3" } - }; - - public static TranscodeSetting[] GetDefaultTranscodingSettings() - { - return DefaultTranscodingSettings; - } - - /// <summary> - /// Gets the profile settings. - /// </summary> - /// <param name="deviceProperties">The device properties.</param> - /// <returns>The TranscodeSettings for the device</returns> - public static TranscodeSetting[] GetProfileSettings(DeviceProperties deviceProperties) - { - foreach (var profile in PlayToConfiguration.Instance.Profiles) - { - if (!string.IsNullOrEmpty(profile.FriendlyName)) - { - if (!Regex.IsMatch(deviceProperties.Name, profile.FriendlyName)) - continue; - } - - if (!string.IsNullOrEmpty(profile.ModelNumber)) - { - if (!Regex.IsMatch(deviceProperties.ModelNumber, profile.ModelNumber)) - continue; - } - - if (!string.IsNullOrEmpty(profile.ModelName)) - { - if (!Regex.IsMatch(deviceProperties.ModelName, profile.ModelName)) - continue; - } - - deviceProperties.DisplayName = profile.Name; - deviceProperties.ClientType = profile.ClientType; - return profile.TranscodeSettings; - - } - - // Since we don't have alot of info about different devices we go down the safe - // route abd use the default transcoding settings if no profile exist - return GetDefaultTranscodingSettings(); - } - } -} |
