jellyfin/MediaBrowser.Dlna/DlnaManager.cs

376 lines
12 KiB
C#
Raw Normal View History

2014-03-13 20:08:02 +01:00
using MediaBrowser.Controller.Dlna;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace MediaBrowser.Dlna
{
public class DlnaManager : IDlnaManager
{
public IEnumerable<DlnaProfile> GetProfiles()
{
2014-03-13 22:36:19 +01:00
var list = new List<DlnaProfile>();
list.Add(new DlnaProfile
2014-03-13 20:08:02 +01:00
{
2014-03-13 22:36:19 +01:00
Name = "Samsung TV (B Series)",
2014-03-13 20:08:02 +01:00
ClientType = "DLNA",
FriendlyName = "^TV$",
ModelNumber = @"1\.0",
ModelName = "Samsung DTV DMR",
TranscodingProfiles = new[]
{
new TranscodingProfile
{
Container = "mp3",
Type = DlnaProfileType.Audio
2014-03-14 15:27:32 +01:00
},
new TranscodingProfile
{
Container = "ts",
Type = DlnaProfileType.Video
2014-03-13 20:08:02 +01:00
}
},
DirectPlayProfiles = new[]
{
2014-03-14 15:27:32 +01:00
new DirectPlayProfile
{
Containers = new[]{"mp3"},
Type = DlnaProfileType.Audio
},
2014-03-13 20:08:02 +01:00
new DirectPlayProfile
{
Containers = new[]{"mkv"},
MimeType = "x-mkv",
Type = DlnaProfileType.Video
2014-03-13 22:36:19 +01:00
},
new DirectPlayProfile
{
Containers = new[]{"avi"},
MimeType = "x-msvideo",
Type = DlnaProfileType.Video
2014-03-14 15:27:32 +01:00
},
new DirectPlayProfile
{
Containers = new[]{"mp4"},
Type = DlnaProfileType.Video
2014-03-13 20:08:02 +01:00
}
}
2014-03-13 22:36:19 +01:00
});
2014-03-13 20:08:02 +01:00
2014-03-13 22:36:19 +01:00
list.Add(new DlnaProfile
2014-03-13 20:08:02 +01:00
{
2014-03-13 22:36:19 +01:00
Name = "Samsung TV (E/F-series)",
2014-03-13 20:08:02 +01:00
ClientType = "DLNA",
FriendlyName = @"(^\[TV\][A-Z]{2}\d{2}(E|F)[A-Z]?\d{3,4}.*)|^\[TV\] Samsung",
ModelNumber = @"(1\.0)|(AllShare1\.0)",
TranscodingProfiles = new[]
{
new TranscodingProfile
{
Container = "mp3",
Type = DlnaProfileType.Audio
2014-03-14 15:27:32 +01:00
},
new TranscodingProfile
{
Container = "ts",
Type = DlnaProfileType.Video
2014-03-13 20:08:02 +01:00
}
},
DirectPlayProfiles = new[]
{
2014-03-14 15:27:32 +01:00
new DirectPlayProfile
{
Containers = new[]{"mp3"},
Type = DlnaProfileType.Audio
},
2014-03-13 20:08:02 +01:00
new DirectPlayProfile
{
Containers = new[]{"mkv"},
MimeType = "x-mkv",
Type = DlnaProfileType.Video
2014-03-13 22:36:19 +01:00
},
new DirectPlayProfile
{
Containers = new[]{"avi"},
MimeType = "x-msvideo",
Type = DlnaProfileType.Video
2014-03-14 15:27:32 +01:00
},
new DirectPlayProfile
{
Containers = new[]{"mp4"},
Type = DlnaProfileType.Video
2014-03-13 20:08:02 +01:00
}
}
2014-03-13 22:36:19 +01:00
});
2014-03-13 20:08:02 +01:00
2014-03-13 22:36:19 +01:00
list.Add(new DlnaProfile
2014-03-13 20:08:02 +01:00
{
2014-03-13 22:36:19 +01:00
Name = "Samsung TV (C/D-series)",
2014-03-13 20:08:02 +01:00
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)",
TranscodingProfiles = new[]
{
new TranscodingProfile
{
Container = "mp3",
Type = DlnaProfileType.Audio
2014-03-14 15:27:32 +01:00
},
new TranscodingProfile
{
Container = "ts",
Type = DlnaProfileType.Video
2014-03-13 20:08:02 +01:00
}
},
DirectPlayProfiles = new[]
{
2014-03-14 15:27:32 +01:00
new DirectPlayProfile
{
Containers = new[]{"mp3"},
Type = DlnaProfileType.Audio
},
2014-03-13 20:08:02 +01:00
new DirectPlayProfile
{
Containers = new[]{"mkv"},
MimeType = "x-mkv",
Type = DlnaProfileType.Video
2014-03-13 22:36:19 +01:00
},
new DirectPlayProfile
{
Containers = new[]{"avi"},
MimeType = "x-msvideo",
Type = DlnaProfileType.Video
2014-03-14 15:27:32 +01:00
},
new DirectPlayProfile
{
Containers = new[]{"mp4"},
Type = DlnaProfileType.Video
2014-03-13 20:08:02 +01:00
}
}
2014-03-13 22:36:19 +01:00
});
2014-03-13 20:08:02 +01:00
2014-03-13 22:36:19 +01:00
list.Add(new DlnaProfile
2014-03-13 20:08:02 +01:00
{
2014-03-13 22:36:19 +01:00
Name = "Xbox 360",
2014-03-13 20:08:02 +01:00
ClientType = "DLNA",
ModelName = "Xbox 360",
TranscodingProfiles = new[]
{
new TranscodingProfile
{
Container = "mp3",
Type = DlnaProfileType.Audio
},
new TranscodingProfile
{
Container = "ts",
Type = DlnaProfileType.Video
}
2014-03-13 22:36:19 +01:00
},
DirectPlayProfiles = new[]
{
2014-03-14 15:27:32 +01:00
new DirectPlayProfile
{
Containers = new[]{"mp3"},
Type = DlnaProfileType.Audio
},
2014-03-13 22:36:19 +01:00
new DirectPlayProfile
{
Containers = new[]{"avi"},
MimeType = "x-msvideo",
Type = DlnaProfileType.Video
}
2014-03-13 20:08:02 +01:00
}
2014-03-13 22:36:19 +01:00
});
2014-03-13 20:08:02 +01:00
2014-03-13 22:36:19 +01:00
list.Add(new DlnaProfile
2014-03-13 20:08:02 +01:00
{
2014-03-13 22:36:19 +01:00
Name = "Xbox One",
2014-03-13 20:08:02 +01:00
ModelName = "Xbox One",
ClientType = "DLNA",
FriendlyName = "Xbox-SystemOS",
TranscodingProfiles = new[]
{
new TranscodingProfile
{
Container = "mp3",
Type = DlnaProfileType.Audio
},
new TranscodingProfile
{
Container = "ts",
Type = DlnaProfileType.Video
}
2014-03-13 22:36:19 +01:00
},
DirectPlayProfiles = new[]
{
2014-03-14 15:27:32 +01:00
new DirectPlayProfile
{
Containers = new[]{"mp3"},
Type = DlnaProfileType.Audio
},
2014-03-13 22:36:19 +01:00
new DirectPlayProfile
{
Containers = new[]{"avi"},
MimeType = "x-msvideo",
Type = DlnaProfileType.Video
}
2014-03-13 20:08:02 +01:00
}
2014-03-13 22:36:19 +01:00
});
2014-03-13 20:08:02 +01:00
2014-03-13 22:36:19 +01:00
list.Add(new DlnaProfile
{
2014-03-14 15:27:32 +01:00
Name = "Sony Bravia (2012)",
2014-03-13 22:36:19 +01:00
ClientType = "DLNA",
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[]
{
2014-03-14 15:27:32 +01:00
new DirectPlayProfile
{
Containers = new[]{"mp3"},
Type = DlnaProfileType.Audio
},
2014-03-13 22:36:19 +01:00
new DirectPlayProfile
{
Containers = new[]{"avi"},
Type = DlnaProfileType.Video,
MimeType = "avi"
}
}
});
2014-03-13 20:08:02 +01:00
//WDTV does not need any transcoding of the formats we support statically
2014-03-13 22:36:19 +01:00
list.Add(new DlnaProfile
2014-03-13 20:08:02 +01:00
{
2014-03-13 22:36:19 +01:00
Name = "WDTV Live",
2014-03-13 20:08:02 +01:00
ClientType = "DLNA",
2014-03-13 21:35:12 +01:00
ModelName = "WD TV HD Live",
DirectPlayProfiles = new[]
{
new DirectPlayProfile
{
Containers = new[]{"mp3", "flac", "m4a", "wma"},
Type = DlnaProfileType.Audio
},
new DirectPlayProfile
{
Containers = new[]{"avi", "mp4", "mkv", "ts"},
Type = DlnaProfileType.Video
}
}
2014-03-13 22:36:19 +01:00
});
2014-03-13 20:08:02 +01:00
2014-03-13 22:36:19 +01:00
list.Add(new DlnaProfile
2014-03-13 20:08:02 +01:00
{
//Linksys DMA2100us does not need any transcoding of the formats we support statically
2014-03-13 22:36:19 +01:00
Name = "Linksys DMA2100",
2014-03-13 20:08:02 +01:00
ClientType = "DLNA",
2014-03-13 22:36:19 +01:00
ModelName = "DMA2100us",
2014-03-13 20:08:02 +01:00
2014-03-13 22:36:19 +01:00
DirectPlayProfiles = new[]
{
new DirectPlayProfile
{
Containers = new[]{"mp3", "flac", "m4a", "wma"},
Type = DlnaProfileType.Audio
},
new DirectPlayProfile
{
Containers = new[]{"avi", "mp4", "mkv", "ts"},
Type = DlnaProfileType.Video
}
}
});
return list;
2014-03-13 20:08:02 +01:00
}
public DlnaProfile GetDefaultProfile()
{
2014-03-13 21:35:12 +01:00
return new DlnaProfile
{
TranscodingProfiles = new[]
{
new TranscodingProfile
{
Container = "mp3",
Type = DlnaProfileType.Audio
},
new TranscodingProfile
{
Container = "ts",
Type = DlnaProfileType.Video
}
2014-03-13 22:59:24 +01:00
},
DirectPlayProfiles = new[]
{
new DirectPlayProfile
{
2014-03-14 15:27:32 +01:00
Containers = new[]{"mp3", "wma"},
2014-03-13 22:59:24 +01:00
Type = DlnaProfileType.Audio
},
new DirectPlayProfile
{
Containers = new[]{"avi", "mp4"},
Type = DlnaProfileType.Video
}
2014-03-13 21:35:12 +01:00
}
};
2014-03-13 20:08:02 +01:00
}
public DlnaProfile GetProfile(string friendlyName, string modelName, string modelNumber)
{
foreach (var profile in GetProfiles())
{
if (!string.IsNullOrEmpty(profile.FriendlyName))
{
if (!Regex.IsMatch(friendlyName, profile.FriendlyName))
continue;
}
if (!string.IsNullOrEmpty(profile.ModelNumber))
{
if (!Regex.IsMatch(modelNumber, profile.ModelNumber))
continue;
}
if (!string.IsNullOrEmpty(profile.ModelName))
{
if (!Regex.IsMatch(modelName, profile.ModelName))
continue;
}
return profile;
}
return GetDefaultProfile();
}
}
2014-03-14 15:27:32 +01:00
}