package openmods.codecs;

import openmods.codecs.adapters.*;
import paulscode.sound.ICodec;
import paulscode.sound.SoundSystemConfig;

public class ClientProxy implements IProxy {
    private static void registerCodec(Class<? extends ICodec> cls, String ext, String... mimeTypes) {
        try {
            SoundSystemConfig.setCodec(ext, cls);
            for (String type : mimeTypes)
                NotEnoughCodecs.KNOWN_MIME_TYPES.put(type, ext);
        } catch (Throwable t) {
            Log.warn(t, "Can't register codec %s for extension %s", cls.getName(), ext);
        }
    }

    private static void registerCodec(String clsName, String ext, String... mimeTypes) {
        try {
            Class<?> cls = Class.forName(clsName);
            Class<? extends ICodec> castedCls = cls.asSubclass(ICodec.class);
            registerCodec(castedCls, ext, mimeTypes);
        } catch (Throwable t) {
            Log.warn(t, "Can't register codec %s for extension %s", clsName, ext);
        }
    }

    @Override
    public void registerCodecs() {
        registerCodec(CodecMP3.class, "MP3", "audio/mpeg", "audio/x-mpeg", "audio/mpeg3", "audio/x-mpeg3");
        registerCodec(CodecADTS.class, "AAC", "audio/aac", "audio/aacp", "audio/mp4", "audio/mpeg4-generic");
        registerCodec(CodecMP4.class, "MP4", "audio/mp4", "audio/mpeg4-generic");
        registerCodec(CodecMP4.class, "M4A");
        registerCodec(CodecFLAC.class, "FLAC", "audio/flac");

        registerCodec("paulscode.sound.codecs.CodecIBXM", "XM", "audio/xm"); // unconfirmed, but whatever
        registerCodec("paulscode.sound.codecs.CodecWav", "WAV", "audio/wav", "audio/x-wav", "audio/wave");
    }
}

@@ -1534,16 +1534,30 @@
 udio/xm%22
+, %22audio/x-xm%22
 ); // un
@@ -1580,16 +1580,205 @@
 hatever%0A
+        registerCodec(%22paulscode.sound.codecs.CodecIBXM%22, %22S3M%22, %22audio/s3m%22, %22audio/x-s3m%22);%0A        registerCodec(%22paulscode.sound.codecs.CodecIBXM%22, %22MOD%22, %22audio/mod%22, %22audio/x-mod%22);%0A%0A
         

Add few other tracker formats