|
@@ -1,29 +1,51 @@
|
|
|
-using MediaBrowser.Controller.Dlna;
|
|
|
+using MediaBrowser.Common.Configuration;
|
|
|
+using MediaBrowser.Common.IO;
|
|
|
+using MediaBrowser.Controller.Dlna;
|
|
|
+using MediaBrowser.Model.Serialization;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
namespace MediaBrowser.Dlna
|
|
|
{
|
|
|
public class DlnaManager : IDlnaManager
|
|
|
{
|
|
|
- public IEnumerable<DlnaProfile> GetProfiles()
|
|
|
+ private IApplicationPaths _appPaths;
|
|
|
+ private readonly IXmlSerializer _xmlSerializer;
|
|
|
+ private readonly IFileSystem _fileSystem;
|
|
|
+
|
|
|
+ public DlnaManager(IXmlSerializer xmlSerializer, IFileSystem fileSystem)
|
|
|
{
|
|
|
- var list = new List<DlnaProfile>();
|
|
|
+ _xmlSerializer = xmlSerializer;
|
|
|
+ _fileSystem = fileSystem;
|
|
|
+
|
|
|
+ //GetProfiles();
|
|
|
+ }
|
|
|
|
|
|
- list.Add(new DlnaProfile
|
|
|
+ public IEnumerable<DeviceProfile> GetProfiles()
|
|
|
+ {
|
|
|
+ var list = new List<DeviceProfile>();
|
|
|
+
|
|
|
+ #region Samsung
|
|
|
+
|
|
|
+ list.Add(new DeviceProfile
|
|
|
{
|
|
|
Name = "Samsung TV (B Series)",
|
|
|
ClientType = "DLNA",
|
|
|
- FriendlyName = "^TV$",
|
|
|
- ModelNumber = @"1\.0",
|
|
|
- ModelName = "Samsung DTV DMR",
|
|
|
+
|
|
|
+ Identification = new DeviceIdentification
|
|
|
+ {
|
|
|
+ FriendlyName = "^TV$",
|
|
|
+ ModelNumber = @"1\.0",
|
|
|
+ ModelName = "Samsung DTV DMR"
|
|
|
+ },
|
|
|
|
|
|
TranscodingProfiles = new[]
|
|
|
{
|
|
|
new TranscodingProfile
|
|
|
{
|
|
|
Container = "mp3",
|
|
|
- Type = DlnaProfileType.Audio
|
|
|
+ Type = DlnaProfileType.Audio,
|
|
|
},
|
|
|
new TranscodingProfile
|
|
|
{
|
|
@@ -37,7 +59,7 @@ namespace MediaBrowser.Dlna
|
|
|
new DirectPlayProfile
|
|
|
{
|
|
|
Containers = new[]{"mp3"},
|
|
|
- Type = DlnaProfileType.Audio
|
|
|
+ Type = DlnaProfileType.Audio,
|
|
|
},
|
|
|
new DirectPlayProfile
|
|
|
{
|
|
@@ -57,14 +79,20 @@ namespace MediaBrowser.Dlna
|
|
|
Type = DlnaProfileType.Video
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
});
|
|
|
|
|
|
- list.Add(new DlnaProfile
|
|
|
+ list.Add(new DeviceProfile
|
|
|
{
|
|
|
Name = "Samsung TV (E/F-series)",
|
|
|
ClientType = "DLNA",
|
|
|
- FriendlyName = @"(^\[TV\][A-Z]{2}\d{2}(E|F)[A-Z]?\d{3,4}.*)|^\[TV\] Samsung",
|
|
|
- ModelNumber = @"(1\.0)|(AllShare1\.0)",
|
|
|
+
|
|
|
+ Identification = new DeviceIdentification
|
|
|
+ {
|
|
|
+ FriendlyName = @"(^\[TV\][A-Z]{2}\d{2}(E|F)[A-Z]?\d{3,4}.*)|^\[TV\] Samsung|(^\[TV\]Samsung [A-Z]{2}\d{2}(E|F)[A-Z]?\d{3,4}.*)",
|
|
|
+ ModelNumber = @"(1\.0)|(AllShare1\.0)"
|
|
|
+ },
|
|
|
|
|
|
TranscodingProfiles = new[]
|
|
|
{
|
|
@@ -107,12 +135,17 @@ namespace MediaBrowser.Dlna
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- list.Add(new DlnaProfile
|
|
|
+ list.Add(new DeviceProfile
|
|
|
{
|
|
|
Name = "Samsung TV (C/D-series)",
|
|
|
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)",
|
|
|
+
|
|
|
+ Identification = new DeviceIdentification
|
|
|
+ {
|
|
|
+ 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)"
|
|
|
+ },
|
|
|
+
|
|
|
TranscodingProfiles = new[]
|
|
|
{
|
|
|
new TranscodingProfile
|
|
@@ -154,11 +187,20 @@ namespace MediaBrowser.Dlna
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- list.Add(new DlnaProfile
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region Xbox
|
|
|
+
|
|
|
+ list.Add(new DeviceProfile
|
|
|
{
|
|
|
Name = "Xbox 360",
|
|
|
ClientType = "DLNA",
|
|
|
- ModelName = "Xbox 360",
|
|
|
+
|
|
|
+ Identification = new DeviceIdentification
|
|
|
+ {
|
|
|
+ ModelName = "Xbox 360"
|
|
|
+ },
|
|
|
+
|
|
|
TranscodingProfiles = new[]
|
|
|
{
|
|
|
new TranscodingProfile
|
|
@@ -183,18 +225,23 @@ namespace MediaBrowser.Dlna
|
|
|
new DirectPlayProfile
|
|
|
{
|
|
|
Containers = new[]{"avi"},
|
|
|
- MimeType = "x-msvideo",
|
|
|
+ MimeType = "avi",
|
|
|
Type = DlnaProfileType.Video
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- list.Add(new DlnaProfile
|
|
|
+ list.Add(new DeviceProfile
|
|
|
{
|
|
|
Name = "Xbox One",
|
|
|
- ModelName = "Xbox One",
|
|
|
ClientType = "DLNA",
|
|
|
- FriendlyName = "Xbox-SystemOS",
|
|
|
+
|
|
|
+ Identification = new DeviceIdentification
|
|
|
+ {
|
|
|
+ ModelName = "Xbox One",
|
|
|
+ FriendlyName = "Xbox-SystemOS"
|
|
|
+ },
|
|
|
+
|
|
|
TranscodingProfiles = new[]
|
|
|
{
|
|
|
new TranscodingProfile
|
|
@@ -225,11 +272,159 @@ namespace MediaBrowser.Dlna
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- list.Add(new DlnaProfile
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region Sony
|
|
|
+
|
|
|
+ list.Add(new DeviceProfile
|
|
|
{
|
|
|
Name = "Sony Bravia (2012)",
|
|
|
ClientType = "DLNA",
|
|
|
- FriendlyName = @"BRAVIA KDL-\d{2}[A-Z]X\d5(\d|G).*",
|
|
|
+
|
|
|
+ Identification = new DeviceIdentification
|
|
|
+ {
|
|
|
+ FriendlyName = @"BRAVIA KDL-\d{2}[A-Z]X\d5(\d|G).*"
|
|
|
+ },
|
|
|
+
|
|
|
+ TranscodingProfiles = new[]
|
|
|
+ {
|
|
|
+ new TranscodingProfile
|
|
|
+ {
|
|
|
+ Container = "mp3",
|
|
|
+ Type = DlnaProfileType.Audio
|
|
|
+ },
|
|
|
+ new TranscodingProfile
|
|
|
+ {
|
|
|
+ Container = "ts",
|
|
|
+ Type = DlnaProfileType.Video
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ DirectPlayProfiles = new[]
|
|
|
+ {
|
|
|
+ new DirectPlayProfile
|
|
|
+ {
|
|
|
+ Containers = new[]{"mp3"},
|
|
|
+ Type = DlnaProfileType.Audio
|
|
|
+ },
|
|
|
+ new DirectPlayProfile
|
|
|
+ {
|
|
|
+ Containers = new[]{"avi"},
|
|
|
+ Type = DlnaProfileType.Video,
|
|
|
+ MimeType = "avi"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ list.Add(new DeviceProfile
|
|
|
+ {
|
|
|
+ Name = "Sony Bravia (2013)",
|
|
|
+ ClientType = "DLNA",
|
|
|
+
|
|
|
+ Identification = new DeviceIdentification
|
|
|
+ {
|
|
|
+ FriendlyName = @"BRAVIA (KDL-\d{2}W[689]\d{2}A.*)|(KD-\d{2}X9\d{3}A.*)"
|
|
|
+ },
|
|
|
+
|
|
|
+ TranscodingProfiles = new[]
|
|
|
+ {
|
|
|
+ new TranscodingProfile
|
|
|
+ {
|
|
|
+ Container = "mp3",
|
|
|
+ Type = DlnaProfileType.Audio
|
|
|
+ },
|
|
|
+ new TranscodingProfile
|
|
|
+ {
|
|
|
+ Container = "ts",
|
|
|
+ Type = DlnaProfileType.Video,
|
|
|
+ MimeType = "mpeg"
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ DirectPlayProfiles = new[]
|
|
|
+ {
|
|
|
+ new DirectPlayProfile
|
|
|
+ {
|
|
|
+ Containers = new[]{"mp3"},
|
|
|
+ Type = DlnaProfileType.Audio
|
|
|
+ },
|
|
|
+ new DirectPlayProfile
|
|
|
+ {
|
|
|
+ Containers = new[]{"wma"},
|
|
|
+ Type = DlnaProfileType.Audio,
|
|
|
+ MimeType = "x-ms-wma"
|
|
|
+ },
|
|
|
+ new DirectPlayProfile
|
|
|
+ {
|
|
|
+ Containers = new[]{"avi"},
|
|
|
+ Type = DlnaProfileType.Video,
|
|
|
+ MimeType = "avi"
|
|
|
+ },
|
|
|
+ new DirectPlayProfile
|
|
|
+ {
|
|
|
+ Containers = new[]{"mp4"},
|
|
|
+ Type = DlnaProfileType.Video,
|
|
|
+ MimeType = "mp4"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region Panasonic
|
|
|
+
|
|
|
+ list.Add(new DeviceProfile
|
|
|
+ {
|
|
|
+ //Panasonic Viera (2011|2012) Without AVI Support
|
|
|
+ Name = "Panasonic Viera E/S/ST/VT (2011)",
|
|
|
+ ClientType = "DLNA",
|
|
|
+
|
|
|
+ Identification = new DeviceIdentification
|
|
|
+ {
|
|
|
+ FriendlyName = @"(VIERA (E|S)T?(3|5)0?.*)|(VIERA VT30.*)",
|
|
|
+ Manufacturer = "Panasonic"
|
|
|
+ },
|
|
|
+
|
|
|
+ TranscodingProfiles = new[]
|
|
|
+ {
|
|
|
+ new TranscodingProfile
|
|
|
+ {
|
|
|
+ Container = "mp3",
|
|
|
+ Type = DlnaProfileType.Audio
|
|
|
+ },
|
|
|
+ new TranscodingProfile
|
|
|
+ {
|
|
|
+ Container = "ts",
|
|
|
+ Type = DlnaProfileType.Video
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ DirectPlayProfiles = new[]
|
|
|
+ {
|
|
|
+ new DirectPlayProfile
|
|
|
+ {
|
|
|
+ Containers = new[]{"mp3"},
|
|
|
+ Type = DlnaProfileType.Audio
|
|
|
+ },
|
|
|
+ new DirectPlayProfile
|
|
|
+ {
|
|
|
+ Containers = new[]{"mkv"},
|
|
|
+ Type = DlnaProfileType.Video
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ list.Add(new DeviceProfile
|
|
|
+ {
|
|
|
+ //Panasonic Viera (2011|2012) With AVI Support
|
|
|
+ Name = "Panasonic Viera G/GT/DT/UT/VT (2011/2012)",
|
|
|
+ ClientType = "DLNA",
|
|
|
+
|
|
|
+ Identification = new DeviceIdentification
|
|
|
+ {
|
|
|
+ FriendlyName = @"(VIERA (G|D|U)T?(3|5)0?.*)|(VIERA VT50.*)",
|
|
|
+ Manufacturer = "Panasonic"
|
|
|
+ },
|
|
|
|
|
|
TranscodingProfiles = new[]
|
|
|
{
|
|
@@ -252,21 +447,68 @@ namespace MediaBrowser.Dlna
|
|
|
Containers = new[]{"mp3"},
|
|
|
Type = DlnaProfileType.Audio
|
|
|
},
|
|
|
+ new DirectPlayProfile
|
|
|
+ {
|
|
|
+ Containers = new[]{"mkv"},
|
|
|
+ Type = DlnaProfileType.Video
|
|
|
+ },
|
|
|
+ new DirectPlayProfile
|
|
|
+ {
|
|
|
+ Containers = new[]{"avi"},
|
|
|
+ Type = DlnaProfileType.Video ,
|
|
|
+ MimeType="divx"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ //WDTV does not need any transcoding of the formats we support statically
|
|
|
+ list.Add(new DeviceProfile
|
|
|
+ {
|
|
|
+ Name = "Philips (2010-)",
|
|
|
+ ClientType = "DLNA",
|
|
|
+
|
|
|
+ Identification = new DeviceIdentification
|
|
|
+ {
|
|
|
+ FriendlyName = ".*PHILIPS.*",
|
|
|
+ ModelName = "WD TV HD Live"
|
|
|
+ },
|
|
|
+
|
|
|
+ DirectPlayProfiles = new[]
|
|
|
+ {
|
|
|
+ new DirectPlayProfile
|
|
|
+ {
|
|
|
+ Containers = new[]{"mp3", "wma"},
|
|
|
+ Type = DlnaProfileType.Audio
|
|
|
+ },
|
|
|
+
|
|
|
new DirectPlayProfile
|
|
|
{
|
|
|
Containers = new[]{"avi"},
|
|
|
Type = DlnaProfileType.Video,
|
|
|
MimeType = "avi"
|
|
|
+ },
|
|
|
+
|
|
|
+ new DirectPlayProfile
|
|
|
+ {
|
|
|
+ Containers = new[]{"mkv"},
|
|
|
+ Type = DlnaProfileType.Video,
|
|
|
+ MimeType = "x-matroska"
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//WDTV does not need any transcoding of the formats we support statically
|
|
|
- list.Add(new DlnaProfile
|
|
|
+ list.Add(new DeviceProfile
|
|
|
{
|
|
|
Name = "WDTV Live",
|
|
|
ClientType = "DLNA",
|
|
|
- ModelName = "WD TV HD Live",
|
|
|
+
|
|
|
+ Identification = new DeviceIdentification
|
|
|
+ {
|
|
|
+ ModelName = "WD TV HD Live"
|
|
|
+ },
|
|
|
|
|
|
DirectPlayProfiles = new[]
|
|
|
{
|
|
@@ -284,12 +526,16 @@ namespace MediaBrowser.Dlna
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- list.Add(new DlnaProfile
|
|
|
+ list.Add(new DeviceProfile
|
|
|
{
|
|
|
//Linksys DMA2100us does not need any transcoding of the formats we support statically
|
|
|
Name = "Linksys DMA2100",
|
|
|
ClientType = "DLNA",
|
|
|
- ModelName = "DMA2100us",
|
|
|
+
|
|
|
+ Identification = new DeviceIdentification
|
|
|
+ {
|
|
|
+ ModelName = "DMA2100us"
|
|
|
+ },
|
|
|
|
|
|
DirectPlayProfiles = new[]
|
|
|
{
|
|
@@ -307,12 +553,38 @@ namespace MediaBrowser.Dlna
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ list.Add(new DeviceProfile
|
|
|
+ {
|
|
|
+ Name = "Denon AVR",
|
|
|
+ ClientType = "DLNA",
|
|
|
+
|
|
|
+ Identification = new DeviceIdentification
|
|
|
+ {
|
|
|
+ FriendlyName = @"Denon:\[AVR:.*",
|
|
|
+ Manufacturer = "Denon"
|
|
|
+ },
|
|
|
+
|
|
|
+ DirectPlayProfiles = new[]
|
|
|
+ {
|
|
|
+ new DirectPlayProfile
|
|
|
+ {
|
|
|
+ Containers = new[]{"mp3", "flac", "m4a", "wma"},
|
|
|
+ Type = DlnaProfileType.Audio
|
|
|
+ },
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ foreach (var item in list)
|
|
|
+ {
|
|
|
+ //_xmlSerializer.SerializeToFile(item, "d:\\" + _fileSystem.GetValidFilename(item.Name));
|
|
|
+ }
|
|
|
+
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
- public DlnaProfile GetDefaultProfile()
|
|
|
+ public DeviceProfile GetDefaultProfile()
|
|
|
{
|
|
|
- return new DlnaProfile
|
|
|
+ return new DeviceProfile
|
|
|
{
|
|
|
TranscodingProfiles = new[]
|
|
|
{
|
|
@@ -345,32 +617,51 @@ namespace MediaBrowser.Dlna
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- public DlnaProfile GetProfile(string friendlyName, string modelName, string modelNumber)
|
|
|
+ public DeviceProfile GetProfile(DeviceIdentification deviceInfo)
|
|
|
+ {
|
|
|
+ return GetProfiles().FirstOrDefault(i => IsMatch(deviceInfo, i.Identification)) ??
|
|
|
+ GetDefaultProfile();
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool IsMatch(DeviceIdentification deviceInfo, DeviceIdentification profileInfo)
|
|
|
{
|
|
|
- foreach (var profile in GetProfiles())
|
|
|
+ if (!string.IsNullOrEmpty(profileInfo.FriendlyName))
|
|
|
{
|
|
|
- if (!string.IsNullOrEmpty(profile.FriendlyName))
|
|
|
- {
|
|
|
- if (!Regex.IsMatch(friendlyName, profile.FriendlyName))
|
|
|
- continue;
|
|
|
- }
|
|
|
+ if (!Regex.IsMatch(deviceInfo.FriendlyName, profileInfo.FriendlyName))
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
- if (!string.IsNullOrEmpty(profile.ModelNumber))
|
|
|
- {
|
|
|
- if (!Regex.IsMatch(modelNumber, profile.ModelNumber))
|
|
|
- continue;
|
|
|
- }
|
|
|
+ if (!string.IsNullOrEmpty(profileInfo.ModelNumber))
|
|
|
+ {
|
|
|
+ if (!Regex.IsMatch(deviceInfo.ModelNumber, profileInfo.ModelNumber))
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
- if (!string.IsNullOrEmpty(profile.ModelName))
|
|
|
- {
|
|
|
- if (!Regex.IsMatch(modelName, profile.ModelName))
|
|
|
- continue;
|
|
|
- }
|
|
|
+ if (!string.IsNullOrEmpty(profileInfo.ModelName))
|
|
|
+ {
|
|
|
+ if (!Regex.IsMatch(deviceInfo.ModelName, profileInfo.ModelName))
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
- return profile;
|
|
|
+ if (!string.IsNullOrEmpty(profileInfo.Manufacturer))
|
|
|
+ {
|
|
|
+ if (!Regex.IsMatch(deviceInfo.Manufacturer, profileInfo.Manufacturer))
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(profileInfo.ManufacturerUrl))
|
|
|
+ {
|
|
|
+ if (!Regex.IsMatch(deviceInfo.ManufacturerUrl, profileInfo.ManufacturerUrl))
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
+ if (!string.IsNullOrEmpty(profileInfo.SerialNumber))
|
|
|
+ {
|
|
|
+ if (!Regex.IsMatch(deviceInfo.SerialNumber, profileInfo.SerialNumber))
|
|
|
+ return false;
|
|
|
}
|
|
|
- return GetDefaultProfile();
|
|
|
+
|
|
|
+ return true;
|
|
|
}
|
|
|
}
|
|
|
}
|