예제 #1
0
        private bool ReadTag()
        {
            if (this.fileLength - this.fileOffset < 11)
            {
                return(false);
            }

            // Read tag header
            uint tagType   = ReadUInt8();
            uint dataSize  = ReadUInt24();
            uint timeStamp = ReadUInt24();

            timeStamp |= this.ReadUInt8() << 24;
            this.ReadUInt24();

            // Read tag data
            if (dataSize == 0)
            {
                return(true);
            }

            if (this.fileLength - this.fileOffset < dataSize)
            {
                return(false);
            }

            uint mediaInfo = this.ReadUInt8();

            dataSize -= 1;
            byte[] data = this.ReadBytes((int)dataSize);

            if (tagType == 0x8)
            {
                // If we have no audio writer, create one
                if (this.audioExtractor == null)
                {
                    this.audioExtractor = this.GetAudioWriter(mediaInfo);
                    this.ExtractedAudio = this.audioExtractor != null;
                }

                if (this.audioExtractor == null)
                {
                    throw new InvalidOperationException("No supported audio writer found.");
                }

                this.audioExtractor.WriteChunk(data, timeStamp);
            }

            return(true);
        }
예제 #2
0
        private void CloseOutput(bool disposing)
        {
            if (this.audioExtractor != null)
            {
                if (disposing && this.audioExtractor.VideoPath != null)
                {
                    try
                    {
                        File.Delete(this.audioExtractor.VideoPath);
                    }
                    catch { }
                }

                this.audioExtractor.Dispose();
                this.audioExtractor = null;
            }
        }
예제 #3
0
        private bool ReadTag()
        {
            if (this.fileLength - this.fileOffset < 11)
                return false;

            // Read tag header
            uint tagType = ReadUInt8();
            uint dataSize = ReadUInt24();
            uint timeStamp = ReadUInt24();
            timeStamp |= this.ReadUInt8() << 24;
            this.ReadUInt24();

            // Read tag data
            if (dataSize == 0)
                return true;

            if (this.fileLength - this.fileOffset < dataSize)
                return false;

            uint mediaInfo = this.ReadUInt8();
            dataSize -= 1;
            byte[] data = this.ReadBytes((int)dataSize);

            if (tagType == 0x8)
            {
                // If we have no audio writer, create one
                if (this.audioExtractor == null)
                {
                    this.audioExtractor = this.GetAudioWriter(mediaInfo);
                    this.ExtractedAudio = this.audioExtractor != null;
                }

                if (this.audioExtractor == null)
                {
                    throw new InvalidOperationException("No supported audio writer found.");
                }

                this.audioExtractor.WriteChunk(data, timeStamp);
            }

            return true;
        }
예제 #4
0
        private void CloseOutput(bool disposing)
        {
            if (this.audioExtractor != null)
            {
                if (disposing && this.audioExtractor.VideoPath != null)
                {
                    try
                    {
                        File.Delete(this.audioExtractor.VideoPath);
                    }
                    catch { }
                }

                this.audioExtractor.Dispose();
                this.audioExtractor = null;
            }
        }
예제 #5
0
        private bool ReadTag()
        {
            if (fileLength - fileOffset < 11)
                return false;

            // Read tag header
            var tagType = ReadUInt8();
            var dataSize = ReadUInt24();
            var timeStamp = ReadUInt24();
            timeStamp |= ReadUInt8() << 24;
            ReadUInt24();

            // Read tag data
            if (dataSize == 0)
                return true;

            if (fileLength - fileOffset < dataSize)
                return false;

            var mediaInfo = ReadUInt8();
            dataSize -= 1;
            var data = ReadBytes((int) dataSize);

            if (tagType == 0x8) {
                // If we have no audio writer, create one
                if (audioExtractor == null) {
                    audioExtractor = GetAudioWriter(mediaInfo);
                    ExtractedAudio = audioExtractor != null;
                }

                if (audioExtractor == null)
                    throw new InvalidOperationException("No supported audio writer found.");

                audioExtractor.WriteChunk(data, timeStamp);
            }

            return true;
        }
예제 #6
0
        private void CloseOutput(bool disposing)
        {
            if (audioExtractor != null) {
                if (disposing && audioExtractor.VideoPath != null)
                    try {
                        File.Delete(audioExtractor.VideoPath);
                    } catch {}

                audioExtractor.Dispose();
                audioExtractor = null;
            }
        }