    public static void registerCustomCodecs()
    {
        if(codecsRegistered)
            return;
        @SuppressWarnings("unchecked")
        Collection<String> registeredPlugins
                = new HashSet<String>(
                PlugInManager.getPlugInList(
                        null,
                        null,
                        PlugInManager.CODEC));
        boolean commit = false;
        PlugInManager.removePlugIn(
                "com.sun.media.codec.video.colorspace.JavaRGBToYUV",
                PlugInManager.CODEC);
        PlugInManager.removePlugIn(
                "com.sun.media.codec.video.colorspace.JavaRGBConverter",
                PlugInManager.CODEC);
        PlugInManager.removePlugIn(
                "com.sun.media.codec.video.colorspace.RGBScaler",
                PlugInManager.CODEC);
        PlugInManager.removePlugIn(
                "com.sun.media.codec.video.vh263.NativeDecoder",
                PlugInManager.CODEC);
        PlugInManager.removePlugIn(
                "com.ibm.media.codec.video.h263.NativeEncoder",
                PlugInManager.CODEC);
        String gsmCodecPackage = "com.ibm.media.codec.audio.gsm.";
        String[] gsmCodecClasses
                = new String[]
                {
                        "JavaDecoder",
                        "JavaDecoder_ms",
                        "JavaEncoder",
                        "JavaEncoder_ms",
                        "NativeDecoder",
                        "NativeDecoder_ms",
                        "NativeEncoder",
                        "NativeEncoder_ms",
                        "Packetizer"
                };
        for(String gsmCodecClass : gsmCodecClasses)
        {
            PlugInManager.removePlugIn(
                    gsmCodecPackage + gsmCodecClass,
                    PlugInManager.CODEC);
        }
        PlugInManager.removePlugIn(
                "net.sf.fmj.media.codec.JavaSoundCodec",
                PlugInManager.CODEC);
        for (String className : CUSTOM_CODECS)
        {
            if (className == null)
                continue;
            if (registeredPlugins.contains(className))
            {
                if (logger.isDebugEnabled())
                    logger.debug(
                            "Codec " + className + " is already registered");
            }
            else
            {
                commit = true;
                boolean registered;
                Throwable exception = null;
                try
                {
                    Codec codec = (Codec)
                            Class.forName(className).newInstance();
                    registered =
                            PlugInManager.addPlugIn(
                                    className,
                                    codec.getSupportedInputFormats(),
                                    codec.getSupportedOutputFormats(null),
                                    PlugInManager.CODEC);
                }
                catch (Throwable ex)
                {
                    registered = false;
                    exception = ex;
                }
                if (registered)
                {
                    if (logger.isDebugEnabled())
                    {
                        logger.debug(
                                "Codec "
                                    + className
                                    + " is successfully registered");
                    }
                }
                else
                {
                    if (logger.isDebugEnabled())
                    {
                        logger.debug(
                                "Codec "
                                    + className
                                    + " is NOT succsefully registered",
                                exception);
                    }
                }
            }
        }
        @SuppressWarnings("unchecked")
        Vector<String> codecs
                = PlugInManager.getPlugInList(null, null, PlugInManager.CODEC);
        if (codecs != null)
        {
            boolean setPlugInList = false;
            for (int i = CUSTOM_CODECS.length - 1; i >= 0; i--)
            {
                String className = CUSTOM_CODECS[i];
                if (className != null)
                {
                    int classNameIndex = codecs.indexOf(className);
                    if (classNameIndex != -1)
                    {
                        codecs.remove(classNameIndex);
                        codecs.add(0, className);
                        setPlugInList = true;
                    }
                }
            }
            if (setPlugInList)
                PlugInManager.setPlugInList(codecs, PlugInManager.CODEC);
        }
        if (commit && !MediaServiceImpl.isJmfRegistryDisableLoad())
        {
            try
            {
                PlugInManager.commit();
            }
            catch (IOException ex)
            {
                logger.error("Cannot commit to PlugInManager", ex);
            }
        }
        codecsRegistered = true;
    }

    public static void registerCustomCodecs()
    {
        if(codecsRegistered)
            return;
        @SuppressWarnings("unchecked")
        Collection<String> registeredPlugins
                = new HashSet<String>(
                PlugInManager.getPlugInList(
                        null,
                        null,
                        PlugInManager.CODEC));
        boolean commit = false;
        PlugInManager.removePlugIn(
                "com.sun.media.codec.video.colorspace.JavaRGBToYUV",
                PlugInManager.CODEC);
        PlugInManager.removePlugIn(
                "com.sun.media.codec.video.colorspace.JavaRGBConverter",
                PlugInManager.CODEC);
        PlugInManager.removePlugIn(
                "com.sun.media.codec.video.colorspace.RGBScaler",
                PlugInManager.CODEC);
        PlugInManager.removePlugIn(
                "com.sun.media.codec.video.vh263.NativeDecoder",
                PlugInManager.CODEC);
        PlugInManager.removePlugIn(
                "com.ibm.media.codec.video.h263.NativeEncoder",
                PlugInManager.CODEC);
        String gsmCodecPackage = "com.ibm.media.codec.audio.gsm.";
        String[] gsmCodecClasses
                = new String[]
                {
                        "JavaDecoder",
                        "JavaDecoder_ms",
                        "JavaEncoder",
                        "JavaEncoder_ms",
                        "NativeDecoder",
                        "NativeDecoder_ms",
                        "NativeEncoder",
                        "NativeEncoder_ms",
                        "Packetizer"
                };
        for(String gsmCodecClass : gsmCodecClasses)
        {
            PlugInManager.removePlugIn(
                    gsmCodecPackage + gsmCodecClass,
                    PlugInManager.CODEC);
        }
        PlugInManager.removePlugIn(
                "net.sf.fmj.media.codec.JavaSoundCodec",
                PlugInManager.CODEC);
        for (String className : CUSTOM_CODECS)
        {
            if (className == null)
                continue;
            if (registeredPlugins.contains(className))
            {
                if (logger.isDebugEnabled())
                    logger.debug(
                            "Codec " + className + " is already registered");
            }
            else
            {
                commit = true;
                boolean registered;
                Throwable exception = null;
                try
                {
                    Codec codec = (Codec)
                            Class.forName(className).newInstance();
                    registered =
                            PlugInManager.addPlugIn(
                                    className,
                                    codec.getSupportedInputFormats(),
                                    codec.getSupportedOutputFormats(null),
                                    PlugInManager.CODEC);
                }
                catch (Throwable ex)
                {
                    registered = false;
                    exception = ex;
                }
                if (registered)
                {
                    if (logger.isDebugEnabled())
                    {
                        logger.debug(
                                "Codec "
                                    + className
                                    + " is successfully registered");
                    }
                }
                else
                {
                    if (logger.isDebugEnabled())
                    {
                        logger.debug(
                                "Codec "
                                    + className
                                    + " is NOT successfully registered",
                                exception);
                    }
                }
            }
        }
        @SuppressWarnings("unchecked")
        Vector<String> codecs
                = PlugInManager.getPlugInList(null, null, PlugInManager.CODEC);
        if (codecs != null)
        {
            boolean setPlugInList = false;
            for (int i = CUSTOM_CODECS.length - 1; i >= 0; i--)
            {
                String className = CUSTOM_CODECS[i];
                if (className != null)
                {
                    int classNameIndex = codecs.indexOf(className);
                    if (classNameIndex != -1)
                    {
                        codecs.remove(classNameIndex);
                        codecs.add(0, className);
                        setPlugInList = true;
                    }
                }
            }
            if (setPlugInList)
                PlugInManager.setPlugInList(codecs, PlugInManager.CODEC);
        }
        if (commit && !MediaServiceImpl.isJmfRegistryDisableLoad())
        {
            try
            {
                PlugInManager.commit();
            }
            catch (IOException ex)
            {
                logger.error("Cannot commit to PlugInManager", ex);
            }
        }
        codecsRegistered = true;
    }
