Shaka Packager SDK
Loading...
Searching...
No Matches
pes_packet_generator.h
1// Copyright 2016 Google LLC. All rights reserved.
2//
3// Use of this source code is governed by a BSD-style
4// license that can be found in the LICENSE file or at
5// https://developers.google.com/open-source/licenses/bsd
6
7#ifndef PACKAGER_MEDIA_FORMATS_MP2T_PES_PACKET_GENERATOR_H_
8#define PACKAGER_MEDIA_FORMATS_MP2T_PES_PACKET_GENERATOR_H_
9
10#include <cstdint>
11#include <list>
12#include <memory>
13
14#include <packager/macros/classes.h>
15#include <packager/media/base/media_sample.h>
16#include <packager/media/base/stream_info.h>
17
18namespace shaka {
19namespace media {
20
21class AACAudioSpecificConfig;
22class NalUnitToByteStreamConverter;
23class StreamInfo;
24
25namespace mp2t {
26
27class PesPacket;
28
32 public:
36 explicit PesPacketGenerator(int32_t transport_stream_timestamp_offset);
37 virtual ~PesPacketGenerator();
38
44 virtual bool Initialize(const StreamInfo& stream);
45
50 virtual bool PushSample(const MediaSample& sample);
51
53 virtual size_t NumberOfReadyPesPackets();
54
58 virtual std::unique_ptr<PesPacket> GetNextPesPacket();
59
63 virtual bool Flush();
64
65 private:
66 friend class PesPacketGeneratorTest;
67
68 StreamType stream_type_;
69
70 const int32_t transport_stream_timestamp_offset_ = 0;
71 // Calculated by 90000 / input stream's timescale. This is used to scale the
72 // timestamps.
73 double timescale_scale_ = 0.0;
74
75 std::unique_ptr<NalUnitToByteStreamConverter> converter_;
76 std::unique_ptr<AACAudioSpecificConfig> adts_converter_;
77
78 // This is the PES packet that this object is currently working on.
79 // This can be used to create a PES from multiple audio samples.
80 std::unique_ptr<PesPacket> current_processing_pes_;
81
82 // Audio stream id PES packet is codec dependent.
83 uint8_t audio_stream_id_ = 0;
84 std::list<std::unique_ptr<PesPacket>> pes_packets_;
85
86 DISALLOW_COPY_AND_ASSIGN(PesPacketGenerator);
87};
88
89} // namespace mp2t
90} // namespace media
91} // namespace shaka
92
93#endif // PACKAGER_MEDIA_FORMATS_MP2T_PES_PACKET_GENERATOR_H_
Class to hold a media sample.
Abstract class holds stream information.
Definition stream_info.h:72
virtual bool PushSample(const MediaSample &sample)
virtual bool Initialize(const StreamInfo &stream)
virtual std::unique_ptr< PesPacket > GetNextPesPacket()
All the methods that are virtual are virtual for mocking.