vlc | branch: master | Francois Cartegnie <[email protected]> | Thu Jul 23 17:19:16 2015 +0200| [58a0a84700327e66ee4669109a3189f960272d0d] | committer: Francois Cartegnie
demux: dash: move probing to manager > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=58a0a84700327e66ee4669109a3189f960272d0d --- modules/demux/dash/DASHManager.cpp | 26 ++++++++++++++++++++++++++ modules/demux/dash/DASHManager.h | 2 ++ modules/demux/dash/dash.cpp | 2 +- modules/demux/dash/xml/DOMParser.cpp | 26 -------------------------- modules/demux/dash/xml/DOMParser.h | 2 +- 5 files changed, 30 insertions(+), 28 deletions(-) diff --git a/modules/demux/dash/DASHManager.cpp b/modules/demux/dash/DASHManager.cpp index 723e48c..0552879 100644 --- a/modules/demux/dash/DASHManager.cpp +++ b/modules/demux/dash/DASHManager.cpp @@ -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) diff --git a/modules/demux/dash/DASHManager.h b/modules/demux/dash/DASHManager.h index b061124..f5927bb 100644 --- a/modules/demux/dash/DASHManager.h +++ b/modules/demux/dash/DASHManager.h @@ -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 */ }; diff --git a/modules/demux/dash/dash.cpp b/modules/demux/dash/dash.cpp index 2daef0f..67e5f23 100644 --- a/modules/demux/dash/dash.cpp +++ b/modules/demux/dash/dash.cpp @@ -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 diff --git a/modules/demux/dash/xml/DOMParser.cpp b/modules/demux/dash/xml/DOMParser.cpp index 8d8cc32..1fdf924 100644 --- a/modules/demux/dash/xml/DOMParser.cpp +++ b/modules/demux/dash/xml/DOMParser.cpp @@ -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 { diff --git a/modules/demux/dash/xml/DOMParser.h b/modules/demux/dash/xml/DOMParser.h index c50e7be..5331d43 100644 --- a/modules/demux/dash/xml/DOMParser.h +++ b/modules/demux/dash/xml/DOMParser.h @@ -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: _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
