]> git.sesse.net Git - vlc/blobdiff - modules/stream_filter/dash/mpd/Group.cpp
dash: Reworking segments.
[vlc] / modules / stream_filter / dash / mpd / Group.cpp
index 1807f048508ba94f6cf6b9dc5952f0cbb87b433b..0eebada5ddf2e1dd1a9e5e38fa410c07ec6c0418 100644 (file)
 using namespace dash::mpd;
 using namespace dash::exception;
 
-Group::Group    (std::map<std::string, std::string>  attributes)
+Group::Group    ( const std::map<std::string, std::string>&  attributes) :
+    attributes( attributes ),
+    contentProtection( NULL ),
+    accessibility( NULL ),
+    viewpoint( NULL ),
+    rating( NULL )
 {
-    this->attributes        = attributes;
-    this->contentProtection = NULL;
-    this->accessibility     = NULL;
-    this->viewpoint         = NULL;
-    this->rating            = NULL;
 }
+
 Group::~Group   ()
 {
-    for(int i = 0; i < this->representations.size(); i++)
+    for(size_t i = 1; i < this->representations.size(); i++)
         delete(this->representations.at(i));
 
     delete(this->contentProtection);
@@ -46,55 +47,6 @@ Group::~Group   ()
     delete(this->accessibility);
 }
 
-std::string                     Group::getWidth                 () throw(AttributeNotPresentException)
-{
-    if(this->attributes.find("width") == this->attributes.end())
-        throw AttributeNotPresentException();
-
-    return this->attributes["width"];
-}
-std::string                     Group::getNumberOfChannels      () throw(AttributeNotPresentException)
-{
-    if(this->attributes.find("numberOfChannels") == this->attributes.end())
-        throw AttributeNotPresentException();
-
-    return this->attributes["numberOfChannels"];
-}
-std::string                     Group::getLang                  () throw(AttributeNotPresentException)
-{
-    if(this->attributes.find("lang") == this->attributes.end())
-        throw AttributeNotPresentException();
-
-    return this->attributes["lang"];
-}
-std::string                     Group::getParY                  () throw(AttributeNotPresentException)
-{
-    if(this->attributes.find("pary") == this->attributes.end())
-        throw AttributeNotPresentException();
-
-    return this->attributes["pary"];
-}
-std::string                     Group::getParX                  () throw(AttributeNotPresentException)
-{
-    if(this->attributes.find("parx") == this->attributes.end())
-        throw AttributeNotPresentException();
-
-    return this->attributes["parx"];
-}
-std::string                     Group::getSamplingRate          () throw(AttributeNotPresentException)
-{
-    if(this->attributes.find("samplingRate") == this->attributes.end())
-        throw AttributeNotPresentException();
-
-    return this->attributes["samplingRate"];
-}
-std::string                     Group::getMimeType              () throw(AttributeNotPresentException)
-{
-    if(this->attributes.find("mimeType") == this->attributes.end())
-        throw AttributeNotPresentException();
-
-    return this->attributes["mimeType"];
-}
 std::string                     Group::getSubSegmentAlignment   () throw(AttributeNotPresentException)
 {
     if(this->attributes.find("subsegmentAlignmentFlag") == this->attributes.end())
@@ -102,20 +54,7 @@ std::string                     Group::getSubSegmentAlignment   () throw(Attribu
 
     return this->attributes["subsegmentAlignmentFlag"];
 }
-std::string                     Group::getFrameRate             () throw(AttributeNotPresentException)
-{
-    if(this->attributes.find("frameRate") == this->attributes.end())
-        throw AttributeNotPresentException();
 
-    return this->attributes["frameRate"];
-}
-std::string                     Group::getHeight                () throw(AttributeNotPresentException)
-{
-    if(this->attributes.find("height") == this->attributes.end())
-        throw AttributeNotPresentException();
-
-    return this->attributes["height"];
-}
 Viewpoint*                      Group::getViewpoint             () throw(ElementNotPresentException)
 {
     if(this->viewpoint == NULL)
@@ -123,6 +62,7 @@ Viewpoint*                      Group::getViewpoint             () throw(Element
 
     return this->viewpoint;
 }
+
 Rating*                         Group::getRating                () throw(ElementNotPresentException)
 {
     if(this->rating == NULL)
@@ -130,6 +70,7 @@ Rating*                         Group::getRating                () throw(Element
 
     return this->rating;
 }
+
 Accessibility*                  Group::getAccessibility         () throw(ElementNotPresentException)
 {
     if(this->accessibility == NULL)
@@ -137,33 +78,46 @@ Accessibility*                  Group::getAccessibility         () throw(Element
 
     return this->accessibility;
 }
-ContentProtection*              Group::getContentProtection     () throw(ElementNotPresentException)
-{
-    if(this->contentProtection == NULL)
-        throw ElementNotPresentException();
 
-    return this->contentProtection;
-}
 std::vector<Representation*>    Group::getRepresentations       ()
 {
     return this->representations;
 }
+
+const Representation *Group::getRepresentationById(const std::string &id) const
+{
+    std::vector<Representation*>::const_iterator    it = this->representations.begin();
+    std::vector<Representation*>::const_iterator    end = this->representations.end();
+
+    while ( it != end )
+    {
+        if ( (*it)->getId() == id )
+            return *it;
+        ++it;
+    }
+    return NULL;
+}
+
 void                            Group::addRepresentation        (Representation *rep)
 {
     this->representations.push_back(rep);
 }
+
 void                            Group::setRating                (Rating *rating)
 {
     this->rating = rating;
 }
+
 void                            Group::setContentProtection     (ContentProtection *protection)
 {
     this->contentProtection = protection;
 }
+
 void                            Group::setAccessibility         (Accessibility *accessibility)
 {
     this->accessibility = accessibility;
 }
+
 void                            Group::setViewpoint             (Viewpoint *viewpoint)
 {
     this->viewpoint = viewpoint;