Esempio n. 1
0
        public static void Optimize(EBMLDocType ebmlDoc, Stream source, Stream target)
        {
            var dataSrc = new EBMLStreamDataSource(source);
            var dataTrg = new EBMLStreamDataSource(target);

            while(source.Position != source.Length) {
                var id = dataSrc.ReadIdentifier();
                var length = dataSrc.ReadVInt();
                var docElem = ebmlDoc.RetrieveDocElement(id);

                dataTrg.WriteIdentifier(id);
                dataTrg.WriteVInt(length);

                if(docElem.Type != EBMLElementType.Master) {
                    var offset = 0L;
                    var b = dataSrc.GetData(length, out offset);
                    dataTrg.Write(b, (Int32)offset, b.Length);
                }
            }
        }
Esempio n. 2
0
        public void ParseMatroskaTestSuite_ParseFile(string filePath)
        {
            Stream src;
            try {
                src = File.OpenRead(filePath);
                //src = File.OpenRead(@"C:\Users\Arokh\Projects\Visual Studio 2012\Projects\CSEBML\CSEBMLTest\bin\Release\TestFiles\MatroskaTestSuite\test7.mkv");
            } catch(Exception) {
                Assert.Inconclusive("Couldn't open Matroska Test File ({0})", filePath);
                return;
            }

            var ebmlSrc = new EBMLStreamDataSource(src);
            var matroskaDoc = new MatroskaDocType(CSEBML.DocTypes.Matroska.MatroskaVersion.V3);
            var ebmlReader = new EBMLReader(ebmlSrc, matroskaDoc);

            Action<bool> recurse = readValues => {
                try {
                    ebmlReader.Reset();
                    Recurse(ebmlReader, readValues);
                } catch(Exception ex) {
                    ex.Data.Add("ReadValues", readValues);
                    throw;
                }
            };

            recurse(true);
            recurse(false);
        }