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

dash: Adding a RepresentationAttributesElements to represent standard's §5.4.3.2

This will also save some code in a near future.
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent f73b7ff2
......@@ -26,6 +26,8 @@ SOURCES_stream_filter_dash = \
mpd/BasicCMManager.h \
mpd/BasicCMParser.cpp \
mpd/BasicCMParser.h \
mpd/CommonAttributesElements.cpp \
mpd/CommonAttributesElements.h \
mpd/ContentDescription.cpp \
mpd/ContentDescription.h \
mpd/ContentProtection.h \
......
/*****************************************************************************
* CommonAttributesElements.cpp: Defines the common attributes and elements
* for some Dash elements.
*****************************************************************************
* Copyright © 2011 VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <beauze.h@gmail.com>
*
* 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 Lesser 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.
*****************************************************************************/
#include "CommonAttributesElements.h"
using namespace dash::mpd;
using namespace dash::exception;
CommonAttributesElements::CommonAttributesElements( const std::map<std::string, std::string>& attributes ) :
attributes( attributes ),
contentProtection( NULL )
{
}
CommonAttributesElements::~CommonAttributesElements()
{
delete this->contentProtection;
}
std::string CommonAttributesElements::getWidth () const throw(AttributeNotPresentException)
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("width");
if ( it == this->attributes.end())
throw AttributeNotPresentException();
return it->second;
}
std::string CommonAttributesElements::getHeight () const throw(AttributeNotPresentException)
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("height");
if ( it == this->attributes.end() )
throw AttributeNotPresentException();
return it->second;
}
std::string CommonAttributesElements::getParX () const throw(AttributeNotPresentException)
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("parx");
if ( it == this->attributes.end())
throw AttributeNotPresentException();
return it->second;
}
std::string CommonAttributesElements::getParY () const throw(AttributeNotPresentException)
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("pary");
if ( it == this->attributes.end() )
throw AttributeNotPresentException();
return it->second;
}
std::string CommonAttributesElements::getLang () const throw(AttributeNotPresentException)
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("lang");
if ( it == this->attributes.end() )
throw AttributeNotPresentException();
return it->second;
}
std::string CommonAttributesElements::getFrameRate () const throw(AttributeNotPresentException)
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("frameRate");
if ( it == this->attributes.end())
throw AttributeNotPresentException();
return it->second;
}
std::string CommonAttributesElements::getNumberOfChannels () const throw(AttributeNotPresentException)
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("numberOfChannels");
if( it == this->attributes.end() )
throw AttributeNotPresentException();
return it->second;
}
std::string CommonAttributesElements::getSamplingRate () const throw(AttributeNotPresentException)
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("samplingRate");
if ( it == this->attributes.end() )
throw AttributeNotPresentException();
return it->second;
}
ContentProtection* CommonAttributesElements::getContentProtection () const throw(ElementNotPresentException)
{
if(this->contentProtection == NULL)
throw ElementNotPresentException();
return this->contentProtection;
}
/*****************************************************************************
* CommonAttributesElements.h: Defines the common attributes and elements
* for some Dash elements.
*****************************************************************************
* Copyright © 2011 VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <beauze.h@gmail.com>
*
* 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 Lesser 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 COMMONATTRIBUTESELEMENTS_H
#define COMMONATTRIBUTESELEMENTS_H
#include "exceptions/AttributeNotPresentException.h"
#include "exceptions/ElementNotPresentException.h"
#include <map>
#include <string>
#include "mpd/ContentProtection.h"
namespace dash
{
namespace mpd
{
class CommonAttributesElements
{
public:
CommonAttributesElements( const std::map<std::string, std::string>& attributes );
virtual ~CommonAttributesElements();
std::string getWidth () const throw(dash::exception::AttributeNotPresentException);
std::string getHeight () const throw(dash::exception::AttributeNotPresentException);
std::string getParX () const throw(dash::exception::AttributeNotPresentException);
std::string getParY () const throw(dash::exception::AttributeNotPresentException);
std::string getLang () const throw(dash::exception::AttributeNotPresentException);
std::string getFrameRate () const throw(dash::exception::AttributeNotPresentException);
std::string getNumberOfChannels () const throw(dash::exception::AttributeNotPresentException);
std::string getSamplingRate () const throw(dash::exception::AttributeNotPresentException);
ContentProtection* getContentProtection () const throw(dash::exception::ElementNotPresentException);
protected:
std::map<std::string, std::string> attributes;
ContentProtection *contentProtection;
};
}
}
#endif // COMMONATTRIBUTESELEMENTS_H
......@@ -33,38 +33,18 @@ using namespace dash::mpd;
using namespace dash::exception;
Representation::Representation (const std::map<std::string, std::string>& attributes) :
attributes( attributes ),
CommonAttributesElements( attributes ),
segmentInfo( NULL ),
trickModeType( NULL ),
contentProtection( NULL )
trickModeType( NULL )
{
}
Representation::~Representation ()
{
delete(this->segmentInfo);
delete(this->contentProtection);
delete(this->trickModeType);
}
std::string Representation::getFrameRate () const throw(AttributeNotPresentException)
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("frameRate");
if ( it == this->attributes.end())
throw AttributeNotPresentException();
return it->second;
}
std::string Representation::getSamplingRate () const throw(AttributeNotPresentException)
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("samplingRate");
if ( it == this->attributes.end() )
throw AttributeNotPresentException();
return it->second;
}
std::string Representation::getDependencyId () const throw(AttributeNotPresentException)
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("dependencyId");
......@@ -83,51 +63,7 @@ std::string Representation::getId () const throw(Attri
return it->second;
}
std::string Representation::getLang () const throw(AttributeNotPresentException)
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("lang");
if ( it == this->attributes.end() )
throw AttributeNotPresentException();
return it->second;
}
std::string Representation::getParX () const throw(AttributeNotPresentException)
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("parx");
if ( it == this->attributes.end())
throw AttributeNotPresentException();
return it->second;
}
std::string Representation::getParY () const throw(AttributeNotPresentException)
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("pary");
if ( it == this->attributes.end() )
throw AttributeNotPresentException();
return it->second;
}
std::string Representation::getHeight () const throw(AttributeNotPresentException)
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("height");
if ( it == this->attributes.end() )
throw AttributeNotPresentException();
return it->second;
}
std::string Representation::getWidth () const throw(AttributeNotPresentException)
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("width");
if ( it == this->attributes.end())
throw AttributeNotPresentException();
return it->second;
}
int Representation::getBandwidth () const
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("bandwidth");
......@@ -137,15 +73,7 @@ int Representation::getBandwidth () const
return atoi( it->second.c_str() ) / 8;
}
std::string Representation::getNumberOfChannels () const throw(AttributeNotPresentException)
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("numberOfChannels");
if( it == this->attributes.end() )
throw AttributeNotPresentException();
return it->second;
}
SegmentInfo* Representation::getSegmentInfo () const throw(ElementNotPresentException)
{
if(this->segmentInfo == NULL)
......@@ -160,13 +88,7 @@ TrickModeType* Representation::getTrickModeType () const throw(Eleme
return this->trickModeType;
}
ContentProtection* Representation::getContentProtection () const throw(ElementNotPresentException)
{
if(this->contentProtection == NULL)
throw ElementNotPresentException();
return this->contentProtection;
}
void Representation::setTrickModeType (TrickModeType *trickModeType)
{
this->trickModeType = trickModeType;
......
......@@ -26,9 +26,8 @@
#define REPRESENTATION_H_
#include <string>
#include <vector>
#include <map>
#include "mpd/CommonAttributesElements.h"
#include "mpd/SegmentInfo.h"
#include "mpd/TrickModeType.h"
#include "mpd/ContentProtection.h"
......@@ -39,18 +38,12 @@ namespace dash
{
namespace mpd
{
class Representation
class Representation : public CommonAttributesElements
{
public:
Representation ( const std::map<std::string, std::string>& attributes);
virtual ~Representation ();
std::string getWidth () const throw(dash::exception::AttributeNotPresentException);
std::string getHeight () const throw(dash::exception::AttributeNotPresentException);
std::string getParX () const throw(dash::exception::AttributeNotPresentException);
std::string getParY () const throw(dash::exception::AttributeNotPresentException);
std::string getLang () const throw(dash::exception::AttributeNotPresentException);
std::string getFrameRate () const throw(dash::exception::AttributeNotPresentException);
std::string getId () const throw(dash::exception::AttributeNotPresentException);
/*
* @return The bitrate required for this representation
......@@ -59,21 +52,16 @@ namespace dash
*/
int getBandwidth () const;
std::string getDependencyId () const throw(dash::exception::AttributeNotPresentException);
std::string getNumberOfChannels () const throw(dash::exception::AttributeNotPresentException);
std::string getSamplingRate () const throw(dash::exception::AttributeNotPresentException);
SegmentInfo* getSegmentInfo () const throw(dash::exception::ElementNotPresentException);
TrickModeType* getTrickModeType () const throw(dash::exception::ElementNotPresentException);
ContentProtection* getContentProtection () const throw(dash::exception::ElementNotPresentException);
void setSegmentInfo (SegmentInfo *info);
void setTrickModeType (TrickModeType *trickModeType);
void setContentProtection (ContentProtection *protection);
private:
std::map<std::string, std::string> attributes;
SegmentInfo *segmentInfo;
TrickModeType *trickModeType;
ContentProtection *contentProtection;
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment