Commit 3da7f14e authored by François Cartegnie's avatar François Cartegnie 🤞
Browse files

stream_filter: dash: match case insensitively namespaces

and add a missing one
parent fcef78e3
......@@ -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;
}
......@@ -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);
};
}
......
......@@ -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 ()
{
......
Supports Markdown
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