Commit 58a0a847 authored by Francois Cartegnie's avatar Francois Cartegnie

demux: dash: move probing to manager

parent d63b800e
......@@ -34,6 +34,7 @@
#include "mpd/ProgramInformation.h"
#include "xml/DOMParser.h"
#include "../adaptative/logic/RateBasedAdaptationLogic.h"
#include "../adaptative/tools/Helper.h"
#include <vlc_stream.h>
#include <vlc_demux.h>
#include <vlc_meta.h>
......@@ -186,6 +187,31 @@ int DASHManager::doControl(int i_query, va_list args)
return PlaylistManager::doControl(i_query, args);
}
bool DASHManager::isDASH(stream_t *stream)
{
const std::string namespaces[] = {
"xmlns=\"urn:mpeg:mpegB:schema:DASH:MPD:DIS2011\"",
"xmlns=\"urn:mpeg:schema:dash:mpd:2011\"",
"xmlns=\"urn:mpeg:DASH:schema:MPD:2011\"",
"xmlns='urn:mpeg:mpegB:schema:DASH:MPD:DIS2011'",
"xmlns='urn:mpeg:schema:dash:mpd:2011'",
"xmlns='urn:mpeg:DASH:schema:MPD:2011'",
};
const uint8_t *peek;
int peek_size = stream_Peek(stream, &peek, 1024);
if (peek_size < (int)namespaces[0].length())
return false;
std::string header((const char*)peek, peek_size);
for( size_t i=0; i<ARRAY_SIZE(namespaces); i++ )
{
if ( adaptative::Helper::ifind(header, namespaces[i]) )
return true;
}
return false;
}
AbstractAdaptationLogic *DASHManager::createLogic(AbstractAdaptationLogic::LogicType type)
{
switch(type)
......
......@@ -50,6 +50,8 @@ namespace dash
virtual bool updatePlaylist(); //reimpl
virtual AbstractAdaptationLogic *createLogic(AbstractAdaptationLogic::LogicType); //reimpl
static bool isDASH(stream_t *);
protected:
virtual int doControl(int, va_list); /* reimpl */
};
......
......@@ -108,7 +108,7 @@ static int Open(vlc_object_t *p_obj)
free(psz_mime);
}
if(!b_mimematched && !DOMParser::isDash(p_demux->s))
if(!b_mimematched && !DASHManager::isDASH(p_demux->s))
return VLC_EGENERIC;
//Build a XML tree
......
......@@ -26,12 +26,10 @@
#endif
#include "DOMParser.h"
#include "../adaptative/tools/Helper.h"
#include <vector>
#include <stack>
#include <vlc_xml.h>
#include <vlc_stream.h>
using namespace dash::xml;
using namespace dash::mpd;
......@@ -166,30 +164,6 @@ void DOMParser::print ()
{
this->print(this->root, 0);
}
bool DOMParser::isDash (stream_t *stream)
{
const std::string namespaces[] = {
"xmlns=\"urn:mpeg:mpegB:schema:DASH:MPD:DIS2011\"",
"xmlns=\"urn:mpeg:schema:dash:mpd:2011\"",
"xmlns=\"urn:mpeg:DASH:schema:MPD:2011\"",
"xmlns='urn:mpeg:mpegB:schema:DASH:MPD:DIS2011'",
"xmlns='urn:mpeg:schema:dash:mpd:2011'",
"xmlns='urn:mpeg:DASH:schema:MPD:2011'",
};
const uint8_t *peek;
int peek_size = stream_Peek(stream, &peek, 1024);
if (peek_size < (int)namespaces[0].length())
return false;
std::string header((const char*)peek, peek_size);
for( size_t i=0; i<ARRAY_SIZE(namespaces); i++ )
{
if ( adaptative::Helper::ifind(header, namespaces[i]) )
return true;
}
return false;
}
Profile DOMParser::getProfile() const
{
......
......@@ -30,6 +30,7 @@
#endif
#include <vlc_common.h>
#include <vlc_stream.h>
#include "Node.h"
#include "../mpd/Profile.hpp"
......@@ -47,7 +48,6 @@ namespace dash
bool parse ();
Node* getRootNode ();
void print ();
static bool isDash (stream_t *stream);
mpd::Profile getProfile () const;
private:
......
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