25 #ifndef ADMANAGER_MPD_H_
26 #define ADMANAGER_MPD_H_
30 #include "libdash/INode.h"
31 #include "libdash/IDASHManager.h"
32 #include "libdash/xml/Node.h"
33 #include "libdash/IMPD.h"
37 using namespace dash::mpd;
90 virtual void SetAlternateContents(
const std::string &periodId,
const std::string &adId,
const std::string &url, uint64_t startMS=0, uint32_t breakdur=0)
override;
107 #define OFFSET_ALIGN_FACTOR 2000
126 AdNode() : invalid(false), placed(false), adId(), url(), duration(0), basePeriodId(), basePeriodOffset(0), mpd(nullptr)
143 AdNode(
bool invalid,
bool placed, std::string adId, std::string url, uint64_t duration,
144 std::string basePeriodId,
int basePeriodOffset, MPD* mpd)
145 : invalid(invalid), placed(placed), adId(adId), url(url), duration(duration), basePeriodId(basePeriodId),
146 basePeriodOffset(basePeriodOffset), mpd(mpd)
156 AdNode(
const AdNode& adNode) : invalid(adNode.invalid), placed(adNode.placed), adId(adNode.adId),
157 url(adNode.url), duration(adNode.duration), basePeriodId(adNode.basePeriodId),
158 basePeriodOffset(adNode.basePeriodOffset), mpd(adNode.mpd)
174 std::shared_ptr<std::vector<AdNode>>
ads;
183 AdBreakObject() : brkDuration(0), ads(), endPeriodId(), endPeriodOffset(0), adsDuration(0), adjustEndPeriodOffset(false)
196 AdBreakObject(uint32_t _duration, std::shared_ptr<std::vector<AdNode>> _ads, std::string _endPeriodId,
197 uint64_t _endPeriodOffset, uint32_t _adsDuration)
198 : brkDuration(_duration), ads(_ads), endPeriodId(_endPeriodId), endPeriodOffset(_endPeriodOffset), adsDuration(_adsDuration), adjustEndPeriodOffset(false)
266 PlacementObj(): pendingAdbrkId(), openPeriodId(), curEndNumber(0), curAdIdx(-1), adNextOffset(0)
285 std::unordered_map<std::string, AdBreakObject>
mAdBreaks;
329 void SetAlternateContents(
const std::string &periodId,
const std::string &adId,
const std::string &url, uint64_t startMS, uint32_t breakdur=0);
334 void FulFillAdObject();
344 MPD* GetAdMPD(std::string &url,
bool &finalManifest,
bool tryFog =
false);
351 void InsertToPeriodMap(IPeriod *period);
359 bool isPeriodExist(
const std::string &periodId);
367 inline bool isAdBreakObjectExist(
const std::string &adBrkId);
374 void PrunePeriodMaps(std::vector<std::string> &newPeriodIds);
389 void PlaceAds(dash::mpd::IMPD *mpd);
401 int CheckForAdStart(
const float &rate,
bool init,
const std::string &periodId,
double offSet, std::string &breakId,
double &adOffset);
410 bool CheckForAdTerminate(
double fragmentTime);
419 inline bool isPeriodInAdbreak(
const std::string &periodId);