Merge pull request #1440 from cvium/fix-build

Change UsCulture to InvariantCulture
pull/1453/head
Bond-009 6 years ago committed by GitHub
commit e3a3aebbf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.IO; using System.IO;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
@ -143,10 +144,10 @@ namespace MediaBrowser.Api.Playback.Hls
text = text.Replace("#EXTM3U", "#EXTM3U\n#EXT-X-PLAYLIST-TYPE:EVENT"); text = text.Replace("#EXTM3U", "#EXTM3U\n#EXT-X-PLAYLIST-TYPE:EVENT");
var newDuration = "#EXT-X-TARGETDURATION:" + segmentLength.ToString(UsCulture); var newDuration = "#EXT-X-TARGETDURATION:" + segmentLength.ToString(CultureInfo.InvariantCulture);
text = text.Replace("#EXT-X-TARGETDURATION:" + (segmentLength - 1).ToString(UsCulture), newDuration, StringComparison.OrdinalIgnoreCase); text = text.Replace("#EXT-X-TARGETDURATION:" + (segmentLength - 1).ToString(CultureInfo.InvariantCulture), newDuration, StringComparison.OrdinalIgnoreCase);
//text = text.Replace("#EXT-X-TARGETDURATION:" + (segmentLength + 1).ToString(UsCulture), newDuration, StringComparison.OrdinalIgnoreCase); //text = text.Replace("#EXT-X-TARGETDURATION:" + (segmentLength + 1).ToString(CultureInfo.InvariantCulture), newDuration, StringComparison.OrdinalIgnoreCase);
return text; return text;
} }
@ -163,7 +164,7 @@ namespace MediaBrowser.Api.Playback.Hls
var paddedBitrate = Convert.ToInt32(bitrate * 1.15); var paddedBitrate = Convert.ToInt32(bitrate * 1.15);
// Main stream // Main stream
builder.AppendLine("#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=" + paddedBitrate.ToString(UsCulture)); builder.AppendLine("#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=" + paddedBitrate.ToString(CultureInfo.InvariantCulture));
var playlistUrl = "hls/" + Path.GetFileName(firstPlaylist).Replace(".m3u8", "/stream.m3u8"); var playlistUrl = "hls/" + Path.GetFileName(firstPlaylist).Replace(".m3u8", "/stream.m3u8");
builder.AppendLine(playlistUrl); builder.AppendLine(playlistUrl);
@ -231,7 +232,7 @@ namespace MediaBrowser.Api.Playback.Hls
{ {
var itsOffsetMs = 0; var itsOffsetMs = 0;
var itsOffset = itsOffsetMs == 0 ? string.Empty : string.Format("-itsoffset {0} ", TimeSpan.FromMilliseconds(itsOffsetMs).TotalSeconds.ToString(UsCulture)); var itsOffset = itsOffsetMs == 0 ? string.Empty : string.Format("-itsoffset {0} ", TimeSpan.FromMilliseconds(itsOffsetMs).TotalSeconds.ToString(CultureInfo.InvariantCulture));
var videoCodec = EncodingHelper.GetVideoEncoder(state, encodingOptions); var videoCodec = EncodingHelper.GetVideoEncoder(state, encodingOptions);
@ -240,7 +241,7 @@ namespace MediaBrowser.Api.Playback.Hls
var inputModifier = EncodingHelper.GetInputModifier(state, encodingOptions); var inputModifier = EncodingHelper.GetInputModifier(state, encodingOptions);
// If isEncoding is true we're actually starting ffmpeg // If isEncoding is true we're actually starting ffmpeg
var startNumberParam = isEncoding ? GetStartNumber(state).ToString(UsCulture) : "0"; var startNumberParam = isEncoding ? GetStartNumber(state).ToString(CultureInfo.InvariantCulture) : "0";
var baseUrlParam = string.Empty; var baseUrlParam = string.Empty;
@ -272,7 +273,7 @@ namespace MediaBrowser.Api.Playback.Hls
EncodingHelper.GetMapArgs(state), EncodingHelper.GetMapArgs(state),
GetVideoArguments(state, encodingOptions), GetVideoArguments(state, encodingOptions),
GetAudioArguments(state, encodingOptions), GetAudioArguments(state, encodingOptions),
state.SegmentLength.ToString(UsCulture), state.SegmentLength.ToString(CultureInfo.InvariantCulture),
startNumberParam, startNumberParam,
outputPath, outputPath,
outputTsArg, outputTsArg,
@ -293,9 +294,9 @@ namespace MediaBrowser.Api.Playback.Hls
EncodingHelper.GetMapArgs(state), EncodingHelper.GetMapArgs(state),
GetVideoArguments(state, encodingOptions), GetVideoArguments(state, encodingOptions),
GetAudioArguments(state, encodingOptions), GetAudioArguments(state, encodingOptions),
state.SegmentLength.ToString(UsCulture), state.SegmentLength.ToString(CultureInfo.InvariantCulture),
startNumberParam, startNumberParam,
state.HlsListSize.ToString(UsCulture), state.HlsListSize.ToString(CultureInfo.InvariantCulture),
baseUrlParam, baseUrlParam,
outputPath outputPath
).Trim(); ).Trim();

@ -177,7 +177,7 @@ namespace MediaBrowser.Api.Playback.Hls
var cancellationTokenSource = new CancellationTokenSource(); var cancellationTokenSource = new CancellationTokenSource();
var cancellationToken = cancellationTokenSource.Token; var cancellationToken = cancellationTokenSource.Token;
var requestedIndex = int.Parse(segmentId, NumberStyles.Integer, UsCulture); var requestedIndex = int.Parse(segmentId, NumberStyles.Integer, CultureInfo.InvariantCulture);
var state = await GetState(request, cancellationToken).ConfigureAwait(false); var state = await GetState(request, cancellationToken).ConfigureAwait(false);
@ -364,7 +364,7 @@ namespace MediaBrowser.Api.Playback.Hls
var indexString = Path.GetFileNameWithoutExtension(file.Name).Substring(playlistFilename.Length); var indexString = Path.GetFileNameWithoutExtension(file.Name).Substring(playlistFilename.Length);
return int.Parse(indexString, NumberStyles.Integer, UsCulture); return int.Parse(indexString, NumberStyles.Integer, CultureInfo.InvariantCulture);
} }
private void DeleteLastFile(string playlistPath, string segmentExtension, int retryCount) private void DeleteLastFile(string playlistPath, string segmentExtension, int retryCount)
@ -438,7 +438,7 @@ namespace MediaBrowser.Api.Playback.Hls
segmentId = segmentRequest.SegmentId; segmentId = segmentRequest.SegmentId;
} }
return int.Parse(segmentId, NumberStyles.Integer, UsCulture); return int.Parse(segmentId, NumberStyles.Integer, CultureInfo.InvariantCulture);
} }
private string GetSegmentPath(StreamState state, string playlist, int index) private string GetSegmentPath(StreamState state, string playlist, int index)
@ -447,7 +447,7 @@ namespace MediaBrowser.Api.Playback.Hls
var filename = Path.GetFileNameWithoutExtension(playlist); var filename = Path.GetFileNameWithoutExtension(playlist);
return Path.Combine(folder, filename + index.ToString(UsCulture) + GetSegmentFileExtension(state.Request)); return Path.Combine(folder, filename + index.ToString(CultureInfo.InvariantCulture) + GetSegmentFileExtension(state.Request));
} }
private async Task<object> GetSegmentResult(StreamState state, private async Task<object> GetSegmentResult(StreamState state,
@ -628,8 +628,8 @@ namespace MediaBrowser.Api.Playback.Hls
private string ReplaceBitrate(string url, int oldValue, int newValue) private string ReplaceBitrate(string url, int oldValue, int newValue)
{ {
return url.Replace( return url.Replace(
"videobitrate=" + oldValue.ToString(UsCulture), "videobitrate=" + oldValue.ToString(CultureInfo.InvariantCulture),
"videobitrate=" + newValue.ToString(UsCulture), "videobitrate=" + newValue.ToString(CultureInfo.InvariantCulture),
StringComparison.OrdinalIgnoreCase); StringComparison.OrdinalIgnoreCase);
} }
@ -648,8 +648,8 @@ namespace MediaBrowser.Api.Playback.Hls
var url = string.Format("{0}/Subtitles/{1}/subtitles.m3u8?SegmentLength={2}&api_key={3}", var url = string.Format("{0}/Subtitles/{1}/subtitles.m3u8?SegmentLength={2}&api_key={3}",
state.Request.MediaSourceId, state.Request.MediaSourceId,
stream.Index.ToString(UsCulture), stream.Index.ToString(CultureInfo.InvariantCulture),
30.ToString(UsCulture), 30.ToString(CultureInfo.InvariantCulture),
AuthorizationContext.GetAuthorizationInfo(Request).Token); AuthorizationContext.GetAuthorizationInfo(Request).Token);
var line = string.Format(format, var line = string.Format(format,
@ -705,7 +705,7 @@ namespace MediaBrowser.Api.Playback.Hls
private void AppendPlaylist(StringBuilder builder, StreamState state, string url, int bitrate, string subtitleGroup) private void AppendPlaylist(StringBuilder builder, StreamState state, string url, int bitrate, string subtitleGroup)
{ {
var header = "#EXT-X-STREAM-INF:BANDWIDTH=" + bitrate.ToString(UsCulture) + ",AVERAGE-BANDWIDTH=" + bitrate.ToString(UsCulture); var header = "#EXT-X-STREAM-INF:BANDWIDTH=" + bitrate.ToString(CultureInfo.InvariantCulture) + ",AVERAGE-BANDWIDTH=" + bitrate.ToString(CultureInfo.InvariantCulture);
// tvos wants resolution, codecs, framerate // tvos wants resolution, codecs, framerate
//if (state.TargetFramerate.HasValue) //if (state.TargetFramerate.HasValue)
@ -770,7 +770,7 @@ namespace MediaBrowser.Api.Playback.Hls
builder.AppendLine("#EXTM3U"); builder.AppendLine("#EXTM3U");
builder.AppendLine("#EXT-X-PLAYLIST-TYPE:VOD"); builder.AppendLine("#EXT-X-PLAYLIST-TYPE:VOD");
builder.AppendLine("#EXT-X-VERSION:3"); builder.AppendLine("#EXT-X-VERSION:3");
builder.AppendLine("#EXT-X-TARGETDURATION:" + Math.Ceiling(segmentLengths.Length > 0 ? segmentLengths.Max() : state.SegmentLength).ToString(UsCulture)); builder.AppendLine("#EXT-X-TARGETDURATION:" + Math.Ceiling(segmentLengths.Length > 0 ? segmentLengths.Max() : state.SegmentLength).ToString(CultureInfo.InvariantCulture));
builder.AppendLine("#EXT-X-MEDIA-SEQUENCE:0"); builder.AppendLine("#EXT-X-MEDIA-SEQUENCE:0");
var queryStringIndex = Request.RawUrl.IndexOf('?'); var queryStringIndex = Request.RawUrl.IndexOf('?');
@ -785,12 +785,12 @@ namespace MediaBrowser.Api.Playback.Hls
foreach (var length in segmentLengths) foreach (var length in segmentLengths)
{ {
builder.AppendLine("#EXTINF:" + length.ToString("0.0000", UsCulture) + ", nodesc"); builder.AppendLine("#EXTINF:" + length.ToString("0.0000", CultureInfo.InvariantCulture) + ", nodesc");
builder.AppendLine(string.Format("hls1/{0}/{1}{2}{3}", builder.AppendLine(string.Format("hls1/{0}/{1}{2}{3}",
name, name,
index.ToString(UsCulture), index.ToString(CultureInfo.InvariantCulture),
GetSegmentFileExtension(request), GetSegmentFileExtension(request),
queryString)); queryString));
@ -821,17 +821,17 @@ namespace MediaBrowser.Api.Playback.Hls
if (state.OutputAudioBitrate.HasValue) if (state.OutputAudioBitrate.HasValue)
{ {
audioTranscodeParams.Add("-ab " + state.OutputAudioBitrate.Value.ToString(UsCulture)); audioTranscodeParams.Add("-ab " + state.OutputAudioBitrate.Value.ToString(CultureInfo.InvariantCulture));
} }
if (state.OutputAudioChannels.HasValue) if (state.OutputAudioChannels.HasValue)
{ {
audioTranscodeParams.Add("-ac " + state.OutputAudioChannels.Value.ToString(UsCulture)); audioTranscodeParams.Add("-ac " + state.OutputAudioChannels.Value.ToString(CultureInfo.InvariantCulture));
} }
if (state.OutputAudioSampleRate.HasValue) if (state.OutputAudioSampleRate.HasValue)
{ {
audioTranscodeParams.Add("-ar " + state.OutputAudioSampleRate.Value.ToString(UsCulture)); audioTranscodeParams.Add("-ar " + state.OutputAudioSampleRate.Value.ToString(CultureInfo.InvariantCulture));
} }
audioTranscodeParams.Add("-vn"); audioTranscodeParams.Add("-vn");
@ -863,12 +863,12 @@ namespace MediaBrowser.Api.Playback.Hls
if (bitrate.HasValue) if (bitrate.HasValue)
{ {
args += " -ab " + bitrate.Value.ToString(UsCulture); args += " -ab " + bitrate.Value.ToString(CultureInfo.InvariantCulture);
} }
if (state.OutputAudioSampleRate.HasValue) if (state.OutputAudioSampleRate.HasValue)
{ {
args += " -ar " + state.OutputAudioSampleRate.Value.ToString(UsCulture); args += " -ar " + state.OutputAudioSampleRate.Value.ToString(CultureInfo.InvariantCulture);
} }
args += " " + EncodingHelper.GetAudioFilterParam(state, encodingOptions, true); args += " " + EncodingHelper.GetAudioFilterParam(state, encodingOptions, true);
@ -905,7 +905,7 @@ namespace MediaBrowser.Api.Playback.Hls
else else
{ {
var keyFrameArg = string.Format(" -force_key_frames \"expr:gte(t,n_forced*{0})\"", var keyFrameArg = string.Format(" -force_key_frames \"expr:gte(t,n_forced*{0})\"",
state.SegmentLength.ToString(UsCulture)); state.SegmentLength.ToString(CultureInfo.InvariantCulture));
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode; var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
@ -953,7 +953,7 @@ namespace MediaBrowser.Api.Playback.Hls
// If isEncoding is true we're actually starting ffmpeg // If isEncoding is true we're actually starting ffmpeg
var startNumber = GetStartNumber(state); var startNumber = GetStartNumber(state);
var startNumberParam = isEncoding ? startNumber.ToString(UsCulture) : "0"; var startNumberParam = isEncoding ? startNumber.ToString(CultureInfo.InvariantCulture) : "0";
var mapArgs = state.IsOutputVideo ? EncodingHelper.GetMapArgs(state) : string.Empty; var mapArgs = state.IsOutputVideo ? EncodingHelper.GetMapArgs(state) : string.Empty;
@ -984,7 +984,7 @@ namespace MediaBrowser.Api.Playback.Hls
mapArgs, mapArgs,
GetVideoArguments(state, encodingOptions), GetVideoArguments(state, encodingOptions),
GetAudioArguments(state, encodingOptions), GetAudioArguments(state, encodingOptions),
state.SegmentLength.ToString(UsCulture), state.SegmentLength.ToString(CultureInfo.InvariantCulture),
startNumberParam, startNumberParam,
outputPath, outputPath,
outputTsArg, outputTsArg,

@ -1,4 +1,5 @@
using System; using System;
using System.Globalization;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Devices; using MediaBrowser.Controller.Devices;
@ -55,12 +56,12 @@ namespace MediaBrowser.Api.Playback.Hls
if (bitrate.HasValue) if (bitrate.HasValue)
{ {
args += " -ab " + bitrate.Value.ToString(UsCulture); args += " -ab " + bitrate.Value.ToString(CultureInfo.InvariantCulture);
} }
if (state.OutputAudioSampleRate.HasValue) if (state.OutputAudioSampleRate.HasValue)
{ {
args += " -ar " + state.OutputAudioSampleRate.Value.ToString(UsCulture); args += " -ar " + state.OutputAudioSampleRate.Value.ToString(CultureInfo.InvariantCulture);
} }
args += " " + EncodingHelper.GetAudioFilterParam(state, encodingOptions, true); args += " " + EncodingHelper.GetAudioFilterParam(state, encodingOptions, true);
@ -100,7 +101,7 @@ namespace MediaBrowser.Api.Playback.Hls
else else
{ {
var keyFrameArg = string.Format(" -force_key_frames \"expr:gte(t,n_forced*{0})\"", var keyFrameArg = string.Format(" -force_key_frames \"expr:gte(t,n_forced*{0})\"",
state.SegmentLength.ToString(UsCulture)); state.SegmentLength.ToString(CultureInfo.InvariantCulture));
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode; var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;

Loading…
Cancel
Save