コード例 #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="stream">Stream to access in-memory data to be parsed</param>
        /// <param name="mimeType">Mime-type of the stream to process</param>
        /// <param name="readEmbeddedPictures">Embedded pictures will be read if true; ignored if false</param>
        /// <param name="readAllMetaFrames">All metadata frames (including unmapped ones) will be read if true; ignored if false</param>
        /// <param name="writeProgress">Object to use to signal writing progress (optional)</param>
        public AudioFileIO(Stream stream, String mimeType, bool readEmbeddedPictures, bool readAllMetaFrames = false, IProgress <float> writeProgress = null)
        {
            byte alternate = 0;
            bool found     = false;

            audioData = AudioDataIOFactory.GetInstance().GetFromMimeType(mimeType, "In-memory", alternate);

            audioManager       = new AudioDataManager(audioData, stream, writeProgress);
            this.writeProgress = writeProgress;
            found = audioManager.ReadFromFile(readEmbeddedPictures, readAllMetaFrames);

            while (!found && alternate < AudioDataIOFactory.MAX_ALTERNATES)
            {
                alternate++;
                audioData    = AudioDataIOFactory.GetInstance().GetFromMimeType(mimeType, "In-memory", alternate);
                audioManager = new AudioDataManager(audioData, stream, writeProgress);
                found        = audioManager.ReadFromFile(readEmbeddedPictures, readAllMetaFrames);
            }

            metaData = MetaDataIOFactory.GetInstance().GetMetaReader(audioManager);

            if (metaData is DummyTag && (0 == audioManager.getAvailableMetas().Count))
            {
                LogDelegator.GetLogDelegate()(Log.LV_WARNING, "Could not find any metadata");
            }
        }
コード例 #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="stream">Stream to access in-memory data to be parsed</param>
        /// <param name="mimeType">the file's mime type.</param>
        /// <param name="readEmbeddedPictures">Embedded pictures will be read if true; ignored if false</param>
        /// <param name="readAllMetaFrames">All metadata frames (including unmapped ones) will be read if true; ignored if false</param>
        public AudioFileIo(Stream stream, String mimeType, Boolean readEmbeddedPictures, Boolean readAllMetaFrames = false)
        {
            Byte alternate = 0;
            var  found     = false;

            _audioData = AudioDataIoFactory.GetInstance().GetFromMimeType(mimeType, "In-memory", alternate);

            _audioManager = new AudioDataManager(_audioData, stream);
            found         = _audioManager.ReadFromFile(readEmbeddedPictures, readAllMetaFrames);

            while (!found && alternate < AudioDataIoFactory.MaxAlternates)
            {
                alternate++;
                _audioData    = AudioDataIoFactory.GetInstance().GetFromMimeType(mimeType, "In-memory", alternate);
                _audioManager = new AudioDataManager(_audioData, stream);
                found         = _audioManager.ReadFromFile(readEmbeddedPictures, readAllMetaFrames);
            }

            _metaData = MetaDataIOFactory.GetInstance().GetMetaReader(_audioManager);

            if (_metaData is DummyTag && (0 == _audioManager.getAvailableMetas().Count))
            {
                LogDelegator.GetLogDelegate()(Log.LV_WARNING, "Could not find any metadata");
            }
        }
コード例 #3
0
ファイル: AudioFileIO.cs プロジェクト: superowner/atldotnet
        // ------------------------------------------------------------------------------------------

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="path">Path of the file to be parsed</param>
        public AudioFileIO(string path, bool readEmbeddedPictures, bool readAllMetaFrames = false)
        {
            byte alternate = 0;
            bool found     = false;

            thePath = path;

            audioData    = AudioDataIOFactory.GetInstance().GetDataReader(path, alternate);
            audioManager = new AudioDataManager(audioData);
            found        = audioManager.ReadFromFile(readEmbeddedPictures, readAllMetaFrames);

            while (!found && alternate < AudioDataIOFactory.MAX_ALTERNATES)
            {
                alternate++;
                audioData    = AudioDataIOFactory.GetInstance().GetDataReader(path, alternate);
                audioManager = new AudioDataManager(audioData);
                found        = audioManager.ReadFromFile(readEmbeddedPictures, readAllMetaFrames);
            }

            metaData = MetaDataIOFactory.GetInstance().GetMetaReader(audioManager);

            if (metaData is DummyTag && (0 == audioManager.getAvailableMetas().Count))
            {
                LogDelegator.GetLogDelegate()(Log.LV_WARNING, "Could not find any metadata");
            }
        }
コード例 #4
0
ファイル: MetaDataIOFactory.cs プロジェクト: darzid/atldotnet
        // ------------------------------------------------------------------------------------------

        /// <summary>
        /// Gets the instance of this factory (Singleton pattern)
        /// </summary>
        /// <returns>Instance of the MetaReaderFactory of the application</returns>
        public static MetaDataIOFactory GetInstance()
        {
            if (!BitConverter.IsLittleEndian)
            {
                throw new PlatformNotSupportedException("Big-endian based platforms are not supported by ATL");
            }

            if (null == theFactory)
            {
                theFactory                = new MetaDataIOFactory();
                theFactory.tagPriority    = new int[TAG_TYPE_COUNT];
                theFactory.tagPriority[0] = TAG_ID3V2;
                theFactory.tagPriority[1] = TAG_APE;
                theFactory.tagPriority[2] = TAG_NATIVE;
                theFactory.tagPriority[3] = TAG_ID3V1;
            }

            return(theFactory);
        }
コード例 #5
0
        // ------------------------------------------------------------------------------------------

        /// <summary>
        /// Gets the instance of this factory (Singleton pattern)
        /// </summary>
        /// <returns>Instance of the MetaReaderFactory of the application</returns>
        public static MetaDataIOFactory GetInstance()
        {
            if (!BitConverter.IsLittleEndian)
            {
                throw new PlatformNotSupportedException("Big-endian based platforms are not supported by ATL");
            }
            lock (_lockable)
            {
                if (null == theFactory)
                {
                    theFactory                = new MetaDataIOFactory();
                    theFactory.tagPriority    = new int[TAG_TYPE_COUNT];
                    theFactory.tagPriority[0] = TAG_ID3V2;
                    theFactory.tagPriority[1] = TAG_APE;
                    theFactory.tagPriority[2] = TAG_NATIVE;
                    theFactory.tagPriority[3] = TAG_ID3V1;

                    theFactory.formatListByExt  = new Dictionary <string, IList <Format> >();
                    theFactory.formatListByMime = new Dictionary <string, IList <Format> >();

                    Format tempFmt = new Format(TAG_ID3V1 * 1000, "ID3v1");
                    tempFmt.AddExtension("id3v1");
                    theFactory.addFormat(tempFmt);

                    tempFmt = new Format(TAG_ID3V2 * 1000, "ID3v2");
                    tempFmt.AddExtension("id3v2");
                    theFactory.addFormat(tempFmt);

                    tempFmt = new Format(TAG_APE * 1000, "APEtag");
                    tempFmt.AddExtension("ape");
                    theFactory.addFormat(tempFmt);

                    tempFmt = new Format(TAG_NATIVE * 1000, "Native");
                    tempFmt.AddExtension("native");
                    theFactory.addFormat(tempFmt);
                }
            }

            return(theFactory);
        }