Skip to content

Commit

Permalink
Added the Mpeg4VcmVideoEncoder.IsSupported() method.
Browse files Browse the repository at this point in the history
  • Loading branch information
baSSiLL committed Jan 24, 2022
1 parent b2ff650 commit c2c781b
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions SharpAvi/Codecs/Mpeg4VcmVideoEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ namespace SharpAvi.Codecs
/// </remarks>
public class Mpeg4VcmVideoEncoder : IVideoEncoder, IDisposable
{
/// <summary>
/// Checks whether <see cref="Mpeg4VcmVideoEncoder"/> is supported on this platform.
/// </summary>
/// <returns><c>True</c> if supported, <c>false</c> otherwise.</returns>
public static bool IsSupported() => Environment.OSVersion.Platform == PlatformID.Win32NT;

private static void CheckSupportedPlatform()
{
if (!IsSupported())
{
throw new PlatformNotSupportedException($"{nameof(Mpeg4VcmVideoEncoder)} is only supported on the Windows platform.");
}
}

/// <summary>
/// Default preferred order of the supported codecs.
/// </summary>
Expand All @@ -47,8 +61,13 @@ public class Mpeg4VcmVideoEncoder : IVideoEncoder, IDisposable
/// <summary>
/// Gets info about the supported codecs that are installed on the system.
/// </summary>
/// <exception cref="PlatformNotSupportedException">
/// Running not on Windows.
/// </exception>
public static CodecInfo[] GetAvailableCodecs()
{
CheckSupportedPlatform();

var result = new List<CodecInfo>();

var inBitmapInfo = CreateBitmapInfo(8, 8, 32, CodecIds.Uncompressed);
Expand Down Expand Up @@ -147,6 +166,9 @@ private static VfwApi.BitmapInfoHeader CreateBitmapInfo(int width, int height, u
/// <exception cref="InvalidOperationException">
/// No compatible codec was found in the system.
/// </exception>
/// <exception cref="PlatformNotSupportedException">
/// Running not on Windows.
/// </exception>
/// <remarks>
/// <para>
/// It is not guaranteed that the codec will respect the specified <paramref name="quality"/> value.
Expand All @@ -166,10 +188,7 @@ public Mpeg4VcmVideoEncoder(int width, int height, double fps, int frameCount, i
Argument.IsNotNegative(frameCount, nameof(frameCount));
Argument.IsInRange(quality, 1, 100, nameof(quality));

if (Environment.OSVersion.Platform != PlatformID.Win32NT)
{
throw new PlatformNotSupportedException($"{nameof(Mpeg4VcmVideoEncoder)} only supports the Windows platform.");
}
CheckSupportedPlatform();

this.width = width;
this.height = height;
Expand Down

0 comments on commit c2c781b

Please sign in to comment.