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