]> git.sesse.net Git - vlc/blob - modules/stream_filter/dash/mpd/Group.cpp
dash: Group: Adding a getter for Representation by id.
[vlc] / modules / stream_filter / dash / mpd / Group.cpp
1 /*
2  * Group.cpp
3  *****************************************************************************
4  * Copyright (C) 2010 - 2011 Klagenfurt University
5  *
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>
9  *
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.
14  *
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.
19  *
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  *****************************************************************************/
24
25 #include "Group.h"
26
27 using namespace dash::mpd;
28 using namespace dash::exception;
29
30 Group::Group    ( const std::map<std::string, std::string>&  attributes) :
31     attributes( attributes ),
32     contentProtection( NULL ),
33     accessibility( NULL ),
34     viewpoint( NULL ),
35     rating( NULL )
36 {
37 }
38
39 Group::~Group   ()
40 {
41     for(size_t i = 1; i < this->representations.size(); i++)
42         delete(this->representations.at(i));
43
44     delete(this->contentProtection);
45     delete(this->rating);
46     delete(this->viewpoint);
47     delete(this->accessibility);
48 }
49
50 std::string                     Group::getSubSegmentAlignment   () throw(AttributeNotPresentException)
51 {
52     if(this->attributes.find("subsegmentAlignmentFlag") == this->attributes.end())
53         throw AttributeNotPresentException();
54
55     return this->attributes["subsegmentAlignmentFlag"];
56 }
57
58 Viewpoint*                      Group::getViewpoint             () throw(ElementNotPresentException)
59 {
60     if(this->viewpoint == NULL)
61         throw ElementNotPresentException();
62
63     return this->viewpoint;
64 }
65
66 Rating*                         Group::getRating                () throw(ElementNotPresentException)
67 {
68     if(this->rating == NULL)
69         throw ElementNotPresentException();
70
71     return this->rating;
72 }
73
74 Accessibility*                  Group::getAccessibility         () throw(ElementNotPresentException)
75 {
76     if(this->accessibility == NULL)
77         throw ElementNotPresentException();
78
79     return this->accessibility;
80 }
81
82 std::vector<Representation*>    Group::getRepresentations       ()
83 {
84     return this->representations;
85 }
86
87 const Representation *Group::getRepresentationById(const std::string &id) const
88 {
89     std::vector<Representation*>::const_iterator    it = this->representations.begin();
90     std::vector<Representation*>::const_iterator    end = this->representations.end();
91
92     while ( it != end )
93     {
94         if ( (*it)->getId() == id )
95             return *it;
96         ++it;
97     }
98     return NULL;
99 }
100
101 void                            Group::addRepresentation        (Representation *rep)
102 {
103     this->representations.push_back(rep);
104 }
105
106 void                            Group::setRating                (Rating *rating)
107 {
108     this->rating = rating;
109 }
110
111 void                            Group::setContentProtection     (ContentProtection *protection)
112 {
113     this->contentProtection = protection;
114 }
115
116 void                            Group::setAccessibility         (Accessibility *accessibility)
117 {
118     this->accessibility = accessibility;
119 }
120
121 void                            Group::setViewpoint             (Viewpoint *viewpoint)
122 {
123     this->viewpoint = viewpoint;
124 }