Esempio n. 1
0
        public void DocType_Equals()
        {
            var dataSrc = new EBMLBlockDataSource(new byte[][] { new byte[0] }, 0);
            var docType = new EBMLDocType();
            var reader = new EBMLReader(dataSrc, docType);

            Assert.AreEqual(docType, reader.DocType);
        }
Esempio n. 2
0
		public EBMLReader(IEBMLDataSource dataSrc, EBMLDocType ebmlDoc) {
			this.dataSrc = dataSrc;
			this.docType = ebmlDoc;
			this.bytePatterns = new BytePatterns(ebmlDoc.CreateSyncPoints());


			lastElementPos = dataSrc.HasKnownLength ? dataSrc.Length : ~VIntConsts.UNKNOWN_LENGTH;
		}
Esempio n. 3
0
        public void JumpToElementAt()
        {
            var dataSrc = new EBMLFixedByteArrayDataSource(new byte[] { 0x1A, 0x45, 0xDF, 0xA3, 0x80 });
            var docType = new EBMLDocType();
            var reader = new EBMLReader(dataSrc, docType);

            var elemInfo = reader.Next();
            using(reader.EnterElement(elemInfo)) {
                reader.Next();
            }

            Assert.IsTrue(reader.JumpToElementAt(0).IdPos == elemInfo.IdPos, "Basestream was not reset");
        }
Esempio n. 4
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. 5
0
        public void RetrieveValue_ZeroLength()
        {
            var dataSrc = new EBMLBlockDataSource(new byte[][] { new byte[0] }, 0);
            var docType = new EBMLDocType();
            var reader = new EBMLReader(dataSrc, docType);

            reader.RetrieveValue(new ElementInfo(EBMLDocElement.Unknown, 0, 0, 0, 0));
            reader.RetrieveValue(new ElementInfo(EBMLDocElement.Unknown, 1, 1, 1, 0));
        }
Esempio n. 6
0
 public void RetrieveValue_WrongPosition()
 {
     var dataSrc = new EBMLBlockDataSource(new byte[][] { new byte[0] }, 0);
     var docType = new EBMLDocType();
     var reader = new EBMLReader(dataSrc, docType);
     reader.RetrieveValue(new ElementInfo(EBMLDocElement.Unknown, 1, 2, 3, 1));
 }
Esempio n. 7
0
 public void RetrieveValue_NullArgument()
 {
     var dataSrc = new EBMLBlockDataSource(new byte[][] { new byte[0] }, 0);
     var docType = new EBMLDocType();
     var reader = new EBMLReader(dataSrc, docType);
     reader.RetrieveValue(null);
 }
Esempio n. 8
0
        public void Reset()
        {
            var dataSrc = new EBMLFixedByteArrayDataSource(new byte[] { 0x1A, 0x45, 0xDF, 0xA3, 0x80 });
            var docType = new EBMLDocType();
            var reader = new EBMLReader(dataSrc, docType);

            var elemInfo = reader.Next();
            using(reader.EnterElement(elemInfo)) {
                elemInfo = reader.Next();
            }

            reader.Reset();
            Assert.IsTrue(reader.BaseStream.Position == 0, "Bastream was not reset");
        }
Esempio n. 9
0
 public EBMLWriter(IEBMLDataSource dataSrc, EBMLDocType ebmlDoc)
 {
     this.dataSrc = dataSrc;
     this.ebmlDoc = ebmlDoc;
 }