1*103e46e4SHarish Mahendrakar // Copyright (c) 2016 The WebM project authors. All Rights Reserved. 2*103e46e4SHarish Mahendrakar // 3*103e46e4SHarish Mahendrakar // Use of this source code is governed by a BSD-style license 4*103e46e4SHarish Mahendrakar // that can be found in the LICENSE file in the root of the source 5*103e46e4SHarish Mahendrakar // tree. An additional intellectual property rights grant can be found 6*103e46e4SHarish Mahendrakar // in the file PATENTS. All contributing project authors may 7*103e46e4SHarish Mahendrakar // be found in the AUTHORS file in the root of the source tree. 8*103e46e4SHarish Mahendrakar #ifndef SRC_SEGMENT_PARSER_H_ 9*103e46e4SHarish Mahendrakar #define SRC_SEGMENT_PARSER_H_ 10*103e46e4SHarish Mahendrakar 11*103e46e4SHarish Mahendrakar #include <cstdint> 12*103e46e4SHarish Mahendrakar 13*103e46e4SHarish Mahendrakar #include "src/master_parser.h" 14*103e46e4SHarish Mahendrakar #include "webm/callback.h" 15*103e46e4SHarish Mahendrakar #include "webm/reader.h" 16*103e46e4SHarish Mahendrakar #include "webm/status.h" 17*103e46e4SHarish Mahendrakar 18*103e46e4SHarish Mahendrakar namespace webm { 19*103e46e4SHarish Mahendrakar 20*103e46e4SHarish Mahendrakar // Parses Segment elements from a WebM byte stream. This class adheres to the 21*103e46e4SHarish Mahendrakar // ElementParser interface; see element_parser.h for further documentation on 22*103e46e4SHarish Mahendrakar // how it should be used. 23*103e46e4SHarish Mahendrakar // Spec reference: 24*103e46e4SHarish Mahendrakar // http://matroska.org/technical/specs/index.html#Segment 25*103e46e4SHarish Mahendrakar // http://www.webmproject.org/docs/container/#Segment 26*103e46e4SHarish Mahendrakar class SegmentParser : public MasterParser { 27*103e46e4SHarish Mahendrakar public: 28*103e46e4SHarish Mahendrakar SegmentParser(); 29*103e46e4SHarish Mahendrakar 30*103e46e4SHarish Mahendrakar Status Init(const ElementMetadata& metadata, std::uint64_t max_size) override; 31*103e46e4SHarish Mahendrakar 32*103e46e4SHarish Mahendrakar void InitAfterSeek(const Ancestory& child_ancestory, 33*103e46e4SHarish Mahendrakar const ElementMetadata& child_metadata) override; 34*103e46e4SHarish Mahendrakar 35*103e46e4SHarish Mahendrakar Status Feed(Callback* callback, Reader* reader, 36*103e46e4SHarish Mahendrakar std::uint64_t* num_bytes_read) override; 37*103e46e4SHarish Mahendrakar 38*103e46e4SHarish Mahendrakar bool WasSkipped() const override; 39*103e46e4SHarish Mahendrakar 40*103e46e4SHarish Mahendrakar private: 41*103e46e4SHarish Mahendrakar // Set to true iff Callback::OnSegmentBegin has completed. 42*103e46e4SHarish Mahendrakar bool begin_done_; 43*103e46e4SHarish Mahendrakar 44*103e46e4SHarish Mahendrakar // Set to true iff the base class has completed parsing. 45*103e46e4SHarish Mahendrakar bool parse_completed_; 46*103e46e4SHarish Mahendrakar 47*103e46e4SHarish Mahendrakar // The action requested by Callback::OnSegmentBegin. 48*103e46e4SHarish Mahendrakar Action action_ = Action::kRead; 49*103e46e4SHarish Mahendrakar }; 50*103e46e4SHarish Mahendrakar 51*103e46e4SHarish Mahendrakar } // namespace webm 52*103e46e4SHarish Mahendrakar 53*103e46e4SHarish Mahendrakar #endif // SRC_SEGMENT_PARSER_H_ 54