15 #ifndef MPD_BASE_MPD_BUILDER_H_
16 #define MPD_BASE_MPD_BUILDER_H_
25 #include "packager/base/atomic_sequence_num.h"
26 #include "packager/base/callback.h"
27 #include "packager/base/gtest_prod_util.h"
28 #include "packager/base/time/clock.h"
29 #include "packager/base/time/time.h"
30 #include "packager/mpd/base/bandwidth_estimator.h"
31 #include "packager/mpd/base/content_protection_element.h"
32 #include "packager/mpd/base/media_info.pb.h"
33 #include "packager/mpd/base/mpd_options.h"
34 #include "packager/mpd/base/segment_info.h"
35 #include "packager/mpd/base/xml/scoped_xml_ptr.h"
52 class RepresentationXmlNode;
83 virtual bool ToString(std::string* output);
91 MediaInfo* media_info);
96 clock_ = std::move(clock);
102 friend class LiveMpdBuilderTest;
103 template <DashProfile profile>
104 friend class MpdBuilderTest;
106 bool ToStringImpl(std::string* output);
110 template <
typename OutputType>
111 bool WriteMpdToOutput(OutputType* output);
116 xmlDocPtr GenerateMpd();
137 bool GetEarliestTimestamp(
double* timestamp_seconds);
140 std::list<std::unique_ptr<AdaptationSet>> adaptation_sets_;
142 std::list<std::string> base_urls_;
143 std::string availability_start_time_;
145 base::AtomicSequenceNumber adaptation_set_counter_;
146 base::AtomicSequenceNumber representation_counter_;
150 std::unique_ptr<base::Clock> clock_;
206 const std::string& pssh);
212 virtual void AddRole(Role role);
218 xml::scoped_xml_ptr<xmlNode>
GetXml();
233 return adaptation_set_switching_ids_;
237 uint32_t id()
const {
return id_; }
267 uint32_t frame_duration,
284 const std::string& lang,
285 const MpdOptions& mpd_options,
286 base::AtomicSequenceNumber* representation_counter);
289 friend class MpdBuilder;
290 template <DashProfile profile>
291 friend class MpdBuilderTest;
300 enum SegmentAligmentStatus {
301 kSegmentAlignmentUnknown,
302 kSegmentAlignmentTrue,
303 kSegmentAlignmentFalse
312 typedef std::map<uint32_t, std::list<uint64_t> > RepresentationTimeline;
316 bool GetEarliestTimestamp(
double* timestamp_seconds);
325 void CheckLiveSegmentAlignment(uint32_t representation_id,
331 void CheckVodSegmentAlignment();
334 void RecordFrameRate(uint32_t frame_duration, uint32_t timescale);
336 std::list<ContentProtectionElement> content_protection_elements_;
337 std::list<std::unique_ptr<Representation>> representations_;
339 base::AtomicSequenceNumber*
const representation_counter_;
342 const std::string lang_;
343 const MpdOptions& mpd_options_;
346 std::vector<uint32_t> adaptation_set_switching_ids_;
351 std::set<uint32_t> video_widths_;
352 std::set<uint32_t> video_heights_;
360 std::map<double, std::string> video_frame_rates_;
364 std::string content_type_;
374 std::set<std::string> picture_aspect_ratio_;
377 std::set<Role> roles_;
380 SegmentAligmentStatus segments_aligned_;
381 bool force_set_segment_alignment_;
390 RepresentationTimeline representation_segment_start_times_;
396 std::set<uint32_t> trick_play_reference_ids_;
411 uint64_t duration) = 0;
418 uint32_t timescale) = 0;
428 kSuppressFrameRate = 4,
463 const std::string& pssh);
485 xml::scoped_xml_ptr<xmlNode>
GetXml();
498 uint32_t
id()
const {
return id_; }
510 const MediaInfo& media_info,
512 uint32_t representation_id,
513 std::unique_ptr<RepresentationStateChangeListener> state_change_listener);
517 template <DashProfile profile>
518 friend class MpdBuilderTest;
524 bool HasRequiredMediaInfoFields();
528 bool IsContiguous(uint64_t start_time,
530 uint64_t size)
const;
538 std::string GetVideoMimeType()
const;
539 std::string GetAudioMimeType()
const;
540 std::string GetTextMimeType()
const;
544 bool GetEarliestTimestamp(
double* timestamp_seconds);
548 MediaInfo media_info_;
549 std::list<ContentProtectionElement> content_protection_elements_;
550 std::list<SegmentInfo> segment_infos_;
553 std::string mime_type_;
560 uint32_t start_number_;
564 std::unique_ptr<RepresentationStateChangeListener> state_change_listener_;
567 int output_suppression_flags_;
574 #endif // MPD_BASE_MPD_BUILDER_H_
void OnSetFrameRateForRepresentation(uint32_t representation_id, uint32_t frame_duration, uint32_t timescale)
RepresentationType in MPD.
virtual void AddNewSegment(uint64_t start_time, uint64_t duration, uint64_t size)
virtual void OnSetFrameRateForRepresentation(uint32_t frame_duration, uint32_t timescale)=0
bool WriteMpdToFile(media::File *output_file)
Representation(const MediaInfo &media_info, const MpdOptions &mpd_options, uint32_t representation_id, std::unique_ptr< RepresentationStateChangeListener > state_change_listener)
virtual void SetSampleDuration(uint32_t sample_duration)
virtual Representation * AddRepresentation(const MediaInfo &media_info)
This class generates DASH MPDs (Media Presentation Descriptions).
virtual void AddContentProtectionElement(const ContentProtectionElement &element)
virtual void AddTrickPlayReferenceId(uint32_t id)
MpdBuilder(const MpdOptions &mpd_options)
virtual void AddRole(Role role)
void AddBaseUrl(const std::string &base_url)
virtual void UpdateContentProtectionPssh(const std::string &drm_uuid, const std::string &pssh)
AdaptationSet(uint32_t adaptation_set_id, const std::string &lang, const MpdOptions &mpd_options, base::AtomicSequenceNumber *representation_counter)
xml::scoped_xml_ptr< xmlNode > GetXml()
virtual bool ToString(std::string *output)
void AddAdaptationSetSwitching(uint32_t adaptation_set_id)
const std::vector< uint32_t > & adaptation_set_switching_ids() const
virtual void ForceSetSegmentAlignment(bool segment_alignment)
static void MakePathsRelativeToMpd(const std::string &mpd_path, MediaInfo *media_info)
xml::scoped_xml_ptr< xmlNode > GetXml()
virtual void AddContentProtectionElement(const ContentProtectionElement &element)
virtual AdaptationSet * AddAdaptationSet(const std::string &lang)
void OnNewSegmentForRepresentation(uint32_t representation_id, uint64_t start_time, uint64_t duration)
void InjectClockForTesting(std::unique_ptr< base::Clock > clock)
This is for testing.
virtual void UpdateContentProtectionPssh(const std::string &drm_uuid, const std::string &pssh)
virtual void OnNewSegmentForRepresentation(uint64_t start_time, uint64_t duration)=0
void SuppressOnce(SuppressFlag flag)