2014-04-01 01:34:59 +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_MP2T_ES_PARSER_H_
|
|
|
|
#define PACKAGER_MEDIA_FORMATS_MP2T_ES_PARSER_H_
|
2014-04-01 01:34:59 +00:00
|
|
|
|
2023-12-01 17:32:19 +00:00
|
|
|
#include <cstdint>
|
|
|
|
#include <functional>
|
2014-04-01 01:34:59 +00:00
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2014-04-01 01:34:59 +00:00
|
|
|
namespace media {
|
|
|
|
|
2014-04-07 17:48:25 +00:00
|
|
|
class MediaSample;
|
2014-04-10 19:57:10 +00:00
|
|
|
class StreamInfo;
|
2020-10-16 21:18:35 +00:00
|
|
|
class TextSample;
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
namespace mp2t {
|
|
|
|
|
|
|
|
class EsParser {
|
|
|
|
public:
|
2023-12-01 17:32:19 +00:00
|
|
|
typedef std::function<void(std::shared_ptr<StreamInfo>)> NewStreamInfoCB;
|
|
|
|
typedef std::function<void(std::shared_ptr<MediaSample>)> EmitSampleCB;
|
|
|
|
typedef std::function<void(std::shared_ptr<TextSample>)> EmitTextSampleCB;
|
2014-04-01 01:34:59 +00:00
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
EsParser(uint32_t pid) : pid_(pid) {}
|
2014-04-01 01:34:59 +00:00
|
|
|
virtual ~EsParser() {}
|
|
|
|
|
|
|
|
// ES parsing.
|
|
|
|
// Should use kNoTimestamp when a timestamp is not valid.
|
2014-09-30 21:52:21 +00:00
|
|
|
virtual bool Parse(const uint8_t* buf,
|
|
|
|
int size,
|
|
|
|
int64_t pts,
|
|
|
|
int64_t dts) = 0;
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
// Flush any pending buffer.
|
2020-12-10 23:03:41 +00:00
|
|
|
virtual bool Flush() = 0;
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
// Reset the state of the ES parser.
|
|
|
|
virtual void Reset() = 0;
|
2014-04-07 17:48:25 +00:00
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t pid() { return pid_; }
|
2014-04-07 17:48:25 +00:00
|
|
|
|
|
|
|
private:
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t pid_;
|
2014-04-01 01:34:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mp2t
|
|
|
|
} // namespace media
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
#endif
|