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: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent 0b396ef1
...@@ -23,13 +23,15 @@ ...@@ -23,13 +23,15 @@
#include "CommonAttributesElements.h" #include "CommonAttributesElements.h"
#include <cstdlib>
using namespace dash::mpd; using namespace dash::mpd;
using namespace dash::exception; using namespace dash::exception;
CommonAttributesElements::CommonAttributesElements( const std::map<std::string, std::string>& attributes ) : CommonAttributesElements::CommonAttributesElements() :
attributes( attributes ), width( -1 ),
height( -1 ),
parX( 1 ),
parY( 1 ),
frameRate( -1 ),
contentProtection( NULL ) contentProtection( NULL )
{ {
} }
...@@ -39,83 +41,102 @@ CommonAttributesElements::~CommonAttributesElements() ...@@ -39,83 +41,102 @@ CommonAttributesElements::~CommonAttributesElements()
delete this->contentProtection; 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"); return this->mimeType;
if ( it == this->attributes.end()) }
return -1;
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 ( width > 0 )
if ( it == this->attributes.end() ) this->width = width;
return -1; }
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 int CommonAttributesElements::getParX () const
{ {
std::map<std::string, std::string>::const_iterator it = this->attributes.find("parx"); return this->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() );
void CommonAttributesElements::setParX( int parX )
{
if ( parX > 0 )
this->parX = parX;
} }
int CommonAttributesElements::getParY () const int CommonAttributesElements::getParY () const
{ {
std::map<std::string, std::string>::const_iterator it = this->attributes.find("pary"); return this->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() );
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"); return this->lang;
if ( it == this->attributes.end() ) }
throw AttributeNotPresentException();
return it->second; void CommonAttributesElements::addLang( const std::string &lang )
{
if ( lang.empty() == false )
this->lang.push_back( lang );
} }
int CommonAttributesElements::getFrameRate () const int CommonAttributesElements::getFrameRate () const
{ {
std::map<std::string, std::string>::const_iterator it = this->attributes.find("frameRate"); return this->frameRate;
if ( it == this->attributes.end())
return -1;
return atoi( it->second.c_str() );
} }
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 ( frameRate > 0 )
if( it == this->attributes.end() ) this->frameRate = frameRate;
throw AttributeNotPresentException(); }
return it->second;
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 ( channel.empty() == false )
if ( it == this->attributes.end() ) this->channels.push_back( channel );
throw AttributeNotPresentException(); }
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) ContentProtection* CommonAttributesElements::getContentProtection () const throw(ElementNotPresentException)
......
...@@ -24,12 +24,10 @@ ...@@ -24,12 +24,10 @@
#ifndef COMMONATTRIBUTESELEMENTS_H #ifndef COMMONATTRIBUTESELEMENTS_H
#define COMMONATTRIBUTESELEMENTS_H #define COMMONATTRIBUTESELEMENTS_H
#include "exceptions/AttributeNotPresentException.h" #include <list>
#include "exceptions/ElementNotPresentException.h"
#include <map>
#include <string> #include <string>
#include "exceptions/ElementNotPresentException.h"
#include "mpd/ContentProtection.h" #include "mpd/ContentProtection.h"
namespace dash namespace dash
...@@ -39,20 +37,38 @@ namespace dash ...@@ -39,20 +37,38 @@ namespace dash
class CommonAttributesElements class CommonAttributesElements
{ {
public: public:
CommonAttributesElements( const std::map<std::string, std::string>& attributes ); CommonAttributesElements();
virtual ~CommonAttributesElements(); virtual ~CommonAttributesElements();
int getWidth () const; const std::string& getMimeType() const;
int getHeight () const; void setMimeType( const std::string &mimeType );
int getParX () const; int getWidth() const;
int getParY () const; void setWidth( int width );
std::string getLang () const throw(dash::exception::AttributeNotPresentException); int getHeight() const;
int getFrameRate () const; void setHeight( int height );
std::string getNumberOfChannels () const throw(dash::exception::AttributeNotPresentException); int getParX() const;
std::string getSamplingRate () const throw(dash::exception::AttributeNotPresentException); void setParX( int parX );
ContentProtection* getContentProtection () const throw(dash::exception::ElementNotPresentException); 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: 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; ContentProtection *contentProtection;
}; };
} }
......
...@@ -33,7 +33,7 @@ using namespace dash::mpd; ...@@ -33,7 +33,7 @@ using namespace dash::mpd;
using namespace dash::exception; using namespace dash::exception;
Representation::Representation (const std::map<std::string, std::string>& attributes) : Representation::Representation (const std::map<std::string, std::string>& attributes) :
CommonAttributesElements( attributes ), attributes( attributes ),
segmentInfo( NULL ), segmentInfo( NULL ),
trickModeType( NULL ) trickModeType( NULL )
{ {
......
...@@ -60,6 +60,7 @@ namespace dash ...@@ -60,6 +60,7 @@ namespace dash
void setContentProtection (ContentProtection *protection); void setContentProtection (ContentProtection *protection);
private: private:
std::map<std::string, std::string> attributes;
SegmentInfo *segmentInfo; SegmentInfo *segmentInfo;
TrickModeType *trickModeType; 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