using namespace dash::http;
using namespace dash::mpd;
-DOMParser::DOMParser (stream_t *stream)
+DOMParser::DOMParser (stream_t *stream) :
+ root( NULL ),
+ stream( stream ),
+ vlc_xml( NULL ),
+ vlc_reader( NULL )
{
- this->stream = stream;
- this->init();
}
+
DOMParser::~DOMParser ()
{
if(this->vlc_reader)
xml_ReaderDelete(this->vlc_reader);
+ if ( this->vlc_xml )
+ xml_Delete( this->vlc_xml );
}
Node* DOMParser::getRootNode ()
Node *subnode = NULL;
- while(subnode = this->processNode())
+ while((subnode = this->processNode()) != NULL)
node->addSubNode(subnode);
return node;
this->print(node->getSubNodes().at(i), offset);
}
}
-void DOMParser::init ()
-{
- this->root = NULL;
- this->vlc_reader = NULL;
-}
+
void DOMParser::print ()
{
this->print(this->root, 0);
return dash::mpd::NotValid;
}
-bool DOMParser::isDash ()
+bool DOMParser::isDash (stream_t *stream)
{
- const uint8_t *peek, *peek_end;
+ const uint8_t *peek;
- int64_t i_size = stream_Peek(this->stream, &peek, 2048);
- if(i_size < 1)
+ const char* psz_namespace = "urn:mpeg:mpegB:schema:DASH:MPD:DIS2011";
+ if(stream_Peek(stream, &peek, 1024) < (int)strlen(psz_namespace))
return false;
- peek_end = peek + i_size;
- while(peek <= peek_end)
- {
- const char *p = strstr((const char*)peek, "urn:mpeg:mpegB:schema:DASH:MPD:DIS2011");
- if (p != NULL)
- return true;
- peek++;
- };
+ const char *p = strstr((const char*)peek, psz_namespace );
- return false;
+ return p != NULL;
}