1 // Copyright (c) 2016 The WebM project authors. All Rights Reserved. 2 // 3 // Use of this source code is governed by a BSD-style license 4 // that can be found in the LICENSE file in the root of the source 5 // tree. An additional intellectual property rights grant can be found 6 // in the file PATENTS. All contributing project authors may 7 // be found in the AUTHORS file in the root of the source tree. 8 #ifndef SRC_EBML_PARSER_H_ 9 #define SRC_EBML_PARSER_H_ 10 11 #include "src/byte_parser.h" 12 #include "src/int_parser.h" 13 #include "src/master_value_parser.h" 14 #include "webm/dom_types.h" 15 #include "webm/id.h" 16 17 namespace webm { 18 19 // Spec references: 20 // http://matroska.org/technical/specs/index.html#EBML 21 // https://github.com/Matroska-Org/ebml-specification/blob/master/specification.markdown#ebml-header-elements 22 // http://www.webmproject.org/docs/container/#EBML 23 class EbmlParser : public MasterValueParser<Ebml> { 24 public: EbmlParser()25 EbmlParser() 26 : MasterValueParser<Ebml>( 27 MakeChild<UnsignedIntParser>(Id::kEbmlVersion, &Ebml::ebml_version), 28 MakeChild<UnsignedIntParser>(Id::kEbmlReadVersion, 29 &Ebml::ebml_read_version), 30 MakeChild<UnsignedIntParser>(Id::kEbmlMaxIdLength, 31 &Ebml::ebml_max_id_length), 32 MakeChild<UnsignedIntParser>(Id::kEbmlMaxSizeLength, 33 &Ebml::ebml_max_size_length), 34 MakeChild<StringParser>(Id::kDocType, &Ebml::doc_type), 35 MakeChild<UnsignedIntParser>(Id::kDocTypeVersion, 36 &Ebml::doc_type_version), 37 MakeChild<UnsignedIntParser>(Id::kDocTypeReadVersion, 38 &Ebml::doc_type_read_version)) {} 39 40 protected: OnParseCompleted(Callback * callback)41 Status OnParseCompleted(Callback* callback) override { 42 return callback->OnEbml(metadata(Id::kEbml), value()); 43 } 44 }; 45 46 } // namespace webm 47 48 #endif // SRC_EBML_PARSER_H_ 49