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

dash: CommonAttributesElements: Reworking getters/setters.

This will allow the parser to interact with all elements sharing these
attibutes/subelements.
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 0b396ef1
......@@ -23,13 +23,15 @@
#include "CommonAttributesElements.h"
#include <cstdlib>
using namespace dash::mpd;
using namespace dash::exception;
CommonAttributesElements::CommonAttributesElements( const std::map<std::string, std::string>& attributes ) :
attributes( attributes ),
CommonAttributesElements::CommonAttributesElements() :
width( -1 ),
height( -1 ),
parX( 1 ),
parY( 1 ),
frameRate( -1 ),
contentProtection( NULL )
{
}
......@@ -39,83 +41,102 @@ CommonAttributesElements::~CommonAttributesElements()
delete this->contentProtection;
}
int CommonAttributesElements::getWidth () const
const std::string& CommonAttributesElements::getMimeType() const
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("width");
if ( it == this->attributes.end())
return -1;
return this->mimeType;
}
return atoi( it->second.c_str() );
void CommonAttributesElements::setMimeType( const std::string &mimeType )
{
this->mimeType = mimeType;
}
int CommonAttributesElements::getWidth () const
{
return this->width;
}
int CommonAttributesElements::getHeight () const
void CommonAttributesElements::setWidth( int width )
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("height");
if ( it == this->attributes.end() )
return -1;
if ( width > 0 )
this->width = width;
}
return atoi( it->second.c_str() );
int CommonAttributesElements::getHeight () const
{
return this->height;
}
void CommonAttributesElements::setHeight( int height )
{
if ( height > 0 )
this->height = height;
}
int CommonAttributesElements::getParX () const
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("parx");
if ( it == this->attributes.end() )
return 1; //Default value is defined in standard's §5.4.3.2.2
return atoi( it->second.c_str() );
return this->parX;
}
void CommonAttributesElements::setParX( int parX )
{
if ( parX > 0 )
this->parX = parX;
}
int CommonAttributesElements::getParY () const
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("pary");
if ( it == this->attributes.end() )
return 1; //Default value is defined in standard's §5.4.3.2.2
return atoi( it->second.c_str() );
return this->parY;
}
void CommonAttributesElements::setParY( int parY )
{
if ( parY > 0 )
this->setParY( parY );
}
std::string CommonAttributesElements::getLang () const throw(AttributeNotPresentException)
const std::list<std::string>& CommonAttributesElements::getLang() const
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("lang");
if ( it == this->attributes.end() )
throw AttributeNotPresentException();
return this->lang;
}
return it->second;
void CommonAttributesElements::addLang( const std::string &lang )
{
if ( lang.empty() == false )
this->lang.push_back( lang );
}
int CommonAttributesElements::getFrameRate () const
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("frameRate");
if ( it == this->attributes.end())
return -1;
return atoi( it->second.c_str() );
return this->frameRate;
}
std::string CommonAttributesElements::getNumberOfChannels () const throw(AttributeNotPresentException)
void CommonAttributesElements::setFrameRate( int frameRate )
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("numberOfChannels");
if( it == this->attributes.end() )
throw AttributeNotPresentException();
return it->second;
if ( frameRate > 0 )
this->frameRate = frameRate;
}
const std::list<std::string>& CommonAttributesElements::getNumberOfChannels() const
{
return this->channels;
}
std::string CommonAttributesElements::getSamplingRate () const throw(AttributeNotPresentException)
void CommonAttributesElements::addChannel( const std::string &channel )
{
std::map<std::string, std::string>::const_iterator it = this->attributes.find("samplingRate");
if ( it == this->attributes.end() )
throw AttributeNotPresentException();
if ( channel.empty() == false )
this->channels.push_back( channel );
}
return it->second;
const std::list<int>& CommonAttributesElements::getSamplingRates() const
{
return this->sampleRates;
}
void CommonAttributesElements::addSampleRate( int sampleRate )
{
if ( sampleRate > 0 )
this->sampleRates.push_back( sampleRate );
}
ContentProtection* CommonAttributesElements::getContentProtection () const throw(ElementNotPresentException)
......
......@@ -24,12 +24,10 @@
#ifndef COMMONATTRIBUTESELEMENTS_H
#define COMMONATTRIBUTESELEMENTS_H
#include "exceptions/AttributeNotPresentException.h"
#include "exceptions/ElementNotPresentException.h"
#include <map>
#include <list>
#include <string>
#include "exceptions/ElementNotPresentException.h"
#include "mpd/ContentProtection.h"
namespace dash
......@@ -39,20 +37,38 @@ namespace dash
class CommonAttributesElements
{
public:
CommonAttributesElements( const std::map<std::string, std::string>& attributes );
CommonAttributesElements();
virtual ~CommonAttributesElements();
int getWidth () const;
int getHeight () const;
int getParX () const;
int getParY () const;
std::string getLang () const throw(dash::exception::AttributeNotPresentException);
int getFrameRate () const;
std::string getNumberOfChannels () const throw(dash::exception::AttributeNotPresentException);
std::string getSamplingRate () const throw(dash::exception::AttributeNotPresentException);
ContentProtection* getContentProtection () const throw(dash::exception::ElementNotPresentException);
const std::string& getMimeType() const;
void setMimeType( const std::string &mimeType );
int getWidth() const;
void setWidth( int width );
int getHeight() const;
void setHeight( int height );
int getParX() const;
void setParX( int parX );
int getParY() const;
void setParY( int parY );
int getFrameRate() const;
void setFrameRate( int frameRate );
const std::list<std::string>& getLang() const;
void addLang( const std::string &lang );
const std::list<std::string>& getNumberOfChannels() const;
void addChannel( const std::string &channel );
const std::list<int>& getSamplingRates() const;
void addSampleRate( int sampleRate );
ContentProtection* getContentProtection() const throw(dash::exception::ElementNotPresentException);
protected:
std::map<std::string, std::string> attributes;
std::string mimeType;
int width;
int height;
int parX;
int parY;
int frameRate;
std::list<std::string> lang;
std::list<std::string> channels;
std::list<int> sampleRates;
ContentProtection *contentProtection;
};
}
......
......@@ -33,7 +33,7 @@ using namespace dash::mpd;
using namespace dash::exception;
Representation::Representation (const std::map<std::string, std::string>& attributes) :
CommonAttributesElements( attributes ),
attributes( attributes ),
segmentInfo( NULL ),
trickModeType( NULL )
{
......
......@@ -60,6 +60,7 @@ namespace dash
void setContentProtection (ContentProtection *protection);
private:
std::map<std::string, std::string> attributes;
SegmentInfo *segmentInfo;
TrickModeType *trickModeType;
......
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