Пример #1
0
        protected AsfFileConfiguration GetConfiguration(string fileName)
        {
            AsfFileConfiguration config = new AsfFileConfiguration();
            bool isFirstObject          = true;

            _headerObjects = new List <AsfObject>();

            using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                while (true)
                {
                    AsfObject someObject = new AsfObject(stream);
                    if (isFirstObject && someObject.Guid != AsfGuid.ASF_Header_Object) // invalid file
                    {
                        return(null);
                    }

                    isFirstObject = false;

                    if (someObject.Size == 0)
                    {
                        break;
                    }

                    _headerObjects.Add(AsfObject.CreateAsfObject(someObject.Guid, stream, config));
                    if (someObject.Guid == AsfGuid.ASF_Data_Object)
                    {
                        //parse asf objects after data packets, if any
                        long filePosition = config.AsfHeaderSize + config.AsfPacketCount * config.AsfPacketSize;
                        stream.Position = filePosition;
                    }
                }
            }
            return(config);
        }
Пример #2
0
        public void CreateAsfObject()
        {
            AsfFile asfFile             = new AsfFile(testVideoFileName);
            AsfFileConfiguration config = new AsfFileConfiguration();

            AsfFileHeader asfFileHeader;

            using (FileStream fs = new FileStream(testVideoFileName, FileMode.Open, FileAccess.Read))
            {
                asfFileHeader = (AsfFileHeader)AsfObject.CreateAsfObject(AsfGuid.ASF_Header_Object, fs, config);
            }

            Assert.IsNotNull(asfFileHeader);
            Assert.AreEqual <uint>(5292, asfFileHeader.HeaderSize);
        }