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 9 #ifndef SRC_TRACK_ENTRY_PARSER_H_ 10 #define SRC_TRACK_ENTRY_PARSER_H_ 11 12 #include "src/audio_parser.h" 13 #include "src/bool_parser.h" 14 #include "src/byte_parser.h" 15 #include "src/content_encodings_parser.h" 16 #include "src/int_parser.h" 17 #include "src/master_value_parser.h" 18 #include "src/video_parser.h" 19 #include "webm/dom_types.h" 20 #include "webm/id.h" 21 22 namespace webm { 23 24 // Spec reference: 25 // http://matroska.org/technical/specs/index.html#TrackEntry 26 // http://www.webmproject.org/docs/container/#TrackEntry 27 class TrackEntryParser : public MasterValueParser<TrackEntry> { 28 public: TrackEntryParser()29 TrackEntryParser() 30 : MasterValueParser<TrackEntry>( 31 MakeChild<UnsignedIntParser>(Id::kTrackNumber, 32 &TrackEntry::track_number), 33 MakeChild<UnsignedIntParser>(Id::kTrackUid, &TrackEntry::track_uid), 34 MakeChild<IntParser<TrackType>>(Id::kTrackType, 35 &TrackEntry::track_type), 36 MakeChild<BoolParser>(Id::kFlagEnabled, &TrackEntry::is_enabled), 37 MakeChild<BoolParser>(Id::kFlagDefault, &TrackEntry::is_default), 38 MakeChild<BoolParser>(Id::kFlagForced, &TrackEntry::is_forced), 39 MakeChild<BoolParser>(Id::kFlagLacing, &TrackEntry::uses_lacing), 40 MakeChild<UnsignedIntParser>(Id::kDefaultDuration, 41 &TrackEntry::default_duration), 42 MakeChild<StringParser>(Id::kName, &TrackEntry::name), 43 MakeChild<StringParser>(Id::kLanguage, &TrackEntry::language), 44 MakeChild<StringParser>(Id::kCodecId, &TrackEntry::codec_id), 45 MakeChild<BinaryParser>(Id::kCodecPrivate, 46 &TrackEntry::codec_private), 47 MakeChild<StringParser>(Id::kCodecName, &TrackEntry::codec_name), 48 MakeChild<UnsignedIntParser>(Id::kCodecDelay, 49 &TrackEntry::codec_delay), 50 MakeChild<UnsignedIntParser>(Id::kSeekPreRoll, 51 &TrackEntry::seek_pre_roll), 52 MakeChild<VideoParser>(Id::kVideo, &TrackEntry::video), 53 MakeChild<AudioParser>(Id::kAudio, &TrackEntry::audio), 54 MakeChild<ContentEncodingsParser>( 55 Id::kContentEncodings, &TrackEntry::content_encodings)) {} 56 57 protected: OnParseCompleted(Callback * callback)58 Status OnParseCompleted(Callback* callback) override { 59 return callback->OnTrackEntry(metadata(Id::kTrackEntry), value()); 60 } 61 }; 62 63 } // namespace webm 64 65 #endif // SRC_TRACK_ENTRY_PARSER_H_ 66