add more codecs to direct play profiles

This commit is contained in:
Luke Pulverenti 2014-03-22 16:50:28 -04:00
parent e2c0194744
commit 9b294c8bc9
6 changed files with 135 additions and 23 deletions

View File

@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace MediaBrowser.Controller.Dlna namespace MediaBrowser.Controller.Dlna
{ {
@ -6,12 +7,16 @@ namespace MediaBrowser.Controller.Dlna
{ {
public CodecType Type { get; set; } public CodecType Type { get; set; }
public List<ProfileCondition> Conditions { get; set; } public List<ProfileCondition> Conditions { get; set; }
public string[] Codecs { get; set; } public string Codec { get; set; }
public CodecProfile() public CodecProfile()
{ {
Conditions = new List<ProfileCondition>(); Conditions = new List<ProfileCondition>();
Codecs = new string[] { }; }
public List<string> GetCodecs()
{
return (Codec ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToList();
} }
} }

View File

@ -58,6 +58,8 @@ namespace MediaBrowser.Controller.Dlna
public MediaProfile[] MediaProfiles { get; set; } public MediaProfile[] MediaProfiles { get; set; }
public CodecProfile[] CodecProfiles { get; set; } public CodecProfile[] CodecProfiles { get; set; }
public int TimelineOffsetSeconds { get; set; }
public DeviceProfile() public DeviceProfile()
{ {
DirectPlayProfiles = new DirectPlayProfile[] { }; DirectPlayProfiles = new DirectPlayProfile[] { };

View File

@ -1,12 +1,13 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace MediaBrowser.Controller.Dlna namespace MediaBrowser.Controller.Dlna
{ {
public class DirectPlayProfile public class DirectPlayProfile
{ {
public string[] Containers { get; set; } public string[] Containers { get; set; }
public string[] AudioCodecs { get; set; } public string AudioCodec { get; set; }
public string[] VideoCodecs { get; set; } public string VideoCodec { get; set; }
public DlnaProfileType Type { get; set; } public DlnaProfileType Type { get; set; }
@ -16,10 +17,18 @@ namespace MediaBrowser.Controller.Dlna
{ {
Conditions = new List<ProfileCondition>(); Conditions = new List<ProfileCondition>();
AudioCodecs = new string[] { };
VideoCodecs = new string[] { };
Containers = new string[] { }; Containers = new string[] { };
} }
public List<string> GetAudioCodecs()
{
return (AudioCodec ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToList();
}
public List<string> GetVideoCodecs()
{
return (VideoCodec ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToList();
}
} }
public enum DlnaProfileType public enum DlnaProfileType

View File

@ -1,20 +1,26 @@
 using System.Collections.Generic;
using System.Linq;
namespace MediaBrowser.Controller.Dlna namespace MediaBrowser.Controller.Dlna
{ {
public class MediaProfile public class MediaProfile
{ {
public string Container { get; set; } public string Container { get; set; }
public string[] AudioCodecs { get; set; } public string AudioCodec { get; set; }
public string[] VideoCodecs { get; set; } public string VideoCodec { get; set; }
public DlnaProfileType Type { get; set; } public DlnaProfileType Type { get; set; }
public string OrgPn { get; set; } public string OrgPn { get; set; }
public string MimeType { get; set; } public string MimeType { get; set; }
public MediaProfile() public List<string> GetAudioCodecs()
{ {
AudioCodecs = new string[] { }; return (AudioCodec ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToList();
VideoCodecs = new string[] { }; }
public List<string> GetVideoCodecs()
{
return (VideoCodec ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToList();
} }
} }
} }

View File

@ -625,6 +625,8 @@ namespace MediaBrowser.Dlna
Name = "WDTV Live", Name = "WDTV Live",
ClientType = "DLNA", ClientType = "DLNA",
TimelineOffsetSeconds = 5,
Identification = new DeviceIdentification Identification = new DeviceIdentification
{ {
ModelName = "WD TV HD Live", ModelName = "WD TV HD Live",
@ -650,6 +652,11 @@ namespace MediaBrowser.Dlna
Type = DlnaProfileType.Video, Type = DlnaProfileType.Video,
VideoCodec = "h264", VideoCodec = "h264",
AudioCodec = "aac" AudioCodec = "aac"
},
new TranscodingProfile
{
Container = "jpeg",
Type = DlnaProfileType.Photo
} }
}, },
@ -657,20 +664,101 @@ namespace MediaBrowser.Dlna
{ {
new DirectPlayProfile new DirectPlayProfile
{ {
Containers = new[]{"mp3", "flac", "m4a", "wma", "aac"}, Containers = new[]{"avi"},
Type = DlnaProfileType.Video,
VideoCodec = "mpeg1video,mpeg2video,mpeg4,h264,vc1",
AudioCodec = "ac3,dca,mp2,mp3,pcm"
},
new DirectPlayProfile
{
Containers = new[]{"mpeg"},
Type = DlnaProfileType.Video,
VideoCodec = "mpeg1video,mpeg2video",
AudioCodec = "ac3,dca,mp2,mp3,pcm"
},
new DirectPlayProfile
{
Containers = new[]{"mkv"},
Type = DlnaProfileType.Video,
VideoCodec = "mpeg1video,mpeg2video,mpeg4,h264,vc1",
AudioCodec = "ac3,dca,aac,mp2,mp3,pcm"
},
new DirectPlayProfile
{
Containers = new[]{"ts"},
Type = DlnaProfileType.Video,
VideoCodec = "mpeg1video,mpeg2video,h264,vc1",
AudioCodec = "ac3,dca,mp2,mp3"
},
new DirectPlayProfile
{
Containers = new[]{"mp4", "mov"},
Type = DlnaProfileType.Video,
VideoCodec = "h264,mpeg4",
AudioCodec = "ac3,aac,mp2,mp3"
},
new DirectPlayProfile
{
Containers = new[]{"asf"},
Type = DlnaProfileType.Video,
VideoCodec = "vc1",
AudioCodec = "wmav2,wmapro"
},
new DirectPlayProfile
{
Containers = new[]{"asf"},
Type = DlnaProfileType.Video,
VideoCodec = "mpeg2video",
AudioCodec = "mp2,ac3"
},
new DirectPlayProfile
{
Containers = new[]{"mp3"},
AudioCodec = "mp2,mp3",
Type = DlnaProfileType.Audio Type = DlnaProfileType.Audio
}, },
new DirectPlayProfile new DirectPlayProfile
{ {
Containers = new[]{"avi", "mp4", "mkv", "ts"}, Containers = new[]{"mp4"},
Type = DlnaProfileType.Video AudioCodec = "mp4",
Type = DlnaProfileType.Audio
},
new DirectPlayProfile
{
Containers = new[]{"flac"},
AudioCodec = "flac",
Type = DlnaProfileType.Audio
},
new DirectPlayProfile
{
Containers = new[]{"asf"},
AudioCodec = "wmav2,wmapro,wmavoice",
Type = DlnaProfileType.Audio
},
new DirectPlayProfile
{
Containers = new[]{"ogg"},
AudioCodec = "vorbis",
Type = DlnaProfileType.Audio
}, },
new DirectPlayProfile new DirectPlayProfile
{ {
Type = DlnaProfileType.Photo, Type = DlnaProfileType.Photo,
Containers = new[]{"jpeg", "png", "gif", "bmp", "tiff"},
Conditions = new List<ProfileCondition> Conditions = new List<ProfileCondition>
{ {
new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.Width, Value = "1920"}, new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.Width, Value = "1920"},
@ -694,7 +782,7 @@ namespace MediaBrowser.Dlna
new CodecProfile new CodecProfile
{ {
Type = CodecType.VideoCodec, Type = CodecType.VideoCodec,
Codecs = new[]{"h264"}, Codec= "h264",
Conditions = new List<ProfileCondition> Conditions = new List<ProfileCondition>
{ {
@ -706,8 +794,8 @@ namespace MediaBrowser.Dlna
new CodecProfile new CodecProfile
{ {
Type = CodecType.VideoAudioCodec, Type = CodecType.VideoAudioCodec,
Codecs = new[]{"aac"}, Codec= "aac",
Conditions = new List<ProfileCondition> Conditions = new List<ProfileCondition>
{ {

View File

@ -233,20 +233,22 @@ namespace MediaBrowser.Dlna.PlayTo
} }
// Check video codec // Check video codec
if (profile.VideoCodecs.Length > 0) var videoCodecs = profile.GetVideoCodecs();
if (videoCodecs.Count > 0)
{ {
var videoCodec = videoStream == null ? null : videoStream.Codec; var videoCodec = videoStream == null ? null : videoStream.Codec;
if (string.IsNullOrWhiteSpace(videoCodec) || !profile.VideoCodecs.Contains(videoCodec, StringComparer.OrdinalIgnoreCase)) if (string.IsNullOrWhiteSpace(videoCodec) || !videoCodecs.Contains(videoCodec, StringComparer.OrdinalIgnoreCase))
{ {
return false; return false;
} }
} }
if (profile.AudioCodecs.Length > 0) var audioCodecs = profile.GetAudioCodecs();
if (audioCodecs.Count > 0)
{ {
// Check audio codecs // Check audio codecs
var audioCodec = audioStream == null ? null : audioStream.Codec; var audioCodec = audioStream == null ? null : audioStream.Codec;
if (string.IsNullOrWhiteSpace(audioCodec) || !profile.AudioCodecs.Contains(audioCodec, StringComparer.OrdinalIgnoreCase)) if (string.IsNullOrWhiteSpace(audioCodec) || !audioCodecs.Contains(audioCodec, StringComparer.OrdinalIgnoreCase))
{ {
return false; return false;
} }