mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
Code cleanup: some lowlevel codec infrastructure moved
from CUETools.Processor to CUETools.Codecs
This commit is contained in:
@@ -82,7 +82,6 @@
|
||||
<Compile Include="CUESheet.cs" />
|
||||
<Compile Include="CUESheetAudio.cs" />
|
||||
<Compile Include="CUEStyle.cs" />
|
||||
<Compile Include="CUEToolsFormat.cs" />
|
||||
<Compile Include="CUEToolsLocalDB.cs" />
|
||||
<Compile Include="CUEToolsLocalDBEntry.cs" />
|
||||
<Compile Include="CUEToolsProfile.cs" />
|
||||
@@ -90,9 +89,6 @@
|
||||
<Compile Include="CUEToolsScript.cs" />
|
||||
<Compile Include="CUEToolsSelectionEventArgs.cs" />
|
||||
<Compile Include="CUEToolsSourceFile.cs" />
|
||||
<Compile Include="CUEToolsTagger.cs" />
|
||||
<Compile Include="CUEToolsUDC.cs" />
|
||||
<Compile Include="CUEToolsUDCList.cs" />
|
||||
<Compile Include="CUEToolsVerifyTask.cs" />
|
||||
<Compile Include="CUETrackMetadata.cs" />
|
||||
<Compile Include="FileGroupInfo.cs" />
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
namespace CUETools.Processor
|
||||
{
|
||||
public class CUEToolsFormat
|
||||
{
|
||||
public CUEToolsFormat(
|
||||
string _extension,
|
||||
CUEToolsTagger _tagger,
|
||||
bool _allowLossless,
|
||||
bool _allowLossy,
|
||||
bool _allowEmbed,
|
||||
bool _builtin,
|
||||
CUEToolsUDC _encoderLossless,
|
||||
CUEToolsUDC _encoderLossy,
|
||||
CUEToolsUDC _decoder)
|
||||
{
|
||||
extension = _extension;
|
||||
tagger = _tagger;
|
||||
allowLossless = _allowLossless;
|
||||
allowLossy = _allowLossy;
|
||||
allowEmbed = _allowEmbed;
|
||||
builtin = _builtin;
|
||||
encoderLossless = _encoderLossless;
|
||||
encoderLossy = _encoderLossy;
|
||||
decoder = _decoder;
|
||||
}
|
||||
public string DotExtension
|
||||
{
|
||||
get
|
||||
{
|
||||
return "." + extension;
|
||||
}
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return extension;
|
||||
}
|
||||
public string extension;
|
||||
public CUEToolsUDC encoderLossless;
|
||||
public CUEToolsUDC encoderLossy;
|
||||
public CUEToolsUDC decoder;
|
||||
public CUEToolsTagger tagger;
|
||||
public bool allowLossless, allowLossy, allowEmbed, builtin;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace CUETools.Processor
|
||||
{
|
||||
public enum CUEToolsTagger
|
||||
{
|
||||
TagLibSharp = 0,
|
||||
APEv2 = 1,
|
||||
ID3v2 = 2,
|
||||
}
|
||||
}
|
||||
@@ -1,199 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Xml.Serialization;
|
||||
using CUETools.Codecs;
|
||||
|
||||
namespace CUETools.Processor
|
||||
{
|
||||
public class CUEToolsUDC : INotifyPropertyChanged
|
||||
{
|
||||
public string name = "";
|
||||
public string extension = "wav";
|
||||
public string path = "";
|
||||
public string parameters = "";
|
||||
public Type type = null;
|
||||
public AudioEncoderSettings settings = null;
|
||||
public XmlSerializer settingsSerializer = null;
|
||||
public bool lossless = false;
|
||||
public int priority = 0;
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public CUEToolsUDC(
|
||||
string _name,
|
||||
string _extension,
|
||||
bool _lossless,
|
||||
string _supported_modes,
|
||||
string _default_mode,
|
||||
string _path,
|
||||
string _parameters
|
||||
)
|
||||
{
|
||||
name = _name;
|
||||
extension = _extension;
|
||||
lossless = _lossless;
|
||||
priority = 0;
|
||||
path = null;
|
||||
parameters = null;
|
||||
type = typeof(UserDefinedWriter);
|
||||
settingsSerializer = new XmlSerializer(typeof(UserDefinedEncoderSettings));
|
||||
settings = new UserDefinedEncoderSettings() { SupportedModes = _supported_modes, EncoderMode = _default_mode, Path = _path, Parameters = _parameters };
|
||||
}
|
||||
|
||||
public CUEToolsUDC(AudioEncoderClassAttribute enc, Type enctype)
|
||||
{
|
||||
name = enc.EncoderName;
|
||||
extension = enc.Extension;
|
||||
lossless = enc.Lossless;
|
||||
priority = enc.Priority;
|
||||
path = null;
|
||||
parameters = null;
|
||||
type = enctype;
|
||||
settingsSerializer = new XmlSerializer(enc.Settings);
|
||||
settings = Activator.CreateInstance(enc.Settings) as AudioEncoderSettings;
|
||||
if (settings == null)
|
||||
throw new InvalidOperationException("invalid codec");
|
||||
}
|
||||
|
||||
public CUEToolsUDC(
|
||||
string _name,
|
||||
string _extension,
|
||||
string _path,
|
||||
string _parameters
|
||||
)
|
||||
{
|
||||
name = _name;
|
||||
extension = _extension;
|
||||
lossless = true;
|
||||
priority = 0;
|
||||
path = _path;
|
||||
parameters = _parameters;
|
||||
type = null;
|
||||
}
|
||||
|
||||
public CUEToolsUDC(AudioDecoderClass dec, Type dectype)
|
||||
{
|
||||
name = dec.DecoderName;
|
||||
extension = dec.Extension;
|
||||
lossless = true;
|
||||
priority = dec.Priority;
|
||||
path = null;
|
||||
parameters = null;
|
||||
type = dectype;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
set { if (name == value) return; name = value; if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Name")); }
|
||||
}
|
||||
public string FullName
|
||||
{
|
||||
get { return name + " [" + extension + "]"; }
|
||||
//set { name = value; if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Name")); }
|
||||
}
|
||||
public string Path
|
||||
{
|
||||
get
|
||||
{
|
||||
var settings = this.settings as UserDefinedEncoderSettings;
|
||||
return settings == null ? path : settings.Path;
|
||||
}
|
||||
set
|
||||
{
|
||||
var settings = this.settings as UserDefinedEncoderSettings;
|
||||
if (settings == null) path = value;
|
||||
else settings.Path = value;
|
||||
if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Path"));
|
||||
}
|
||||
}
|
||||
public string Parameters
|
||||
{
|
||||
get
|
||||
{
|
||||
var settings = this.settings as UserDefinedEncoderSettings;
|
||||
return settings == null ? parameters : settings.Parameters;
|
||||
}
|
||||
set
|
||||
{
|
||||
var settings = this.settings as UserDefinedEncoderSettings;
|
||||
if (settings == null) parameters = value;
|
||||
else settings.Parameters = value;
|
||||
if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Parameters"));
|
||||
}
|
||||
}
|
||||
public bool Lossless
|
||||
{
|
||||
get { return lossless; }
|
||||
set { lossless = value; if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Lossless")); }
|
||||
}
|
||||
|
||||
public string Extension
|
||||
{
|
||||
get { return extension; }
|
||||
set
|
||||
{
|
||||
if (extension == value) return;
|
||||
if (type != null && type != typeof(UserDefinedWriter)) throw new InvalidOperationException();
|
||||
extension = value;
|
||||
if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Extension"));
|
||||
}
|
||||
}
|
||||
|
||||
public string DotExtension
|
||||
{
|
||||
get { return "." + extension; }
|
||||
}
|
||||
|
||||
public string SupportedModesStr
|
||||
{
|
||||
get
|
||||
{
|
||||
string defaultMode;
|
||||
return this.settings.GetSupportedModes(out defaultMode);
|
||||
}
|
||||
set
|
||||
{
|
||||
var settings = this.settings as UserDefinedEncoderSettings;
|
||||
if (settings == null) throw new InvalidOperationException();
|
||||
settings.SupportedModes = value;
|
||||
if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("SupportedModesStr"));
|
||||
}
|
||||
}
|
||||
|
||||
public string[] SupportedModes
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.SupportedModesStr.Split(' ');
|
||||
}
|
||||
}
|
||||
|
||||
public int EncoderModeIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
string[] modes = this.SupportedModes;
|
||||
if (modes == null || modes.Length < 2)
|
||||
return -1;
|
||||
for (int i = 0; i < modes.Length; i++)
|
||||
if (modes[i] == this.settings.EncoderMode)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanBeDeleted
|
||||
{
|
||||
get
|
||||
{
|
||||
return type == null || type == typeof(UserDefinedWriter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace CUETools.Processor
|
||||
{
|
||||
public class CUEToolsUDCList : BindingList<CUEToolsUDC>
|
||||
{
|
||||
bool m_encoder;
|
||||
|
||||
public CUEToolsUDCList(bool encoder)
|
||||
: base()
|
||||
{
|
||||
AddingNew += OnAddingNew;
|
||||
m_encoder = encoder;
|
||||
}
|
||||
|
||||
private void OnAddingNew(object sender, AddingNewEventArgs e)
|
||||
{
|
||||
e.NewObject = m_encoder ?
|
||||
new CUEToolsUDC("new", "wav", true, "", "", "", "") :
|
||||
new CUEToolsUDC("new", "wav", "", "");
|
||||
}
|
||||
|
||||
public bool TryGetValue(string extension, bool lossless, string name, out CUEToolsUDC result)
|
||||
{
|
||||
foreach (CUEToolsUDC udc in this)
|
||||
{
|
||||
if (udc.extension == extension && udc.lossless == lossless && udc.name == name)
|
||||
{
|
||||
result = udc;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
result = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public CUEToolsUDC GetDefault(string extension, bool lossless)
|
||||
{
|
||||
CUEToolsUDC result = null;
|
||||
foreach (CUEToolsUDC udc in this)
|
||||
{
|
||||
if (udc.extension == extension && udc.lossless == lossless && (result == null || result.priority < udc.priority))
|
||||
{
|
||||
result = udc;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Text;
|
||||
using TagLib.Asf;
|
||||
using CUETools.Codecs;
|
||||
|
||||
namespace CUETools.Processor
|
||||
{
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TagLib;
|
||||
using CUETools.Codecs;
|
||||
|
||||
namespace TagLib.UserDefined {
|
||||
/// <summary>
|
||||
@@ -46,7 +47,7 @@ namespace TagLib.UserDefined {
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private CUETools.Processor.CUEToolsTagger tagger;
|
||||
private CUEToolsTagger tagger;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -71,17 +72,17 @@ namespace TagLib.UserDefined {
|
||||
/// <exception cref="ArgumentNullException">
|
||||
/// <paramref name="path" /> is <see langword="null" />.
|
||||
/// </exception>
|
||||
public File (string path, ReadStyle propertiesStyle, CUETools.Processor.CUEToolsTagger _tagger)
|
||||
public File (string path, ReadStyle propertiesStyle, CUEToolsTagger _tagger)
|
||||
: base (path, propertiesStyle)
|
||||
{
|
||||
tagger = _tagger;
|
||||
// Make sure we have a tag.
|
||||
switch (tagger)
|
||||
{
|
||||
case CUETools.Processor.CUEToolsTagger.APEv2:
|
||||
case CUEToolsTagger.APEv2:
|
||||
GetTag(TagTypes.Ape, true);
|
||||
break;
|
||||
case CUETools.Processor.CUEToolsTagger.ID3v2:
|
||||
case CUEToolsTagger.ID3v2:
|
||||
GetTag(TagTypes.Id3v2, true);
|
||||
break;
|
||||
}
|
||||
@@ -99,17 +100,17 @@ namespace TagLib.UserDefined {
|
||||
/// <exception cref="ArgumentNullException">
|
||||
/// <paramref name="path" /> is <see langword="null" />.
|
||||
/// </exception>
|
||||
public File(string path, CUETools.Processor.CUEToolsTagger _tagger)
|
||||
public File(string path, CUEToolsTagger _tagger)
|
||||
: base(path)
|
||||
{
|
||||
tagger = _tagger;
|
||||
// Make sure we have a tag.
|
||||
switch (tagger)
|
||||
{
|
||||
case CUETools.Processor.CUEToolsTagger.APEv2:
|
||||
case CUEToolsTagger.APEv2:
|
||||
GetTag(TagTypes.Ape, true);
|
||||
break;
|
||||
case CUETools.Processor.CUEToolsTagger.ID3v2:
|
||||
case CUEToolsTagger.ID3v2:
|
||||
GetTag(TagTypes.Id3v2, true);
|
||||
break;
|
||||
}
|
||||
@@ -134,17 +135,17 @@ namespace TagLib.UserDefined {
|
||||
/// />.
|
||||
/// </exception>
|
||||
public File (File.IFileAbstraction abstraction,
|
||||
ReadStyle propertiesStyle, CUETools.Processor.CUEToolsTagger _tagger)
|
||||
ReadStyle propertiesStyle, CUEToolsTagger _tagger)
|
||||
: base (abstraction, propertiesStyle)
|
||||
{
|
||||
tagger = _tagger;
|
||||
// Make sure we have a tag.
|
||||
switch (tagger)
|
||||
{
|
||||
case CUETools.Processor.CUEToolsTagger.APEv2:
|
||||
case CUEToolsTagger.APEv2:
|
||||
GetTag(TagTypes.Ape, true);
|
||||
break;
|
||||
case CUETools.Processor.CUEToolsTagger.ID3v2:
|
||||
case CUEToolsTagger.ID3v2:
|
||||
GetTag(TagTypes.Id3v2, true);
|
||||
break;
|
||||
}
|
||||
@@ -163,17 +164,17 @@ namespace TagLib.UserDefined {
|
||||
/// <paramref name="abstraction" /> is <see langword="null"
|
||||
/// />.
|
||||
/// </exception>
|
||||
public File(File.IFileAbstraction abstraction, CUETools.Processor.CUEToolsTagger _tagger)
|
||||
public File(File.IFileAbstraction abstraction, CUEToolsTagger _tagger)
|
||||
: base (abstraction)
|
||||
{
|
||||
tagger = _tagger;
|
||||
// Make sure we have a tag.
|
||||
switch (tagger)
|
||||
{
|
||||
case CUETools.Processor.CUEToolsTagger.APEv2:
|
||||
case CUEToolsTagger.APEv2:
|
||||
GetTag(TagTypes.Ape, true);
|
||||
break;
|
||||
case CUETools.Processor.CUEToolsTagger.ID3v2:
|
||||
case CUEToolsTagger.ID3v2:
|
||||
GetTag(TagTypes.Id3v2, true);
|
||||
break;
|
||||
}
|
||||
@@ -185,7 +186,7 @@ namespace TagLib.UserDefined {
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public CUETools.Processor.CUEToolsTagger Tagger
|
||||
public CUEToolsTagger Tagger
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -331,8 +332,8 @@ namespace TagLib.UserDefined {
|
||||
|
||||
private static TagLib.File UserDefinedResolver(TagLib.File.IFileAbstraction abstraction, string mimetype, TagLib.ReadStyle style)
|
||||
{
|
||||
foreach (KeyValuePair<string,CUETools.Processor.CUEToolsFormat> fmt in _config.formats)
|
||||
if (fmt.Value.tagger != CUETools.Processor.CUEToolsTagger.TagLibSharp && mimetype == "taglib/" + fmt.Key)
|
||||
foreach (KeyValuePair<string,CUEToolsFormat> fmt in _config.formats)
|
||||
if (fmt.Value.tagger != CUEToolsTagger.TagLibSharp && mimetype == "taglib/" + fmt.Key)
|
||||
return new File(abstraction, style, fmt.Value.tagger);
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user