/// <summary>
        /// Reads the sample entry properties from stream.
        /// </summary>
        /// <param name="reader">The stream reader.</param>
        internal override void ReadSampleEntryPropertiesFromStream(BoxBinaryReader reader)
        {
            predefined1          = reader.ReadUInt16();
            reserved1            = reader.ReadUInt16();
            predefined2          = reader.ReadBytes(12);
            this.Width           = reader.ReadUInt16();
            this.Height          = reader.ReadUInt16();
            this.HorizResolution = reader.ReadUInt32();
            this.VertResolution  = reader.ReadUInt32();
            reserved2            = reader.ReadUInt32();
            this.FrameCount      = reader.ReadUInt16();

            byte[] buffer = new byte[0x20];
            reader.Read(buffer, 0, 0x20);
            int count = buffer[0];

            if (count < 0x20)
            {
                this.CompressorName = Encoding.UTF8.GetString(buffer, 1, count);
            }
            this.Depth  = reader.ReadUInt16();
            predefined3 = reader.ReadUInt16();

            if (reader.PeekNextBoxType() != BoxType.Null)
            {
                ReadInnerBoxes(reader, BoxType.Esds, BoxType.Avcc, BoxType.Avc1, BoxType.Dvc1, BoxType.Btrt, BoxType.Sinf);
                this.VideoCodecData = GetVideoCodecDataFromInnerBoxes();
            }
            else
            {
                var videoInfoHeader = new VideoInfoHeader2(reader);
                this.VideoCodecData = new VideoTrackCodecData(videoInfoHeader);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Reads the header boxes for the video, which includes
        /// ftyp, pdin, bloc, moov, and the optional mdat.
        /// </summary>
        /// <param name="callback"></param>
        private async Task ReadMovieHeaderBoxes()
        {
            var moov = await this.GetBox(BoxType.Moov);

            this.Boxes.Add(moov);

            // See if we have an mdat next and grab it if we do
            var stream = await WebRequestor.GetStreamRangeAsync(this.fileUri, this.fileOffset, this.fileOffset + 8);

            using (var reader = new BoxBinaryReader(stream))
            {
                if (reader.PeekNextBoxType() == BoxType.Mdat)
                {
                    var mdat = await this.GetNextBox();

                    this.Boxes.Add(mdat);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Reads the sample entry properties from stream.
        /// </summary>
        /// <param name="reader">The stream reader.</param>
        internal override void ReadSampleEntryPropertiesFromStream(BoxBinaryReader reader)
        {
            this.reserved1    = reader.ReadUInt16();
            this.reserved2    = reader.ReadUInt16();
            this.reserved3    = reader.ReadUInt32();
            this.ChannelCount = reader.ReadUInt16();
            this.SampleSize   = reader.ReadUInt16();
            this.predefined   = reader.ReadUInt16();
            this.reserved4    = reader.ReadUInt16();
            this.SampleRate   = reader.ReadUInt32();

            if (reader.PeekNextBoxType() != BoxType.Null)
            {
                ReadInnerBoxes(reader, BoxType.Esds, BoxType.Wfex, BoxType.Sinf, BoxType.Dec3, BoxType.Dac3, BoxType.Dmlp, BoxType.Ddts);
                this.AudioCodecData = GetAudioCodecDataFromInnerBoxes();
            }
            else
            {
                var waveFormatEx = new WaveFormatEx(reader);
                this.AudioCodecData = new AudioTrackCodecData(waveFormatEx);
            }
        }
        /// <summary>
        /// Reads the sample entry properties from stream.
        /// </summary>
        /// <param name="reader">The stream reader.</param>
        internal override void ReadSampleEntryPropertiesFromStream(BoxBinaryReader reader)
        {
            this.reserved1 = reader.ReadUInt16();
            this.reserved2 = reader.ReadUInt16();
            this.reserved3 = reader.ReadUInt32();
            this.ChannelCount = reader.ReadUInt16();
            this.SampleSize = reader.ReadUInt16();
            this.predefined = reader.ReadUInt16();
            this.reserved4 = reader.ReadUInt16();
            this.SampleRate = reader.ReadUInt32();

            if (reader.PeekNextBoxType() != BoxType.Null)
            {
                ReadInnerBoxes(reader, BoxType.Esds, BoxType.Wfex, BoxType.Sinf, BoxType.Dec3, BoxType.Dac3, BoxType.Dmlp, BoxType.Ddts);
                this.AudioCodecData = GetAudioCodecDataFromInnerBoxes();
            }
            else
            {
                var waveFormatEx = new WaveFormatEx(reader);
                this.AudioCodecData = new AudioTrackCodecData(waveFormatEx);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Opens a local (offline) file and initializes the CFF data that can be used for
        /// manifest generation.
        /// </summary>
        /// <param name="path">The file URI of the resource to be opened. i.e. ms-appx:////Big_Buck_Bunny.uvu </param>
        public override async Task Parse(Uri path)
        {
            if (StorageFile == null)
            {
                StorageFile = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(path);
            }

            using (var fileStream = await StorageFile.OpenStreamForReadAsync())
            {
                var reader = new BoxBinaryReader(fileStream);
                Box box    = null;

                do
                {
                    box = reader.ReadNextBox();

                    if (box != null)
                    {
                        this.Boxes.Add(box);

                        if (box.Type == BoxType.Moov)
                        {
                            // There may be an mdat after the moov, if so parse it
                            if (reader.PeekNextBoxType() == BoxType.Mdat)
                            {
                                box = reader.ReadNextBox();
                                this.Boxes.Add(box);
                            }

                            // After parsing the moov and optional mdat after it, skip to the mfra
                            // this will jump past the moof and mdats which we don't need to process
                            reader.GotoMovieFragmentRandomAccess();
                        }
                    }
                } while (box != null);
            }

            this.InitializeTrackRegistry();
        }
        /// <summary>
        /// Reads the sample entry properties from stream.
        /// </summary>
        /// <param name="reader">The stream reader.</param>
        internal override void ReadSampleEntryPropertiesFromStream(BoxBinaryReader reader)
        {
            predefined1 = reader.ReadUInt16();
            reserved1 = reader.ReadUInt16();
            predefined2 = reader.ReadBytes(12);
            this.Width = reader.ReadUInt16();
            this.Height = reader.ReadUInt16();
            this.HorizResolution = reader.ReadUInt32();
            this.VertResolution = reader.ReadUInt32();
            reserved2 = reader.ReadUInt32();
            this.FrameCount = reader.ReadUInt16();

            byte[] buffer = new byte[0x20];
            reader.Read(buffer, 0, 0x20);
            int count = buffer[0];
            if (count < 0x20)
            {
                this.CompressorName = Encoding.UTF8.GetString(buffer, 1, count);
            }
            this.Depth = reader.ReadUInt16();
            predefined3 = reader.ReadUInt16();

            if (reader.PeekNextBoxType() != BoxType.Null)
            {
                ReadInnerBoxes(reader, BoxType.Esds, BoxType.Avcc, BoxType.Avc1, BoxType.Dvc1, BoxType.Btrt, BoxType.Sinf);
                this.VideoCodecData = GetVideoCodecDataFromInnerBoxes();
            }
            else
            {
                var videoInfoHeader = new VideoInfoHeader2(reader);
                this.VideoCodecData = new VideoTrackCodecData(videoInfoHeader);
            }

        }