Representation.cpp 5.97 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 36 37 38 39
Representation::Representation  (const std::map<std::string, std::string>&  attributes) :
    attributes( attributes ),
    segmentInfo( NULL ),
    trickModeType( NULL ),
    contentProtection( NULL )
40 41
{
}
42

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

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

56
    return it->second;
57 58

}
59
std::string         Representation::getSamplingRate         () const throw(AttributeNotPresentException)
60
{
61 62
    std::map<std::string, std::string>::const_iterator  it = this->attributes.find("samplingRate");
    if ( it == this->attributes.end() )
63 64
        throw AttributeNotPresentException();

65
    return it->second;
66 67

}
68
std::string         Representation::getDependencyId         () const throw(AttributeNotPresentException)
69
{
70 71
    std::map<std::string, std::string>::const_iterator  it = this->attributes.find("dependencyId");
    if ( it == this->attributes.end() )
72 73
        throw AttributeNotPresentException();

74
    return it->second;
75 76

}
77
std::string         Representation::getId                   () const throw(AttributeNotPresentException)
78
{
79 80
    std::map<std::string, std::string>::const_iterator  it = this->attributes.find("id");
    if ( it == this->attributes.end())
81 82
        throw AttributeNotPresentException();

83
    return it->second;
84 85

}
86
std::string         Representation::getLang                 () const throw(AttributeNotPresentException)
87
{
88 89
    std::map<std::string, std::string>::const_iterator  it = this->attributes.find("lang");
    if ( it == this->attributes.end() )
90 91
        throw AttributeNotPresentException();

92
    return it->second;
93 94

}
95
std::string         Representation::getParX                 () const throw(AttributeNotPresentException)
96
{
97 98
    std::map<std::string, std::string>::const_iterator  it = this->attributes.find("parx");
    if ( it == this->attributes.end())
99 100
        throw AttributeNotPresentException();

101
    return it->second;
102 103

}
104
std::string         Representation::getParY                 () const throw(AttributeNotPresentException)
105
{
106 107
    std::map<std::string, std::string>::const_iterator  it = this->attributes.find("pary");
    if ( it == this->attributes.end() )
108 109
        throw AttributeNotPresentException();

110
    return it->second;
111 112

}
113
std::string         Representation::getHeight               () const throw(AttributeNotPresentException)
114
{
115 116
    std::map<std::string, std::string>::const_iterator  it = this->attributes.find("height");
    if ( it == this->attributes.end() )
117 118
        throw AttributeNotPresentException();

119
    return it->second;
120 121

}
122
std::string         Representation::getWidth                () const throw(AttributeNotPresentException)
123
{
124 125
    std::map<std::string, std::string>::const_iterator  it = this->attributes.find("width");
    if ( it == this->attributes.end())
126 127
        throw AttributeNotPresentException();

128
    return it->second;
129 130

}
131
int     Representation::getBandwidth            () const
132
{
133 134
    std::map<std::string, std::string>::const_iterator  it = this->attributes.find("bandwidth");
    if ( it == this->attributes.end())
135
        return -1;
136

137
    return atoi( it->second.c_str() ) / 8;
138 139

}
140
std::string         Representation::getNumberOfChannels     () const throw(AttributeNotPresentException)
141
{
142 143
    std::map<std::string, std::string>::const_iterator  it = this->attributes.find("numberOfChannels");
    if( it == this->attributes.end() )
144 145
        throw AttributeNotPresentException();

146
    return it->second;
147 148

}
149
SegmentInfo*        Representation::getSegmentInfo          () const throw(ElementNotPresentException)
150 151 152 153 154 155
{
    if(this->segmentInfo == NULL)
        throw ElementNotPresentException();

    return this->segmentInfo;
}
156
TrickModeType*      Representation::getTrickModeType        () const throw(ElementNotPresentException)
157 158 159 160 161 162
{
    if(this->segmentInfo == NULL)
        throw ElementNotPresentException();

    return this->trickModeType;
}
163
ContentProtection*  Representation::getContentProtection    () const throw(ElementNotPresentException)
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
{
    if(this->contentProtection == NULL)
        throw ElementNotPresentException();

    return this->contentProtection;
}
void                Representation::setTrickModeType        (TrickModeType *trickModeType)
{
    this->trickModeType = trickModeType;
}
void                Representation::setContentProtection    (ContentProtection *protection)
{
    this->contentProtection = protection;
}
void                Representation::setSegmentInfo          (SegmentInfo *info)
{
    this->segmentInfo = info;
}