mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 13:57:14 -04:00
added codec profiles
This commit is contained in:
parent
bd7486b952
commit
e2c0194744
51
MediaBrowser.Controller/Dlna/CodecProfile.cs
Normal file
51
MediaBrowser.Controller/Dlna/CodecProfile.cs
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Controller.Dlna
|
||||||
|
{
|
||||||
|
public class CodecProfile
|
||||||
|
{
|
||||||
|
public CodecType Type { get; set; }
|
||||||
|
public List<ProfileCondition> Conditions { get; set; }
|
||||||
|
public string[] Codecs { get; set; }
|
||||||
|
|
||||||
|
public CodecProfile()
|
||||||
|
{
|
||||||
|
Conditions = new List<ProfileCondition>();
|
||||||
|
Codecs = new string[] { };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum CodecType
|
||||||
|
{
|
||||||
|
VideoCodec = 0,
|
||||||
|
VideoAudioCodec = 1,
|
||||||
|
AudioCodec = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ProfileCondition
|
||||||
|
{
|
||||||
|
public ProfileConditionType Condition { get; set; }
|
||||||
|
public ProfileConditionValue Property { get; set; }
|
||||||
|
public string Value { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ProfileConditionType
|
||||||
|
{
|
||||||
|
Equals = 0,
|
||||||
|
NotEquals = 1,
|
||||||
|
LessThanEqual = 2,
|
||||||
|
GreaterThanEqual = 3
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ProfileConditionValue
|
||||||
|
{
|
||||||
|
AudioChannels,
|
||||||
|
AudioBitrate,
|
||||||
|
Filesize,
|
||||||
|
Width,
|
||||||
|
Height,
|
||||||
|
VideoBitrate,
|
||||||
|
VideoFramerate,
|
||||||
|
VideoLevel
|
||||||
|
}
|
||||||
|
}
|
@ -56,12 +56,14 @@ namespace MediaBrowser.Controller.Dlna
|
|||||||
public string ProtocolInfo { get; set; }
|
public string ProtocolInfo { get; set; }
|
||||||
|
|
||||||
public MediaProfile[] MediaProfiles { get; set; }
|
public MediaProfile[] MediaProfiles { get; set; }
|
||||||
|
public CodecProfile[] CodecProfiles { get; set; }
|
||||||
|
|
||||||
public DeviceProfile()
|
public DeviceProfile()
|
||||||
{
|
{
|
||||||
DirectPlayProfiles = new DirectPlayProfile[] { };
|
DirectPlayProfiles = new DirectPlayProfile[] { };
|
||||||
TranscodingProfiles = new TranscodingProfile[] { };
|
TranscodingProfiles = new TranscodingProfile[] { };
|
||||||
MediaProfiles = new MediaProfile[] { };
|
MediaProfiles = new MediaProfile[] { };
|
||||||
|
CodecProfiles = new CodecProfile[] { };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,37 +22,10 @@ namespace MediaBrowser.Controller.Dlna
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ProfileCondition
|
|
||||||
{
|
|
||||||
public ProfileConditionType Condition { get; set; }
|
|
||||||
public ProfileConditionValue Property { get; set; }
|
|
||||||
public string Value { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum DlnaProfileType
|
public enum DlnaProfileType
|
||||||
{
|
{
|
||||||
Audio = 0,
|
Audio = 0,
|
||||||
Video = 1,
|
Video = 1,
|
||||||
Photo = 2
|
Photo = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ProfileConditionType
|
|
||||||
{
|
|
||||||
Equals = 0,
|
|
||||||
NotEquals = 1,
|
|
||||||
LessThanEqual = 2,
|
|
||||||
GreaterThanEqual = 3
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ProfileConditionValue
|
|
||||||
{
|
|
||||||
AudioChannels,
|
|
||||||
AudioBitrate,
|
|
||||||
Filesize,
|
|
||||||
VideoWidth,
|
|
||||||
VideoHeight,
|
|
||||||
VideoBitrate,
|
|
||||||
VideoFramerate,
|
|
||||||
VideoLevel
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -78,6 +78,7 @@
|
|||||||
<Compile Include="Channels\Channel.cs" />
|
<Compile Include="Channels\Channel.cs" />
|
||||||
<Compile Include="Collections\CollectionCreationOptions.cs" />
|
<Compile Include="Collections\CollectionCreationOptions.cs" />
|
||||||
<Compile Include="Collections\ICollectionManager.cs" />
|
<Compile Include="Collections\ICollectionManager.cs" />
|
||||||
|
<Compile Include="Dlna\CodecProfile.cs" />
|
||||||
<Compile Include="Dlna\DeviceIdentification.cs" />
|
<Compile Include="Dlna\DeviceIdentification.cs" />
|
||||||
<Compile Include="Dlna\DirectPlayProfile.cs" />
|
<Compile Include="Dlna\DirectPlayProfile.cs" />
|
||||||
<Compile Include="Dlna\IDlnaManager.cs" />
|
<Compile Include="Dlna\IDlnaManager.cs" />
|
||||||
|
@ -657,7 +657,7 @@ namespace MediaBrowser.Dlna
|
|||||||
{
|
{
|
||||||
new DirectPlayProfile
|
new DirectPlayProfile
|
||||||
{
|
{
|
||||||
Containers = new[]{"mp3", "flac", "m4a", "wma"},
|
Containers = new[]{"mp3", "flac", "m4a", "wma", "aac"},
|
||||||
Type = DlnaProfileType.Audio
|
Type = DlnaProfileType.Audio
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -665,6 +665,54 @@ namespace MediaBrowser.Dlna
|
|||||||
{
|
{
|
||||||
Containers = new[]{"avi", "mp4", "mkv", "ts"},
|
Containers = new[]{"avi", "mp4", "mkv", "ts"},
|
||||||
Type = DlnaProfileType.Video
|
Type = DlnaProfileType.Video
|
||||||
|
},
|
||||||
|
|
||||||
|
new DirectPlayProfile
|
||||||
|
{
|
||||||
|
Type = DlnaProfileType.Photo,
|
||||||
|
|
||||||
|
Conditions = new List<ProfileCondition>
|
||||||
|
{
|
||||||
|
new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.Width, Value = "1920"},
|
||||||
|
new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.Height, Value = "1080"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
MediaProfiles = new[]
|
||||||
|
{
|
||||||
|
new MediaProfile
|
||||||
|
{
|
||||||
|
Container ="ts",
|
||||||
|
OrgPn = "MPEG_TS_SD_NA",
|
||||||
|
Type = DlnaProfileType.Video
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
CodecProfiles = new[]
|
||||||
|
{
|
||||||
|
new CodecProfile
|
||||||
|
{
|
||||||
|
Type = CodecType.VideoCodec,
|
||||||
|
Codecs = new[]{"h264"},
|
||||||
|
|
||||||
|
Conditions = new List<ProfileCondition>
|
||||||
|
{
|
||||||
|
new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.Width, Value = "1920"},
|
||||||
|
new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.Height, Value = "1080"},
|
||||||
|
new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.VideoLevel, Value = "41"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
new CodecProfile
|
||||||
|
{
|
||||||
|
Type = CodecType.VideoAudioCodec,
|
||||||
|
Codecs = new[]{"aac"},
|
||||||
|
|
||||||
|
Conditions = new List<ProfileCondition>
|
||||||
|
{
|
||||||
|
new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.AudioChannels, Value = "2"}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -171,12 +171,15 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||||||
{
|
{
|
||||||
var mediaPath = item.Path;
|
var mediaPath = item.Path;
|
||||||
|
|
||||||
|
if (profile.Containers.Length > 0)
|
||||||
|
{
|
||||||
// Check container type
|
// Check container type
|
||||||
var mediaContainer = Path.GetExtension(mediaPath);
|
var mediaContainer = Path.GetExtension(mediaPath);
|
||||||
if (!profile.Containers.Any(i => string.Equals("." + i.TrimStart('.'), mediaContainer, StringComparison.OrdinalIgnoreCase)))
|
if (!profile.Containers.Any(i => string.Equals("." + i.TrimStart('.'), mediaContainer, StringComparison.OrdinalIgnoreCase)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check additional conditions
|
// Check additional conditions
|
||||||
if (!profile.Conditions.Any(i => IsConditionSatisfied(i, mediaPath, null, null)))
|
if (!profile.Conditions.Any(i => IsConditionSatisfied(i, mediaPath, null, null)))
|
||||||
@ -191,12 +194,15 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||||||
{
|
{
|
||||||
var mediaPath = item.Path;
|
var mediaPath = item.Path;
|
||||||
|
|
||||||
|
if (profile.Containers.Length > 0)
|
||||||
|
{
|
||||||
// Check container type
|
// Check container type
|
||||||
var mediaContainer = Path.GetExtension(mediaPath);
|
var mediaContainer = Path.GetExtension(mediaPath);
|
||||||
if (!profile.Containers.Any(i => string.Equals("." + i.TrimStart('.'), mediaContainer, StringComparison.OrdinalIgnoreCase)))
|
if (!profile.Containers.Any(i => string.Equals("." + i.TrimStart('.'), mediaContainer, StringComparison.OrdinalIgnoreCase)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check additional conditions
|
// Check additional conditions
|
||||||
if (!profile.Conditions.Any(i => IsConditionSatisfied(i, mediaPath, null, audioStream)))
|
if (!profile.Conditions.Any(i => IsConditionSatisfied(i, mediaPath, null, audioStream)))
|
||||||
@ -216,12 +222,15 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||||||
|
|
||||||
var mediaPath = item.Path;
|
var mediaPath = item.Path;
|
||||||
|
|
||||||
|
if (profile.Containers.Length > 0)
|
||||||
|
{
|
||||||
// Check container type
|
// Check container type
|
||||||
var mediaContainer = Path.GetExtension(mediaPath);
|
var mediaContainer = Path.GetExtension(mediaPath);
|
||||||
if (!profile.Containers.Any(i => string.Equals("." + i.TrimStart('.'), mediaContainer, StringComparison.OrdinalIgnoreCase)))
|
if (!profile.Containers.Any(i => string.Equals("." + i.TrimStart('.'), mediaContainer, StringComparison.OrdinalIgnoreCase)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check video codec
|
// Check video codec
|
||||||
if (profile.VideoCodecs.Length > 0)
|
if (profile.VideoCodecs.Length > 0)
|
||||||
@ -330,9 +339,9 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||||||
return videoStream == null ? null : videoStream.BitRate;
|
return videoStream == null ? null : videoStream.BitRate;
|
||||||
case ProfileConditionValue.VideoFramerate:
|
case ProfileConditionValue.VideoFramerate:
|
||||||
return videoStream == null ? null : (ConvertToLong(videoStream.AverageFrameRate ?? videoStream.RealFrameRate));
|
return videoStream == null ? null : (ConvertToLong(videoStream.AverageFrameRate ?? videoStream.RealFrameRate));
|
||||||
case ProfileConditionValue.VideoHeight:
|
case ProfileConditionValue.Height:
|
||||||
return videoStream == null ? null : videoStream.Height;
|
return videoStream == null ? null : videoStream.Height;
|
||||||
case ProfileConditionValue.VideoWidth:
|
case ProfileConditionValue.Width:
|
||||||
return videoStream == null ? null : videoStream.Width;
|
return videoStream == null ? null : videoStream.Width;
|
||||||
case ProfileConditionValue.VideoLevel:
|
case ProfileConditionValue.VideoLevel:
|
||||||
return videoStream == null ? null : ConvertToLong(videoStream.Level);
|
return videoStream == null ? null : ConvertToLong(videoStream.Level);
|
||||||
|
Loading…
Reference in New Issue
Block a user