Representation.cpp 3.24 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
    CommonAttributesElements( attributes ),
37
    segmentInfo( NULL ),
38
    trickModeType( NULL )
39 40
{
}
41

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

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

54
    return it->second;
55 56

}
57
std::string         Representation::getId                   () const throw(AttributeNotPresentException)
58
{
59 60
    std::map<std::string, std::string>::const_iterator  it = this->attributes.find("id");
    if ( it == this->attributes.end())
61 62
        throw AttributeNotPresentException();

63
    return it->second;
64 65 66

}

67
int     Representation::getBandwidth            () const
68
{
69 70
    std::map<std::string, std::string>::const_iterator  it = this->attributes.find("bandwidth");
    if ( it == this->attributes.end())
71
        return -1;
72

73
    return atoi( it->second.c_str() ) / 8;
74 75 76

}

77
SegmentInfo*        Representation::getSegmentInfo          () const throw(ElementNotPresentException)
78 79 80 81 82 83
{
    if(this->segmentInfo == NULL)
        throw ElementNotPresentException();

    return this->segmentInfo;
}
84
TrickModeType*      Representation::getTrickModeType        () const throw(ElementNotPresentException)
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
{
    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;
}