7 #ifndef PACKAGER_HLS_BASE_MEDIA_PLAYLIST_H_
8 #define PACKAGER_HLS_BASE_MEDIA_PLAYLIST_H_
16 #include <packager/hls_params.h>
17 #include <packager/macros/classes.h>
18 #include <packager/mpd/base/bandwidth_estimator.h>
19 #include <packager/mpd/base/media_info.pb.h>
20 #include "packager/media/base/fourccs.h"
30 enum class EntryType {
34 kExtPlacementOpportunity,
38 EntryType type()
const {
return type_; }
39 virtual std::string ToString() = 0;
51 enum class MediaPlaylistStreamType {
58 enum class EncryptionMethod {
74 const std::string& file_name,
75 const std::string& name,
76 const std::string& group_id);
79 const std::string& file_name()
const {
return file_name_; }
80 const std::string& name()
const {
return name_; }
81 const std::string& group_id()
const {
return group_id_; }
82 MediaPlaylistStreamType stream_type()
const {
return stream_type_; }
83 const std::string& codec()
const {
return codec_; }
84 const std::string& supplemental_codec()
const {
return supplemental_codec_; }
85 const media::FourCC& compatible_brand()
const {
return compatible_brand_; }
86 const std::list<std::unique_ptr<HlsEntry>>& entries()
const {
104 const std::vector<std::string>& characteristics);
108 const std::string& url,
109 const std::string& key_id,
110 const std::string& iv,
111 const std::string& key_format,
112 const std::string& key_format_versions);
119 MediaInfo GetMediaInfo()
const {
return media_info_; }
134 virtual void AddSegment(
const std::string& file_name,
137 uint64_t start_byte_offset,
147 uint64_t start_byte_offset,
162 const std::string& url,
163 const std::string& key_id,
164 const std::string& iv,
165 const std::string& key_format,
166 const std::string& key_format_versions);
182 virtual bool WriteToFile(
const std::filesystem::path& file_path);
237 const std::string&
language()
const {
return language_; }
239 const std::vector<std::string>& characteristics()
const {
240 return characteristics_;
243 bool forced_subtitle()
const {
return forced_subtitle_; }
245 bool is_dvs()
const {
249 const char DVS_CHARACTERISTICS[] =
"public.accessibility.describes-video";
250 return characteristics_.size() == 1 &&
251 characteristics_[0] == DVS_CHARACTERISTICS;
256 void AddSegmentInfoEntry(
const std::string& segment_file_name,
259 uint64_t start_byte_offset,
263 void AdjustLastSegmentInfoEntryDuration(int64_t next_timestamp);
270 void RemoveOldSegment(int64_t start_time);
272 const HlsParams& hls_params_;
274 const std::string file_name_;
275 const std::string name_;
276 const std::string group_id_;
277 MediaInfo media_info_;
278 MediaPlaylistStreamType stream_type_ = MediaPlaylistStreamType::kUnknown;
280 bool use_byte_range_ =
false;
282 std::string supplemental_codec_;
283 media::FourCC compatible_brand_;
284 std::string language_;
285 std::vector<std::string> characteristics_;
286 bool forced_subtitle_ =
false;
287 uint32_t media_sequence_number_ = 0;
288 bool inserted_discontinuity_tag_ =
false;
289 int discontinuity_sequence_number_ = 0;
291 double longest_segment_duration_seconds_ = 0.0;
292 int32_t time_scale_ = 0;
294 BandwidthEstimator bandwidth_estimator_;
298 uint64_t previous_segment_end_offset_ = 0;
301 bool target_duration_set_ =
false;
302 int32_t target_duration_ = 0;
306 std::list<std::unique_ptr<HlsEntry>> entries_;
307 double current_buffer_depth_ = 0;
310 std::list<std::string> segments_to_be_removed_;
313 struct KeyFrameInfo {
315 uint64_t start_byte_offset;
317 std::string segment_file_name;
319 std::list<KeyFrameInfo> key_frames_;
327 const std::string& url,
328 const std::string& key_id,
329 const std::string& iv,
330 const std::string& key_format,
331 const std::string& key_format_versions);
333 std::string ToString()
override;
334 std::string ToString(std::string);
340 const MediaPlaylist::EncryptionMethod method_;
341 const std::string url_;
342 const std::string key_id_;
343 const std::string iv_;
344 const std::string key_format_;
345 const std::string key_format_versions_;
All the methods that are virtual are virtual for mocking.