aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Model/Dlna
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Model/Dlna')
-rw-r--r--MediaBrowser.Model/Dlna/ConditionProcessor.cs13
-rw-r--r--MediaBrowser.Model/Dlna/DeviceProfile.cs9
-rw-r--r--MediaBrowser.Model/Dlna/Filter.cs3
-rw-r--r--MediaBrowser.Model/Dlna/MediaFormatProfileResolver.cs147
-rw-r--r--MediaBrowser.Model/Dlna/SearchCriteria.cs15
-rw-r--r--MediaBrowser.Model/Dlna/StreamBuilder.cs28
-rw-r--r--MediaBrowser.Model/Dlna/StreamInfo.cs30
7 files changed, 122 insertions, 123 deletions
diff --git a/MediaBrowser.Model/Dlna/ConditionProcessor.cs b/MediaBrowser.Model/Dlna/ConditionProcessor.cs
index 488d742f5..64ce2aaba 100644
--- a/MediaBrowser.Model/Dlna/ConditionProcessor.cs
+++ b/MediaBrowser.Model/Dlna/ConditionProcessor.cs
@@ -1,6 +1,6 @@
-using MediaBrowser.Model.MediaInfo;
+using MediaBrowser.Model.Extensions;
+using MediaBrowser.Model.MediaInfo;
using System;
-using System.Globalization;
namespace MediaBrowser.Model.Dlna
{
@@ -98,7 +98,6 @@ namespace MediaBrowser.Model.Dlna
}
}
- private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
private bool IsConditionSatisfied(ProfileCondition condition, int? currentValue)
{
if (!currentValue.HasValue)
@@ -108,7 +107,7 @@ namespace MediaBrowser.Model.Dlna
}
int expected;
- if (int.TryParse(condition.Value, NumberStyles.Any, UsCulture, out expected))
+ if (IntHelper.TryParseCultureInvariant(condition.Value, out expected))
{
switch (condition.Condition)
{
@@ -141,9 +140,9 @@ namespace MediaBrowser.Model.Dlna
switch (condition.Condition)
{
case ProfileConditionType.Equals:
- return string.Equals(currentValue, expected, StringComparison.OrdinalIgnoreCase);
+ return StringHelper.EqualsIgnoreCase(currentValue, expected);
case ProfileConditionType.NotEquals:
- return !string.Equals(currentValue, expected, StringComparison.OrdinalIgnoreCase);
+ return !StringHelper.EqualsIgnoreCase(currentValue, expected);
default:
throw new InvalidOperationException("Unexpected ProfileConditionType");
}
@@ -158,7 +157,7 @@ namespace MediaBrowser.Model.Dlna
}
double expected;
- if (double.TryParse(condition.Value, NumberStyles.Any, UsCulture, out expected))
+ if (DoubleHelper.TryParseCultureInvariant(condition.Value, out expected))
{
switch (condition.Condition)
{
diff --git a/MediaBrowser.Model/Dlna/DeviceProfile.cs b/MediaBrowser.Model/Dlna/DeviceProfile.cs
index a3e217ef3..2ed483fa1 100644
--- a/MediaBrowser.Model/Dlna/DeviceProfile.cs
+++ b/MediaBrowser.Model/Dlna/DeviceProfile.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Model.MediaInfo;
+using MediaBrowser.Model.Extensions;
+using MediaBrowser.Model.MediaInfo;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -125,7 +126,7 @@ namespace MediaBrowser.Model.Dlna
continue;
}
- if (!string.Equals(container, i.Container, StringComparison.OrdinalIgnoreCase))
+ if (!StringHelper.EqualsIgnoreCase(container, i.Container))
{
continue;
}
@@ -151,7 +152,7 @@ namespace MediaBrowser.Model.Dlna
continue;
}
- if (!string.Equals(container, i.Container, StringComparison.OrdinalIgnoreCase))
+ if (!StringHelper.EqualsIgnoreCase(container, i.Container))
{
continue;
}
@@ -161,7 +162,7 @@ namespace MediaBrowser.Model.Dlna
continue;
}
- if (!string.Equals(videoCodec, i.VideoCodec, StringComparison.OrdinalIgnoreCase))
+ if (!StringHelper.EqualsIgnoreCase(videoCodec, i.VideoCodec))
{
continue;
}
diff --git a/MediaBrowser.Model/Dlna/Filter.cs b/MediaBrowser.Model/Dlna/Filter.cs
index 760adb585..d92f881ce 100644
--- a/MediaBrowser.Model/Dlna/Filter.cs
+++ b/MediaBrowser.Model/Dlna/Filter.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using MediaBrowser.Model.Extensions;
namespace MediaBrowser.Model.Dlna
{
@@ -17,7 +18,7 @@ namespace MediaBrowser.Model.Dlna
public Filter(string filter)
{
- _all = string.Equals(filter, "*", StringComparison.OrdinalIgnoreCase);
+ _all = StringHelper.EqualsIgnoreCase(filter, "*");
List<string> list = new List<string>();
foreach (string s in (filter ?? string.Empty).Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries))
diff --git a/MediaBrowser.Model/Dlna/MediaFormatProfileResolver.cs b/MediaBrowser.Model/Dlna/MediaFormatProfileResolver.cs
index 3c35ca0f6..022c0efda 100644
--- a/MediaBrowser.Model/Dlna/MediaFormatProfileResolver.cs
+++ b/MediaBrowser.Model/Dlna/MediaFormatProfileResolver.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Model.MediaInfo;
+using MediaBrowser.Model.Extensions;
+using MediaBrowser.Model.MediaInfo;
using System;
using System.Collections.Generic;
@@ -8,53 +9,53 @@ namespace MediaBrowser.Model.Dlna
{
public IEnumerable<MediaFormatProfile> ResolveVideoFormat(string container, string videoCodec, string audioCodec, int? width, int? height, TransportStreamTimestamp timestampType)
{
- if (string.Equals(container, "asf", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(container, "asf"))
{
MediaFormatProfile? val = ResolveVideoASFFormat(videoCodec, audioCodec, width, height);
return val.HasValue ? new List<MediaFormatProfile> { val.Value } : new List<MediaFormatProfile>();
}
- if (string.Equals(container, "mp4", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(container, "mp4"))
{
MediaFormatProfile? val = ResolveVideoMP4Format(videoCodec, audioCodec, width, height);
return val.HasValue ? new List<MediaFormatProfile> { val.Value } : new List<MediaFormatProfile>();
}
- if (string.Equals(container, "avi", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(container, "avi"))
return new[] { MediaFormatProfile.AVI };
- if (string.Equals(container, "mkv", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(container, "mkv"))
return new[] { MediaFormatProfile.MATROSKA };
- if (string.Equals(container, "mpeg2ps", StringComparison.OrdinalIgnoreCase) ||
- string.Equals(container, "ts", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(container, "mpeg2ps") ||
+ StringHelper.EqualsIgnoreCase(container, "ts"))
return new[] { MediaFormatProfile.MPEG_PS_NTSC, MediaFormatProfile.MPEG_PS_PAL };
- if (string.Equals(container, "mpeg1video", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(container, "mpeg1video"))
return new[] { MediaFormatProfile.MPEG1 };
- if (string.Equals(container, "mpeg2ts", StringComparison.OrdinalIgnoreCase) ||
- string.Equals(container, "mpegts", StringComparison.OrdinalIgnoreCase) ||
- string.Equals(container, "m2ts", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(container, "mpeg2ts") ||
+ StringHelper.EqualsIgnoreCase(container, "mpegts") ||
+ StringHelper.EqualsIgnoreCase(container, "m2ts"))
{
return ResolveVideoMPEG2TSFormat(videoCodec, audioCodec, width, height, timestampType);
}
- if (string.Equals(container, "flv", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(container, "flv"))
return new[] { MediaFormatProfile.FLV };
- if (string.Equals(container, "wtv", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(container, "wtv"))
return new[] { MediaFormatProfile.WTV };
- if (string.Equals(container, "3gp", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(container, "3gp"))
{
MediaFormatProfile? val = ResolveVideo3GPFormat(videoCodec, audioCodec);
return val.HasValue ? new List<MediaFormatProfile> { val.Value } : new List<MediaFormatProfile>();
}
- if (string.Equals(container, "ogv", StringComparison.OrdinalIgnoreCase) || string.Equals(container, "ogg", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(container, "ogv") || StringHelper.EqualsIgnoreCase(container, "ogg"))
return new[] { MediaFormatProfile.OGV };
return new List<MediaFormatProfile>();
@@ -80,7 +81,7 @@ namespace MediaBrowser.Model.Dlna
resolution = "H";
}
- if (string.Equals(videoCodec, "mpeg2video", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(videoCodec, "mpeg2video"))
{
List<MediaFormatProfile> list = new List<MediaFormatProfile>();
@@ -88,18 +89,18 @@ namespace MediaBrowser.Model.Dlna
list.Add(ValueOf("MPEG_TS_SD_EU" + suffix));
list.Add(ValueOf("MPEG_TS_SD_KO" + suffix));
- if ((timestampType == TransportStreamTimestamp.Valid) && string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
+ if ((timestampType == TransportStreamTimestamp.Valid) && StringHelper.EqualsIgnoreCase(audioCodec, "aac"))
{
list.Add(MediaFormatProfile.MPEG_TS_JP_T);
}
return list;
}
- if (string.Equals(videoCodec, "h264", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(videoCodec, "h264"))
{
- if (string.Equals(audioCodec, "lpcm", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(audioCodec, "lpcm"))
return new[] { MediaFormatProfile.AVC_TS_HD_50_LPCM_T };
- if (string.Equals(audioCodec, "dts", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(audioCodec, "dts"))
{
if (timestampType == TransportStreamTimestamp.None)
{
@@ -108,7 +109,7 @@ namespace MediaBrowser.Model.Dlna
return new[] { MediaFormatProfile.AVC_TS_HD_DTS_T };
}
- if (string.Equals(audioCodec, "mp3", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(audioCodec, "mp3"))
{
if (timestampType == TransportStreamTimestamp.None)
{
@@ -118,19 +119,19 @@ namespace MediaBrowser.Model.Dlna
return new[] { ValueOf(string.Format("AVC_TS_HP_{0}D_MPEG1_L2_T", resolution)) };
}
- if (string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(audioCodec, "aac"))
return new[] { ValueOf(string.Format("AVC_TS_MP_{0}D_AAC_MULT5{1}", resolution, suffix)) };
- if (string.Equals(audioCodec, "mp3", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(audioCodec, "mp3"))
return new[] { ValueOf(string.Format("AVC_TS_MP_{0}D_MPEG1_L3{1}", resolution, suffix)) };
if (string.IsNullOrEmpty(audioCodec) ||
- string.Equals(audioCodec, "ac3", StringComparison.OrdinalIgnoreCase))
+ StringHelper.EqualsIgnoreCase(audioCodec, "ac3"))
return new[] { ValueOf(string.Format("AVC_TS_MP_{0}D_AC3{1}", resolution, suffix)) };
}
- else if (string.Equals(videoCodec, "vc1", StringComparison.OrdinalIgnoreCase))
+ else if (StringHelper.EqualsIgnoreCase(videoCodec, "vc1"))
{
- if (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "ac3", StringComparison.OrdinalIgnoreCase))
+ if (string.IsNullOrEmpty(audioCodec) || StringHelper.EqualsIgnoreCase(audioCodec, "ac3"))
{
if ((width.HasValue && width.Value > 720) || (height.HasValue && height.Value > 576))
{
@@ -138,23 +139,23 @@ namespace MediaBrowser.Model.Dlna
}
return new[] { MediaFormatProfile.VC1_TS_AP_L1_AC3_ISO };
}
- if (string.Equals(audioCodec, "dts", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(audioCodec, "dts"))
{
- suffix = string.Equals(suffix, "_ISO") ? suffix : "_T";
+ suffix = StringHelper.EqualsIgnoreCase(suffix, "_ISO") ? suffix : "_T";
return new[] { ValueOf(string.Format("VC1_TS_HD_DTS{0}", suffix)) };
}
}
- else if (string.Equals(videoCodec, "mpeg4", StringComparison.OrdinalIgnoreCase) || string.Equals(videoCodec, "msmpeg4", StringComparison.OrdinalIgnoreCase))
+ else if (StringHelper.EqualsIgnoreCase(videoCodec, "mpeg4") || StringHelper.EqualsIgnoreCase(videoCodec, "msmpeg4"))
{
- if (string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(audioCodec, "aac"))
return new[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_AAC{0}", suffix)) };
- if (string.Equals(audioCodec, "mp3", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(audioCodec, "mp3"))
return new[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_MPEG1_L3{0}", suffix)) };
- if (string.Equals(audioCodec, "mp2", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(audioCodec, "mp2"))
return new[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_MPEG2_L2{0}", suffix)) };
- if (string.Equals(audioCodec, "ac3", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(audioCodec, "ac3"))
return new[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_AC3{0}", suffix)) };
}
@@ -168,16 +169,16 @@ namespace MediaBrowser.Model.Dlna
private MediaFormatProfile? ResolveVideoMP4Format(string videoCodec, string audioCodec, int? width, int? height)
{
- if (string.Equals(videoCodec, "h264", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(videoCodec, "h264"))
{
- if (string.Equals(audioCodec, "lpcm", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(audioCodec, "lpcm"))
return MediaFormatProfile.AVC_MP4_LPCM;
if (string.IsNullOrEmpty(audioCodec) ||
- string.Equals(audioCodec, "ac3", StringComparison.OrdinalIgnoreCase))
+ StringHelper.EqualsIgnoreCase(audioCodec, "ac3"))
{
return MediaFormatProfile.AVC_MP4_MP_SD_AC3;
}
- if (string.Equals(audioCodec, "mp3", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(audioCodec, "mp3"))
{
return MediaFormatProfile.AVC_MP4_MP_SD_MPEG1_L3;
}
@@ -185,41 +186,41 @@ namespace MediaBrowser.Model.Dlna
{
if ((width.Value <= 720) && (height.Value <= 576))
{
- if (string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(audioCodec, "aac"))
return MediaFormatProfile.AVC_MP4_MP_SD_AAC_MULT5;
}
else if ((width.Value <= 1280) && (height.Value <= 720))
{
- if (string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(audioCodec, "aac"))
return MediaFormatProfile.AVC_MP4_MP_HD_720p_AAC;
}
else if ((width.Value <= 1920) && (height.Value <= 1080))
{
- if (string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(audioCodec, "aac"))
{
return MediaFormatProfile.AVC_MP4_MP_HD_1080i_AAC;
}
}
}
}
- else if (string.Equals(videoCodec, "mpeg4", StringComparison.OrdinalIgnoreCase) ||
- string.Equals(videoCodec, "msmpeg4", StringComparison.OrdinalIgnoreCase))
+ else if (StringHelper.EqualsIgnoreCase(videoCodec, "mpeg4") ||
+ StringHelper.EqualsIgnoreCase(videoCodec, "msmpeg4"))
{
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) || StringHelper.EqualsIgnoreCase(audioCodec, "aac"))
return MediaFormatProfile.MPEG4_P2_MP4_ASP_AAC;
- if (string.Equals(audioCodec, "ac3", StringComparison.OrdinalIgnoreCase) || string.Equals(audioCodec, "mp3", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(audioCodec, "ac3") || StringHelper.EqualsIgnoreCase(audioCodec, "mp3"))
{
return MediaFormatProfile.MPEG4_P2_MP4_NDSD;
}
}
- else if (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
+ else if (string.IsNullOrEmpty(audioCodec) || StringHelper.EqualsIgnoreCase(audioCodec, "aac"))
{
return MediaFormatProfile.MPEG4_P2_MP4_SP_L6_AAC;
}
}
- else if (string.Equals(videoCodec, "h263", StringComparison.OrdinalIgnoreCase) && string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
+ else if (StringHelper.EqualsIgnoreCase(videoCodec, "h263") && StringHelper.EqualsIgnoreCase(audioCodec, "aac"))
{
return MediaFormatProfile.MPEG4_H263_MP4_P0_L10_AAC;
}
@@ -229,20 +230,20 @@ namespace MediaBrowser.Model.Dlna
private MediaFormatProfile? ResolveVideo3GPFormat(string videoCodec, string audioCodec)
{
- if (string.Equals(videoCodec, "h264", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(videoCodec, "h264"))
{
- if (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
+ if (string.IsNullOrEmpty(audioCodec) || StringHelper.EqualsIgnoreCase(audioCodec, "aac"))
return MediaFormatProfile.AVC_3GPP_BL_QCIF15_AAC;
}
- else if (string.Equals(videoCodec, "mpeg4", StringComparison.OrdinalIgnoreCase) ||
- string.Equals(videoCodec, "msmpeg4", StringComparison.OrdinalIgnoreCase))
+ else if (StringHelper.EqualsIgnoreCase(videoCodec, "mpeg4") ||
+ StringHelper.EqualsIgnoreCase(videoCodec, "msmpeg4"))
{
- if (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "wma", StringComparison.OrdinalIgnoreCase))
+ if (string.IsNullOrEmpty(audioCodec) || StringHelper.EqualsIgnoreCase(audioCodec, "wma"))
return MediaFormatProfile.MPEG4_P2_3GPP_SP_L0B_AAC;
- if (string.Equals(audioCodec, "amrnb", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(audioCodec, "amrnb"))
return MediaFormatProfile.MPEG4_P2_3GPP_SP_L0B_AMR;
}
- else if (string.Equals(videoCodec, "h263", StringComparison.OrdinalIgnoreCase) && string.Equals(audioCodec, "amrnb", StringComparison.OrdinalIgnoreCase))
+ else if (StringHelper.EqualsIgnoreCase(videoCodec, "h263") && StringHelper.EqualsIgnoreCase(audioCodec, "amrnb"))
{
return MediaFormatProfile.MPEG4_H263_3GPP_P0_L10_AMR;
}
@@ -252,15 +253,15 @@ namespace MediaBrowser.Model.Dlna
private MediaFormatProfile? ResolveVideoASFFormat(string videoCodec, string audioCodec, int? width, int? height)
{
- if (string.Equals(videoCodec, "wmv", StringComparison.OrdinalIgnoreCase) &&
- (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "wma", StringComparison.OrdinalIgnoreCase) || string.Equals(videoCodec, "wmapro", StringComparison.OrdinalIgnoreCase)))
+ if (StringHelper.EqualsIgnoreCase(videoCodec, "wmv") &&
+ (string.IsNullOrEmpty(audioCodec) || StringHelper.EqualsIgnoreCase(audioCodec, "wma") || StringHelper.EqualsIgnoreCase(videoCodec, "wmapro")))
{
if (width.HasValue && height.HasValue)
{
if ((width.Value <= 720) && (height.Value <= 576))
{
- if (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "wma", StringComparison.OrdinalIgnoreCase))
+ if (string.IsNullOrEmpty(audioCodec) || StringHelper.EqualsIgnoreCase(audioCodec, "wma"))
{
return MediaFormatProfile.WMVMED_FULL;
}
@@ -268,14 +269,14 @@ namespace MediaBrowser.Model.Dlna
}
}
- if (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "wma", StringComparison.OrdinalIgnoreCase))
+ if (string.IsNullOrEmpty(audioCodec) || StringHelper.EqualsIgnoreCase(audioCodec, "wma"))
{
return MediaFormatProfile.WMVHIGH_FULL;
}
return MediaFormatProfile.WMVHIGH_PRO;
}
- if (string.Equals(videoCodec, "vc1", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(videoCodec, "vc1"))
{
if (width.HasValue && height.HasValue)
{
@@ -287,7 +288,7 @@ namespace MediaBrowser.Model.Dlna
return MediaFormatProfile.VC1_ASF_AP_L3_WMA;
}
}
- else if (string.Equals(videoCodec, "mpeg2video", StringComparison.OrdinalIgnoreCase))
+ else if (StringHelper.EqualsIgnoreCase(videoCodec, "mpeg2video"))
{
return MediaFormatProfile.DVR_MS;
}
@@ -297,27 +298,27 @@ namespace MediaBrowser.Model.Dlna
public MediaFormatProfile? ResolveAudioFormat(string container, int? bitrate, int? frequency, int? channels)
{
- if (string.Equals(container, "asf", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(container, "asf"))
return ResolveAudioASFFormat(bitrate);
- if (string.Equals(container, "mp3", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(container, "mp3"))
return MediaFormatProfile.MP3;
- if (string.Equals(container, "lpcm", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(container, "lpcm"))
return ResolveAudioLPCMFormat(frequency, channels);
- if (string.Equals(container, "mp4", StringComparison.OrdinalIgnoreCase) ||
- string.Equals(container, "aac", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(container, "mp4") ||
+ StringHelper.EqualsIgnoreCase(container, "aac"))
return ResolveAudioMP4Format(bitrate);
- if (string.Equals(container, "adts", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(container, "adts"))
return ResolveAudioADTSFormat(bitrate);
- if (string.Equals(container, "flac", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(container, "flac"))
return MediaFormatProfile.FLAC;
- if (string.Equals(container, "oga", StringComparison.OrdinalIgnoreCase) ||
- string.Equals(container, "ogg", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(container, "oga") ||
+ StringHelper.EqualsIgnoreCase(container, "ogg"))
return MediaFormatProfile.OGG;
return null;
@@ -379,17 +380,17 @@ namespace MediaBrowser.Model.Dlna
public MediaFormatProfile? ResolveImageFormat(string container, int? width, int? height)
{
- if (string.Equals(container, "jpeg", StringComparison.OrdinalIgnoreCase) ||
- string.Equals(container, "jpg", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(container, "jpeg") ||
+ StringHelper.EqualsIgnoreCase(container, "jpg"))
return ResolveImageJPGFormat(width, height);
- if (string.Equals(container, "png", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(container, "png"))
return MediaFormatProfile.PNG_LRG;
- if (string.Equals(container, "gif", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(container, "gif"))
return MediaFormatProfile.GIF_LRG;
- if (string.Equals(container, "raw", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(container, "raw"))
return MediaFormatProfile.RAW;
return null;
diff --git a/MediaBrowser.Model/Dlna/SearchCriteria.cs b/MediaBrowser.Model/Dlna/SearchCriteria.cs
index bb4221b51..ced852583 100644
--- a/MediaBrowser.Model/Dlna/SearchCriteria.cs
+++ b/MediaBrowser.Model/Dlna/SearchCriteria.cs
@@ -1,4 +1,5 @@
-using System;
+using MediaBrowser.Model.Extensions;
+using System;
namespace MediaBrowser.Model.Dlna
{
@@ -15,22 +16,22 @@ namespace MediaBrowser.Model.Dlna
SearchType = SearchType.Unknown;
- if (search.IndexOf("upnp:class", StringComparison.OrdinalIgnoreCase) != -1 &&
- search.IndexOf("derivedfrom", StringComparison.OrdinalIgnoreCase) != -1)
+ if (StringHelper.IndexOfIgnoreCase(search, "upnp:class") != -1 &&
+ StringHelper.IndexOfIgnoreCase(search, "derivedfrom") != -1)
{
- if (search.IndexOf("object.item.audioItem", StringComparison.OrdinalIgnoreCase) != -1)
+ if (StringHelper.IndexOfIgnoreCase(search, "object.item.audioItem") != -1)
{
SearchType = SearchType.Audio;
}
- else if (search.IndexOf("object.item.imageItem", StringComparison.OrdinalIgnoreCase) != -1)
+ else if (StringHelper.IndexOfIgnoreCase(search, "object.item.imageItem") != -1)
{
SearchType = SearchType.Image;
}
- else if (search.IndexOf("object.item.videoItem", StringComparison.OrdinalIgnoreCase) != -1)
+ else if (StringHelper.IndexOfIgnoreCase(search, "object.item.videoItem") != -1)
{
SearchType = SearchType.Video;
}
- else if (search.IndexOf("object.container.playlistContainer", StringComparison.OrdinalIgnoreCase) != -1)
+ else if (StringHelper.IndexOfIgnoreCase(search, "object.container.playlistContainer") != -1)
{
SearchType = SearchType.Playlist;
}
diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs
index 2e7ead823..7472d4eaf 100644
--- a/MediaBrowser.Model/Dlna/StreamBuilder.cs
+++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs
@@ -1,17 +1,15 @@
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
+using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.MediaInfo;
using System;
using System.Collections.Generic;
-using System.Globalization;
using System.Linq;
namespace MediaBrowser.Model.Dlna
{
public class StreamBuilder
{
- private readonly CultureInfo _usCulture = new CultureInfo("en-US");
-
public StreamInfo BuildAudioItem(AudioOptions options)
{
ValidateAudioInput(options);
@@ -27,7 +25,7 @@ namespace MediaBrowser.Model.Dlna
mediaSources = new List<MediaSourceInfo>();
foreach (MediaSourceInfo i in mediaSources)
{
- if (string.Equals(i.Id, mediaSourceId, StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(i.Id, mediaSourceId))
mediaSources.Add(i);
}
}
@@ -60,7 +58,7 @@ namespace MediaBrowser.Model.Dlna
mediaSources = new List<MediaSourceInfo>();
foreach (MediaSourceInfo i in mediaSources)
{
- if (string.Equals(i.Id, mediaSourceId, StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(i.Id, mediaSourceId))
mediaSources.Add(i);
}
}
@@ -505,7 +503,7 @@ namespace MediaBrowser.Model.Dlna
case ProfileConditionValue.AudioBitrate:
{
int num;
- if (int.TryParse(value, NumberStyles.Any, _usCulture, out num))
+ if (IntHelper.TryParseCultureInvariant(value, out num))
{
item.AudioBitrate = num;
}
@@ -514,7 +512,7 @@ namespace MediaBrowser.Model.Dlna
case ProfileConditionValue.AudioChannels:
{
int num;
- if (int.TryParse(value, NumberStyles.Any, _usCulture, out num))
+ if (IntHelper.TryParseCultureInvariant(value, out num))
{
item.MaxAudioChannels = num;
}
@@ -537,7 +535,7 @@ namespace MediaBrowser.Model.Dlna
case ProfileConditionValue.Height:
{
int num;
- if (int.TryParse(value, NumberStyles.Any, _usCulture, out num))
+ if (IntHelper.TryParseCultureInvariant(value, out num))
{
item.MaxHeight = num;
}
@@ -546,7 +544,7 @@ namespace MediaBrowser.Model.Dlna
case ProfileConditionValue.VideoBitrate:
{
int num;
- if (int.TryParse(value, NumberStyles.Any, _usCulture, out num))
+ if (IntHelper.TryParseCultureInvariant(value, out num))
{
item.VideoBitrate = num;
}
@@ -554,8 +552,8 @@ namespace MediaBrowser.Model.Dlna
}
case ProfileConditionValue.VideoFramerate:
{
- int num;
- if (int.TryParse(value, NumberStyles.Any, _usCulture, out num))
+ double num;
+ if (DoubleHelper.TryParseCultureInvariant(value, out num))
{
item.MaxFramerate = num;
}
@@ -564,7 +562,7 @@ namespace MediaBrowser.Model.Dlna
case ProfileConditionValue.VideoLevel:
{
int num;
- if (int.TryParse(value, NumberStyles.Any, _usCulture, out num))
+ if (IntHelper.TryParseCultureInvariant(value, out num))
{
item.VideoLevel = num;
}
@@ -573,7 +571,7 @@ namespace MediaBrowser.Model.Dlna
case ProfileConditionValue.Width:
{
int num;
- if (int.TryParse(value, NumberStyles.Any, _usCulture, out num))
+ if (IntHelper.TryParseCultureInvariant(value, out num))
{
item.MaxWidth = num;
}
@@ -594,7 +592,7 @@ namespace MediaBrowser.Model.Dlna
bool any = false;
foreach (string i in profile.GetContainers())
{
- if (string.Equals(i, mediaContainer, StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(i, mediaContainer))
{
any = true;
break;
@@ -624,7 +622,7 @@ namespace MediaBrowser.Model.Dlna
bool any = false;
foreach (string i in profile.GetContainers())
{
- if (string.Equals(i, mediaContainer, StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(i, mediaContainer))
{
any = true;
break;
diff --git a/MediaBrowser.Model/Dlna/StreamInfo.cs b/MediaBrowser.Model/Dlna/StreamInfo.cs
index e4ec0d853..b5aded684 100644
--- a/MediaBrowser.Model/Dlna/StreamInfo.cs
+++ b/MediaBrowser.Model/Dlna/StreamInfo.cs
@@ -1,10 +1,10 @@
using MediaBrowser.Model.Drawing;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
+using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.MediaInfo;
using System;
using System.Collections.Generic;
-using System.Globalization;
namespace MediaBrowser.Model.Dlna
{
@@ -45,7 +45,7 @@ namespace MediaBrowser.Model.Dlna
public int? MaxWidth { get; set; }
public int? MaxHeight { get; set; }
- public int? MaxFramerate { get; set; }
+ public double? MaxFramerate { get; set; }
public string DeviceProfileId { get; set; }
public string DeviceId { get; set; }
@@ -89,7 +89,7 @@ namespace MediaBrowser.Model.Dlna
return string.Format("{0}/audio/{1}/stream{2}?{3}", baseUrl, ItemId, extension, dlnaCommand);
}
- if (string.Equals(Protocol, "hls", StringComparison.OrdinalIgnoreCase))
+ if (StringHelper.EqualsIgnoreCase(Protocol, "hls"))
{
return string.Format("{0}/videos/{1}/stream.m3u8?{2}", baseUrl, ItemId, dlnaCommand);
}
@@ -97,8 +97,6 @@ namespace MediaBrowser.Model.Dlna
return string.Format("{0}/videos/{1}/stream{2}?{3}", baseUrl, ItemId, extension, dlnaCommand);
}
- private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
-
private static string BuildDlnaParam(StreamInfo item)
{
List<string> list = new List<string>
@@ -109,16 +107,16 @@ namespace MediaBrowser.Model.Dlna
(item.IsDirectStream).ToString().ToLower(),
item.VideoCodec ?? string.Empty,
item.AudioCodec ?? string.Empty,
- item.AudioStreamIndex.HasValue ? item.AudioStreamIndex.Value.ToString(UsCulture) : string.Empty,
- item.SubtitleStreamIndex.HasValue ? item.SubtitleStreamIndex.Value.ToString(UsCulture) : string.Empty,
- item.VideoBitrate.HasValue ? item.VideoBitrate.Value.ToString(UsCulture) : string.Empty,
- item.AudioBitrate.HasValue ? item.AudioBitrate.Value.ToString(UsCulture) : string.Empty,
- item.MaxAudioChannels.HasValue ? item.MaxAudioChannels.Value.ToString(UsCulture) : string.Empty,
- item.MaxFramerate.HasValue ? item.MaxFramerate.Value.ToString(UsCulture) : string.Empty,
- item.MaxWidth.HasValue ? item.MaxWidth.Value.ToString(UsCulture) : string.Empty,
- item.MaxHeight.HasValue ? item.MaxHeight.Value.ToString(UsCulture) : string.Empty,
- item.StartPositionTicks.ToString(UsCulture),
- item.VideoLevel.HasValue ? item.VideoLevel.Value.ToString(UsCulture) : string.Empty
+ item.AudioStreamIndex.HasValue ? StringHelper.ToStringCultureInvariant(item.AudioStreamIndex.Value) : string.Empty,
+ item.SubtitleStreamIndex.HasValue ? StringHelper.ToStringCultureInvariant(item.SubtitleStreamIndex.Value) : string.Empty,
+ item.VideoBitrate.HasValue ? StringHelper.ToStringCultureInvariant(item.VideoBitrate.Value) : string.Empty,
+ item.AudioBitrate.HasValue ? StringHelper.ToStringCultureInvariant(item.AudioBitrate.Value) : string.Empty,
+ item.MaxAudioChannels.HasValue ? StringHelper.ToStringCultureInvariant(item.MaxAudioChannels.Value) : string.Empty,
+ item.MaxFramerate.HasValue ? StringHelper.ToStringCultureInvariant(item.MaxFramerate.Value) : string.Empty,
+ item.MaxWidth.HasValue ? StringHelper.ToStringCultureInvariant(item.MaxWidth.Value) : string.Empty,
+ item.MaxHeight.HasValue ? StringHelper.ToStringCultureInvariant(item.MaxHeight.Value) : string.Empty,
+ StringHelper.ToStringCultureInvariant(item.StartPositionTicks),
+ item.VideoLevel.HasValue ? StringHelper.ToStringCultureInvariant(item.VideoLevel.Value) : string.Empty
};
return string.Format("Params={0}", string.Join(";", list.ToArray()));
@@ -332,7 +330,7 @@ namespace MediaBrowser.Model.Dlna
{
get
{
- TransportStreamTimestamp defaultValue = string.Equals(Container, "m2ts", StringComparison.OrdinalIgnoreCase)
+ TransportStreamTimestamp defaultValue = StringHelper.EqualsIgnoreCase(Container, "m2ts")
? TransportStreamTimestamp.Valid
: TransportStreamTimestamp.None;