mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-10 08:34:12 +01:00
Use boolean instead on generic int for disposition state value
Former-commit-id: d79bbaef97
This commit is contained in:
parent
57e2585f52
commit
2b6a74dd7e
3 changed files with 32 additions and 6 deletions
|
@ -120,8 +120,9 @@ public async Task Probe_Success_Disposition_Async()
|
|||
{
|
||||
var info = await FFProbe.AnalyseAsync(TestResources.Mp4Video);
|
||||
Assert.IsNotNull(info.PrimaryAudioStream);
|
||||
Assert.AreEqual(1, info.PrimaryAudioStream.Disposition["default"]);
|
||||
Assert.AreEqual(0, info.PrimaryAudioStream.Disposition["forced"]);
|
||||
Assert.IsNotNull(info.PrimaryAudioStream.Disposition);
|
||||
Assert.AreEqual(true, info.PrimaryAudioStream.Disposition["default"]);
|
||||
Assert.AreEqual(false, info.PrimaryAudioStream.Disposition["forced"]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -67,7 +67,7 @@ private VideoStream ParseVideoStream(FFProbeStream stream)
|
|||
PixelFormat = stream.PixelFormat,
|
||||
Rotation = (int)float.Parse(stream.GetRotate() ?? "0"),
|
||||
Language = stream.GetLanguage(),
|
||||
Disposition = stream.Disposition,
|
||||
Disposition = MediaAnalysisUtils.FormatDisposition(stream.Disposition),
|
||||
Tags = stream.Tags,
|
||||
};
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ private AudioStream ParseAudioStream(FFProbeStream stream)
|
|||
SampleRateHz = !string.IsNullOrEmpty(stream.SampleRate) ? MediaAnalysisUtils.ParseIntInvariant(stream.SampleRate) : default,
|
||||
Profile = stream.Profile,
|
||||
Language = stream.GetLanguage(),
|
||||
Disposition = stream.Disposition,
|
||||
Disposition = MediaAnalysisUtils.FormatDisposition(stream.Disposition),
|
||||
Tags = stream.Tags,
|
||||
};
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ private SubtitleStream ParseSubtitleStream(FFProbeStream stream)
|
|||
CodecLongName = stream.CodecLongName,
|
||||
Duration = MediaAnalysisUtils.ParseDuration(stream),
|
||||
Language = stream.GetLanguage(),
|
||||
Disposition = stream.Disposition,
|
||||
Disposition = MediaAnalysisUtils.FormatDisposition(stream.Disposition),
|
||||
Tags = stream.Tags,
|
||||
};
|
||||
}
|
||||
|
@ -172,5 +172,30 @@ public static TimeSpan ParseDuration(FFProbeStream ffProbeStream)
|
|||
{
|
||||
return ParseDuration(ffProbeStream.Duration);
|
||||
}
|
||||
|
||||
public static Dictionary<string, bool>? FormatDisposition(Dictionary<string, int>? disposition)
|
||||
{
|
||||
if (disposition == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var result = new Dictionary<string, bool>(disposition.Count);
|
||||
|
||||
foreach (var pair in disposition)
|
||||
{
|
||||
result.Add(pair.Key, ToBool(pair.Value));
|
||||
}
|
||||
|
||||
static bool ToBool(int value) => value switch
|
||||
{
|
||||
0 => false,
|
||||
1 => true,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(value),
|
||||
$"Not expected disposition state value: {value}")
|
||||
};
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@ public class MediaStream
|
|||
public int BitRate { get; internal set; }
|
||||
public TimeSpan Duration { get; internal set; }
|
||||
public string? Language { get; internal set; }
|
||||
public Dictionary<string, int>? Disposition { get; internal set; }
|
||||
public Dictionary<string, bool>? Disposition { get; internal set; }
|
||||
public Dictionary<string, string>? Tags { get; internal set; }
|
||||
|
||||
public Codec GetCodecInfo() => FFMpeg.GetCodec(CodecName);
|
||||
|
|
Loading…
Reference in a new issue