Esempio n. 1
0
        private CodecFactory()
        {
            _codecs = new Dictionary <object, CodecFactoryEntry>();
            Register("mp3", new CodecFactoryEntry((s) =>
            {
                //if (MP3.MP3MediafoundationDecoder.IsSupported)
                //    return new MP3.MP3MediafoundationDecoder(s);
                //else
                //    return new MP3.MP3FileReader(s).DataStream;
                return(new MP3.DmoMP3Decoder(s));
            },
                                                  "mp3", "mpeg3"));
            Register("wave", new CodecFactoryEntry((s) =>
            {
                IWaveSource res = new WAV.WaveFileReader(s);
                if (res.WaveFormat.WaveFormatTag != AudioEncoding.Pcm &&
                    res.WaveFormat.WaveFormatTag != AudioEncoding.IeeeFloat &&
                    res.WaveFormat.WaveFormatTag != AudioEncoding.Extensible)
                {
                    res.Dispose();
                    res = new MediaFoundation.MediaFoundationDecoder(s);
                }
                return(res);
            },
                                                   "wav", "wave"));
            Register("flac", new CodecFactoryEntry((s) =>
            {
                return(new FLAC.FlacFile(s));
            },
                                                   "flac", "fla"));

            if (AAC.AACDecoder.IsSupported)
            {
                Register("aac", new CodecFactoryEntry((s) =>
                {
                    return(new AAC.AACDecoder(s));
                },
                                                      "aac", "adt", "adts", "m2ts", "mp2", "3g2", "3gp2", "3gp", "3gpp", "m4a", "m4v", "mp4v", "mp4", "mov"));
            }

            if (WMA.WMADecoder.IsSupported)
            {
                Register("wma", new CodecFactoryEntry((s) =>
                {
                    return(new WMA.WMADecoder(s));
                },
                                                      "asf", "wm", "wmv", "wma"));
            }

            if (MP1.MP1Decoder.IsSupported)
            {
                Register("mp1", new CodecFactoryEntry((s) =>
                {
                    return(new MP1.MP1Decoder(s));
                },
                                                      "mp1", "m2ts"));
            }

            if (MP2.MP2Decoder.IsSupported)
            {
                Register("mp2", new CodecFactoryEntry((s) =>
                {
                    return(new MP1.MP1Decoder(s));
                },
                                                      "mp2", "m2ts"));
            }

            if (DDP.DDPDecoder.IsSupported)
            {
                Register("ddp", new CodecFactoryEntry((s) =>
                {
                    return(new DDP.DDPDecoder(s));
                },
                                                      "mp2", "m2ts", "m4a", "m4v", "mp4v", "mp4", "mov", "asf", "wm", "wmv", "wma", "avi", "ac3", "ec3"));
            }
        }
Esempio n. 2
0
        private CodecFactory()
        {
            _codecs = new Dictionary<object, CodecFactoryEntry>();
            Register("mp3", new CodecFactoryEntry((s) =>
            {
                //if (MP3.MP3MediafoundationDecoder.IsSupported)
                //    return new MP3.MP3MediafoundationDecoder(s);
                //else
                //    return new MP3.MP3FileReader(s).DataStream;
                return new MP3.DmoMP3Decoder(s);
            },
                "mp3", "mpeg3"));
            Register("wave", new CodecFactoryEntry((s) =>
            {
                IWaveSource res = new WAV.WaveFileReader(s);
                if (res.WaveFormat.WaveFormatTag != AudioEncoding.Pcm &&
                    res.WaveFormat.WaveFormatTag != AudioEncoding.IeeeFloat &&
                    res.WaveFormat.WaveFormatTag != AudioEncoding.Extensible)
                {
                    res.Dispose();
                    res = new MediaFoundation.MediaFoundationDecoder(s);
                }
                return res;
            },
                "wav", "wave"));
            Register("flac", new CodecFactoryEntry((s) =>
            {
                return new FLAC.FlacFile(s);
            },
                "flac", "fla"));

            if (AAC.AACDecoder.IsSupported)
            {
                Register("aac", new CodecFactoryEntry((s) =>
                {
                    return new AAC.AACDecoder(s);
                },
                    "aac", "adt", "adts", "m2ts", "mp2", "3g2", "3gp2", "3gp", "3gpp", "m4a", "m4v", "mp4v", "mp4", "mov"));
            }

            if (WMA.WMADecoder.IsSupported)
            {
                Register("wma", new CodecFactoryEntry((s) =>
                {
                    return new WMA.WMADecoder(s);
                },
                    "asf", "wm", "wmv", "wma"));
            }

            if (MP1.MP1Decoder.IsSupported)
            {
                Register("mp1", new CodecFactoryEntry((s) =>
                {
                    return new MP1.MP1Decoder(s);
                },
                    "mp1", "m2ts"));
            }

            if (MP2.MP2Decoder.IsSupported)
            {
                Register("mp2", new CodecFactoryEntry((s) =>
                {
                    return new MP1.MP1Decoder(s);
                },
                    "mp2", "m2ts"));
            }

            if (DDP.DDPDecoder.IsSupported)
            {
                Register("ddp", new CodecFactoryEntry((s) =>
                {
                    return new DDP.DDPDecoder(s);
                },
                    "mp2", "m2ts", "m4a", "m4v", "mp4v", "mp4", "mov", "asf", "wm", "wmv", "wma", "avi", "ac3", "ec3"));
            }
        }