6 #ifndef MEDIA_FORMATS_WVM_WVM_MEDIA_PARSER_H_
7 #define MEDIA_FORMATS_WVM_WVM_MEDIA_PARSER_H_
15 #include "packager/base/compiler_specific.h"
16 #include "packager/media/base/media_parser.h"
17 #include "packager/media/base/network_util.h"
18 #include "packager/media/codecs/h264_byte_to_unit_stream_converter.h"
23 class AesCbcDecryptor;
33 uint32_t demux_stream_id;
34 uint32_t parsed_audio_or_video_stream_id;
35 std::shared_ptr<MediaSample> media_sample;
43 std::shared_ptr<MediaSample> audio_sample;
44 std::shared_ptr<MediaSample> video_sample;
45 uint32_t audio_stream_id;
46 uint32_t video_stream_id;
47 int64_t audio_sample_duration;
48 int64_t video_sample_duration;
60 KeySource* decryption_key_source)
override;
61 bool Flush()
override WARN_UNUSED_RESULT;
62 bool Parse(
const uint8_t* buf,
int size)
override WARN_UNUSED_RESULT;
72 TrackTrickPlayFactor = 5,
73 TrackAdaptationInterval = 6,
80 VideoTicksPerFrame = 13,
84 AudioNumChannels = 17,
85 AudioSampleFrequency = 18,
99 VideoPixelHeight = 32,
101 SparseDownloadUrl = 34,
102 SparseDownloadRangeTranslations = 35,
103 SparseDownloadMap = 36,
104 AudioSampleSize = 37,
105 Audio_EsDescriptor = 38,
106 Video_AVCDecoderConfigurationRecord = 39,
107 Audio_EC3SpecificData = 40,
108 AudioIdentifier = 41,
110 VideoStreamType = 43,
112 AudioStreamType = 45,
113 Audio_DtsSpecificData = 46,
114 Audio_AC3SpecificData = 47,
133 PackHeaderStuffingSkip,
166 bool ParseIndexEntry();
168 bool DemuxNextPes(
bool is_program_end);
170 void StartMediaSampleDemux();
172 template <
typename T>
173 Tag GetTag(
const uint8_t& tag,
174 const uint32_t& length,
175 const uint8_t* start_index,
177 if (length ==
sizeof(uint8_t)) {
178 *value = (uint8_t)(*start_index);
179 }
else if (length ==
sizeof(int8_t)) {
180 *value = (int8_t)(*start_index);
181 }
else if (length ==
sizeof(uint16_t)) {
182 *value = (uint16_t)(ntohsFromBuffer(start_index));
183 }
else if (length ==
sizeof(int16_t)) {
184 *value = (int16_t)(ntohsFromBuffer(start_index));
185 }
else if (length ==
sizeof(uint32_t)) {
186 *value = (uint32_t)(ntohlFromBuffer(start_index));
187 }
else if (length ==
sizeof(int32_t)) {
188 *value = (int32_t)(ntohlFromBuffer(start_index));
189 }
else if (length ==
sizeof(uint64_t)) {
190 *value = (uint64_t)(ntohllFromBuffer(start_index));
191 }
else if (length ==
sizeof(int64_t)) {
192 *value = (int64_t)(ntohllFromBuffer(start_index));
201 bool Output(
bool must_process_encrypted);
203 bool GetAssetKey(
const uint8_t* asset_id,
EncryptionKey* encryption_key);
207 bool EmitSample(uint32_t parsed_audio_or_video_stream_id,
209 const std::shared_ptr<MediaSample>& new_sample,
212 bool EmitPendingSamples();
214 bool EmitLastSample(uint32_t stream_id,
215 const std::shared_ptr<MediaSample>& new_sample);
222 bool is_initialized_;
226 uint32_t skip_bytes_;
227 bool metadata_is_complete_;
228 uint8_t current_program_id_;
229 uint32_t pes_stream_id_;
230 uint32_t prev_pes_stream_id_;
231 size_t pes_packet_bytes_;
232 uint8_t pes_flags_1_;
233 uint8_t pes_flags_2_;
234 uint8_t prev_pes_flags_1_;
235 size_t pes_header_data_bytes_;
239 uint8_t index_program_id_;
240 std::shared_ptr<MediaSample> media_sample_;
241 size_t crypto_unit_start_pos_;
245 std::vector<uint8_t, std::allocator<uint8_t>> ecm_;
246 std::vector<uint8_t> psm_data_;
247 std::vector<uint8_t> index_data_;
248 std::map<std::string, uint32_t> program_demux_stream_map_;
249 int stream_id_count_;
250 std::vector<std::shared_ptr<StreamInfo>> stream_infos_;
251 std::deque<DemuxStreamIdMediaSample> media_sample_queue_;
252 std::vector<uint8_t> sample_data_;
254 std::unique_ptr<AesCbcDecryptor> content_decryptor_;
263 #endif // MEDIA_FORMATS_WVM_WVM_MEDIA_PARSER_H_