7 #ifndef PACKAGER_MEDIA_BASE_DEMUXER_H_
8 #define PACKAGER_MEDIA_BASE_DEMUXER_H_
14 #include "packager/base/compiler_specific.h"
15 #include "packager/media/base/container_names.h"
16 #include "packager/media/origin/origin_handler.h"
17 #include "packager/status.h"
38 explicit Demuxer(
const std::string& file_name);
45 void SetKeySource(std::unique_ptr<KeySource> key_source);
64 std::shared_ptr<MediaHandler> handler);
72 const std::string& language_override);
74 void set_dump_stream_info(
bool dump_stream_info) {
75 dump_stream_info_ = dump_stream_info;
83 return Status(error::INTERNAL_ERROR,
84 "Demuxer should not be the downstream handler.");
99 QueuedSample(uint32_t track_id, std::shared_ptr<T> sample)
100 : track_id(track_id), sample(sample) {}
105 std::shared_ptr<T> sample;
111 Status InitializeParser();
114 void ParserInitEvent(
const std::vector<std::shared_ptr<StreamInfo>>& streams);
118 bool NewMediaSampleEvent(uint32_t track_id,
119 std::shared_ptr<MediaSample> sample);
120 bool NewTextSampleEvent(uint32_t track_id,
121 std::shared_ptr<TextSample> sample);
123 bool PushMediaSample(uint32_t track_id, std::shared_ptr<MediaSample> sample);
124 bool PushTextSample(uint32_t track_id, std::shared_ptr<TextSample> sample);
129 std::string file_name_;
130 File* media_file_ =
nullptr;
132 bool all_streams_ready_ =
false;
134 std::deque<QueuedSample<MediaSample>> queued_media_samples_;
135 std::deque<QueuedSample<TextSample>> queued_text_samples_;
136 std::unique_ptr<MediaParser> parser_;
138 std::map<uint32_t, size_t> track_id_to_stream_index_map_;
141 std::vector<size_t> stream_indexes_;
143 std::map<size_t, std::string> language_overrides_;
144 MediaContainerName container_name_ = CONTAINER_UNKNOWN;
145 std::unique_ptr<uint8_t[]> buffer_;
146 std::unique_ptr<KeySource> key_source_;
147 bool cancelled_ =
false;
149 bool dump_stream_info_ =
false;
150 Status init_event_status_;
All the methods that are virtual are virtual for mocking.