Exemplo n.º 1
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();
        }