brace multiline if statements
This commit is contained in:
parent
98db8f72e0
commit
7f307f9082
|
@ -140,55 +140,73 @@ namespace Emby.Dlna
|
||||||
if (!string.IsNullOrEmpty(profileInfo.DeviceDescription))
|
if (!string.IsNullOrEmpty(profileInfo.DeviceDescription))
|
||||||
{
|
{
|
||||||
if (deviceInfo.DeviceDescription == null || !IsRegexMatch(deviceInfo.DeviceDescription, profileInfo.DeviceDescription))
|
if (deviceInfo.DeviceDescription == null || !IsRegexMatch(deviceInfo.DeviceDescription, profileInfo.DeviceDescription))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(profileInfo.FriendlyName))
|
if (!string.IsNullOrEmpty(profileInfo.FriendlyName))
|
||||||
{
|
{
|
||||||
if (deviceInfo.FriendlyName == null || !IsRegexMatch(deviceInfo.FriendlyName, profileInfo.FriendlyName))
|
if (deviceInfo.FriendlyName == null || !IsRegexMatch(deviceInfo.FriendlyName, profileInfo.FriendlyName))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(profileInfo.Manufacturer))
|
if (!string.IsNullOrEmpty(profileInfo.Manufacturer))
|
||||||
{
|
{
|
||||||
if (deviceInfo.Manufacturer == null || !IsRegexMatch(deviceInfo.Manufacturer, profileInfo.Manufacturer))
|
if (deviceInfo.Manufacturer == null || !IsRegexMatch(deviceInfo.Manufacturer, profileInfo.Manufacturer))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(profileInfo.ManufacturerUrl))
|
if (!string.IsNullOrEmpty(profileInfo.ManufacturerUrl))
|
||||||
{
|
{
|
||||||
if (deviceInfo.ManufacturerUrl == null || !IsRegexMatch(deviceInfo.ManufacturerUrl, profileInfo.ManufacturerUrl))
|
if (deviceInfo.ManufacturerUrl == null || !IsRegexMatch(deviceInfo.ManufacturerUrl, profileInfo.ManufacturerUrl))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(profileInfo.ModelDescription))
|
if (!string.IsNullOrEmpty(profileInfo.ModelDescription))
|
||||||
{
|
{
|
||||||
if (deviceInfo.ModelDescription == null || !IsRegexMatch(deviceInfo.ModelDescription, profileInfo.ModelDescription))
|
if (deviceInfo.ModelDescription == null || !IsRegexMatch(deviceInfo.ModelDescription, profileInfo.ModelDescription))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(profileInfo.ModelName))
|
if (!string.IsNullOrEmpty(profileInfo.ModelName))
|
||||||
{
|
{
|
||||||
if (deviceInfo.ModelName == null || !IsRegexMatch(deviceInfo.ModelName, profileInfo.ModelName))
|
if (deviceInfo.ModelName == null || !IsRegexMatch(deviceInfo.ModelName, profileInfo.ModelName))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(profileInfo.ModelNumber))
|
if (!string.IsNullOrEmpty(profileInfo.ModelNumber))
|
||||||
{
|
{
|
||||||
if (deviceInfo.ModelNumber == null || !IsRegexMatch(deviceInfo.ModelNumber, profileInfo.ModelNumber))
|
if (deviceInfo.ModelNumber == null || !IsRegexMatch(deviceInfo.ModelNumber, profileInfo.ModelNumber))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(profileInfo.ModelUrl))
|
if (!string.IsNullOrEmpty(profileInfo.ModelUrl))
|
||||||
{
|
{
|
||||||
if (deviceInfo.ModelUrl == null || !IsRegexMatch(deviceInfo.ModelUrl, profileInfo.ModelUrl))
|
if (deviceInfo.ModelUrl == null || !IsRegexMatch(deviceInfo.ModelUrl, profileInfo.ModelUrl))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(profileInfo.SerialNumber))
|
if (!string.IsNullOrEmpty(profileInfo.SerialNumber))
|
||||||
{
|
{
|
||||||
if (deviceInfo.SerialNumber == null || !IsRegexMatch(deviceInfo.SerialNumber, profileInfo.SerialNumber))
|
if (deviceInfo.SerialNumber == null || !IsRegexMatch(deviceInfo.SerialNumber, profileInfo.SerialNumber))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -208,7 +208,9 @@ namespace Emby.Dlna.PlayTo
|
||||||
|
|
||||||
var command = rendererCommands.ServiceActions.FirstOrDefault(c => c.Name == "SetMute");
|
var command = rendererCommands.ServiceActions.FirstOrDefault(c => c.Name == "SetMute");
|
||||||
if (command == null)
|
if (command == null)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var service = GetServiceRenderingControl();
|
var service = GetServiceRenderingControl();
|
||||||
|
|
||||||
|
@ -237,7 +239,9 @@ namespace Emby.Dlna.PlayTo
|
||||||
|
|
||||||
var command = rendererCommands.ServiceActions.FirstOrDefault(c => c.Name == "SetVolume");
|
var command = rendererCommands.ServiceActions.FirstOrDefault(c => c.Name == "SetVolume");
|
||||||
if (command == null)
|
if (command == null)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var service = GetServiceRenderingControl();
|
var service = GetServiceRenderingControl();
|
||||||
|
|
||||||
|
@ -260,7 +264,9 @@ namespace Emby.Dlna.PlayTo
|
||||||
|
|
||||||
var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "Seek");
|
var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "Seek");
|
||||||
if (command == null)
|
if (command == null)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var service = GetAvTransportService();
|
var service = GetAvTransportService();
|
||||||
|
|
||||||
|
@ -285,7 +291,9 @@ namespace Emby.Dlna.PlayTo
|
||||||
|
|
||||||
var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "SetAVTransportURI");
|
var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "SetAVTransportURI");
|
||||||
if (command == null)
|
if (command == null)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var dictionary = new Dictionary<string, string>
|
var dictionary = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
|
@ -452,7 +460,9 @@ namespace Emby.Dlna.PlayTo
|
||||||
_connectFailureCount = 0;
|
_connectFailureCount = 0;
|
||||||
|
|
||||||
if (_disposed)
|
if (_disposed)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If we're not playing anything make sure we don't get data more often than neccessry to keep the Session alive
|
// If we're not playing anything make sure we don't get data more often than neccessry to keep the Session alive
|
||||||
if (transportState.Value == TRANSPORTSTATE.STOPPED)
|
if (transportState.Value == TRANSPORTSTATE.STOPPED)
|
||||||
|
@ -472,7 +482,9 @@ namespace Emby.Dlna.PlayTo
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
if (_disposed)
|
if (_disposed)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_logger.LogError(ex, "Error updating device info for {DeviceName}", Properties.Name);
|
_logger.LogError(ex, "Error updating device info for {DeviceName}", Properties.Name);
|
||||||
|
|
||||||
|
@ -573,7 +585,9 @@ namespace Emby.Dlna.PlayTo
|
||||||
cancellationToken: cancellationToken).ConfigureAwait(false);
|
cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
if (result == null || result.Document == null)
|
if (result == null || result.Document == null)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var valueNode = result.Document.Descendants(uPnpNamespaces.RenderingControl + "GetMuteResponse")
|
var valueNode = result.Document.Descendants(uPnpNamespaces.RenderingControl + "GetMuteResponse")
|
||||||
.Select(i => i.Element("CurrentMute"))
|
.Select(i => i.Element("CurrentMute"))
|
||||||
|
|
|
@ -19,7 +19,9 @@ namespace Emby.Server.Implementations.Library.Resolvers.Books
|
||||||
|
|
||||||
// Only process items that are in a collection folder containing books
|
// Only process items that are in a collection folder containing books
|
||||||
if (!string.Equals(collectionType, CollectionType.Books, StringComparison.OrdinalIgnoreCase))
|
if (!string.Equals(collectionType, CollectionType.Books, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (args.IsDirectory)
|
if (args.IsDirectory)
|
||||||
{
|
{
|
||||||
|
@ -55,7 +57,9 @@ namespace Emby.Server.Implementations.Library.Resolvers.Books
|
||||||
|
|
||||||
// Don't return a Book if there is more (or less) than one document in the directory
|
// Don't return a Book if there is more (or less) than one document in the directory
|
||||||
if (bookFiles.Count != 1)
|
if (bookFiles.Count != 1)
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new Book
|
return new Book
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,7 +40,9 @@ namespace Emby.Server.Implementations.Services
|
||||||
if (httpResult != null)
|
if (httpResult != null)
|
||||||
{
|
{
|
||||||
if (httpResult.RequestContext == null)
|
if (httpResult.RequestContext == null)
|
||||||
|
{
|
||||||
httpResult.RequestContext = request;
|
httpResult.RequestContext = request;
|
||||||
|
}
|
||||||
|
|
||||||
response.StatusCode = httpResult.Status;
|
response.StatusCode = httpResult.Status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,11 +42,15 @@ namespace Emby.Server.Implementations.Services
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mi.GetParameters().Length != 1)
|
if (mi.GetParameters().Length != 1)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var actionName = mi.Name;
|
var actionName = mi.Name;
|
||||||
if (!AllVerbs.Contains(actionName, StringComparer.OrdinalIgnoreCase))
|
if (!AllVerbs.Contains(actionName, StringComparer.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
list.Add(mi);
|
list.Add(mi);
|
||||||
}
|
}
|
||||||
|
|
|
@ -445,12 +445,14 @@ namespace Emby.Server.Implementations.Services
|
||||||
&& requestComponents.Length >= this.TotalComponentsCount - this.wildcardCount;
|
&& requestComponents.Length >= this.TotalComponentsCount - this.wildcardCount;
|
||||||
|
|
||||||
if (!isValidWildCardPath)
|
if (!isValidWildCardPath)
|
||||||
|
{
|
||||||
throw new ArgumentException(
|
throw new ArgumentException(
|
||||||
string.Format(
|
string.Format(
|
||||||
CultureInfo.InvariantCulture,
|
CultureInfo.InvariantCulture,
|
||||||
"Path Mismatch: Request Path '{0}' has invalid number of components compared to: '{1}'",
|
"Path Mismatch: Request Path '{0}' has invalid number of components compared to: '{1}'",
|
||||||
pathInfo,
|
pathInfo,
|
||||||
this.restPath));
|
this.restPath));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var requestKeyValuesMap = new Dictionary<string, string>();
|
var requestKeyValuesMap = new Dictionary<string, string>();
|
||||||
|
|
|
@ -19,10 +19,14 @@ namespace Emby.Server.Implementations.Sorting
|
||||||
public int Compare(BaseItem x, BaseItem y)
|
public int Compare(BaseItem x, BaseItem y)
|
||||||
{
|
{
|
||||||
if (x == null)
|
if (x == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException(nameof(x));
|
throw new ArgumentNullException(nameof(x));
|
||||||
|
}
|
||||||
|
|
||||||
if (y == null)
|
if (y == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException(nameof(y));
|
throw new ArgumentNullException(nameof(y));
|
||||||
|
}
|
||||||
|
|
||||||
return DateTime.Compare(x.DateCreated, y.DateCreated);
|
return DateTime.Compare(x.DateCreated, y.DateCreated);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,14 @@ namespace Emby.Server.Implementations.Sorting
|
||||||
public int Compare(BaseItem x, BaseItem y)
|
public int Compare(BaseItem x, BaseItem y)
|
||||||
{
|
{
|
||||||
if (x == null)
|
if (x == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException(nameof(x));
|
throw new ArgumentNullException(nameof(x));
|
||||||
|
}
|
||||||
|
|
||||||
if (y == null)
|
if (y == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException(nameof(y));
|
throw new ArgumentNullException(nameof(y));
|
||||||
|
}
|
||||||
|
|
||||||
return (x.RunTimeTicks ?? 0).CompareTo(y.RunTimeTicks ?? 0);
|
return (x.RunTimeTicks ?? 0).CompareTo(y.RunTimeTicks ?? 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,14 @@ namespace Emby.Server.Implementations.Sorting
|
||||||
public int Compare(BaseItem x, BaseItem y)
|
public int Compare(BaseItem x, BaseItem y)
|
||||||
{
|
{
|
||||||
if (x == null)
|
if (x == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException(nameof(x));
|
throw new ArgumentNullException(nameof(x));
|
||||||
|
}
|
||||||
|
|
||||||
if (y == null)
|
if (y == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException(nameof(y));
|
throw new ArgumentNullException(nameof(y));
|
||||||
|
}
|
||||||
|
|
||||||
return string.Compare(x.SortName, y.SortName, StringComparison.CurrentCultureIgnoreCase);
|
return string.Compare(x.SortName, y.SortName, StringComparison.CurrentCultureIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2951,7 +2951,9 @@ namespace MediaBrowser.Controller.Entities
|
||||||
public IEnumerable<BaseItem> GetTrailers()
|
public IEnumerable<BaseItem> GetTrailers()
|
||||||
{
|
{
|
||||||
if (this is IHasTrailers)
|
if (this is IHasTrailers)
|
||||||
|
{
|
||||||
return ((IHasTrailers)this).LocalTrailerIds.Select(LibraryManager.GetItemById).Where(i => i != null).OrderBy(i => i.SortName);
|
return ((IHasTrailers)this).LocalTrailerIds.Select(LibraryManager.GetItemById).Where(i => i != null).OrderBy(i => i.SortName);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return Array.Empty<BaseItem>();
|
return Array.Empty<BaseItem>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,10 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||||
var endTime = time[1];
|
var endTime = time[1];
|
||||||
var idx = endTime.IndexOf(" ", StringComparison.Ordinal);
|
var idx = endTime.IndexOf(" ", StringComparison.Ordinal);
|
||||||
if (idx > 0)
|
if (idx > 0)
|
||||||
|
{
|
||||||
endTime = endTime.Substring(0, idx);
|
endTime = endTime.Substring(0, idx);
|
||||||
|
}
|
||||||
|
|
||||||
subEvent.EndPositionTicks = GetTicks(endTime);
|
subEvent.EndPositionTicks = GetTicks(endTime);
|
||||||
var multiline = new List<string>();
|
var multiline = new List<string>();
|
||||||
while ((line = reader.ReadLine()) != null)
|
while ((line = reader.ReadLine()) != null)
|
||||||
|
|
|
@ -41,7 +41,9 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||||
|
|
||||||
lineNumber++;
|
lineNumber++;
|
||||||
if (!eventsStarted)
|
if (!eventsStarted)
|
||||||
|
{
|
||||||
header.AppendLine(line);
|
header.AppendLine(line);
|
||||||
|
}
|
||||||
|
|
||||||
if (line.Trim().ToLowerInvariant() == "[events]")
|
if (line.Trim().ToLowerInvariant() == "[events]")
|
||||||
{
|
{
|
||||||
|
@ -62,17 +64,29 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||||
for (int i = 0; i < format.Length; i++)
|
for (int i = 0; i < format.Length; i++)
|
||||||
{
|
{
|
||||||
if (format[i].Trim().ToLowerInvariant() == "layer")
|
if (format[i].Trim().ToLowerInvariant() == "layer")
|
||||||
|
{
|
||||||
indexLayer = i;
|
indexLayer = i;
|
||||||
|
}
|
||||||
else if (format[i].Trim().ToLowerInvariant() == "start")
|
else if (format[i].Trim().ToLowerInvariant() == "start")
|
||||||
|
{
|
||||||
indexStart = i;
|
indexStart = i;
|
||||||
|
}
|
||||||
else if (format[i].Trim().ToLowerInvariant() == "end")
|
else if (format[i].Trim().ToLowerInvariant() == "end")
|
||||||
|
{
|
||||||
indexEnd = i;
|
indexEnd = i;
|
||||||
|
}
|
||||||
else if (format[i].Trim().ToLowerInvariant() == "text")
|
else if (format[i].Trim().ToLowerInvariant() == "text")
|
||||||
|
{
|
||||||
indexText = i;
|
indexText = i;
|
||||||
|
}
|
||||||
else if (format[i].Trim().ToLowerInvariant() == "effect")
|
else if (format[i].Trim().ToLowerInvariant() == "effect")
|
||||||
|
{
|
||||||
indexEffect = i;
|
indexEffect = i;
|
||||||
|
}
|
||||||
else if (format[i].Trim().ToLowerInvariant() == "style")
|
else if (format[i].Trim().ToLowerInvariant() == "style")
|
||||||
|
{
|
||||||
indexStyle = i;
|
indexStyle = i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,28 +103,48 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||||
string[] splittedLine;
|
string[] splittedLine;
|
||||||
|
|
||||||
if (s.StartsWith("dialogue:"))
|
if (s.StartsWith("dialogue:"))
|
||||||
|
{
|
||||||
splittedLine = line.Substring(10).Split(',');
|
splittedLine = line.Substring(10).Split(',');
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
splittedLine = line.Split(',');
|
splittedLine = line.Split(',');
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < splittedLine.Length; i++)
|
for (int i = 0; i < splittedLine.Length; i++)
|
||||||
{
|
{
|
||||||
if (i == indexStart)
|
if (i == indexStart)
|
||||||
|
{
|
||||||
start = splittedLine[i].Trim();
|
start = splittedLine[i].Trim();
|
||||||
|
}
|
||||||
else if (i == indexEnd)
|
else if (i == indexEnd)
|
||||||
|
{
|
||||||
end = splittedLine[i].Trim();
|
end = splittedLine[i].Trim();
|
||||||
|
}
|
||||||
else if (i == indexLayer)
|
else if (i == indexLayer)
|
||||||
|
{
|
||||||
layer = splittedLine[i];
|
layer = splittedLine[i];
|
||||||
|
}
|
||||||
else if (i == indexEffect)
|
else if (i == indexEffect)
|
||||||
|
{
|
||||||
effect = splittedLine[i];
|
effect = splittedLine[i];
|
||||||
|
}
|
||||||
else if (i == indexText)
|
else if (i == indexText)
|
||||||
|
{
|
||||||
text = splittedLine[i];
|
text = splittedLine[i];
|
||||||
|
}
|
||||||
else if (i == indexStyle)
|
else if (i == indexStyle)
|
||||||
|
{
|
||||||
style = splittedLine[i];
|
style = splittedLine[i];
|
||||||
|
}
|
||||||
else if (i == indexName)
|
else if (i == indexName)
|
||||||
|
{
|
||||||
name = splittedLine[i];
|
name = splittedLine[i];
|
||||||
|
}
|
||||||
else if (i > indexText)
|
else if (i > indexText)
|
||||||
|
{
|
||||||
text += "," + splittedLine[i];
|
text += "," + splittedLine[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -169,13 +203,17 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||||
CheckAndAddSubTags(ref fontName, ref extraTags, out italic);
|
CheckAndAddSubTags(ref fontName, ref extraTags, out italic);
|
||||||
text = text.Remove(start, end - start + 1);
|
text = text.Remove(start, end - start + 1);
|
||||||
if (italic)
|
if (italic)
|
||||||
|
{
|
||||||
text = text.Insert(start, "<font face=\"" + fontName + "\"" + extraTags + "><i>");
|
text = text.Insert(start, "<font face=\"" + fontName + "\"" + extraTags + "><i>");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
text = text.Insert(start, "<font face=\"" + fontName + "\"" + extraTags + ">");
|
text = text.Insert(start, "<font face=\"" + fontName + "\"" + extraTags + ">");
|
||||||
|
|
||||||
int indexOfEndTag = text.IndexOf("{\\fn}", start);
|
int indexOfEndTag = text.IndexOf("{\\fn}", start);
|
||||||
if (indexOfEndTag > 0)
|
if (indexOfEndTag > 0)
|
||||||
|
{
|
||||||
text = text.Remove(indexOfEndTag, "{\\fn}".Length).Insert(indexOfEndTag, "</font>");
|
text = text.Remove(indexOfEndTag, "{\\fn}".Length).Insert(indexOfEndTag, "</font>");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
text += "</font>";
|
text += "</font>";
|
||||||
}
|
}
|
||||||
|
@ -194,13 +232,17 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||||
{
|
{
|
||||||
text = text.Remove(start, end - start + 1);
|
text = text.Remove(start, end - start + 1);
|
||||||
if (italic)
|
if (italic)
|
||||||
|
{
|
||||||
text = text.Insert(start, "<font size=\"" + fontSize + "\"" + extraTags + "><i>");
|
text = text.Insert(start, "<font size=\"" + fontSize + "\"" + extraTags + "><i>");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
text = text.Insert(start, "<font size=\"" + fontSize + "\"" + extraTags + ">");
|
text = text.Insert(start, "<font size=\"" + fontSize + "\"" + extraTags + ">");
|
||||||
|
|
||||||
int indexOfEndTag = text.IndexOf("{\\fs}", start);
|
int indexOfEndTag = text.IndexOf("{\\fs}", start);
|
||||||
if (indexOfEndTag > 0)
|
if (indexOfEndTag > 0)
|
||||||
|
{
|
||||||
text = text.Remove(indexOfEndTag, "{\\fs}".Length).Insert(indexOfEndTag, "</font>");
|
text = text.Remove(indexOfEndTag, "{\\fs}".Length).Insert(indexOfEndTag, "</font>");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
text += "</font>";
|
text += "</font>";
|
||||||
}
|
}
|
||||||
|
@ -226,12 +268,16 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||||
|
|
||||||
text = text.Remove(start, end - start + 1);
|
text = text.Remove(start, end - start + 1);
|
||||||
if (italic)
|
if (italic)
|
||||||
|
{
|
||||||
text = text.Insert(start, "<font color=\"" + color + "\"" + extraTags + "><i>");
|
text = text.Insert(start, "<font color=\"" + color + "\"" + extraTags + "><i>");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
text = text.Insert(start, "<font color=\"" + color + "\"" + extraTags + ">");
|
text = text.Insert(start, "<font color=\"" + color + "\"" + extraTags + ">");
|
||||||
int indexOfEndTag = text.IndexOf("{\\c}", start);
|
int indexOfEndTag = text.IndexOf("{\\c}", start);
|
||||||
if (indexOfEndTag > 0)
|
if (indexOfEndTag > 0)
|
||||||
|
{
|
||||||
text = text.Remove(indexOfEndTag, "{\\c}".Length).Insert(indexOfEndTag, "</font>");
|
text = text.Remove(indexOfEndTag, "{\\c}".Length).Insert(indexOfEndTag, "</font>");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
text += "</font>";
|
text += "</font>";
|
||||||
}
|
}
|
||||||
|
@ -256,7 +302,9 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||||
|
|
||||||
text = text.Remove(start, end - start + 1);
|
text = text.Remove(start, end - start + 1);
|
||||||
if (italic)
|
if (italic)
|
||||||
|
{
|
||||||
text = text.Insert(start, "<font color=\"" + color + "\"" + extraTags + "><i>");
|
text = text.Insert(start, "<font color=\"" + color + "\"" + extraTags + "><i>");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
text = text.Insert(start, "<font color=\"" + color + "\"" + extraTags + ">");
|
text = text.Insert(start, "<font color=\"" + color + "\"" + extraTags + ">");
|
||||||
text += "</font>";
|
text += "</font>";
|
||||||
|
@ -268,19 +316,25 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||||
text = text.Replace(@"{\i0}", "</i>");
|
text = text.Replace(@"{\i0}", "</i>");
|
||||||
text = text.Replace(@"{\i}", "</i>");
|
text = text.Replace(@"{\i}", "</i>");
|
||||||
if (CountTagInText(text, "<i>") > CountTagInText(text, "</i>"))
|
if (CountTagInText(text, "<i>") > CountTagInText(text, "</i>"))
|
||||||
|
{
|
||||||
text += "</i>";
|
text += "</i>";
|
||||||
|
}
|
||||||
|
|
||||||
text = text.Replace(@"{\u1}", "<u>");
|
text = text.Replace(@"{\u1}", "<u>");
|
||||||
text = text.Replace(@"{\u0}", "</u>");
|
text = text.Replace(@"{\u0}", "</u>");
|
||||||
text = text.Replace(@"{\u}", "</u>");
|
text = text.Replace(@"{\u}", "</u>");
|
||||||
if (CountTagInText(text, "<u>") > CountTagInText(text, "</u>"))
|
if (CountTagInText(text, "<u>") > CountTagInText(text, "</u>"))
|
||||||
|
{
|
||||||
text += "</u>";
|
text += "</u>";
|
||||||
|
}
|
||||||
|
|
||||||
text = text.Replace(@"{\b1}", "<b>");
|
text = text.Replace(@"{\b1}", "<b>");
|
||||||
text = text.Replace(@"{\b0}", "</b>");
|
text = text.Replace(@"{\b0}", "</b>");
|
||||||
text = text.Replace(@"{\b}", "</b>");
|
text = text.Replace(@"{\b}", "</b>");
|
||||||
if (CountTagInText(text, "<b>") > CountTagInText(text, "</b>"))
|
if (CountTagInText(text, "<b>") > CountTagInText(text, "</b>"))
|
||||||
|
{
|
||||||
text += "</b>";
|
text += "</b>";
|
||||||
|
}
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
@ -288,7 +342,9 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||||
private static bool IsInteger(string s)
|
private static bool IsInteger(string s)
|
||||||
{
|
{
|
||||||
if (int.TryParse(s, out var i))
|
if (int.TryParse(s, out var i))
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,7 +356,9 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
if (index == text.Length)
|
if (index == text.Length)
|
||||||
|
{
|
||||||
return count;
|
return count;
|
||||||
|
}
|
||||||
index = text.IndexOf(tag, index + 1);
|
index = text.IndexOf(tag, index + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,18 +32,25 @@ namespace MediaBrowser.Model.Dlna
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.Equals(container, "avi", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(container, "avi", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return new MediaFormatProfile[] { MediaFormatProfile.AVI };
|
return new MediaFormatProfile[] { MediaFormatProfile.AVI };
|
||||||
|
}
|
||||||
|
|
||||||
if (string.Equals(container, "mkv", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(container, "mkv", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return new MediaFormatProfile[] { MediaFormatProfile.MATROSKA };
|
return new MediaFormatProfile[] { MediaFormatProfile.MATROSKA };
|
||||||
|
}
|
||||||
|
|
||||||
if (string.Equals(container, "mpeg2ps", StringComparison.OrdinalIgnoreCase) ||
|
if (string.Equals(container, "mpeg2ps", StringComparison.OrdinalIgnoreCase) ||
|
||||||
string.Equals(container, "ts", StringComparison.OrdinalIgnoreCase))
|
string.Equals(container, "ts", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return new MediaFormatProfile[] { MediaFormatProfile.MPEG_PS_NTSC, MediaFormatProfile.MPEG_PS_PAL };
|
return new MediaFormatProfile[] { MediaFormatProfile.MPEG_PS_NTSC, MediaFormatProfile.MPEG_PS_PAL };
|
||||||
|
}
|
||||||
|
|
||||||
if (string.Equals(container, "mpeg1video", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(container, "mpeg1video", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return new MediaFormatProfile[] { MediaFormatProfile.MPEG1 };
|
return new MediaFormatProfile[] { MediaFormatProfile.MPEG1 };
|
||||||
|
}
|
||||||
|
|
||||||
if (string.Equals(container, "mpeg2ts", StringComparison.OrdinalIgnoreCase) ||
|
if (string.Equals(container, "mpeg2ts", StringComparison.OrdinalIgnoreCase) ||
|
||||||
string.Equals(container, "mpegts", StringComparison.OrdinalIgnoreCase) ||
|
string.Equals(container, "mpegts", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
@ -54,10 +61,14 @@ namespace MediaBrowser.Model.Dlna
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.Equals(container, "flv", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(container, "flv", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return new MediaFormatProfile[] { MediaFormatProfile.FLV };
|
return new MediaFormatProfile[] { MediaFormatProfile.FLV };
|
||||||
|
}
|
||||||
|
|
||||||
if (string.Equals(container, "wtv", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(container, "wtv", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return new MediaFormatProfile[] { MediaFormatProfile.WTV };
|
return new MediaFormatProfile[] { MediaFormatProfile.WTV };
|
||||||
|
}
|
||||||
|
|
||||||
if (string.Equals(container, "3gp", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(container, "3gp", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
|
@ -66,7 +77,9 @@ namespace MediaBrowser.Model.Dlna
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.Equals(container, "ogv", StringComparison.OrdinalIgnoreCase) || string.Equals(container, "ogg", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(container, "ogv", StringComparison.OrdinalIgnoreCase) || string.Equals(container, "ogg", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return new MediaFormatProfile[] { MediaFormatProfile.OGV };
|
return new MediaFormatProfile[] { MediaFormatProfile.OGV };
|
||||||
|
}
|
||||||
|
|
||||||
return Array.Empty<MediaFormatProfile>();
|
return Array.Empty<MediaFormatProfile>();
|
||||||
}
|
}
|
||||||
|
@ -111,7 +124,9 @@ namespace MediaBrowser.Model.Dlna
|
||||||
if (string.Equals(videoCodec, "h264", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(videoCodec, "h264", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
if (string.Equals(audioCodec, "lpcm", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(audioCodec, "lpcm", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return new MediaFormatProfile[] { MediaFormatProfile.AVC_TS_HD_50_LPCM_T };
|
return new MediaFormatProfile[] { MediaFormatProfile.AVC_TS_HD_50_LPCM_T };
|
||||||
|
}
|
||||||
|
|
||||||
if (string.Equals(audioCodec, "dts", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(audioCodec, "dts", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
|
@ -134,14 +149,20 @@ namespace MediaBrowser.Model.Dlna
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return new MediaFormatProfile[] { ValueOf(string.Format("AVC_TS_MP_{0}D_AAC_MULT5{1}", resolution, suffix)) };
|
return new MediaFormatProfile[] { ValueOf(string.Format("AVC_TS_MP_{0}D_AAC_MULT5{1}", resolution, suffix)) };
|
||||||
|
}
|
||||||
|
|
||||||
if (string.Equals(audioCodec, "mp3", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(audioCodec, "mp3", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return new MediaFormatProfile[] { ValueOf(string.Format("AVC_TS_MP_{0}D_MPEG1_L3{1}", resolution, suffix)) };
|
return new MediaFormatProfile[] { ValueOf(string.Format("AVC_TS_MP_{0}D_MPEG1_L3{1}", resolution, suffix)) };
|
||||||
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(audioCodec) ||
|
if (string.IsNullOrEmpty(audioCodec) ||
|
||||||
string.Equals(audioCodec, "ac3", StringComparison.OrdinalIgnoreCase))
|
string.Equals(audioCodec, "ac3", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return new MediaFormatProfile[] { ValueOf(string.Format("AVC_TS_MP_{0}D_AC3{1}", resolution, suffix)) };
|
return new MediaFormatProfile[] { ValueOf(string.Format("AVC_TS_MP_{0}D_AC3{1}", resolution, suffix)) };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (string.Equals(videoCodec, "vc1", StringComparison.OrdinalIgnoreCase))
|
else if (string.Equals(videoCodec, "vc1", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
|
@ -165,13 +186,24 @@ namespace MediaBrowser.Model.Dlna
|
||||||
else if (string.Equals(videoCodec, "mpeg4", StringComparison.OrdinalIgnoreCase) || string.Equals(videoCodec, "msmpeg4", StringComparison.OrdinalIgnoreCase))
|
else if (string.Equals(videoCodec, "mpeg4", StringComparison.OrdinalIgnoreCase) || string.Equals(videoCodec, "msmpeg4", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
if (string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return new MediaFormatProfile[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_AAC{0}", suffix)) };
|
return new MediaFormatProfile[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_AAC{0}", suffix)) };
|
||||||
|
}
|
||||||
|
|
||||||
if (string.Equals(audioCodec, "mp3", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(audioCodec, "mp3", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return new MediaFormatProfile[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_MPEG1_L3{0}", suffix)) };
|
return new MediaFormatProfile[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_MPEG1_L3{0}", suffix)) };
|
||||||
|
}
|
||||||
|
|
||||||
if (string.Equals(audioCodec, "mp2", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(audioCodec, "mp2", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return new MediaFormatProfile[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_MPEG2_L2{0}", suffix)) };
|
return new MediaFormatProfile[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_MPEG2_L2{0}", suffix)) };
|
||||||
|
}
|
||||||
|
|
||||||
if (string.Equals(audioCodec, "ac3", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(audioCodec, "ac3", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return new MediaFormatProfile[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_AC3{0}", suffix)) };
|
return new MediaFormatProfile[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_AC3{0}", suffix)) };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new MediaFormatProfile[] { };
|
return new MediaFormatProfile[] { };
|
||||||
|
@ -187,7 +219,9 @@ namespace MediaBrowser.Model.Dlna
|
||||||
if (string.Equals(videoCodec, "h264", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(videoCodec, "h264", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
if (string.Equals(audioCodec, "lpcm", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(audioCodec, "lpcm", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return MediaFormatProfile.AVC_MP4_LPCM;
|
return MediaFormatProfile.AVC_MP4_LPCM;
|
||||||
|
}
|
||||||
if (string.IsNullOrEmpty(audioCodec) ||
|
if (string.IsNullOrEmpty(audioCodec) ||
|
||||||
string.Equals(audioCodec, "ac3", StringComparison.OrdinalIgnoreCase))
|
string.Equals(audioCodec, "ac3", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
|
@ -204,12 +238,16 @@ namespace MediaBrowser.Model.Dlna
|
||||||
if ((width.Value <= 720) && (height.Value <= 576))
|
if ((width.Value <= 720) && (height.Value <= 576))
|
||||||
{
|
{
|
||||||
if (string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return MediaFormatProfile.AVC_MP4_MP_SD_AAC_MULT5;
|
return MediaFormatProfile.AVC_MP4_MP_SD_AAC_MULT5;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ((width.Value <= 1280) && (height.Value <= 720))
|
else if ((width.Value <= 1280) && (height.Value <= 720))
|
||||||
{
|
{
|
||||||
if (string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return MediaFormatProfile.AVC_MP4_MP_HD_720p_AAC;
|
return MediaFormatProfile.AVC_MP4_MP_HD_720p_AAC;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ((width.Value <= 1920) && (height.Value <= 1080))
|
else if ((width.Value <= 1920) && (height.Value <= 1080))
|
||||||
{
|
{
|
||||||
|
@ -226,7 +264,9 @@ namespace MediaBrowser.Model.Dlna
|
||||||
if (width.HasValue && height.HasValue && width.Value <= 720 && height.Value <= 576)
|
if (width.HasValue && height.HasValue && width.Value <= 720 && height.Value <= 576)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
|
if (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return MediaFormatProfile.MPEG4_P2_MP4_ASP_AAC;
|
return MediaFormatProfile.MPEG4_P2_MP4_ASP_AAC;
|
||||||
|
}
|
||||||
if (string.Equals(audioCodec, "ac3", StringComparison.OrdinalIgnoreCase) || string.Equals(audioCodec, "mp3", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(audioCodec, "ac3", StringComparison.OrdinalIgnoreCase) || string.Equals(audioCodec, "mp3", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
return MediaFormatProfile.MPEG4_P2_MP4_NDSD;
|
return MediaFormatProfile.MPEG4_P2_MP4_NDSD;
|
||||||
|
@ -250,15 +290,22 @@ namespace MediaBrowser.Model.Dlna
|
||||||
if (string.Equals(videoCodec, "h264", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(videoCodec, "h264", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
|
if (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return MediaFormatProfile.AVC_3GPP_BL_QCIF15_AAC;
|
return MediaFormatProfile.AVC_3GPP_BL_QCIF15_AAC;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (string.Equals(videoCodec, "mpeg4", StringComparison.OrdinalIgnoreCase) ||
|
else if (string.Equals(videoCodec, "mpeg4", StringComparison.OrdinalIgnoreCase) ||
|
||||||
string.Equals(videoCodec, "msmpeg4", StringComparison.OrdinalIgnoreCase))
|
string.Equals(videoCodec, "msmpeg4", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "wma", StringComparison.OrdinalIgnoreCase))
|
if (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "wma", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return MediaFormatProfile.MPEG4_P2_3GPP_SP_L0B_AAC;
|
return MediaFormatProfile.MPEG4_P2_3GPP_SP_L0B_AAC;
|
||||||
|
}
|
||||||
|
|
||||||
if (string.Equals(audioCodec, "amrnb", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(audioCodec, "amrnb", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return MediaFormatProfile.MPEG4_P2_3GPP_SP_L0B_AMR;
|
return MediaFormatProfile.MPEG4_P2_3GPP_SP_L0B_AMR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (string.Equals(videoCodec, "h263", StringComparison.OrdinalIgnoreCase) && string.Equals(audioCodec, "amrnb", StringComparison.OrdinalIgnoreCase))
|
else if (string.Equals(videoCodec, "h263", StringComparison.OrdinalIgnoreCase) && string.Equals(audioCodec, "amrnb", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
|
@ -300,11 +347,19 @@ namespace MediaBrowser.Model.Dlna
|
||||||
if (width.HasValue && height.HasValue)
|
if (width.HasValue && height.HasValue)
|
||||||
{
|
{
|
||||||
if ((width.Value <= 720) && (height.Value <= 576))
|
if ((width.Value <= 720) && (height.Value <= 576))
|
||||||
|
{
|
||||||
return MediaFormatProfile.VC1_ASF_AP_L1_WMA;
|
return MediaFormatProfile.VC1_ASF_AP_L1_WMA;
|
||||||
|
}
|
||||||
|
|
||||||
if ((width.Value <= 1280) && (height.Value <= 720))
|
if ((width.Value <= 1280) && (height.Value <= 720))
|
||||||
|
{
|
||||||
return MediaFormatProfile.VC1_ASF_AP_L2_WMA;
|
return MediaFormatProfile.VC1_ASF_AP_L2_WMA;
|
||||||
|
}
|
||||||
|
|
||||||
if ((width.Value <= 1920) && (height.Value <= 1080))
|
if ((width.Value <= 1920) && (height.Value <= 1080))
|
||||||
|
{
|
||||||
return MediaFormatProfile.VC1_ASF_AP_L3_WMA;
|
return MediaFormatProfile.VC1_ASF_AP_L3_WMA;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (string.Equals(videoCodec, "mpeg2video", StringComparison.OrdinalIgnoreCase))
|
else if (string.Equals(videoCodec, "mpeg2video", StringComparison.OrdinalIgnoreCase))
|
||||||
|
@ -318,27 +373,41 @@ namespace MediaBrowser.Model.Dlna
|
||||||
public MediaFormatProfile? ResolveAudioFormat(string container, int? bitrate, int? frequency, int? channels)
|
public MediaFormatProfile? ResolveAudioFormat(string container, int? bitrate, int? frequency, int? channels)
|
||||||
{
|
{
|
||||||
if (string.Equals(container, "asf", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(container, "asf", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return ResolveAudioASFFormat(bitrate);
|
return ResolveAudioASFFormat(bitrate);
|
||||||
|
}
|
||||||
|
|
||||||
if (string.Equals(container, "mp3", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(container, "mp3", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return MediaFormatProfile.MP3;
|
return MediaFormatProfile.MP3;
|
||||||
|
}
|
||||||
|
|
||||||
if (string.Equals(container, "lpcm", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(container, "lpcm", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return ResolveAudioLPCMFormat(frequency, channels);
|
return ResolveAudioLPCMFormat(frequency, channels);
|
||||||
|
}
|
||||||
|
|
||||||
if (string.Equals(container, "mp4", StringComparison.OrdinalIgnoreCase) ||
|
if (string.Equals(container, "mp4", StringComparison.OrdinalIgnoreCase) ||
|
||||||
string.Equals(container, "aac", StringComparison.OrdinalIgnoreCase))
|
string.Equals(container, "aac", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return ResolveAudioMP4Format(bitrate);
|
return ResolveAudioMP4Format(bitrate);
|
||||||
|
}
|
||||||
|
|
||||||
if (string.Equals(container, "adts", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(container, "adts", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return ResolveAudioADTSFormat(bitrate);
|
return ResolveAudioADTSFormat(bitrate);
|
||||||
|
}
|
||||||
|
|
||||||
if (string.Equals(container, "flac", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(container, "flac", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return MediaFormatProfile.FLAC;
|
return MediaFormatProfile.FLAC;
|
||||||
|
}
|
||||||
|
|
||||||
if (string.Equals(container, "oga", StringComparison.OrdinalIgnoreCase) ||
|
if (string.Equals(container, "oga", StringComparison.OrdinalIgnoreCase) ||
|
||||||
string.Equals(container, "ogg", StringComparison.OrdinalIgnoreCase))
|
string.Equals(container, "ogg", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return MediaFormatProfile.OGG;
|
return MediaFormatProfile.OGG;
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -410,13 +479,19 @@ namespace MediaBrowser.Model.Dlna
|
||||||
return ResolveImageJPGFormat(width, height);
|
return ResolveImageJPGFormat(width, height);
|
||||||
|
|
||||||
if (string.Equals(container, "png", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(container, "png", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return ResolveImagePNGFormat(width, height);
|
return ResolveImagePNGFormat(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
if (string.Equals(container, "gif", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(container, "gif", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return MediaFormatProfile.GIF_LRG;
|
return MediaFormatProfile.GIF_LRG;
|
||||||
|
}
|
||||||
|
|
||||||
if (string.Equals(container, "raw", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(container, "raw", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return MediaFormatProfile.RAW;
|
return MediaFormatProfile.RAW;
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -426,10 +501,14 @@ namespace MediaBrowser.Model.Dlna
|
||||||
if (width.HasValue && height.HasValue)
|
if (width.HasValue && height.HasValue)
|
||||||
{
|
{
|
||||||
if ((width.Value <= 160) && (height.Value <= 160))
|
if ((width.Value <= 160) && (height.Value <= 160))
|
||||||
|
{
|
||||||
return MediaFormatProfile.JPEG_TN;
|
return MediaFormatProfile.JPEG_TN;
|
||||||
|
}
|
||||||
|
|
||||||
if ((width.Value <= 640) && (height.Value <= 480))
|
if ((width.Value <= 640) && (height.Value <= 480))
|
||||||
|
{
|
||||||
return MediaFormatProfile.JPEG_SM;
|
return MediaFormatProfile.JPEG_SM;
|
||||||
|
}
|
||||||
|
|
||||||
if ((width.Value <= 1024) && (height.Value <= 768))
|
if ((width.Value <= 1024) && (height.Value <= 768))
|
||||||
{
|
{
|
||||||
|
@ -447,7 +526,9 @@ namespace MediaBrowser.Model.Dlna
|
||||||
if (width.HasValue && height.HasValue)
|
if (width.HasValue && height.HasValue)
|
||||||
{
|
{
|
||||||
if ((width.Value <= 160) && (height.Value <= 160))
|
if ((width.Value <= 160) && (height.Value <= 160))
|
||||||
|
{
|
||||||
return MediaFormatProfile.PNG_TN;
|
return MediaFormatProfile.PNG_TN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return MediaFormatProfile.PNG_LRG;
|
return MediaFormatProfile.PNG_LRG;
|
||||||
|
|
|
@ -114,9 +114,13 @@ namespace Rssdp.Infrastructure
|
||||||
var headersToAddTo = IsContentHeader(headerName) ? contentHeaders : headers;
|
var headersToAddTo = IsContentHeader(headerName) ? contentHeaders : headers;
|
||||||
|
|
||||||
if (values.Count > 1)
|
if (values.Count > 1)
|
||||||
|
{
|
||||||
headersToAddTo.TryAddWithoutValidation(headerName, values);
|
headersToAddTo.TryAddWithoutValidation(headerName, values);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
headersToAddTo.TryAddWithoutValidation(headerName, values.First());
|
headersToAddTo.TryAddWithoutValidation(headerName, values.First());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int ParseHeaders(System.Net.Http.Headers.HttpHeaders headers, System.Net.Http.Headers.HttpHeaders contentHeaders, string[] lines)
|
private int ParseHeaders(System.Net.Http.Headers.HttpHeaders headers, System.Net.Http.Headers.HttpHeaders contentHeaders, string[] lines)
|
||||||
|
@ -160,7 +164,9 @@ namespace Rssdp.Infrastructure
|
||||||
|
|
||||||
var indexOfSeparator = headerValue.IndexOfAny(SeparatorCharacters);
|
var indexOfSeparator = headerValue.IndexOfAny(SeparatorCharacters);
|
||||||
if (indexOfSeparator <= 0)
|
if (indexOfSeparator <= 0)
|
||||||
|
{
|
||||||
values.Add(headerValue);
|
values.Add(headerValue);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var segments = headerValue.Split(SeparatorCharacters);
|
var segments = headerValue.Split(SeparatorCharacters);
|
||||||
|
@ -170,7 +176,9 @@ namespace Rssdp.Infrastructure
|
||||||
{
|
{
|
||||||
var segment = segments[segmentIndex];
|
var segment = segments[segmentIndex];
|
||||||
if (segment.Trim().StartsWith("\"", StringComparison.OrdinalIgnoreCase))
|
if (segment.Trim().StartsWith("\"", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
segment = CombineQuotedSegments(segments, ref segmentIndex, segment);
|
segment = CombineQuotedSegments(segments, ref segmentIndex, segment);
|
||||||
|
}
|
||||||
|
|
||||||
values.Add(segment);
|
values.Add(segment);
|
||||||
}
|
}
|
||||||
|
@ -199,12 +207,16 @@ namespace Rssdp.Infrastructure
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index + 1 < segments.Length)
|
if (index + 1 < segments.Length)
|
||||||
|
{
|
||||||
trimmedSegment += "," + segments[index + 1].TrimEnd();
|
trimmedSegment += "," + segments[index + 1].TrimEnd();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
segmentIndex = segments.Length;
|
segmentIndex = segments.Length;
|
||||||
if (trimmedSegment.StartsWith("\"", StringComparison.OrdinalIgnoreCase) && trimmedSegment.EndsWith("\"", StringComparison.OrdinalIgnoreCase))
|
if (trimmedSegment.StartsWith("\"", StringComparison.OrdinalIgnoreCase) && trimmedSegment.EndsWith("\"", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return trimmedSegment.Substring(1, trimmedSegment.Length - 2);
|
return trimmedSegment.Substring(1, trimmedSegment.Length - 2);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return trimmedSegment;
|
return trimmedSegment;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,9 @@ namespace Rssdp.Infrastructure
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if (retVal != null)
|
if (retVal != null)
|
||||||
|
{
|
||||||
retVal.Dispose();
|
retVal.Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +66,9 @@ namespace Rssdp.Infrastructure
|
||||||
message.Method = new HttpMethod(parts[0].Trim());
|
message.Method = new HttpMethod(parts[0].Trim());
|
||||||
Uri requestUri;
|
Uri requestUri;
|
||||||
if (Uri.TryCreate(parts[1].Trim(), UriKind.RelativeOrAbsolute, out requestUri))
|
if (Uri.TryCreate(parts[1].Trim(), UriKind.RelativeOrAbsolute, out requestUri))
|
||||||
|
{
|
||||||
message.RequestUri = requestUri;
|
message.RequestUri = requestUri;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
System.Diagnostics.Debug.WriteLine(parts[1]);
|
System.Diagnostics.Debug.WriteLine(parts[1]);
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,9 @@ namespace Rssdp.Infrastructure
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
if (retVal != null)
|
if (retVal != null)
|
||||||
|
{
|
||||||
retVal.Dispose();
|
retVal.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +79,9 @@ namespace Rssdp.Infrastructure
|
||||||
|
|
||||||
int statusCode = -1;
|
int statusCode = -1;
|
||||||
if (!Int32.TryParse(parts[1].Trim(), out statusCode))
|
if (!Int32.TryParse(parts[1].Trim(), out statusCode))
|
||||||
|
{
|
||||||
throw new ArgumentException("data status line is invalid. Status code is not a valid integer.", nameof(data));
|
throw new ArgumentException("data status line is invalid. Status code is not a valid integer.", nameof(data));
|
||||||
|
}
|
||||||
|
|
||||||
message.StatusCode = (HttpStatusCode)statusCode;
|
message.StatusCode = (HttpStatusCode)statusCode;
|
||||||
|
|
||||||
|
|
|
@ -480,17 +480,21 @@ namespace Rssdp.Infrastructure
|
||||||
|
|
||||||
var handlers = this.RequestReceived;
|
var handlers = this.RequestReceived;
|
||||||
if (handlers != null)
|
if (handlers != null)
|
||||||
|
{
|
||||||
handlers(this, new RequestReceivedEventArgs(data, remoteEndPoint, receivedOnLocalIpAddress));
|
handlers(this, new RequestReceivedEventArgs(data, remoteEndPoint, receivedOnLocalIpAddress));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnResponseReceived(HttpResponseMessage data, IPEndPoint endPoint, IPAddress localIpAddress)
|
private void OnResponseReceived(HttpResponseMessage data, IPEndPoint endPoint, IPAddress localIpAddress)
|
||||||
{
|
{
|
||||||
var handlers = this.ResponseReceived;
|
var handlers = this.ResponseReceived;
|
||||||
if (handlers != null)
|
if (handlers != null)
|
||||||
|
{
|
||||||
handlers(this, new ResponseReceivedEventArgs(data, endPoint)
|
handlers(this, new ResponseReceivedEventArgs(data, endPoint)
|
||||||
{
|
{
|
||||||
LocalIpAddress = localIpAddress
|
LocalIpAddress = localIpAddress
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,9 @@ namespace Rssdp
|
||||||
|
|
||||||
var rootDevice = device as SsdpRootDevice;
|
var rootDevice = device as SsdpRootDevice;
|
||||||
if (rootDevice == null)
|
if (rootDevice == null)
|
||||||
|
{
|
||||||
rootDevice = ((SsdpEmbeddedDevice)device).RootDevice;
|
rootDevice = ((SsdpEmbeddedDevice)device).RootDevice;
|
||||||
|
}
|
||||||
|
|
||||||
return rootDevice;
|
return rootDevice;
|
||||||
}
|
}
|
||||||
|
@ -163,7 +165,9 @@ namespace Rssdp
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(_Udn) && !String.IsNullOrEmpty(this.Uuid))
|
if (String.IsNullOrEmpty(_Udn) && !String.IsNullOrEmpty(this.Uuid))
|
||||||
|
{
|
||||||
return "uuid:" + this.Uuid;
|
return "uuid:" + this.Uuid;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return _Udn;
|
return _Udn;
|
||||||
}
|
}
|
||||||
|
@ -283,7 +287,9 @@ namespace Rssdp
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wasAdded)
|
if (wasAdded)
|
||||||
|
{
|
||||||
OnDeviceAdded(device);
|
OnDeviceAdded(device);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -314,7 +320,9 @@ namespace Rssdp
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wasRemoved)
|
if (wasRemoved)
|
||||||
|
{
|
||||||
OnDeviceRemoved(device);
|
OnDeviceRemoved(device);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -327,7 +335,9 @@ namespace Rssdp
|
||||||
{
|
{
|
||||||
var handlers = this.DeviceAdded;
|
var handlers = this.DeviceAdded;
|
||||||
if (handlers != null)
|
if (handlers != null)
|
||||||
|
{
|
||||||
handlers(this, new DeviceEventArgs(device));
|
handlers(this, new DeviceEventArgs(device));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -340,7 +350,9 @@ namespace Rssdp
|
||||||
{
|
{
|
||||||
var handlers = this.DeviceRemoved;
|
var handlers = this.DeviceRemoved;
|
||||||
if (handlers != null)
|
if (handlers != null)
|
||||||
|
{
|
||||||
handlers(this, new DeviceEventArgs(device));
|
handlers(this, new DeviceEventArgs(device));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,10 +217,12 @@ namespace Rssdp.Infrastructure
|
||||||
|
|
||||||
var handlers = this.DeviceAvailable;
|
var handlers = this.DeviceAvailable;
|
||||||
if (handlers != null)
|
if (handlers != null)
|
||||||
|
{
|
||||||
handlers(this, new DeviceAvailableEventArgs(device, isNewDevice)
|
handlers(this, new DeviceAvailableEventArgs(device, isNewDevice)
|
||||||
{
|
{
|
||||||
LocalIpAddress = localIpAddress
|
LocalIpAddress = localIpAddress
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -426,7 +428,9 @@ namespace Rssdp.Infrastructure
|
||||||
};
|
};
|
||||||
|
|
||||||
if (NotificationTypeMatchesFilter(deadDevice))
|
if (NotificationTypeMatchesFilter(deadDevice))
|
||||||
|
{
|
||||||
OnDeviceUnavailable(deadDevice, false);
|
OnDeviceUnavailable(deadDevice, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -439,7 +443,9 @@ namespace Rssdp.Infrastructure
|
||||||
{
|
{
|
||||||
message.Headers.TryGetValues(headerName, out values);
|
message.Headers.TryGetValues(headerName, out values);
|
||||||
if (values != null)
|
if (values != null)
|
||||||
|
{
|
||||||
retVal = values.FirstOrDefault();
|
retVal = values.FirstOrDefault();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
|
@ -453,7 +459,9 @@ namespace Rssdp.Infrastructure
|
||||||
{
|
{
|
||||||
message.Headers.TryGetValues(headerName, out values);
|
message.Headers.TryGetValues(headerName, out values);
|
||||||
if (values != null)
|
if (values != null)
|
||||||
|
{
|
||||||
retVal = values.FirstOrDefault();
|
retVal = values.FirstOrDefault();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
|
@ -467,7 +475,9 @@ namespace Rssdp.Infrastructure
|
||||||
{
|
{
|
||||||
request.Headers.TryGetValues(headerName, out values);
|
request.Headers.TryGetValues(headerName, out values);
|
||||||
if (values != null)
|
if (values != null)
|
||||||
|
{
|
||||||
value = values.FirstOrDefault();
|
value = values.FirstOrDefault();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Uri retVal;
|
Uri retVal;
|
||||||
|
@ -483,7 +493,9 @@ namespace Rssdp.Infrastructure
|
||||||
{
|
{
|
||||||
response.Headers.TryGetValues(headerName, out values);
|
response.Headers.TryGetValues(headerName, out values);
|
||||||
if (values != null)
|
if (values != null)
|
||||||
|
{
|
||||||
value = values.FirstOrDefault();
|
value = values.FirstOrDefault();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Uri retVal;
|
Uri retVal;
|
||||||
|
@ -560,7 +572,9 @@ namespace Rssdp.Infrastructure
|
||||||
foreach (var removedDevice in existingDevices)
|
foreach (var removedDevice in existingDevices)
|
||||||
{
|
{
|
||||||
if (NotificationTypeMatchesFilter(removedDevice))
|
if (NotificationTypeMatchesFilter(removedDevice))
|
||||||
|
{
|
||||||
OnDeviceUnavailable(removedDevice, expired);
|
OnDeviceUnavailable(removedDevice, expired);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -572,7 +586,9 @@ namespace Rssdp.Infrastructure
|
||||||
private TimeSpan SearchTimeToMXValue(TimeSpan searchWaitTime)
|
private TimeSpan SearchTimeToMXValue(TimeSpan searchWaitTime)
|
||||||
{
|
{
|
||||||
if (searchWaitTime.TotalSeconds < 2 || searchWaitTime == TimeSpan.Zero)
|
if (searchWaitTime.TotalSeconds < 2 || searchWaitTime == TimeSpan.Zero)
|
||||||
|
{
|
||||||
return OneSecond;
|
return OneSecond;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return searchWaitTime.Subtract(OneSecond);
|
return searchWaitTime.Subtract(OneSecond);
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,7 +215,9 @@ namespace Rssdp.Infrastructure
|
||||||
if (commsServer != null)
|
if (commsServer != null)
|
||||||
{
|
{
|
||||||
if (!commsServer.IsShared)
|
if (!commsServer.IsShared)
|
||||||
|
{
|
||||||
commsServer.Dispose();
|
commsServer.Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_RecentSearchRequests = null;
|
_RecentSearchRequests = null;
|
||||||
|
@ -328,7 +330,9 @@ namespace Rssdp.Infrastructure
|
||||||
{
|
{
|
||||||
SendSearchResponse(SsdpConstants.UpnpDeviceTypeRootDevice, device, GetUsn(device.Udn, SsdpConstants.UpnpDeviceTypeRootDevice), endPoint, receivedOnlocalIpAddress, cancellationToken);
|
SendSearchResponse(SsdpConstants.UpnpDeviceTypeRootDevice, device, GetUsn(device.Udn, SsdpConstants.UpnpDeviceTypeRootDevice), endPoint, receivedOnlocalIpAddress, cancellationToken);
|
||||||
if (this.SupportPnpRootDevice)
|
if (this.SupportPnpRootDevice)
|
||||||
|
{
|
||||||
SendSearchResponse(SsdpConstants.PnpDeviceTypeRootDevice, device, GetUsn(device.Udn, SsdpConstants.PnpDeviceTypeRootDevice), endPoint, receivedOnlocalIpAddress, cancellationToken);
|
SendSearchResponse(SsdpConstants.PnpDeviceTypeRootDevice, device, GetUsn(device.Udn, SsdpConstants.PnpDeviceTypeRootDevice), endPoint, receivedOnlocalIpAddress, cancellationToken);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SendSearchResponse(device.Udn, device, device.Udn, endPoint, receivedOnlocalIpAddress, cancellationToken);
|
SendSearchResponse(device.Udn, device, device.Udn, endPoint, receivedOnlocalIpAddress, cancellationToken);
|
||||||
|
@ -394,7 +398,9 @@ namespace Rssdp.Infrastructure
|
||||||
{
|
{
|
||||||
var lastRequest = _RecentSearchRequests[newRequest.Key];
|
var lastRequest = _RecentSearchRequests[newRequest.Key];
|
||||||
if (lastRequest.IsOld())
|
if (lastRequest.IsOld())
|
||||||
|
{
|
||||||
_RecentSearchRequests[newRequest.Key] = newRequest;
|
_RecentSearchRequests[newRequest.Key] = newRequest;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
isDuplicateRequest = true;
|
isDuplicateRequest = true;
|
||||||
}
|
}
|
||||||
|
@ -402,7 +408,9 @@ namespace Rssdp.Infrastructure
|
||||||
{
|
{
|
||||||
_RecentSearchRequests.Add(newRequest.Key, newRequest);
|
_RecentSearchRequests.Add(newRequest.Key, newRequest);
|
||||||
if (_RecentSearchRequests.Count > 10)
|
if (_RecentSearchRequests.Count > 10)
|
||||||
|
{
|
||||||
CleanUpRecentSearchRequestsAsync();
|
CleanUpRecentSearchRequestsAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -462,7 +470,9 @@ namespace Rssdp.Infrastructure
|
||||||
{
|
{
|
||||||
SendAliveNotification(device, SsdpConstants.UpnpDeviceTypeRootDevice, GetUsn(device.Udn, SsdpConstants.UpnpDeviceTypeRootDevice), cancellationToken);
|
SendAliveNotification(device, SsdpConstants.UpnpDeviceTypeRootDevice, GetUsn(device.Udn, SsdpConstants.UpnpDeviceTypeRootDevice), cancellationToken);
|
||||||
if (this.SupportPnpRootDevice)
|
if (this.SupportPnpRootDevice)
|
||||||
|
{
|
||||||
SendAliveNotification(device, SsdpConstants.PnpDeviceTypeRootDevice, GetUsn(device.Udn, SsdpConstants.PnpDeviceTypeRootDevice), cancellationToken);
|
SendAliveNotification(device, SsdpConstants.PnpDeviceTypeRootDevice, GetUsn(device.Udn, SsdpConstants.PnpDeviceTypeRootDevice), cancellationToken);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SendAliveNotification(device, device.Udn, device.Udn, cancellationToken);
|
SendAliveNotification(device, device.Udn, device.Udn, cancellationToken);
|
||||||
|
@ -506,7 +516,9 @@ namespace Rssdp.Infrastructure
|
||||||
{
|
{
|
||||||
tasks.Add(SendByeByeNotification(device, SsdpConstants.UpnpDeviceTypeRootDevice, GetUsn(device.Udn, SsdpConstants.UpnpDeviceTypeRootDevice), cancellationToken));
|
tasks.Add(SendByeByeNotification(device, SsdpConstants.UpnpDeviceTypeRootDevice, GetUsn(device.Udn, SsdpConstants.UpnpDeviceTypeRootDevice), cancellationToken));
|
||||||
if (this.SupportPnpRootDevice)
|
if (this.SupportPnpRootDevice)
|
||||||
|
{
|
||||||
tasks.Add(SendByeByeNotification(device, "pnp:rootdevice", GetUsn(device.Udn, "pnp:rootdevice"), cancellationToken));
|
tasks.Add(SendByeByeNotification(device, "pnp:rootdevice", GetUsn(device.Udn, "pnp:rootdevice"), cancellationToken));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.Add(SendByeByeNotification(device, device.Udn, device.Udn, cancellationToken));
|
tasks.Add(SendByeByeNotification(device, device.Udn, device.Udn, cancellationToken));
|
||||||
|
@ -547,20 +559,27 @@ namespace Rssdp.Infrastructure
|
||||||
var timer = _RebroadcastAliveNotificationsTimer;
|
var timer = _RebroadcastAliveNotificationsTimer;
|
||||||
_RebroadcastAliveNotificationsTimer = null;
|
_RebroadcastAliveNotificationsTimer = null;
|
||||||
if (timer != null)
|
if (timer != null)
|
||||||
|
{
|
||||||
timer.Dispose();
|
timer.Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private TimeSpan GetMinimumNonZeroCacheLifetime()
|
private TimeSpan GetMinimumNonZeroCacheLifetime()
|
||||||
{
|
{
|
||||||
var nonzeroCacheLifetimesQuery = (from device
|
var nonzeroCacheLifetimesQuery = (
|
||||||
in _Devices
|
from device
|
||||||
where device.CacheLifetime != TimeSpan.Zero
|
in _Devices
|
||||||
select device.CacheLifetime).ToList();
|
where device.CacheLifetime != TimeSpan.Zero
|
||||||
|
select device.CacheLifetime).ToList();
|
||||||
|
|
||||||
if (nonzeroCacheLifetimesQuery.Any())
|
if (nonzeroCacheLifetimesQuery.Any())
|
||||||
|
{
|
||||||
return nonzeroCacheLifetimesQuery.Min();
|
return nonzeroCacheLifetimesQuery.Min();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return TimeSpan.Zero;
|
return TimeSpan.Zero;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetFirstHeaderValue(System.Net.Http.Headers.HttpRequestHeaders httpRequestHeaders, string headerName)
|
private string GetFirstHeaderValue(System.Net.Http.Headers.HttpRequestHeaders httpRequestHeaders, string headerName)
|
||||||
|
@ -568,7 +587,9 @@ namespace Rssdp.Infrastructure
|
||||||
string retVal = null;
|
string retVal = null;
|
||||||
IEnumerable<String> values = null;
|
IEnumerable<String> values = null;
|
||||||
if (httpRequestHeaders.TryGetValues(headerName, out values) && values != null)
|
if (httpRequestHeaders.TryGetValues(headerName, out values) && values != null)
|
||||||
|
{
|
||||||
retVal = values.FirstOrDefault();
|
retVal = values.FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
@ -588,7 +609,9 @@ namespace Rssdp.Infrastructure
|
||||||
{
|
{
|
||||||
var rootDevice = device as SsdpRootDevice;
|
var rootDevice = device as SsdpRootDevice;
|
||||||
if (rootDevice != null)
|
if (rootDevice != null)
|
||||||
|
{
|
||||||
WriteTrace(text + " " + device.DeviceType + " - " + device.Uuid + " - " + rootDevice.Location);
|
WriteTrace(text + " " + device.DeviceType + " - " + device.Uuid + " - " + rootDevice.Location);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
WriteTrace(text + " " + device.DeviceType + " - " + device.Uuid);
|
WriteTrace(text + " " + device.DeviceType + " - " + device.Uuid);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user