コード例 #1
0
ファイル: File.cs プロジェクト: juschubut/kenos
        private void ReadHeader(EBMLElement element)
        {
            string doctype = null;
            ulong  i       = 0;

            while (i < element.DataSize)
            {
                EBMLElement child = new EBMLElement(this, element.DataOffset + i);

                EBMLID ebml_id = (EBMLID)child.ID;

                switch (ebml_id)
                {
                case EBMLID.EBMLDocType:
                    doctype = child.ReadString();
                    break;

                default:
                    break;
                }

                i += child.Size;
            }

            // Check DocType
            if (String.IsNullOrEmpty(doctype) || (doctype != "matroska" && doctype != "webm"))
            {
                throw new UnsupportedFormatException("DocType is not matroska or webm");
            }
        }
コード例 #2
0
ファイル: File.cs プロジェクト: juschubut/kenos
        /// <summary>
        ///    Reads the file with a specified read style.
        /// </summary>
        /// <param name="propertiesStyle">
        ///    A <see cref="ReadStyle" /> value specifying at what level
        ///    of accuracy to read the media properties, or <see
        ///    cref="ReadStyle.None" /> to ignore the properties.
        /// </param>
        private void Read(ReadStyle propertiesStyle)
        {
            ulong offset = 0;

            while (offset < (ulong)Length)
            {
                EBMLElement element = new EBMLElement(this, offset);

                EBMLID     ebml_id     = (EBMLID)element.ID;
                MatroskaID matroska_id = (MatroskaID)element.ID;

                switch (ebml_id)
                {
                case EBMLID.EBMLHeader:
                    ReadHeader(element);
                    break;

                default:
                    break;
                }
                switch (matroska_id)
                {
                case MatroskaID.MatroskaSegment:
                    ReadSegment(element);
                    break;

                default:
                    break;
                }

                offset += element.Size;
            }
        }