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 *****************************************************************************/
28 #include "BasicCMManager.h"
32 using namespace dash::mpd;
34 BasicCMManager::BasicCMManager (MPD *mpd)
38 BasicCMManager::~BasicCMManager ()
43 std::vector<Segment*> BasicCMManager::getSegments( const Representation *rep )
45 std::vector<Segment *> retSegments;
46 SegmentInfo* info = rep->getSegmentInfo();
47 Segment* initSegment = info->getInitialisationSegment();
50 retSegments.push_back( initSegment );
51 retSegments.insert( retSegments.end(), info->getSegments().begin(),
52 info->getSegments().end() );
55 const std::vector<Period*>& BasicCMManager::getPeriods () const
57 return this->mpd->getPeriods();
60 Representation* BasicCMManager::getBestRepresentation (Period *period)
62 std::vector<Group *> groups = period->getGroups();
65 Representation *best = NULL;
67 for(size_t i = 0; i < groups.size(); i++)
69 std::vector<Representation *> reps = groups.at(i)->getRepresentations();
70 for(size_t j = 0; j < reps.size(); j++)
72 int currentBitrate = reps.at(j)->getBandwidth();
73 assert( currentBitrate != -1 );
75 if( currentBitrate > bitrate)
77 bitrate = currentBitrate;
84 Period* BasicCMManager::getFirstPeriod ()
86 std::vector<Period *> periods = this->mpd->getPeriods();
88 if(periods.size() == 0)
94 Representation* BasicCMManager::getRepresentation(Period *period, int bitrate ) const
96 std::vector<Group *> groups = period->getGroups();
98 Representation *best = NULL;
99 std::cout << "Sarching for best representation with bitrate: " << bitrate << std::endl;
101 for(size_t i = 0; i < groups.size(); i++)
103 std::vector<Representation *> reps = groups.at(i)->getRepresentations();
104 for( size_t j = 0; j < reps.size(); j++ )
106 int currentBitrate = reps.at(j)->getBandwidth();
107 assert( currentBitrate != -1 );
110 ( currentBitrate > best->getBandwidth() &&
111 currentBitrate < bitrate ) )
113 std::cout << "Found a better Representation (#" << j << ") in group #" << i << std::endl;
120 Period* BasicCMManager::getNextPeriod (Period *period)
122 std::vector<Period *> periods = this->mpd->getPeriods();
124 for(size_t i = 0; i < periods.size(); i++)
126 if(periods.at(i) == period && (i + 1) < periods.size())
127 return periods.at(i + 1);
133 const MPD* BasicCMManager::getMPD() const
137 Representation* BasicCMManager::getRepresentation (Period *period, int bitrate, int width, int height) const
139 return this->getRepresentation(period, bitrate);