6 #ifndef PACKAGER_MEDIA_FORMATS_WVM_WVM_MEDIA_PARSER_H_
7 #define PACKAGER_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;
61 KeySource* decryption_key_source)
override;
62 bool Flush()
override WARN_UNUSED_RESULT;
63 bool Parse(
const uint8_t* buf,
int size)
override WARN_UNUSED_RESULT;
73 TrackTrickPlayFactor = 5,
74 TrackAdaptationInterval = 6,
81 VideoTicksPerFrame = 13,
85 AudioNumChannels = 17,
86 AudioSampleFrequency = 18,
100 VideoPixelHeight = 32,
102 SparseDownloadUrl = 34,
103 SparseDownloadRangeTranslations = 35,
104 SparseDownloadMap = 36,
105 AudioSampleSize = 37,
106 Audio_EsDescriptor = 38,
107 Video_AVCDecoderConfigurationRecord = 39,
108 Audio_EC3SpecificData = 40,
109 AudioIdentifier = 41,
111 VideoStreamType = 43,
113 AudioStreamType = 45,
114 Audio_DtsSpecificData = 46,
115 Audio_AC3SpecificData = 47,
134 PackHeaderStuffingSkip,
167 bool ParseIndexEntry();
169 bool DemuxNextPes(
bool is_program_end);
171 void StartMediaSampleDemux();
173 template <
typename T>
174 Tag GetTag(
const uint8_t& tag,
175 const uint32_t& length,
176 const uint8_t* start_index,
178 if (length ==
sizeof(uint8_t)) {
179 *value = (uint8_t)(*start_index);
180 }
else if (length ==
sizeof(int8_t)) {
181 *value = (int8_t)(*start_index);
182 }
else if (length ==
sizeof(uint16_t)) {
183 *value = (uint16_t)(ntohsFromBuffer(start_index));
184 }
else if (length ==
sizeof(int16_t)) {
185 *value = (int16_t)(ntohsFromBuffer(start_index));
186 }
else if (length ==
sizeof(uint32_t)) {
187 *value = (uint32_t)(ntohlFromBuffer(start_index));
188 }
else if (length ==
sizeof(int32_t)) {
189 *value = (int32_t)(ntohlFromBuffer(start_index));
190 }
else if (length ==
sizeof(uint64_t)) {
191 *value = (uint64_t)(ntohllFromBuffer(start_index));
192 }
else if (length ==
sizeof(int64_t)) {
193 *value = (int64_t)(ntohllFromBuffer(start_index));
202 bool Output(
bool must_process_encrypted);
204 bool GetAssetKey(
const uint8_t* asset_id,
EncryptionKey* encryption_key);
208 bool EmitSample(uint32_t parsed_audio_or_video_stream_id,
210 const std::shared_ptr<MediaSample>& new_sample,
213 bool EmitPendingSamples();
215 bool EmitLastSample(uint32_t stream_id,
216 const std::shared_ptr<MediaSample>& new_sample);
223 bool is_initialized_;
227 uint32_t skip_bytes_;
228 bool metadata_is_complete_;
229 uint8_t current_program_id_;
230 uint32_t pes_stream_id_;
231 uint32_t prev_pes_stream_id_;
232 size_t pes_packet_bytes_;
233 uint8_t pes_flags_1_;
234 uint8_t pes_flags_2_;
235 uint8_t prev_pes_flags_1_;
236 size_t pes_header_data_bytes_;
240 uint8_t index_program_id_;
241 std::shared_ptr<MediaSample> media_sample_;
242 size_t crypto_unit_start_pos_;
246 std::vector<uint8_t, std::allocator<uint8_t>> ecm_;
247 std::vector<uint8_t> psm_data_;
248 std::vector<uint8_t> index_data_;
249 std::map<std::string, uint32_t> program_demux_stream_map_;
250 int stream_id_count_;
251 std::vector<std::shared_ptr<StreamInfo>> stream_infos_;
252 std::deque<DemuxStreamIdMediaSample> media_sample_queue_;
253 std::vector<uint8_t> sample_data_;
255 std::unique_ptr<AesCbcDecryptor> content_decryptor_;
264 #endif // PACKAGER_MEDIA_FORMATS_WVM_WVM_MEDIA_PARSER_H_