Dash: major warnings cleanup
[vlc.git] / modules / stream_filter / dash / mpd / BasicCMParser.cpp
blobab58f56062c0691e82393ac801a849b0a3d7480a
1 /*
2 * BasicCMParser.cpp
3 *****************************************************************************
4 * Copyright (C) 2010 - 2011 Klagenfurt University
6 * Created on: Aug 10, 2010
7 * Authors: Christopher Mueller <christopher.mueller@itec.uni-klu.ac.at>
8 * Christian Timmerer <christian.timmerer@itec.uni-klu.ac.at>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as published
12 * by the Free Software Foundation; either version 2.1 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
24 #ifdef HAVE_CONFIG_H
25 # include "config.h"
26 #endif
28 #include "BasicCMParser.h"
30 using namespace dash::mpd;
31 using namespace dash::xml;
33 BasicCMParser::BasicCMParser (Node *root)
35 this->root = root;
37 BasicCMParser::~BasicCMParser ()
41 bool BasicCMParser::parse ()
43 this->setMPD();
44 return true;
46 void BasicCMParser::setMPD ()
48 this->mpd = new MPD(this->root->getAttributes());
49 this->setMPDBaseUrl(this->root);
50 this->setPeriods(this->root);
52 void BasicCMParser::setMPDBaseUrl (Node *root)
54 std::vector<Node *> baseUrls = DOMHelper::getChildElementByTagName(root, "BaseURL");
56 for(size_t i = 0; i < baseUrls.size(); i++)
58 BaseUrl *url = new BaseUrl(baseUrls.at(i)->getText());
59 this->mpd->addBaseUrl(url);
62 void BasicCMParser::setPeriods (Node *root)
64 std::vector<Node *> periods = DOMHelper::getElementByTagName(root, "Period", false);
66 for(size_t i = 0; i < periods.size(); i++)
68 Period *period = new Period(periods.at(i)->getAttributes());
69 this->setGroups(periods.at(i), period);
70 this->mpd->addPeriod(period);
73 void BasicCMParser::setGroups (Node *root, Period *period)
75 std::vector<Node *> groups = DOMHelper::getElementByTagName(root, "Group", false);
77 for(size_t i = 0; i < groups.size(); i++)
79 Group *group = new Group(groups.at(i)->getAttributes());
80 this->setRepresentations(groups.at(i), group);
81 period->addGroup(group);
84 void BasicCMParser::setRepresentations (Node *root, Group *group)
86 std::vector<Node *> representations = DOMHelper::getElementByTagName(root, "Representation", false);
88 for(size_t i = 0; i < representations.size(); i++)
90 Representation *rep = new Representation(representations.at(i)->getAttributes());
91 this->setSegmentInfo(representations.at(i), rep);
92 group->addRepresentation(rep);
95 void BasicCMParser::setSegmentInfo (Node *root, Representation *rep)
97 std::vector<Node *> segmentInfo = DOMHelper::getChildElementByTagName(root, "SegmentInfo");
99 for(size_t i = 0; i < segmentInfo.size(); i++)
101 SegmentInfo *info = new SegmentInfo(segmentInfo.at(i)->getAttributes());
102 this->setInitSegment(segmentInfo.at(i), info);
103 this->setSegments(segmentInfo.at(i), info);
104 rep->setSegmentInfo(info);
105 return;
108 void BasicCMParser::setInitSegment (Node *root, SegmentInfo *info)
110 std::vector<Node *> initSeg = DOMHelper::getChildElementByTagName(root, "InitialisationSegmentURL");
112 for(size_t i = 0; i < initSeg.size(); i++)
114 InitSegment *seg = new InitSegment(initSeg.at(i)->getAttributes());
115 info->setInitSegment(seg);
116 return;
119 void BasicCMParser::setSegments (Node *root, SegmentInfo *info)
121 std::vector<Node *> segments = DOMHelper::getElementByTagName(root, "Url", false);
123 for(size_t i = 0; i < segments.size(); i++)
125 Segment *seg = new Segment(segments.at(i)->getAttributes());
126 info->addSegment(seg);
129 MPD* BasicCMParser::getMPD ()
131 return this->mpd;