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/stl_util.h"
29 #include "packager/base/time/clock.h"
30 #include "packager/base/time/time.h"
31 #include "packager/mpd/base/bandwidth_estimator.h"
32 #include "packager/mpd/base/content_protection_element.h"
33 #include "packager/mpd/base/media_info.pb.h"
34 #include "packager/mpd/base/mpd_options.h"
35 #include "packager/mpd/base/segment_info.h"
36 #include "packager/mpd/base/xml/scoped_xml_ptr.h"
53 class RepresentationXmlNode;
90 virtual bool ToString(std::string* output);
93 MpdType
type()
const {
return type_; }
101 MediaInfo* media_info);
106 clock_ = clock.Pass();
112 friend class DynamicMpdBuilderTest;
114 bool ToStringImpl(std::string* output);
118 template <
typename OutputType>
119 bool WriteMpdToOutput(OutputType* output);
124 xmlDocPtr GenerateMpd();
145 bool GetEarliestTimestamp(
double* timestamp_seconds);
149 std::list<AdaptationSet*> adaptation_sets_;
150 STLElementDeleter<std::list<AdaptationSet*> > adaptation_sets_deleter_;
152 std::list<std::string> base_urls_;
153 std::string availability_start_time_;
155 base::AtomicSequenceNumber adaptation_set_counter_;
156 base::AtomicSequenceNumber representation_counter_;
160 scoped_ptr<base::Clock> clock_;
216 const std::string& pssh);
222 virtual void AddRole(Role role);
228 xml::scoped_xml_ptr<xmlNode>
GetXml();
242 virtual void SetGroup(
int group_number);
245 virtual int Group()
const;
248 uint32_t id()
const {
return id_; }
278 uint32_t frame_duration,
290 const std::string& lang,
292 MpdBuilder::MpdType mpd_type,
293 base::AtomicSequenceNumber* representation_counter);
297 template <MpdBuilder::MpdType type>
298 friend class MpdBuilderTest;
307 enum SegmentAligmentStatus {
308 kSegmentAlignmentUnknown,
309 kSegmentAlignmentTrue,
310 kSegmentAlignmentFalse
319 typedef std::map<uint32_t, std::list<uint64_t> > RepresentationTimeline;
323 bool GetEarliestTimestamp(
double* timestamp_seconds);
332 void CheckLiveSegmentAlignment(uint32_t representation_id,
338 void CheckVodSegmentAlignment();
341 void RecordFrameRate(uint32_t frame_duration, uint32_t timescale);
343 std::list<ContentProtectionElement> content_protection_elements_;
344 std::list<Representation*> representations_;
345 STLElementDeleter<std::list<Representation*> > representations_deleter_;
347 base::AtomicSequenceNumber*
const representation_counter_;
350 const std::string lang_;
352 const MpdBuilder::MpdType mpd_type_;
362 std::set<uint32_t> video_widths_;
363 std::set<uint32_t> video_heights_;
371 std::map<double, std::string> video_frame_rates_;
375 std::string content_type_;
385 std::set<std::string> picture_aspect_ratio_;
388 std::set<Role> roles_;
391 SegmentAligmentStatus segments_aligned_;
392 bool force_set_segment_alignment_;
401 RepresentationTimeline representation_segment_start_times_;
416 uint64_t duration) = 0;
423 uint32_t timescale) = 0;
433 kSuppressFrameRate = 4,
468 const std::string& pssh);
490 xml::scoped_xml_ptr<xmlNode>
GetXml();
503 uint32_t
id()
const {
return id_; }
515 const MediaInfo& media_info,
517 uint32_t representation_id,
518 scoped_ptr<RepresentationStateChangeListener> state_change_listener);
522 template <MpdBuilder::MpdType type>
523 friend class MpdBuilderTest;
529 bool HasRequiredMediaInfoFields();
533 bool IsContiguous(uint64_t start_time,
535 uint64_t size)
const;
544 std::string GetVideoMimeType()
const;
545 std::string GetAudioMimeType()
const;
546 std::string GetTextMimeType()
const;
550 bool GetEarliestTimestamp(
double* timestamp_seconds);
554 MediaInfo media_info_;
555 std::list<ContentProtectionElement> content_protection_elements_;
556 std::list<SegmentInfo> segment_infos_;
559 std::string mime_type_;
566 uint32_t start_number_;
570 scoped_ptr<RepresentationStateChangeListener> state_change_listener_;
573 int output_suppression_flags_;
580 #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)
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)
Representation(const MediaInfo &media_info, const MpdOptions &mpd_options, uint32_t representation_id, scoped_ptr< RepresentationStateChangeListener > state_change_listener)
void InjectClockForTesting(scoped_ptr< base::Clock > clock)
This is for testing.
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)
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)