7 #ifndef PACKAGER_MEDIA_BASE_DEMUXER_H_
8 #define PACKAGER_MEDIA_BASE_DEMUXER_H_
14 #include <packager/macros/classes.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);
49 Status
Run()
override;
63 Status
SetHandler(
const std::string& stream_label,
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;
78 void set_input_format(std::string input_format) {
79 input_format_ = input_format;
86 Status
Process(std::unique_ptr<StreamData> stream_data)
override {
87 return Status(error::INTERNAL_ERROR,
88 "Demuxer should not be the downstream handler.");
101 template <
typename T>
102 struct QueuedSample {
103 QueuedSample(uint32_t track_id, std::shared_ptr<T> sample)
104 : track_id(track_id), sample(sample) {}
109 std::shared_ptr<T> sample;
115 Status InitializeParser();
118 void ParserInitEvent(
const std::vector<std::shared_ptr<StreamInfo>>& streams);
122 bool NewMediaSampleEvent(uint32_t track_id,
123 std::shared_ptr<MediaSample> sample);
124 bool NewTextSampleEvent(uint32_t track_id,
125 std::shared_ptr<TextSample> sample);
127 bool PushMediaSample(uint32_t track_id, std::shared_ptr<MediaSample> sample);
128 bool PushTextSample(uint32_t track_id, std::shared_ptr<TextSample> sample);
133 std::string file_name_;
134 File* media_file_ =
nullptr;
136 bool all_streams_ready_ =
false;
138 std::deque<QueuedSample<MediaSample>> queued_media_samples_;
139 std::deque<QueuedSample<TextSample>> queued_text_samples_;
140 std::unique_ptr<MediaParser> parser_;
142 std::map<uint32_t, size_t> track_id_to_stream_index_map_;
145 std::vector<size_t> stream_indexes_;
147 std::map<size_t, std::string> language_overrides_;
148 MediaContainerName container_name_ = CONTAINER_UNKNOWN;
149 std::unique_ptr<uint8_t[]> buffer_;
150 std::unique_ptr<KeySource> key_source_;
151 bool cancelled_ =
false;
153 bool dump_stream_info_ =
false;
154 Status init_event_status_;
156 std::string input_format_;
All the methods that are virtual are virtual for mocking.