3 *****************************************************************************
4 * Copyright (C) 2010 - 2012 Klagenfurt University
6 * Created on: Jan 27, 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 *****************************************************************************/
29 #include "IsoffMainManager.h"
31 using namespace dash::mpd;
33 IsoffMainManager::IsoffMainManager (MPD *mpd)
37 IsoffMainManager::~IsoffMainManager ()
42 std::vector<Segment*> IsoffMainManager::getSegments (const Representation *rep)
44 std::vector<Segment *> retSegments;
45 SegmentList* list= rep->getSegmentList();
46 Segment* initSegment = rep->getSegmentBase()->getInitSegment();
49 retSegments.push_back(initSegment);
51 retSegments.insert(retSegments.end(), list->getSegments().begin(), list->getSegments().end());
54 const std::vector<Period*>& IsoffMainManager::getPeriods () const
56 return this->mpd->getPeriods();
58 Representation* IsoffMainManager::getBestRepresentation (Period *period)
60 std::vector<AdaptationSet *> adaptationSets = period->getAdaptationSets();
63 Representation *best = NULL;
65 for(size_t i = 0; i < adaptationSets.size(); i++)
67 std::vector<Representation *> reps = adaptationSets.at(i)->getRepresentations();
68 for(size_t j = 0; j < reps.size(); j++)
70 int currentBitrate = reps.at(j)->getBandwidth();
72 if(currentBitrate > bitrate)
74 bitrate = currentBitrate;
81 Period* IsoffMainManager::getFirstPeriod ()
83 std::vector<Period *> periods = this->mpd->getPeriods();
85 if(periods.size() == 0)
90 Representation* IsoffMainManager::getRepresentation (Period *period, int bitrate )
92 std::vector<AdaptationSet *> adaptationSets = period->getAdaptationSets();
94 Representation *best = NULL;
95 std::cout << "Searching for best representation with bitrate: " << bitrate << std::endl;
97 for(size_t i = 0; i < adaptationSets.size(); i++)
99 std::vector<Representation *> reps = adaptationSets.at(i)->getRepresentations();
100 for( size_t j = 0; j < reps.size(); j++ )
102 int currentBitrate = reps.at(j)->getBandwidth();
104 if(best == NULL || (currentBitrate > best->getBandwidth() && currentBitrate < bitrate))
106 std::cout << "Found a better Representation bandwidth=" << reps.at(j)->getBandwidth() << " in adaptationSet #" << i << std::endl;
113 Period* IsoffMainManager::getNextPeriod (Period *period)
115 std::vector<Period *> periods = this->mpd->getPeriods();
117 for(size_t i = 0; i < periods.size(); i++)
119 if(periods.at(i) == period && (i + 1) < periods.size())
120 return periods.at(i + 1);
125 const MPD* IsoffMainManager::getMPD () const