check video profile with substring

This commit is contained in:
Luke Pulverenti 2014-10-07 22:25:24 -04:00
parent 4999f19485
commit bebba65d61
6 changed files with 72 additions and 29 deletions

View file

@ -79,7 +79,7 @@ namespace MediaBrowser.Dlna
new Windows81Profile(), new Windows81Profile(),
//new WindowsMediaCenterProfile(), //new WindowsMediaCenterProfile(),
new WindowsPhoneProfile(), new WindowsPhoneProfile(),
new AndroidProfile(), new AndroidProfile(true, true),
new DirectTvProfile(), new DirectTvProfile(),
new DishHopperJoeyProfile(), new DishHopperJoeyProfile(),
new DefaultProfile() new DefaultProfile()

View file

@ -16,6 +16,7 @@ namespace MediaBrowser.Dlna.Ssdp
/// The number of times to send the message /// The number of times to send the message
/// </summary> /// </summary>
public int TotalSendCount { get; private set; } public int TotalSendCount { get; private set; }
public bool IgnoreBindFailure { get; private set; }
/// <summary> /// <summary>
/// The number of times the message has been sent /// The number of times the message has been sent
@ -24,10 +25,11 @@ namespace MediaBrowser.Dlna.Ssdp
private readonly ILogger _logger; private readonly ILogger _logger;
public Datagram(EndPoint toEndPoint, EndPoint fromEndPoint, ILogger logger, string message, int totalSendCount) public Datagram(EndPoint toEndPoint, EndPoint fromEndPoint, ILogger logger, string message, int totalSendCount, bool ignoreBindFailure)
{ {
Message = message; Message = message;
_logger = logger; _logger = logger;
IgnoreBindFailure = ignoreBindFailure;
TotalSendCount = totalSendCount; TotalSendCount = totalSendCount;
FromEndPoint = fromEndPoint; FromEndPoint = fromEndPoint;
ToEndPoint = toEndPoint; ToEndPoint = toEndPoint;
@ -42,7 +44,14 @@ namespace MediaBrowser.Dlna.Ssdp
if (FromEndPoint != null) if (FromEndPoint != null)
{ {
client.Bind(FromEndPoint); try
{
client.Bind(FromEndPoint);
}
catch
{
if (!IgnoreBindFailure) throw;
}
} }
client.BeginSendTo(msg, 0, msg.Length, SocketFlags.None, ToEndPoint, result => client.BeginSendTo(msg, 0, msg.Length, SocketFlags.None, ToEndPoint, result =>
@ -53,7 +62,10 @@ namespace MediaBrowser.Dlna.Ssdp
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.ErrorException("Error sending Datagram to {0} from {1}: " + Message, ex, ToEndPoint, FromEndPoint == null ? "" : FromEndPoint.ToString()); if (!IgnoreBindFailure)
{
_logger.ErrorException("Error sending Datagram to {0} from {1}: " + Message, ex, ToEndPoint, FromEndPoint == null ? "" : FromEndPoint.ToString());
}
} }
finally finally
{ {

View file

@ -124,18 +124,19 @@ namespace MediaBrowser.Dlna.Ssdp
EndPoint localAddress, EndPoint localAddress,
int sendCount = 1) int sendCount = 1)
{ {
SendDatagram(header, values, _ssdpEndp, localAddress, sendCount); SendDatagram(header, values, _ssdpEndp, localAddress, false, sendCount);
} }
public void SendDatagram(string header, public void SendDatagram(string header,
Dictionary<string, string> values, Dictionary<string, string> values,
EndPoint endpoint, EndPoint endpoint,
EndPoint localAddress, EndPoint localAddress,
bool ignoreBindFailure,
int sendCount = 1) int sendCount = 1)
{ {
var msg = new SsdpMessageBuilder().BuildMessage(header, values); var msg = new SsdpMessageBuilder().BuildMessage(header, values);
var dgram = new Datagram(endpoint, localAddress, _logger, msg, sendCount); var dgram = new Datagram(endpoint, localAddress, _logger, msg, sendCount, ignoreBindFailure);
if (_messageQueue.Count == 0) if (_messageQueue.Count == 0)
{ {
@ -171,7 +172,8 @@ namespace MediaBrowser.Dlna.Ssdp
values["ST"] = d.Type; values["ST"] = d.Type;
values["USN"] = d.USN; values["USN"] = d.USN;
SendDatagram(header, values, endpoint, new IPEndPoint(d.Address, 0)); SendDatagram(header, values, endpoint, new IPEndPoint(d.Address, 0), true);
//SendDatagram(header, values, endpoint, null, true);
if (_config.GetDlnaConfiguration().EnableDebugLogging) if (_config.GetDlnaConfiguration().EnableDebugLogging)
{ {

View file

@ -145,6 +145,8 @@ namespace MediaBrowser.Model.Dlna
switch (condition.Condition) switch (condition.Condition)
{ {
case ProfileConditionType.SubstringOf:
return StringHelper.IndexOfIgnoreCase(currentValue, expected) != -1;
case ProfileConditionType.Equals: case ProfileConditionType.Equals:
return StringHelper.EqualsIgnoreCase(currentValue, expected); return StringHelper.EqualsIgnoreCase(currentValue, expected);
case ProfileConditionType.NotEquals: case ProfileConditionType.NotEquals:

View file

@ -5,6 +5,7 @@
Equals = 0, Equals = 0,
NotEquals = 1, NotEquals = 1,
LessThanEqual = 2, LessThanEqual = 2,
GreaterThanEqual = 3 GreaterThanEqual = 3,
SubstringOf = 4
} }
} }

View file

@ -1,23 +1,31 @@
using System.Xml.Serialization; using System.Collections.Generic;
using System.Xml.Serialization;
namespace MediaBrowser.Model.Dlna.Profiles namespace MediaBrowser.Model.Dlna.Profiles
{ {
[XmlRoot("Profile")] [XmlRoot("Profile")]
public class AndroidProfile : DefaultProfile public class AndroidProfile : DefaultProfile
{ {
public AndroidProfile() public AndroidProfile(bool supportsHls, bool supportsMpegDash)
{ {
Name = "Android"; Name = "Android";
TranscodingProfiles = new[] List<TranscodingProfile> transcodingProfiles = new List<TranscodingProfile>();
transcodingProfiles.Add(new TranscodingProfile
{ {
new TranscodingProfile Container = "mp3",
{ AudioCodec = "mp3",
Container = "mp3", Type = DlnaProfileType.Audio
AudioCodec = "mp3", });
Type = DlnaProfileType.Audio
}, if (supportsMpegDash)
new TranscodingProfile {
}
if (supportsHls)
{
transcodingProfiles.Add(new TranscodingProfile
{ {
Protocol = "hls", Protocol = "hls",
Container = "ts", Container = "ts",
@ -26,17 +34,19 @@ namespace MediaBrowser.Model.Dlna.Profiles
Type = DlnaProfileType.Video, Type = DlnaProfileType.Video,
VideoProfile = "Baseline", VideoProfile = "Baseline",
Context = EncodingContext.Streaming Context = EncodingContext.Streaming
}, });
new TranscodingProfile }
{ transcodingProfiles.Add(new TranscodingProfile
Container = "mp4", {
VideoCodec = "h264", Container = "mp4",
AudioCodec = "aac", VideoCodec = "h264",
Type = DlnaProfileType.Video, AudioCodec = "aac",
VideoProfile = "Baseline", Type = DlnaProfileType.Video,
Context = EncodingContext.Static VideoProfile = "Baseline",
} Context = EncodingContext.Static
}; });
TranscodingProfiles = transcodingProfiles.ToArray();
DirectPlayProfiles = new[] DirectPlayProfiles = new[]
{ {
@ -88,6 +98,22 @@ namespace MediaBrowser.Model.Dlna.Profiles
new CodecProfile new CodecProfile
{ {
Type = CodecType.Video, Type = CodecType.Video,
Codec= "h264",
Conditions = new []
{
new ProfileCondition(ProfileConditionType.SubstringOf, ProfileConditionValue.VideoProfile, "baseline"),
new ProfileCondition(ProfileConditionType.LessThanEqual, ProfileConditionValue.Width, "1920"),
new ProfileCondition(ProfileConditionType.LessThanEqual, ProfileConditionValue.Height, "1080"),
new ProfileCondition(ProfileConditionType.LessThanEqual, ProfileConditionValue.VideoBitDepth, "8"),
new ProfileCondition(ProfileConditionType.NotEquals, ProfileConditionValue.IsAnamorphic, "true")
}
},
new CodecProfile
{
Type = CodecType.Video,
Conditions = new [] Conditions = new []
{ {
new ProfileCondition(ProfileConditionType.LessThanEqual, ProfileConditionValue.Width, "1920"), new ProfileCondition(ProfileConditionType.LessThanEqual, ProfileConditionValue.Width, "1920"),