mirror of
https://github.com/BililiveRecorder/BililiveRecorder.git
synced 2024-12-25 19:56:10 +08:00
32 lines
1.1 KiB
C#
32 lines
1.1 KiB
C#
using System;
|
|
using System.Linq;
|
|
using BililiveRecorder.Flv.Amf;
|
|
using BililiveRecorder.Flv.Pipeline.Actions;
|
|
|
|
namespace BililiveRecorder.Flv.Pipeline.Rules
|
|
{
|
|
public class FfmpegDetectionRule : ISimpleProcessingRule
|
|
{
|
|
public bool EndTagDetected { get; private set; }
|
|
public bool LavfEncoderDetected { get; private set; }
|
|
|
|
public void Run(FlvProcessingContext context, Action next)
|
|
{
|
|
if (!this.EndTagDetected && context.Actions.Any(x => x is PipelineEndAction))
|
|
this.EndTagDetected = true;
|
|
|
|
if (!this.LavfEncoderDetected && context.Actions.Any(action =>
|
|
{
|
|
if (action is PipelineScriptAction scriptAction
|
|
&& (scriptAction?.Tag?.ScriptData?.GetMetadataValue()?.TryGetValue("encoder", out var encoderValue) ?? false)
|
|
&& encoderValue is ScriptDataString encoder)
|
|
return encoder.Value.StartsWith("Lavf", StringComparison.Ordinal);
|
|
return false;
|
|
}))
|
|
this.LavfEncoderDetected = true;
|
|
|
|
next();
|
|
}
|
|
}
|
|
}
|