Move cuetools.net codec locally.

This commit is contained in:
2022-12-16 18:20:23 +00:00
parent 631bbfdbd0
commit 93b833c5bc
69 changed files with 11306 additions and 28 deletions

View File

@@ -0,0 +1,54 @@
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Xml.Serialization;
using System.Text;
using Newtonsoft.Json;
using System.IO;
namespace CUETools.Codecs
{
public interface IAudioDecoderSettings
{
string Name { get; }
string Extension { get; }
Type DecoderType { get; }
int Priority { get; }
IAudioDecoderSettings Clone();
}
public static class IAudioDecoderSettingsExtensions
{
public static bool HasBrowsableAttributes(this IAudioDecoderSettings settings)
{
bool hasBrowsable = false;
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(settings))
{
bool isBrowsable = true;
foreach (var attribute in property.Attributes)
{
var browsable = attribute as BrowsableAttribute;
isBrowsable &= browsable == null || browsable.Browsable;
}
hasBrowsable |= isBrowsable;
}
return hasBrowsable;
}
public static void Init(this IAudioDecoderSettings settings)
{
// Iterate through each property and call ResetValue()
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(settings))
property.ResetValue(settings);
}
public static IAudioSource Open(this IAudioDecoderSettings settings, string path, Stream IO = null)
{
return Activator.CreateInstance(settings.DecoderType, settings, path, IO) as IAudioSource;
}
}
}