Representation.cpp 3.32 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
/*
 * Representation.cpp
 *****************************************************************************
 * Copyright (C) 2010 - 2011 Klagenfurt University
 *
 * Created on: Aug 10, 2010
 * Authors: Christopher Mueller <christopher.mueller@itec.uni-klu.ac.at>
 *          Christian Timmerer  <christian.timmerer@itec.uni-klu.ac.at>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

28 29
#include <cstdlib>

30 31 32 33 34
#include "Representation.h"

using namespace dash::mpd;
using namespace dash::exception;

35
Representation::Representation  (const std::map<std::string, std::string>&  attributes) :
36
    qualityRanking( -1 ),
37
    attributes( attributes ),
38
    segmentInfo( NULL ),
39
    trickModeType( NULL )
40 41
{
}
42

43 44 45 46 47 48
Representation::~Representation ()
{
    delete(this->segmentInfo);
    delete(this->trickModeType);
}

49
std::string         Representation::getDependencyId         () const throw(AttributeNotPresentException)
50
{
51 52
    std::map<std::string, std::string>::const_iterator  it = this->attributes.find("dependencyId");
    if ( it == this->attributes.end() )
53 54
        throw AttributeNotPresentException();

55
    return it->second;
56 57
}

58 59 60 61
const std::string&  Representation::getId                   () const
{
    return this->id;
}
62

63 64 65 66
void    Representation::setId(const std::string &id)
{
    if ( id.empty() == false )
        this->id = id;
67 68
}

69
int     Representation::getBandwidth            () const
70
{
71 72
    return this->bandwidth;
}
73

74 75 76 77
void    Representation::setBandwidth( int bandwidth )
{
    if ( bandwidth >= 0 )
        this->bandwidth = bandwidth;
78 79
}

80
SegmentInfo*        Representation::getSegmentInfo          () const throw(ElementNotPresentException)
81 82 83 84 85 86
{
    if(this->segmentInfo == NULL)
        throw ElementNotPresentException();

    return this->segmentInfo;
}
87
TrickModeType*      Representation::getTrickModeType        () const throw(ElementNotPresentException)
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
{
    if(this->segmentInfo == NULL)
        throw ElementNotPresentException();

    return this->trickModeType;
}

void                Representation::setTrickModeType        (TrickModeType *trickModeType)
{
    this->trickModeType = trickModeType;
}
void                Representation::setContentProtection    (ContentProtection *protection)
{
    this->contentProtection = protection;
}
void                Representation::setSegmentInfo          (SegmentInfo *info)
{
    this->segmentInfo = info;
}
107 108 109 110 111 112 113 114 115 116 117 118


int Representation::getQualityRanking() const
{
    return this->qualityRanking;
}

void Representation::setQualityRanking( int qualityRanking )
{
    if ( qualityRanking > 0 )
        this->qualityRanking = qualityRanking;
}