[vlc-commits] stream_filter: dash: match case insensitively namespaces
Francois Cartegnie
git at videolan.org
Thu Nov 13 12:39:43 CET 2014
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Nov 12 19:55:07 2014 +0100| [3da7f14ed4ab271084d98e5f1f397029c283ec72] | committer: Francois Cartegnie
stream_filter: dash: match case insensitively namespaces
and add a missing one
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3da7f14ed4ab271084d98e5f1f397029c283ec72
---
modules/stream_filter/dash/Helper.cpp | 9 ++++++++-
modules/stream_filter/dash/Helper.h | 1 +
modules/stream_filter/dash/xml/DOMParser.cpp | 17 +++++++++++++----
3 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/modules/stream_filter/dash/Helper.cpp b/modules/stream_filter/dash/Helper.cpp
index 5236517..57815ce 100644
--- a/modules/stream_filter/dash/Helper.cpp
+++ b/modules/stream_filter/dash/Helper.cpp
@@ -26,7 +26,7 @@
#endif
#include "Helper.h"
-
+#include <algorithm>
using namespace dash;
std::string Helper::combinePaths (const std::string &path1, const std::string &path2)
@@ -48,3 +48,10 @@ std::string Helper::getDirectoryPath (const std::string &path)
return path.substr(0, pos);
}
+
+bool Helper::ifind(std::string haystack, std::string needle)
+{
+ transform(haystack.begin(), haystack.end(), haystack.begin(), toupper);
+ transform(needle.begin(), needle.end(), needle.begin(), toupper);
+ return haystack.find(needle) != std::string::npos;
+}
diff --git a/modules/stream_filter/dash/Helper.h b/modules/stream_filter/dash/Helper.h
index c4b2f9b..4d33bae 100644
--- a/modules/stream_filter/dash/Helper.h
+++ b/modules/stream_filter/dash/Helper.h
@@ -34,6 +34,7 @@ namespace dash
public:
static std::string combinePaths (const std::string &path1, const std::string &path2);
static std::string getDirectoryPath (const std::string &path);
+ static bool ifind (std::string haystack, std::string needle);
};
}
diff --git a/modules/stream_filter/dash/xml/DOMParser.cpp b/modules/stream_filter/dash/xml/DOMParser.cpp
index 9b3a4d1..c86def4 100644
--- a/modules/stream_filter/dash/xml/DOMParser.cpp
+++ b/modules/stream_filter/dash/xml/DOMParser.cpp
@@ -26,6 +26,7 @@
#endif
#include "DOMParser.h"
+#include "../Helper.h"
#include <vector>
@@ -141,16 +142,24 @@ void DOMParser::print ()
}
bool DOMParser::isDash (stream_t *stream)
{
- const char* psz_namespaceDIS = "urn:mpeg:mpegB:schema:DASH:MPD:DIS2011";
- const char* psz_namespaceIS = "urn:mpeg:DASH:schema:MPD:2011";
+ 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\"",
+ };
const uint8_t *peek;
int peek_size = stream_Peek(stream, &peek, 1024);
- if (peek_size < (int)strlen(psz_namespaceDIS))
+ if (peek_size < (int)namespaces[0].length())
return false;
std::string header((const char*)peek, peek_size);
- return (header.find(psz_namespaceDIS) != std::string::npos) || (header.find(psz_namespaceIS) != std::string::npos);
+ for( size_t i=0; i<ARRAY_SIZE(namespaces); i++ )
+ {
+ if ( Helper::ifind(header, namespaces[i]) )
+ return true;
+ }
+ return false;
}
Profile DOMParser::getProfile ()
{
More information about the vlc-commits
mailing list