• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_CLUSTER_PARSER_H_
9 #define SRC_CLUSTER_PARSER_H_
10 
11 #include "src/block_group_parser.h"
12 #include "src/block_parser.h"
13 #include "src/int_parser.h"
14 #include "src/master_value_parser.h"
15 #include "webm/dom_types.h"
16 #include "webm/id.h"
17 
18 namespace webm {
19 
20 // Spec reference:
21 // http://matroska.org/technical/specs/index.html#Cluster
22 // http://www.webmproject.org/docs/container/#Cluster
23 class ClusterParser : public MasterValueParser<Cluster> {
24  public:
ClusterParser()25   ClusterParser()
26       : MasterValueParser<Cluster>(
27             MakeChild<UnsignedIntParser>(Id::kTimecode, &Cluster::timecode),
28             MakeChild<UnsignedIntParser>(Id::kPrevSize,
29                                          &Cluster::previous_size),
30             MakeChild<SimpleBlockParser>(Id::kSimpleBlock,
31                                          &Cluster::simple_blocks)
32                 .UseAsStartEvent(),
33             MakeChild<BlockGroupParser>(Id::kBlockGroup, &Cluster::block_groups)
34                 .UseAsStartEvent()) {}
35 
36  protected:
OnParseStarted(Callback * callback,Action * action)37   Status OnParseStarted(Callback* callback, Action* action) override {
38     return callback->OnClusterBegin(metadata(Id::kCluster), value(), action);
39   }
40 
OnParseCompleted(Callback * callback)41   Status OnParseCompleted(Callback* callback) override {
42     return callback->OnClusterEnd(metadata(Id::kCluster), value());
43   }
44 };
45 
46 }  // namespace webm
47 
48 #endif  // SRC_CLUSTER_PARSER_H_
49