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 <cstddef>
11#include <cstdint>
12#include <list>
13#include <memory>
14
15#include <packager/macros/classes.h>
16#include <packager/media/base/media_sample.h>
17#include <packager/media/base/stream_info.h>
18
19namespace shaka {
20namespace media {
21
22class AACAudioSpecificConfig;
23class NalUnitToByteStreamConverter;
24class StreamInfo;
25
26namespace mp2t {
27
28class PesPacket;
29
33 public:
37 explicit PesPacketGenerator(int32_t transport_stream_timestamp_offset);
38 virtual ~PesPacketGenerator();
39
45 virtual bool Initialize(const StreamInfo& stream);
46
51 virtual bool PushSample(const MediaSample& sample);
52
54 virtual size_t NumberOfReadyPesPackets();
55
59 virtual std::unique_ptr<PesPacket> GetNextPesPacket();
60
64 virtual bool Flush();
65
66 private:
67 friend class PesPacketGeneratorTest;
68
69 StreamType stream_type_;
70
71 const int32_t transport_stream_timestamp_offset_ = 0;
72 // Calculated by 90000 / input stream's timescale. This is used to scale the
73 // timestamps.
74 double timescale_scale_ = 0.0;
75
76 std::unique_ptr<NalUnitToByteStreamConverter> converter_;
77 std::unique_ptr<AACAudioSpecificConfig> adts_converter_;
78
79 // This is the PES packet that this object is currently working on.
80 // This can be used to create a PES from multiple audio samples.
81 std::unique_ptr<PesPacket> current_processing_pes_;
82
83 // Audio stream id PES packet is codec dependent.
84 uint8_t audio_stream_id_ = 0;
85 std::list<std::unique_ptr<PesPacket>> pes_packets_;
86
87 DISALLOW_COPY_AND_ASSIGN(PesPacketGenerator);
88};
89
90} // namespace mp2t
91} // namespace media
92} // namespace shaka
93
94#endif // PACKAGER_MEDIA_FORMATS_MP2T_PES_PACKET_GENERATOR_H_
Class to hold a media sample.
Abstract class holds stream information.
Definition stream_info.h:73
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.