Commit 37540a61 authored by Francois Cartegnie's avatar Francois Cartegnie

stream_filter: dash: fix and add missing profiles

parent 3da7f14e
......@@ -43,6 +43,7 @@ libdash_plugin_la_SOURCES = \
stream_filter/dash/mpd/ContentDescription.cpp \
stream_filter/dash/mpd/ContentDescription.h \
stream_filter/dash/mpd/IMPDManager.h \
stream_filter/dash/mpd/IMPDManager.cpp \
stream_filter/dash/mpd/IMPDParser.h \
stream_filter/dash/mpd/IsoffMainParser.cpp \
stream_filter/dash/mpd/IsoffMainParser.h \
......
/*
* IMPDManager.cpp
*****************************************************************************
* Copyright (C) 2014 - VideoLAN Authors
*
* 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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "IMPDManager.h"
using namespace dash::mpd;
Profile::Name Profile::getNameByURN(std::string urn)
{
struct
{
const Name name;
const char * urn;
}
urnmap[] =
{
{ Full, "urn:mpeg:dash:profile:full:2011" },
{ ISOOnDemand, "urn:mpeg:dash:profile:isoff-on-demand:2011" },
{ ISOOnDemand, "urn:mpeg:mpegB:profile:dash:isoff-basic-on-demand:cm" },
{ ISOOnDemand, "urn:mpeg:dash:profile:isoff-ondemand:2011" },
{ ISOMain, "urn:mpeg:dash:profile:isoff-main:2011" },
{ ISOLive, "urn:mpeg:dash:profile:isoff-live:2011" },
{ MPEG2TSMain, "urn:mpeg:dash:profile:mp2t-main:2011" },
{ MPEG2TSSimple,"urn:mpeg:dash:profile:mp2t-simple:2011" },
{ Unknown, "" },
};
for( int i=0; urnmap[i].name != Unknown; i++ )
{
if ( urn == urnmap[i].urn )
return urnmap[i].name;
}
return Unknown;
}
......@@ -34,14 +34,22 @@ namespace dash
{
class MPD;
enum Profile
class Profile
{
UnknownProfile,
Full2011,
Basic,
BasicCM,
IsoffMain
public:
enum Name
{
Unknown,
Full,
ISOOnDemand,
ISOMain,
ISOLive,
MPEG2TSMain,
MPEG2TSSimple,
};
static Name getNameByURN( std::string urn );
};
class IMPDManager
{
public:
......
......@@ -30,7 +30,7 @@
using namespace dash::mpd;
MPD::MPD () :
profile( dash::mpd::UnknownProfile ),
profile( dash::mpd::Profile::Unknown ),
live( false ),
availabilityStartTime( -1 ),
availabilityEndTime( -1 ),
......@@ -158,12 +158,12 @@ void MPD::setAvailabilityEndTime(time_t time)
this->availabilityEndTime = time;
}
Profile MPD::getProfile() const
Profile::Name MPD::getProfile() const
{
return this->profile;
}
void MPD::setProfile(Profile profile)
void MPD::setProfile(Profile::Name profile)
{
this->profile = profile;
}
......@@ -44,8 +44,8 @@ namespace dash
MPD();
virtual ~MPD();
Profile getProfile() const;
void setProfile( Profile profile );
Profile::Name getProfile() const;
void setProfile( Profile::Name profile );
bool isLive() const;
void setLive( bool live );
time_t getAvailabilityStartTime() const;
......@@ -69,7 +69,7 @@ namespace dash
void setProgramInformation (ProgramInformation *progInfo);
private:
Profile profile;
Profile::Name profile;
bool live;
time_t availabilityStartTime;
time_t availabilityEndTime;
......
......@@ -31,14 +31,15 @@
using namespace dash::xml;
using namespace dash::mpd;
MPD* MPDFactory::create (dash::xml::Node *root, stream_t *p_stream, Profile profile)
MPD* MPDFactory::create (dash::xml::Node *root, stream_t *p_stream, Profile::Name profile)
{
switch(profile)
{
case dash::mpd::Full2011:
case dash::mpd::Basic:
case dash::mpd::BasicCM: return MPDFactory::createBasicCMMPD(root, p_stream);
case dash::mpd::IsoffMain: return MPDFactory::createIsoffMainMPD(root, p_stream);
case dash::mpd::Profile::Full:
case dash::mpd::Profile::ISOOnDemand:
return MPDFactory::createBasicCMMPD(root, p_stream);
case dash::mpd::Profile::ISOMain:
return MPDFactory::createIsoffMainMPD(root, p_stream);
default: return NULL;
}
......@@ -49,7 +50,7 @@ MPD* MPDFactory::createBasicCMMPD (dash::xml::Node *root, stream_t *p_stream)
if(mpdParser.parse() == false || mpdParser.getMPD() == NULL)
return NULL;
mpdParser.getMPD()->setProfile( dash::mpd::BasicCM );
mpdParser.getMPD()->setProfile( dash::mpd::Profile::ISOOnDemand );
return mpdParser.getMPD();
}
MPD* MPDFactory::createIsoffMainMPD (dash::xml::Node *root, stream_t *p_stream)
......@@ -58,6 +59,6 @@ MPD* MPDFactory::createIsoffMainMPD (dash::xml::Node *root, stream_t *p_stream)
if(mpdParser.parse() == false || mpdParser.getMPD() == NULL)
return NULL;
mpdParser.getMPD()->setProfile( dash::mpd::IsoffMain );
mpdParser.getMPD()->setProfile( dash::mpd::Profile::ISOMain );
return mpdParser.getMPD();
}
......@@ -36,7 +36,7 @@ namespace dash
class MPDFactory
{
public:
static MPD* create(dash::xml::Node *root, stream_t *p_stream, Profile profile);
static MPD* create(dash::xml::Node *root, stream_t *p_stream, Profile::Name profile);
private:
static MPD* createBasicCMMPD (dash::xml::Node *root, stream_t *p_stream);
......
......@@ -33,11 +33,11 @@ IMPDManager* MPDManagerFactory::create( MPD *mpd )
{
switch( mpd->getProfile() )
{
case mpd::BasicCM:
case mpd::Full2011: return new BasicCMManager (mpd);
case mpd::IsoffMain: return new IsoffMainManager (mpd);
case mpd::Basic:
case mpd::UnknownProfile:
case mpd::Profile::ISOOnDemand:
case mpd::Profile::Full:
return new BasicCMManager (mpd);
case mpd::Profile::ISOMain:
return new IsoffMainManager (mpd);
default:
return NULL;
}
......
......@@ -161,22 +161,14 @@ bool DOMParser::isDash (stream_t *stream)
}
return false;
}
Profile DOMParser::getProfile ()
Profile::Name DOMParser::getProfile ()
{
if(this->root == NULL)
return dash::mpd::UnknownProfile;
return dash::mpd::Profile::Unknown;
std::string profile = this->root->getAttributeValue("profiles");
if ( profile.length() == 0 )
profile = this->root->getAttributeValue("profile"); //The standard spells it the both ways...
if(profile.find("urn:mpeg:mpegB:profile:dash:isoff-basic-on-demand:cm") != std::string::npos ||
profile.find("urn:mpeg:dash:profile:isoff-ondemand:2011") != std::string::npos ||
profile.find("urn:mpeg:dash:profile:isoff-on-demand:2011") != std::string::npos)
return dash::mpd::BasicCM;
if(profile.find("urn:mpeg:dash:profile:isoff-main:2011") != std::string::npos)
return dash::mpd::IsoffMain;
return dash::mpd::UnknownProfile;
return dash::mpd::Profile::getNameByURN(profile);
}
......@@ -46,7 +46,7 @@ namespace dash
Node* getRootNode ();
void print ();
static bool isDash (stream_t *stream);
mpd::Profile getProfile ();
mpd::Profile::Name getProfile ();
private:
Node *root;
......
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