From fe527e7bc9734c9827ffb057c6be559712cfdd73 Mon Sep 17 00:00:00 2001 From: genteure Date: Fri, 17 Jun 2022 23:16:40 +0800 Subject: [PATCH] FLV: Refactor text log accompanying recording files --- .../Recording/StandardRecordTask.cs | 6 +-- BililiveRecorder.Flv/IFlvTagWriter.cs | 3 +- .../IFlvWriterTargetProvider.cs | 2 +- .../PipelineLogAlternativeHeaderAction.cs | 18 ------- .../PipelineLogMessageWithLocationAction.cs | 8 +-- .../Pipeline/Rules/HandleNewHeaderRule.cs | 16 +++++- .../Pipeline/Rules/HandleNewScriptRule.cs | 14 +++--- .../Writer/FlvProcessingContextWriter.cs | 10 ++-- .../Writer/FlvTagFileWriter.cs | 49 ++++++++++++++----- .../Writer/FlvTagListWriter.cs | 8 +-- .../Tool/Analyze/AnalyzeHandler.cs | 2 +- .../Tool/Fix/FixHandler.cs | 14 +++--- .../PublicApi.HasNoChangesAsync.verified.txt | 22 ++++----- .../FlvTests/WriterTests.cs | 2 +- .../RuleTests/IntegratedBadTests.cs | 4 +- .../RuleTests/IntegratedGoodTests.cs | 4 +- .../RuleTests/IntegratedTestBase.cs | 2 +- test/data | 2 +- 18 files changed, 96 insertions(+), 90 deletions(-) delete mode 100644 BililiveRecorder.Flv/Pipeline/Actions/PipelineLogAlternativeHeaderAction.cs diff --git a/BililiveRecorder.Core/Recording/StandardRecordTask.cs b/BililiveRecorder.Core/Recording/StandardRecordTask.cs index 7a1a823..4daedd0 100644 --- a/BililiveRecorder.Core/Recording/StandardRecordTask.cs +++ b/BililiveRecorder.Core/Recording/StandardRecordTask.cs @@ -296,11 +296,11 @@ namespace BililiveRecorder.Core.Recording return (stream, state); } - public Stream CreateAlternativeHeaderStream() + public Stream CreateAccompanyingTextLogStream() { var path = string.IsNullOrWhiteSpace(this.last_path) - ? Path.ChangeExtension(this.task.CreateFileName().fullPath, "headers.txt") - : Path.ChangeExtension(this.last_path, "headers.txt"); + ? Path.ChangeExtension(this.task.CreateFileName().fullPath, "txt") + : Path.ChangeExtension(this.last_path, "txt"); try { Directory.CreateDirectory(Path.GetDirectoryName(path)); } diff --git a/BililiveRecorder.Flv/IFlvTagWriter.cs b/BililiveRecorder.Flv/IFlvTagWriter.cs index b73a534..2541379 100644 --- a/BililiveRecorder.Flv/IFlvTagWriter.cs +++ b/BililiveRecorder.Flv/IFlvTagWriter.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Threading.Tasks; using BililiveRecorder.Flv.Amf; @@ -15,6 +14,6 @@ namespace BililiveRecorder.Flv Task WriteTag(Tag tag); Task OverwriteMetadata(ScriptTagBody metadata); - Task WriteAlternativeHeaders(IEnumerable tags); + Task WriteAccompanyingTextLog(double lastTagDuration, string message); } } diff --git a/BililiveRecorder.Flv/IFlvWriterTargetProvider.cs b/BililiveRecorder.Flv/IFlvWriterTargetProvider.cs index 108cd44..03da0b7 100644 --- a/BililiveRecorder.Flv/IFlvWriterTargetProvider.cs +++ b/BililiveRecorder.Flv/IFlvWriterTargetProvider.cs @@ -6,6 +6,6 @@ namespace BililiveRecorder.Flv { (Stream stream, object? state) CreateOutputStream(); - Stream CreateAlternativeHeaderStream(); + Stream CreateAccompanyingTextLogStream(); } } diff --git a/BililiveRecorder.Flv/Pipeline/Actions/PipelineLogAlternativeHeaderAction.cs b/BililiveRecorder.Flv/Pipeline/Actions/PipelineLogAlternativeHeaderAction.cs deleted file mode 100644 index d67d2b5..0000000 --- a/BililiveRecorder.Flv/Pipeline/Actions/PipelineLogAlternativeHeaderAction.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace BililiveRecorder.Flv.Pipeline.Actions -{ - public class PipelineLogAlternativeHeaderAction : PipelineAction - { - public IReadOnlyList Tags { get; set; } - - public PipelineLogAlternativeHeaderAction(IReadOnlyList tags) - { - this.Tags = tags ?? throw new ArgumentNullException(nameof(tags)); - } - - public override PipelineAction Clone() => new PipelineLogAlternativeHeaderAction(this.Tags.ToArray()); - } -} diff --git a/BililiveRecorder.Flv/Pipeline/Actions/PipelineLogMessageWithLocationAction.cs b/BililiveRecorder.Flv/Pipeline/Actions/PipelineLogMessageWithLocationAction.cs index 20c8d1d..a4e7d79 100644 --- a/BililiveRecorder.Flv/Pipeline/Actions/PipelineLogMessageWithLocationAction.cs +++ b/BililiveRecorder.Flv/Pipeline/Actions/PipelineLogMessageWithLocationAction.cs @@ -1,20 +1,16 @@ using System; -using Serilog.Events; namespace BililiveRecorder.Flv.Pipeline.Actions { public class PipelineLogMessageWithLocationAction : PipelineAction { - public PipelineLogMessageWithLocationAction(LogEventLevel level, string message) + public PipelineLogMessageWithLocationAction(string message) { - this.Level = level; this.Message = message ?? throw new ArgumentNullException(nameof(message)); } - public LogEventLevel Level { get; } - public string Message { get; } - public override PipelineAction Clone() => new PipelineLogMessageWithLocationAction(this.Level, this.Message); + public override PipelineAction Clone() => new PipelineLogMessageWithLocationAction(this.Message); } } diff --git a/BililiveRecorder.Flv/Pipeline/Rules/HandleNewHeaderRule.cs b/BililiveRecorder.Flv/Pipeline/Rules/HandleNewHeaderRule.cs index 9d3648d..00530da 100644 --- a/BililiveRecorder.Flv/Pipeline/Rules/HandleNewHeaderRule.cs +++ b/BililiveRecorder.Flv/Pipeline/Rules/HandleNewHeaderRule.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text; using BililiveRecorder.Flv.Pipeline.Actions; using StructLinq; using StructLinq.Where; @@ -81,7 +82,20 @@ namespace BililiveRecorder.Flv.Pipeline.Rules // 输出所有 Header 到一个独立的文件,以防出现无法播放的问题 // 如果不能正常播放,后期可以使用这里保存的 Header 配合 FlvInteractiveRebase 工具手动修复 if (multiple_header_present) - yield return new PipelineLogAlternativeHeaderAction(header.AllTags); + { + var b = new StringBuilder("连续遇到了多个不同的音视频Header,如果录制的文件不能正常播放可以尝试用这里的数据进行手动修复\n"); + + foreach (var tag in header.AllTags) + { + b.Append("\n"); + b.Append(tag.ToString()); + b.Append("\n"); + b.Append(tag.BinaryDataForSerializationUseOnly); + b.Append("\n"); + } + + yield return new PipelineLogMessageWithLocationAction(b.ToString()); + } } else diff --git a/BililiveRecorder.Flv/Pipeline/Rules/HandleNewScriptRule.cs b/BililiveRecorder.Flv/Pipeline/Rules/HandleNewScriptRule.cs index c81fe5f..8468950 100644 --- a/BililiveRecorder.Flv/Pipeline/Rules/HandleNewScriptRule.cs +++ b/BililiveRecorder.Flv/Pipeline/Rules/HandleNewScriptRule.cs @@ -93,19 +93,19 @@ namespace BililiveRecorder.Flv.Pipeline.Rules } else { - // 记录信息,不输出到文件,不对文件进行分段。 - var message = $"重复收到 onMetaData, onMetaData 内容: {data?.ToJson() ?? "(null)"}"; + // 记录信息,不对文件进行分段。 + var message = $"收到直播服务器发送的 onMetaData 数据,请检查此位置是否有重复的直播片段或缺少数据。\n造成这个问题的原因可能是录播姬所连接的直播服务器与它的上级服务器的连接断开重连了。\n数据内容: {data?.ToJson() ?? "(null)"}"; context.AddComment(new ProcessingComment(CommentType.OnMetaData, false, message)); - yield return new PipelineLogMessageWithLocationAction(Serilog.Events.LogEventLevel.Warning, "重复收到 onMetaData"); + yield return new PipelineLogMessageWithLocationAction(message); yield return (new PipelineScriptAction(new Tag { Type = TagType.Script, ScriptData = new ScriptTagBody(new List - { - (ScriptDataString)onMetaData, - value - }) + { + (ScriptDataString)onMetaData, + value + }) })); yield break; } diff --git a/BililiveRecorder.Flv/Writer/FlvProcessingContextWriter.cs b/BililiveRecorder.Flv/Writer/FlvProcessingContextWriter.cs index 30983f1..d82ea30 100644 --- a/BililiveRecorder.Flv/Writer/FlvProcessingContextWriter.cs +++ b/BililiveRecorder.Flv/Writer/FlvProcessingContextWriter.cs @@ -96,20 +96,16 @@ namespace BililiveRecorder.Flv.Writer PipelineHeaderAction headerAction => this.WriteHeaderTags(headerAction), PipelineDataAction dataAction => this.WriteDataTags(dataAction), PipelineEndAction endAction => this.WriteEndTag(endAction), - PipelineLogAlternativeHeaderAction logAlternativeHeaderAction => this.WriteAlternativeHeader(logAlternativeHeaderAction), PipelineLogMessageWithLocationAction pipelineLogMessageWithLocationAction => this.LogMessageWithLocation(pipelineLogMessageWithLocationAction), _ => Task.CompletedTask, }; - private Task LogMessageWithLocation(PipelineLogMessageWithLocationAction logMessageWithLocationAction) + private async Task LogMessageWithLocation(PipelineLogMessageWithLocationAction logMessageWithLocationAction) { - this.logger?.Write(logMessageWithLocationAction.Level, logMessageWithLocationAction.Message + $"\n 位置:视频时间 {this.lastDuration} 秒, 文件位置 {this.tagWriter.FileSize} 字节。"); - return Task.CompletedTask; + this.logger?.Debug("写入录制记录,位置:视频时间 {FileDuration} 秒, 文件位置 {FileSize} 字节。\n{Message}", this.lastDuration, this.tagWriter.FileSize, logMessageWithLocationAction.Message); + await this.tagWriter.WriteAccompanyingTextLog(this.lastDuration, logMessageWithLocationAction.Message).ConfigureAwait(false); } - private Task WriteAlternativeHeader(PipelineLogAlternativeHeaderAction logAlternativeHeaderAction) => - this.tagWriter.WriteAlternativeHeaders(logAlternativeHeaderAction.Tags); - private Task OpenNewFile() { this.CloseCurrentFileImpl(); diff --git a/BililiveRecorder.Flv/Writer/FlvTagFileWriter.cs b/BililiveRecorder.Flv/Writer/FlvTagFileWriter.cs index 41fcf58..49be0e5 100644 --- a/BililiveRecorder.Flv/Writer/FlvTagFileWriter.cs +++ b/BililiveRecorder.Flv/Writer/FlvTagFileWriter.cs @@ -1,7 +1,6 @@ using System; using System.Buffers; using System.Buffers.Binary; -using System.Collections.Generic; using System.IO; using System.Text; using System.Threading.Tasks; @@ -19,6 +18,7 @@ namespace BililiveRecorder.Flv.Writer private readonly ILogger? logger; private Stream? stream; + private StreamWriter? textFile; private uint lastMetadataLength; private bool disposedValue; @@ -43,10 +43,20 @@ namespace BililiveRecorder.Flv.Writer try { this.stream.Dispose(); } catch (Exception ex) - { this.logger?.Warning(ex, "关闭文件时发生错误"); } + { this.logger?.Warning(ex, "关闭录像文件时发生错误"); } this.stream = null; + if (this.textFile is not null) + { + try + { this.textFile.Dispose(); } + catch (Exception ex) + { this.logger?.Warning(ex, "关闭录像记录文本文件时发生错误"); } + + this.textFile = null; + } + return true; } @@ -93,24 +103,37 @@ namespace BililiveRecorder.Flv.Writer } } - public async Task WriteAlternativeHeaders(IEnumerable tags) + public async Task WriteAccompanyingTextLog(double lastTagDuration, string message) { if (this.disposedValue) throw new ObjectDisposedException(nameof(FlvTagFileWriter)); - using var writer = new StreamWriter(this.targetProvider.CreateAlternativeHeaderStream(), Encoding.UTF8); - await writer.WriteLineAsync("----- Group Start -----").ConfigureAwait(false); - await writer.WriteLineAsync("连续遇到了多个不同的音视频Header,如果录制的文件不能正常播放可以尝试用这里的数据进行修复").ConfigureAwait(false); - await writer.WriteLineAsync(DateTimeOffset.Now.ToString("O")).ConfigureAwait(false); - - foreach (var tag in tags) + if (this.textFile is null || !this.textFile.BaseStream.CanWrite) { - await writer.WriteLineAsync().ConfigureAwait(false); - await writer.WriteLineAsync(tag.ToString()).ConfigureAwait(false); - await writer.WriteLineAsync(tag.BinaryDataForSerializationUseOnly).ConfigureAwait(false); + this.textFile = new StreamWriter(this.targetProvider.CreateAccompanyingTextLogStream(), Encoding.UTF8); + + await this.textFile.WriteLineAsync("此文件内记录了对应的视频文件中可能存在的问题").ConfigureAwait(false); + await this.textFile.WriteAsync("B站录播姬 ").ConfigureAwait(false); + await this.textFile.WriteLineAsync(GitVersionInformation.FullSemVer).ConfigureAwait(false); + await this.textFile.WriteLineAsync().ConfigureAwait(false); } - await writer.WriteLineAsync("----- Group End -----").ConfigureAwait(false); + var fileTime = TimeSpan.FromSeconds(lastTagDuration); + + await this.textFile.WriteLineAsync("-----记录开始-----").ConfigureAwait(false); + await this.textFile.WriteAsync("记录时间: ").ConfigureAwait(false); + await this.textFile.WriteLineAsync(DateTimeOffset.Now.ToString("O")).ConfigureAwait(false); + await this.textFile.WriteAsync("视频时间: ").ConfigureAwait(false); + await this.textFile.WriteLineAsync($"{(int)Math.Floor(fileTime.TotalHours):D2}:{fileTime.Minutes:D2}:{fileTime.Seconds:D2}.{fileTime.Milliseconds:D3}").ConfigureAwait(false); + await this.textFile.WriteAsync("文件位置: ").ConfigureAwait(false); + await this.textFile.WriteAsync(this.FileSize.ToString()).ConfigureAwait(false); + await this.textFile.WriteLineAsync(" 字节").ConfigureAwait(false); + + await this.textFile.WriteLineAsync(message).ConfigureAwait(false); + + await this.textFile.WriteLineAsync("-----记录结束-----").ConfigureAwait(false); + + await this.textFile.FlushAsync().ConfigureAwait(false); } public Task WriteTag(Tag tag) diff --git a/BililiveRecorder.Flv/Writer/FlvTagListWriter.cs b/BililiveRecorder.Flv/Writer/FlvTagListWriter.cs index db16641..6a1a9bc 100644 --- a/BililiveRecorder.Flv/Writer/FlvTagListWriter.cs +++ b/BililiveRecorder.Flv/Writer/FlvTagListWriter.cs @@ -12,11 +12,11 @@ namespace BililiveRecorder.Flv.Writer public FlvTagListWriter() { this.Files = new List>(); - this.AlternativeHeaders = new List(); + this.AccompanyingTextLogs = new List<(double, string)>(); } public List> Files { get; } - public List AlternativeHeaders { get; } + public List<(double lastTagDuration, string message)> AccompanyingTextLogs { get; } public long FileSize => -1; @@ -42,9 +42,9 @@ namespace BililiveRecorder.Flv.Writer public Task OverwriteMetadata(ScriptTagBody metadata) => Task.CompletedTask; - public Task WriteAlternativeHeaders(IEnumerable tags) + public Task WriteAccompanyingTextLog(double lastTagDuration, string message) { - this.AlternativeHeaders.AddRange(tags); + this.AccompanyingTextLogs.Add((lastTagDuration, message)); return Task.CompletedTask; } diff --git a/BililiveRecorder.ToolBox/Tool/Analyze/AnalyzeHandler.cs b/BililiveRecorder.ToolBox/Tool/Analyze/AnalyzeHandler.cs index 3cc2412..56c4ef6 100644 --- a/BililiveRecorder.ToolBox/Tool/Analyze/AnalyzeHandler.cs +++ b/BililiveRecorder.ToolBox/Tool/Analyze/AnalyzeHandler.cs @@ -218,7 +218,7 @@ namespace BililiveRecorder.ToolBox.Tool.Analyze public void Dispose() { } public Task OverwriteMetadata(ScriptTagBody metadata) => Task.CompletedTask; - public Task WriteAlternativeHeaders(IEnumerable tags) => Task.CompletedTask; + public Task WriteAccompanyingTextLog(double lastTagDuration, string message) => Task.CompletedTask; public Task WriteTag(Tag tag) => Task.CompletedTask; } } diff --git a/BililiveRecorder.ToolBox/Tool/Fix/FixHandler.cs b/BililiveRecorder.ToolBox/Tool/Fix/FixHandler.cs index f9dcc85..865e5b7 100644 --- a/BililiveRecorder.ToolBox/Tool/Fix/FixHandler.cs +++ b/BililiveRecorder.ToolBox/Tool/Fix/FixHandler.cs @@ -170,15 +170,15 @@ namespace BililiveRecorder.ToolBox.Tool.Fix XmlFlvFile.Serializer.Serialize(file, new XmlFlvFile { Tags = w.Files[i] }); } - if (w.AlternativeHeaders.Count > 0) + if (w.AccompanyingTextLogs.Count > 0) { - var path = Path.ChangeExtension(request.OutputBase, $"headers.txt"); + var path = Path.ChangeExtension(request.OutputBase, "txt"); using var writer = new StreamWriter(File.Open(path, FileMode.Append, FileAccess.Write, FileShare.None)); - foreach (var tag in w.AlternativeHeaders) + foreach (var (lastTagDuration, message) in w.AccompanyingTextLogs) { writer.WriteLine(); - writer.WriteLine(tag.ToString()); - writer.WriteLine(tag.BinaryDataForSerializationUseOnly); + writer.WriteLine(lastTagDuration); + writer.WriteLine(message); } } }); @@ -264,9 +264,9 @@ namespace BililiveRecorder.ToolBox.Tool.Fix this.pathTemplate = pathTemplate; } - public Stream CreateAlternativeHeaderStream() + public Stream CreateAccompanyingTextLogStream() { - var path = Path.ChangeExtension(this.pathTemplate, "header.txt"); + var path = Path.ChangeExtension(this.pathTemplate, "txt"); return new FileStream(path, FileMode.Append, FileAccess.Write, FileShare.Read); } diff --git a/test/BililiveRecorder.Flv.Tests/Expectations/PublicApi.HasNoChangesAsync.verified.txt b/test/BililiveRecorder.Flv.Tests/Expectations/PublicApi.HasNoChangesAsync.verified.txt index f8a470a..44e28db 100644 --- a/test/BililiveRecorder.Flv.Tests/Expectations/PublicApi.HasNoChangesAsync.verified.txt +++ b/test/BililiveRecorder.Flv.Tests/Expectations/PublicApi.HasNoChangesAsync.verified.txt @@ -342,12 +342,12 @@ namespace BililiveRecorder.Flv bool CloseCurrentFile(); System.Threading.Tasks.Task CreateNewFile(); System.Threading.Tasks.Task OverwriteMetadata(BililiveRecorder.Flv.Amf.ScriptTagBody metadata); - System.Threading.Tasks.Task WriteAlternativeHeaders(System.Collections.Generic.IEnumerable tags); + System.Threading.Tasks.Task WriteAccompanyingTextLog(double lastTagDuration, string message); System.Threading.Tasks.Task WriteTag(BililiveRecorder.Flv.Tag tag); } public interface IFlvWriterTargetProvider { - System.IO.Stream CreateAlternativeHeaderStream(); + System.IO.Stream CreateAccompanyingTextLogStream(); [return: System.Runtime.CompilerServices.TupleElementNames(new string[] { "stream", "state"})] @@ -671,16 +671,9 @@ namespace BililiveRecorder.Flv.Pipeline.Actions public BililiveRecorder.Flv.Tag? VideoHeader { get; set; } public override BililiveRecorder.Flv.Pipeline.Actions.PipelineAction Clone() { } } - public class PipelineLogAlternativeHeaderAction : BililiveRecorder.Flv.Pipeline.Actions.PipelineAction - { - public PipelineLogAlternativeHeaderAction(System.Collections.Generic.IReadOnlyList tags) { } - public System.Collections.Generic.IReadOnlyList Tags { get; set; } - public override BililiveRecorder.Flv.Pipeline.Actions.PipelineAction Clone() { } - } public class PipelineLogMessageWithLocationAction : BililiveRecorder.Flv.Pipeline.Actions.PipelineAction { - public PipelineLogMessageWithLocationAction(Serilog.Events.LogEventLevel level, string message) { } - public Serilog.Events.LogEventLevel Level { get; } + public PipelineLogMessageWithLocationAction(string message) { } public string Message { get; } public override BililiveRecorder.Flv.Pipeline.Actions.PipelineAction Clone() { } } @@ -832,13 +825,16 @@ namespace BililiveRecorder.Flv.Writer public void Dispose() { } protected virtual void Dispose(bool disposing) { } public System.Threading.Tasks.Task OverwriteMetadata(BililiveRecorder.Flv.Amf.ScriptTagBody metadata) { } - public System.Threading.Tasks.Task WriteAlternativeHeaders(System.Collections.Generic.IEnumerable tags) { } + public System.Threading.Tasks.Task WriteAccompanyingTextLog(double lastTagDuration, string message) { } public System.Threading.Tasks.Task WriteTag(BililiveRecorder.Flv.Tag tag) { } } public class FlvTagListWriter : BililiveRecorder.Flv.IFlvTagWriter, System.IDisposable { public FlvTagListWriter() { } - public System.Collections.Generic.List AlternativeHeaders { get; } + [System.Runtime.CompilerServices.TupleElementNames(new string[] { + "lastTagDuration", + "message"})] + public System.Collections.Generic.List> AccompanyingTextLogs { get; } public long FileSize { get; } public System.Collections.Generic.List> Files { get; } public object? State { get; } @@ -846,7 +842,7 @@ namespace BililiveRecorder.Flv.Writer public System.Threading.Tasks.Task CreateNewFile() { } public void Dispose() { } public System.Threading.Tasks.Task OverwriteMetadata(BililiveRecorder.Flv.Amf.ScriptTagBody metadata) { } - public System.Threading.Tasks.Task WriteAlternativeHeaders(System.Collections.Generic.IEnumerable tags) { } + public System.Threading.Tasks.Task WriteAccompanyingTextLog(double lastTagDuration, string message) { } public System.Threading.Tasks.Task WriteTag(BililiveRecorder.Flv.Tag tag) { } } } diff --git a/test/BililiveRecorder.Flv.Tests/FlvTests/WriterTests.cs b/test/BililiveRecorder.Flv.Tests/FlvTests/WriterTests.cs index 21c8986..a974d70 100644 --- a/test/BililiveRecorder.Flv.Tests/FlvTests/WriterTests.cs +++ b/test/BililiveRecorder.Flv.Tests/FlvTests/WriterTests.cs @@ -43,7 +43,7 @@ namespace BililiveRecorder.Flv.Tests.FlvTests private bool flag = false; - public Stream CreateAlternativeHeaderStream() => throw new System.NotImplementedException(); + public Stream CreateAccompanyingTextLogStream() => throw new System.NotImplementedException(); public (Stream stream, object? state) CreateOutputStream() { diff --git a/test/BililiveRecorder.Flv.Tests/RuleTests/IntegratedBadTests.cs b/test/BililiveRecorder.Flv.Tests/RuleTests/IntegratedBadTests.cs index a94dbfa..a297f34 100644 --- a/test/BililiveRecorder.Flv.Tests/RuleTests/IntegratedBadTests.cs +++ b/test/BililiveRecorder.Flv.Tests/RuleTests/IntegratedBadTests.cs @@ -39,7 +39,7 @@ namespace BililiveRecorder.Flv.Tests.RuleTests var outputResult = new OutputResult { - AlternativeHeaders = flvTagListWriter.AlternativeHeaders.Select(x => x.BinaryDataForSerializationUseOnly).ToArray(), + AccompanyingTextLogs = flvTagListWriter.AccompanyingTextLogs.Select(x => x.lastTagDuration + "\n" + x.message).ToArray(), Comments = comments.GroupBy(x => x.Type).Select(x => new CommentCount(x.Key, x.Count())).ToArray(), TagCounts = flvTagListWriter.Files.Select(x => x.Count).ToArray() }; @@ -69,7 +69,7 @@ namespace BililiveRecorder.Flv.Tests.RuleTests public CommentCount[] Comments { get; set; } = Array.Empty(); - public string?[] AlternativeHeaders { get; set; } = Array.Empty(); + public string?[] AccompanyingTextLogs { get; set; } = Array.Empty(); } public struct CommentCount diff --git a/test/BililiveRecorder.Flv.Tests/RuleTests/IntegratedGoodTests.cs b/test/BililiveRecorder.Flv.Tests/RuleTests/IntegratedGoodTests.cs index f9a15cf..c6ecb66 100644 --- a/test/BililiveRecorder.Flv.Tests/RuleTests/IntegratedGoodTests.cs +++ b/test/BililiveRecorder.Flv.Tests/RuleTests/IntegratedGoodTests.cs @@ -33,7 +33,7 @@ namespace BililiveRecorder.Flv.Tests.RuleTests Assert.Empty(comments); - Assert.Empty(flvTagListWriter.AlternativeHeaders); + Assert.Empty(flvTagListWriter.AccompanyingTextLogs); var outputTags = Assert.Single(flvTagListWriter.Files); Assert.Equal(originalTags.Count, outputTags.Count); @@ -77,7 +77,7 @@ namespace BililiveRecorder.Flv.Tests.RuleTests comments.RemoveAll(x => !x.ActionRequired); Assert.Equal(CommentType.TimestampJump, Assert.Single(comments).Type); - Assert.Empty(output.AlternativeHeaders); + Assert.Empty(output.AccompanyingTextLogs); var outputTags = Assert.Single(output.Files); Assert.Equal(originalTags.Count, outputTags.Count); diff --git a/test/BililiveRecorder.Flv.Tests/RuleTests/IntegratedTestBase.cs b/test/BililiveRecorder.Flv.Tests/RuleTests/IntegratedTestBase.cs index 296605b..b5e105a 100644 --- a/test/BililiveRecorder.Flv.Tests/RuleTests/IntegratedTestBase.cs +++ b/test/BililiveRecorder.Flv.Tests/RuleTests/IntegratedTestBase.cs @@ -47,7 +47,7 @@ namespace BililiveRecorder.Flv.Tests.RuleTests // 不应该有任何问题 Shouldn't have any problems Assert.Empty(comments); // 不应该有多个 Header Shouldn't have multiple headers - Assert.Empty(output.AlternativeHeaders); + Assert.Empty(output.AccompanyingTextLogs); // 只应该有一个文件输出 Should output only a single file var outputTags = Assert.Single(output.Files); diff --git a/test/data b/test/data index 6ae84c0..d5c346c 160000 --- a/test/data +++ b/test/data @@ -1 +1 @@ -Subproject commit 6ae84c024d9d556774f9da4677503bbc9aa8315c +Subproject commit d5c346c26e2d8c5bc7d3aa68a6d281f0b603e31a