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;
89 virtual bool ToString(std::string* output);
92 MpdType
type()
const {
return type_; }
100 MediaInfo* media_info);
105 clock_ = std::move(clock);
111 friend class DynamicMpdBuilderTest;
113 bool ToStringImpl(std::string* output);
117 template <
typename OutputType>
118 bool WriteMpdToOutput(OutputType* output);
123 xmlDocPtr GenerateMpd();
144 bool GetEarliestTimestamp(
double* timestamp_seconds);
148 std::list<std::unique_ptr<AdaptationSet>> adaptation_sets_;
150 std::list<std::string> base_urls_;
151 std::string availability_start_time_;
153 base::AtomicSequenceNumber adaptation_set_counter_;
154 base::AtomicSequenceNumber representation_counter_;
158 std::unique_ptr<base::Clock> clock_;
214 const std::string& pssh);
220 virtual void AddRole(Role role);
226 xml::scoped_xml_ptr<xmlNode>
GetXml();
240 virtual void SetGroup(
int group_number);
243 virtual int Group()
const;
246 uint32_t id()
const {
return id_; }
276 uint32_t frame_duration,
288 const std::string& lang,
290 MpdBuilder::MpdType mpd_type,
291 base::AtomicSequenceNumber* representation_counter);
295 template <MpdBuilder::MpdType type>
296 friend class MpdBuilderTest;
305 enum SegmentAligmentStatus {
306 kSegmentAlignmentUnknown,
307 kSegmentAlignmentTrue,
308 kSegmentAlignmentFalse
317 typedef std::map<uint32_t, std::list<uint64_t> > RepresentationTimeline;
321 bool GetEarliestTimestamp(
double* timestamp_seconds);
330 void CheckLiveSegmentAlignment(uint32_t representation_id,
336 void CheckVodSegmentAlignment();
339 void RecordFrameRate(uint32_t frame_duration, uint32_t timescale);
341 std::list<ContentProtectionElement> content_protection_elements_;
342 std::list<std::unique_ptr<Representation>> representations_;
344 base::AtomicSequenceNumber*
const representation_counter_;
347 const std::string lang_;
349 const MpdBuilder::MpdType mpd_type_;
359 std::set<uint32_t> video_widths_;
360 std::set<uint32_t> video_heights_;
368 std::map<double, std::string> video_frame_rates_;
372 std::string content_type_;
382 std::set<std::string> picture_aspect_ratio_;
385 std::set<Role> roles_;
388 SegmentAligmentStatus segments_aligned_;
389 bool force_set_segment_alignment_;
398 RepresentationTimeline representation_segment_start_times_;
413 uint64_t duration) = 0;
420 uint32_t timescale) = 0;
430 kSuppressFrameRate = 4,
465 const std::string& pssh);
487 xml::scoped_xml_ptr<xmlNode>
GetXml();
500 uint32_t
id()
const {
return id_; }
512 const MediaInfo& media_info,
514 uint32_t representation_id,
515 std::unique_ptr<RepresentationStateChangeListener> state_change_listener);
519 template <MpdBuilder::MpdType type>
520 friend class MpdBuilderTest;
526 bool HasRequiredMediaInfoFields();
530 bool IsContiguous(uint64_t start_time,
532 uint64_t size)
const;
541 std::string GetVideoMimeType()
const;
542 std::string GetAudioMimeType()
const;
543 std::string GetTextMimeType()
const;
547 bool GetEarliestTimestamp(
double* timestamp_seconds);
551 MediaInfo media_info_;
552 std::list<ContentProtectionElement> content_protection_elements_;
553 std::list<SegmentInfo> segment_infos_;
556 std::string mime_type_;
563 uint32_t start_number_;
567 std::unique_ptr<RepresentationStateChangeListener> state_change_listener_;
570 int output_suppression_flags_;
577 #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)
AdaptationSet(uint32_t adaptation_set_id, const std::string &lang, const MpdOptions &mpd_options, MpdBuilder::MpdType mpd_type, base::AtomicSequenceNumber *representation_counter)
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 AddRole(Role role)
void AddBaseUrl(const std::string &base_url)
virtual void UpdateContentProtectionPssh(const std::string &drm_uuid, const std::string &pssh)
virtual void SetGroup(int group_number)
xml::scoped_xml_ptr< xmlNode > GetXml()
virtual bool ToString(std::string *output)
virtual void ForceSetSegmentAlignment(bool segment_alignment)
static void MakePathsRelativeToMpd(const std::string &mpd_path, MediaInfo *media_info)
MpdBuilder(MpdType type, const MpdOptions &mpd_options)
xml::scoped_xml_ptr< xmlNode > GetXml()
virtual void AddContentProtectionElement(const ContentProtectionElement &element)
virtual AdaptationSet * AddAdaptationSet(const std::string &lang)
virtual int Group() const
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)