2015-10-08 21:48:07 +00:00
|
|
|
// Copyright 2014 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2017-12-20 00:56:36 +00:00
|
|
|
#ifndef PACKAGER_MEDIA_FORMATS_WEBM_WEBM_INFO_PARSER_H_
|
|
|
|
#define PACKAGER_MEDIA_FORMATS_WEBM_WEBM_INFO_PARSER_H_
|
2015-10-08 21:48:07 +00:00
|
|
|
|
2022-12-17 05:40:00 +00:00
|
|
|
#include <chrono>
|
|
|
|
|
2023-10-10 23:51:11 +00:00
|
|
|
#include <packager/media/formats/webm/webm_parser.h>
|
2015-10-08 21:48:07 +00:00
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2015-10-08 21:48:07 +00:00
|
|
|
namespace media {
|
|
|
|
|
2015-10-15 22:39:16 +00:00
|
|
|
/// Parser for WebM Info element.
|
2015-10-14 22:46:23 +00:00
|
|
|
class WebMInfoParser : public WebMParserClient {
|
2015-10-08 21:48:07 +00:00
|
|
|
public:
|
|
|
|
WebMInfoParser();
|
|
|
|
~WebMInfoParser() override;
|
|
|
|
|
2015-10-15 22:39:16 +00:00
|
|
|
/// Parses a WebM Info element in |buf|.
|
|
|
|
/// @return -1 if the parse fails.
|
|
|
|
/// @return 0 if more data is needed.
|
|
|
|
/// @return The number of bytes parsed on success.
|
2015-10-14 22:46:23 +00:00
|
|
|
int Parse(const uint8_t* buf, int size);
|
2015-10-08 21:48:07 +00:00
|
|
|
|
2015-10-14 22:46:23 +00:00
|
|
|
int64_t timecode_scale() const { return timecode_scale_; }
|
2015-10-08 21:48:07 +00:00
|
|
|
double duration() const { return duration_; }
|
2022-12-17 05:40:00 +00:00
|
|
|
std::chrono::system_clock::time_point date_utc() const { return date_utc_; }
|
2015-10-08 21:48:07 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// WebMParserClient methods
|
|
|
|
WebMParserClient* OnListStart(int id) override;
|
|
|
|
bool OnListEnd(int id) override;
|
2015-10-14 22:46:23 +00:00
|
|
|
bool OnUInt(int id, int64_t val) override;
|
2015-10-08 21:48:07 +00:00
|
|
|
bool OnFloat(int id, double val) override;
|
2015-10-14 22:46:23 +00:00
|
|
|
bool OnBinary(int id, const uint8_t* data, int size) override;
|
2015-10-08 21:48:07 +00:00
|
|
|
bool OnString(int id, const std::string& str) override;
|
|
|
|
|
2015-10-14 22:46:23 +00:00
|
|
|
int64_t timecode_scale_;
|
2015-10-08 21:48:07 +00:00
|
|
|
double duration_;
|
2022-12-17 05:40:00 +00:00
|
|
|
std::chrono::system_clock::time_point date_utc_;
|
2015-10-08 21:48:07 +00:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(WebMInfoParser);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace media
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|
2015-10-08 21:48:07 +00:00
|
|
|
|
2017-12-20 00:56:36 +00:00
|
|
|
#endif // PACKAGER_MEDIA_FORMATS_WEBM_WEBM_INFO_PARSER_H_
|