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_TS_SECTION_PES_H_
|
|
|
|
#define PACKAGER_MEDIA_FORMATS_MP2T_TS_SECTION_PES_H_
|
2014-04-01 01:34:59 +00:00
|
|
|
|
2023-10-11 08:49:50 +00:00
|
|
|
#include <cstdint>
|
|
|
|
#include <memory>
|
|
|
|
|
2023-10-14 16:36:01 +00:00
|
|
|
#include <packager/macros/classes.h>
|
2023-10-10 23:51:11 +00:00
|
|
|
#include <packager/media/base/byte_queue.h>
|
|
|
|
#include <packager/media/formats/mp2t/ts_section.h>
|
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 {
|
|
|
|
namespace mp2t {
|
|
|
|
|
|
|
|
class EsParser;
|
|
|
|
|
|
|
|
class TsSectionPes : public TsSection {
|
|
|
|
public:
|
2016-08-17 17:41:40 +00:00
|
|
|
explicit TsSectionPes(std::unique_ptr<EsParser> es_parser);
|
2015-07-22 23:40:45 +00:00
|
|
|
~TsSectionPes() override;
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
// TsSection implementation.
|
2015-07-22 23:40:45 +00:00
|
|
|
bool Parse(bool payload_unit_start_indicator,
|
|
|
|
const uint8_t* buf,
|
|
|
|
int size) override;
|
2020-12-10 23:03:41 +00:00
|
|
|
bool Flush() override;
|
2015-07-22 23:40:45 +00:00
|
|
|
void Reset() override;
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Emit a reassembled PES packet.
|
|
|
|
// Return true if successful.
|
|
|
|
// |emit_for_unknown_size| is used to force emission for PES packets
|
|
|
|
// whose size is unknown.
|
|
|
|
bool Emit(bool emit_for_unknown_size);
|
|
|
|
|
|
|
|
// Parse a PES packet, return true if successful.
|
2014-09-30 21:52:21 +00:00
|
|
|
bool ParseInternal(const uint8_t* raw_pes, int raw_pes_size);
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
void ResetPesState();
|
|
|
|
|
|
|
|
// Bytes of the current PES.
|
|
|
|
ByteQueue pes_byte_queue_;
|
|
|
|
|
|
|
|
// ES parser.
|
2016-08-17 17:41:40 +00:00
|
|
|
std::unique_ptr<EsParser> es_parser_;
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
// Do not start parsing before getting a unit start indicator.
|
|
|
|
bool wait_for_pusi_;
|
|
|
|
|
|
|
|
// Used to unroll PTS and DTS.
|
|
|
|
bool previous_pts_valid_;
|
2014-09-30 21:52:21 +00:00
|
|
|
int64_t previous_pts_;
|
2014-04-01 01:34:59 +00:00
|
|
|
bool previous_dts_valid_;
|
2014-09-30 21:52:21 +00:00
|
|
|
int64_t previous_dts_;
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(TsSectionPes);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mp2t
|
|
|
|
} // namespace media
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|