Commit e16536dc authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen Committed by Jean-Baptiste Kempf

dash: Handle parsing of ContentProtection, Accessibility, Rating and Viewpoint...

dash: Handle parsing of ContentProtection, Accessibility, Rating and Viewpoint in CommonAttributesElements

All of these fields are of ContentDescription type, so
ContentProtection, Viewpoint, Rating and Accessibility classes are now
removed in favour of a unique class.
Moreover, the SchemeInformation is defined as a string by the standard.
Therefore, the SchemeInformation class has been removed.
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent 993077b7
......@@ -20,7 +20,6 @@ SOURCES_stream_filter_dash = \
http/HTTPConnectionManager.cpp \
http/HTTPConnectionManager.h \
http/IHTTPConnection.h \
mpd/Accessibility.h \
mpd/BaseUrl.h \
mpd/BasicCMManager.cpp \
mpd/BasicCMManager.h \
......@@ -30,7 +29,6 @@ SOURCES_stream_filter_dash = \
mpd/CommonAttributesElements.h \
mpd/ContentDescription.cpp \
mpd/ContentDescription.h \
mpd/ContentProtection.h \
mpd/Group.cpp \
mpd/Group.h \
mpd/IMPDManager.h \
......@@ -45,18 +43,14 @@ SOURCES_stream_filter_dash = \
mpd/Period.h \
mpd/ProgramInformation.cpp \
mpd/ProgramInformation.h \
mpd/Rating.h \
mpd/Representation.cpp \
mpd/Representation.h \
mpd/SchemeInformation.cpp \
mpd/SchemeInformation.h \
mpd/Segment.cpp \
mpd/Segment.h \
mpd/SegmentInfo.cpp \
mpd/SegmentInfo.h \
mpd/TrickModeType.cpp \
mpd/TrickModeType.h \
mpd/Viewpoint.h \
xml/DOMHelper.cpp \
xml/DOMHelper.h \
xml/DOMParser.cpp \
......
/*
* Accessibility.h
*****************************************************************************
* 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.
*****************************************************************************/
#ifndef ACCESSIBILITY_H_
#define ACCESSIBILITY_H_
#include "mpd/ContentDescription.h"
namespace dash
{
namespace mpd
{
class Accessibility : public ContentDescription
{
};
}
}
#endif /* ACCESSIBILITY_H_ */
......@@ -26,6 +26,7 @@
#endif
#include "BasicCMParser.h"
#include "mpd/ContentDescription.h"
#include <cstdlib>
#include <sstream>
......@@ -129,6 +130,7 @@ void BasicCMParser::setMPDBaseUrl (Node *root)
this->mpd->addBaseUrl(url);
}
}
void BasicCMParser::setPeriods (Node *root)
{
std::vector<Node *> periods = DOMHelper::getElementByTagName(root, "Period", false);
......@@ -322,6 +324,33 @@ MPD* BasicCMParser::getMPD()
return this->mpd;
}
void BasicCMParser::parseContentDescriptor(Node *node, const std::string &name, void (CommonAttributesElements::*addPtr)(ContentDescription *), CommonAttributesElements *self) const
{
std::vector<Node*> descriptors = DOMHelper::getChildElementByTagName( node, name );
if ( descriptors.empty() == true )
return ;
std::vector<Node*>::const_iterator it = descriptors.begin();
std::vector<Node*>::const_iterator end = descriptors.end();
while ( it != end )
{
const std::map<std::string, std::string> attr = (*it)->getAttributes();
std::map<std::string, std::string>::const_iterator itAttr = attr.find( "schemeIdUri" );
if ( itAttr == attr.end() )
{
++it;
continue ;
}
ContentDescription *desc = new ContentDescription;
desc->setSchemeIdUri( itAttr->second );
Node *schemeInfo = DOMHelper::getFirstChildElementByName( node, "SchemeInformation" );
if ( schemeInfo != NULL )
desc->setSchemeInformation( schemeInfo->getText() );
(self->*addPtr)( desc );
++it;
}
}
bool BasicCMParser::parseCommonAttributesElements( Node *node, CommonAttributesElements *common) const
{
const std::map<std::string, std::string> &attr = node->getAttributes();
......@@ -384,6 +413,16 @@ bool BasicCMParser::parseCommonAttributesElements( Node *node, CommonAttribut
common->addSampleRate( rate );
}
}
this->parseContentDescriptor( node, "ContentProtection",
&CommonAttributesElements::addContentProtection,
common );
this->parseContentDescriptor( node, "Accessibility",
&CommonAttributesElements::addAccessibility,
common );
this->parseContentDescriptor( node, "Rating",
&CommonAttributesElements::addRating, common );
this->parseContentDescriptor( node, "Viewpoint",
&CommonAttributesElements::addViewpoint, common );
//FIXME: Handle : group, maximumRAPPeriod startWithRAP attributes
//FIXME: Handle : ContentProtection Accessibility Rating Viewpoing MultipleViews elements
return true;
......
......@@ -64,6 +64,9 @@ namespace dash
void setInitSegment (dash::xml::Node *root, SegmentInfo *info);
bool setSegments (dash::xml::Node *root, SegmentInfo *info);
void setMPDBaseUrl (dash::xml::Node *root);
void parseContentDescriptor( xml::Node *node, const std::string &name,
void (CommonAttributesElements::*addPtr)(ContentDescription*),
CommonAttributesElements *self ) const;
bool parseCommonAttributesElements( dash::xml::Node *node, CommonAttributesElements *common ) const;
bool parseSegment( Segment *seg, const std::map<std::string, std::string> &attr );
ProgramInformation* parseProgramInformation();
......
......@@ -23,22 +23,28 @@
#include "CommonAttributesElements.h"
#include "mpd/ContentDescription.h"
#include <vlc_common.h>
#include <vlc_arrays.h>
using namespace dash::mpd;
using namespace dash::exception;
CommonAttributesElements::CommonAttributesElements() :
width( -1 ),
height( -1 ),
parX( 1 ),
parY( 1 ),
frameRate( -1 ),
contentProtection( NULL )
frameRate( -1 )
{
}
CommonAttributesElements::~CommonAttributesElements()
{
delete this->contentProtection;
vlc_delete_all( this->contentProtections );
vlc_delete_all( this->accessibilities );
vlc_delete_all( this->ratings );
vlc_delete_all( this->viewpoints );
}
const std::string& CommonAttributesElements::getMimeType() const
......@@ -139,10 +145,46 @@ void CommonAttributesElements::addSampleRate( int sampleRate )
this->sampleRates.push_back( sampleRate );
}
ContentProtection* CommonAttributesElements::getContentProtection () const throw(ElementNotPresentException)
const std::list<ContentDescription*> &CommonAttributesElements::getContentProtections() const
{
return this->contentProtections;
}
void CommonAttributesElements::addContentProtection(ContentDescription *desc)
{
if ( desc != NULL )
this->contentProtections.push_back( desc );
}
const std::list<ContentDescription*> &CommonAttributesElements::getAccessibilities() const
{
return this->accessibilities;
}
void CommonAttributesElements::addAccessibility(ContentDescription *desc)
{
if(this->contentProtection == NULL)
throw ElementNotPresentException();
if ( desc )
this->accessibilities.push_back( desc );
}
const std::list<ContentDescription*> &CommonAttributesElements::getRatings() const
{
return this->ratings;
}
return this->contentProtection;
void CommonAttributesElements::addRating(ContentDescription *desc)
{
if ( desc )
this->ratings.push_back( desc );
}
const std::list<ContentDescription*> &CommonAttributesElements::getViewpoints() const
{
return this->viewpoints;
}
void CommonAttributesElements::addViewpoint(ContentDescription *desc)
{
if ( desc )
this->viewpoints.push_back( desc );
}
......@@ -27,13 +27,12 @@
#include <list>
#include <string>
#include "exceptions/ElementNotPresentException.h"
#include "mpd/ContentProtection.h"
namespace dash
{
namespace mpd
{
class ContentDescription;
class CommonAttributesElements
{
public:
......@@ -57,7 +56,14 @@ namespace dash
void addChannel( const std::string &channel );
const std::list<int>& getSamplingRates() const;
void addSampleRate( int sampleRate );
ContentProtection* getContentProtection() const throw(dash::exception::ElementNotPresentException);
const std::list<ContentDescription*>& getContentProtections() const;
void addContentProtection( ContentDescription *desc );
const std::list<ContentDescription*>& getAccessibilities() const;
void addAccessibility( ContentDescription *desc );
const std::list<ContentDescription*>& getRatings() const;
void addRating( ContentDescription* desc );
const std::list<ContentDescription*>& getViewpoints() const;
void addViewpoint( ContentDescription *desc );
protected:
std::string mimeType;
......@@ -69,7 +75,10 @@ namespace dash
std::list<std::string> lang;
std::list<std::string> channels;
std::list<int> sampleRates;
ContentProtection *contentProtection;
std::list<ContentDescription*> contentProtections;
std::list<ContentDescription*> accessibilities;
std::list<ContentDescription*> ratings;
std::list<ContentDescription*> viewpoints;
};
}
}
......
......@@ -28,34 +28,25 @@
#include "ContentDescription.h"
using namespace dash::mpd;
using namespace dash::exception;
ContentDescription::ContentDescription (std::map<std::string,std::string> attributes)
void ContentDescription::setSchemeIdUri(const std::string &uri)
{
this->attributes = attributes;
this->schemeInformation = NULL;
if ( uri.empty() == false )
this->schemeIdUri = uri;
}
ContentDescription::~ContentDescription ()
const std::string& ContentDescription::getSchemeIdUri() const
{
delete(this->schemeInformation);
return this->schemeIdUri;
}
SchemeInformation* ContentDescription::getSchemeInformation () throw(ElementNotPresentException)
const std::string& ContentDescription::getSchemeInformation() const
{
if(this->schemeInformation == NULL)
throw ElementNotPresentException();
return this->schemeInformation;
}
std::string ContentDescription::getSchemeIdUri () throw(AttributeNotPresentException)
{
if(this->attributes.find("schemeIdUri") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["schmeIdUri"];
}
void ContentDescription::setSchemeInformation (SchemeInformation *schemeInfo)
void ContentDescription::setSchemeInformation( const std::string &schemeInfo )
{
this->schemeInformation = schemeInfo;
if ( schemeInfo.empty() == false )
this->schemeInformation = schemeInfo;
}
......@@ -26,11 +26,6 @@
#define CONTENTDESCRIPTION_H_
#include <string>
#include <map>
#include "mpd/SchemeInformation.h"
#include "exceptions/AttributeNotPresentException.h"
#include "exceptions/ElementNotPresentException.h"
namespace dash
{
......@@ -39,16 +34,14 @@ namespace dash
class ContentDescription
{
public:
ContentDescription (std::map<std::string, std::string> attributes);
virtual ~ContentDescription ();
std::string getSchemeIdUri () throw(dash::exception::AttributeNotPresentException);
SchemeInformation* getSchemeInformation () throw(dash::exception::ElementNotPresentException);
void setSchemeInformation (SchemeInformation *schemeInfo);
const std::string& getSchemeIdUri() const;
void setSchemeIdUri( const std::string &uri );
const std::string& getSchemeInformation() const;
void setSchemeInformation( const std::string &schemeInfo );
private:
std::map<std::string, std::string> attributes;
SchemeInformation *schemeInformation;
std::string schemeIdUri;
std::string schemeInformation;
};
}
}
......
/*
* ContentProtection.h
*****************************************************************************
* 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.
*****************************************************************************/
#ifndef CONTENTPROTECTION_H_
#define CONTENTPROTECTION_H_
#include "mpd/ContentDescription.h"
namespace dash
{
namespace mpd
{
class ContentProtection : public ContentDescription
{
};
}
}
#endif /* CONTENTPROTECTION_H_ */
......@@ -24,27 +24,20 @@
#include "Group.h"
#include <vlc_common.h>
#include <vlc_arrays.h>
using namespace dash::mpd;
using namespace dash::exception;
Group::Group ( const std::map<std::string, std::string>& attributes) :
attributes( attributes ),
contentProtection( NULL ),
accessibility( NULL ),
viewpoint( NULL ),
rating( NULL )
attributes( attributes )
{
}
Group::~Group ()
{
for(size_t i = 1; i < this->representations.size(); i++)
delete(this->representations.at(i));
delete(this->contentProtection);
delete(this->rating);
delete(this->viewpoint);
delete(this->accessibility);
vlc_delete_all( this->representations );
}
std::string Group::getSubSegmentAlignment () throw(AttributeNotPresentException)
......@@ -55,30 +48,6 @@ std::string Group::getSubSegmentAlignment () throw(Attribu
return this->attributes["subsegmentAlignmentFlag"];
}
Viewpoint* Group::getViewpoint () throw(ElementNotPresentException)
{
if(this->viewpoint == NULL)
throw ElementNotPresentException();
return this->viewpoint;
}
Rating* Group::getRating () throw(ElementNotPresentException)
{
if(this->rating == NULL)
throw ElementNotPresentException();
return this->rating;
}
Accessibility* Group::getAccessibility () throw(ElementNotPresentException)
{
if(this->accessibility == NULL)
throw ElementNotPresentException();
return this->accessibility;
}
std::vector<Representation*> Group::getRepresentations ()
{
return this->representations;
......@@ -102,23 +71,3 @@ void Group::addRepresentation (Representation
{
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;
}
......@@ -31,12 +31,7 @@
#include "mpd/Representation.h"
#include "mpd/CommonAttributesElements.h"
#include "mpd/ContentProtection.h"
#include "mpd/Accessibility.h"
#include "mpd/Viewpoint.h"
#include "mpd/Rating.h"
#include "exceptions/AttributeNotPresentException.h"
#include "exceptions/ElementNotPresentException.h"
namespace dash
{
......@@ -51,23 +46,12 @@ namespace dash
std::string getSubSegmentAlignment () throw(dash::exception::AttributeNotPresentException);
std::vector<Representation *> getRepresentations ();
const Representation* getRepresentationById ( const std::string &id ) const;
Viewpoint* getViewpoint () throw(dash::exception::ElementNotPresentException);
Accessibility* getAccessibility () throw(dash::exception::ElementNotPresentException);
Rating* getRating () throw(dash::exception::ElementNotPresentException);
void addRepresentation (Representation *rep);
void setViewpoint (Viewpoint *viewpoint);
void setContentProtection (ContentProtection *protection);
void setAccessibility (Accessibility *accessibility);
void setRating (Rating *rating);
private:
std::map<std::string, std::string> attributes;
std::vector<Representation *> representations;
ContentProtection *contentProtection;
Accessibility *accessibility;
Viewpoint *viewpoint;
Rating *rating;
};
}
}
......
/*
* Rating.h
*****************************************************************************
* 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.
*****************************************************************************/
#ifndef RATING_H_
#define RATING_H_
#include "mpd/ContentDescription.h"
namespace dash
{
namespace mpd
{
class Rating : public ContentDescription
{
};
}
}
#endif /* RATING_H_ */
......@@ -87,10 +87,7 @@ void Representation::setTrickModeType (TrickModeType *tric
{
this->trickModeType = trickModeType;
}
void Representation::setContentProtection (ContentProtection *protection)
{
this->contentProtection = protection;
}
void Representation::setSegmentInfo (SegmentInfo *info)
{
this->segmentInfo = info;
......
......@@ -30,8 +30,6 @@
#include "mpd/CommonAttributesElements.h"
#include "mpd/SegmentInfo.h"
#include "mpd/TrickModeType.h"
#include "mpd/ContentProtection.h"
#include "exceptions/AttributeNotPresentException.h"
#include "exceptions/ElementNotPresentException.h"
namespace dash
......@@ -62,7 +60,6 @@ namespace dash
void setSegmentInfo (SegmentInfo *info);
void setTrickModeType (TrickModeType *trickModeType);
void setContentProtection (ContentProtection *protection);
private:
int bandwidth;
......
/*
* SchemeInformation.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
#include "SchemeInformation.h"
using namespace dash::mpd;
SchemeInformation::SchemeInformation ()
{
}
SchemeInformation::~SchemeInformation ()
{
}
/*
* SchemeInformation.h
*****************************************************************************
* 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.
*****************************************************************************/
#ifndef SCHEMEINFORMATION_H_
#define SCHEMEINFORMATION_H_
namespace dash
{
namespace mpd
{
class SchemeInformation
{
public:
SchemeInformation ();
virtual ~SchemeInformation ();
};
}
}
#endif /* SCHEMEINFORMATION_H_ */
/*
* Viewpoint.h
*****************************************************************************
* 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.
*****************************************************************************/
#ifndef VIEWPOINT_H_
#define VIEWPOINT_H_
#include "mpd/ContentDescription.h"
namespace dash
{
namespace mpd
{
class Viewpoint : public ContentDescription
{
};
}
}