Esempio n. 1
0
        /// <summary>
        /// Scan matroska file and fill MkvTracks
        /// </summary>
        public void GetInfo()
        {
            // Debug
            log.Info("\r\nFile path: " + mpegFilePath + "\r\n" +
                     "File name: " + mpegFileName + "\r\n" +
                     "File size: " + mpegFileSize.ToString("#,##0"));

            streamManager = new MpegStreamManager(mpegFilePath);
            vStream = new MpegVideoStream();
            aStream = new MpegAudioStream();

            bool isVideo = mvp.Parse(ref streamManager);

            if (isVideo)
            {
                vStream = mvp.VideoStream;
            }

            bool isAudio = map.Parse(ref streamManager);

            if (isAudio)
            {
                aStream = map.AudioStream;
            }

            streamManager.Close();

            return;
        }
        /// <summary>
        /// Search audio stream using passed MpegStreamManager
        /// </summary>
        public bool Parse(ref MpegStreamManager msManager)
        {
            audioStream = new MpegAudioStream();
            long offset = 0;

            // Search 0x00 0x00 0x01 0xC0 marker [Audio Stream]
            bool isAudioContains =
                msManager.SearchMarker(ref offset, new byte[4]{0x00, 0x00, 0x01, 0xC0});

            if (!isAudioContains)
            {
                // there isn't audio
                return false;
            }

            offset += 13;

            bool isAudio = false;

            while (!isAudio && offset < (msManager.StreamSize - 10))
            {
                if ((msManager.GetByte(offset) == 0xFF) &&
                    (msManager.GetByte(offset + 1) & 0xF0) == 0xF0)
                {
                    isAudio = ParseAudioStream(ref msManager, offset);
                }
                offset ++;
            }

            if (isAudio)
            {
                // Audio information added
                return true;
            }

            return false;
        }