6 #ifndef MEDIA_FORMATS_WVM_WVM_MEDIA_PARSER_H_
7 #define MEDIA_FORMATS_WVM_WVM_MEDIA_PARSER_H_
14 #include "packager/base/memory/scoped_ptr.h"
15 #include "packager/media/base/media_parser.h"
16 #include "packager/media/base/network_util.h"
17 #include "packager/media/filters/h264_byte_to_unit_stream_converter.h"
19 namespace edash_packager {
22 class AesCbcCtsDecryptor;
32 uint32_t demux_stream_id;
33 uint32_t parsed_audio_or_video_stream_id;
34 scoped_refptr<MediaSample> media_sample;
42 scoped_refptr<MediaSample> audio_sample;
43 scoped_refptr<MediaSample> video_sample;
44 uint32_t audio_stream_id;
45 uint32_t video_stream_id;
46 int64_t audio_sample_duration;
47 int64_t video_sample_duration;
58 KeySource* decryption_key_source) OVERRIDE;
60 virtual void Flush() OVERRIDE;
62 virtual bool Parse(
const uint8_t* buf,
int size) OVERRIDE;
71 TrackTrickPlayRate = 5,
72 TrackAdaptationInterval = 6,
79 VideoTicksPerFrame = 13,
83 AudioNumChannels = 17,
84 AudioSampleFrequency = 18,
98 VideoPixelHeight = 32,
100 SparseDownloadUrl = 34,
101 SparseDownloadRangeTranslations = 35,
102 SparseDownloadMap = 36,
103 AudioSampleSize = 37,
104 Audio_EsDescriptor = 38,
105 AVCDecoderConfigurationRecord = 39,
106 Audio_EC3SpecificData = 40,
107 AudioIdentifier = 41,
109 VideoStreamType = 43,
111 AudioStreamType = 45,
112 Audio_DtsSpecificData = 46,
113 Audio_AC3SpecificData = 47,
132 PackHeaderStuffingSkip,
165 bool ParseIndexEntry();
167 bool DemuxNextPes(
bool is_program_end);
169 void StartMediaSampleDemux();
171 template <
typename T>
172 Tag GetTag(
const uint8_t& tag,
173 const uint32_t& length,
174 const uint8_t* start_index,
176 if (length ==
sizeof(uint8_t)) {
177 *value = (uint8_t)(*start_index);
178 }
else if (length ==
sizeof(int8_t)) {
179 *value = (int8_t)(*start_index);
180 }
else if (length ==
sizeof(uint16_t)) {
181 *value = (uint16_t)(ntohsFromBuffer(start_index));
182 }
else if (length ==
sizeof(int16_t)) {
183 *value = (int16_t)(ntohsFromBuffer(start_index));
184 }
else if (length ==
sizeof(uint32_t)) {
185 *value = (uint32_t)(ntohlFromBuffer(start_index));
186 }
else if (length ==
sizeof(int32_t)) {
187 *value = (int32_t)(ntohlFromBuffer(start_index));
188 }
else if (length ==
sizeof(uint64_t)) {
189 *value = (uint64_t)(ntohllFromBuffer(start_index));
190 }
else if (length ==
sizeof(int64_t)) {
191 *value = (int64_t)(ntohllFromBuffer(start_index));
200 bool Output(
bool must_process_encrypted);
202 bool GetAssetKey(
const uint32_t asset_id,
EncryptionKey* encryption_key);
206 bool EmitSample(uint32_t parsed_audio_or_video_stream_id,
208 scoped_refptr<MediaSample>& new_sample,
211 bool EmitPendingSamples();
213 bool EmitLastSample(uint32_t stream_id,
214 scoped_refptr<MediaSample>& new_sample);
221 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 uint16_t pes_packet_bytes_;
232 uint8_t pes_flags_1_;
233 uint8_t pes_flags_2_;
234 uint8_t prev_pes_flags_1_;
235 uint8_t pes_header_data_bytes_;
239 uint8_t index_program_id_;
240 scoped_refptr<MediaSample> media_sample_;
241 uint32_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<scoped_refptr<StreamInfo> > stream_infos_;
251 std::deque<DemuxStreamIdMediaSample> media_sample_queue_;
252 std::vector<uint8_t> sample_data_;
254 scoped_ptr<AesCbcCtsDecryptor> content_decryptor_;
263 #endif // MEDIA_FORMATS_WVM_WVM_MEDIA_PARSER_H_