Commit d073d3be authored by François Cartegnie's avatar François Cartegnie 🤞

stream_filter: dash: log through libvlc

parent 5d7dc083
......@@ -90,6 +90,8 @@ libdash_plugin_la_SOURCES = \
stream_filter/dash/DASHDownloader.h \
stream_filter/dash/DASHManager.cpp \
stream_filter/dash/DASHManager.h \
stream_filter/dash/Logger.cpp \
stream_filter/dash/Logger.h \
stream_filter/dash/Helper.cpp \
stream_filter/dash/Helper.h
libdash_plugin_la_CXXFLAGS = $(AM_CFLAGS) -I$(srcdir)/stream_filter/dash
......
/*
* Logger.cpp
*****************************************************************************
* Copyright (C) 2014 - VideoLAN authors
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "Logger.h"
#include <iostream>
using namespace dash;
vlc_object_t * Logger::p_object = NULL;
void Logger::Debug( const std::string &msg )
{
if ( Logger::p_object )
msg_Dbg( Logger::p_object, "%s", msg.c_str() );
else
std::cout << msg << std::endl;
}
void Logger::Error( const std::string &msg )
{
if ( Logger::p_object )
msg_Err( Logger::p_object, "%s", msg.c_str() );
else
std::cerr << msg << std::endl;
}
/*
* Logger.h
*****************************************************************************
* Copyright (C) 2014 - VideoLAN authors
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef LOGGER_H
#define LOGGER_H
#include <vlc_common.h>
#include <string>
namespace dash {
class Logger
{
public:
static void Error( const std::string &msg );
static void Debug( const std::string &msg );
static void setObject( vlc_object_t *p_obj ) { Logger::p_object = p_obj; }
private:
static vlc_object_t *p_object;
};
}
#endif // LOGGER_H
......@@ -43,6 +43,7 @@
#include "http/HTTPConnectionManager.h"
#include "adaptationlogic/IAdaptationLogic.h"
#include "mpd/MPDFactory.h"
#include "Logger.h"
#define SEEK 0
......@@ -94,6 +95,7 @@ static int Control (stream_t *p_stream, int i_query, va_list args);
static int Open(vlc_object_t *p_obj)
{
stream_t *p_stream = (stream_t*) p_obj;
dash::Logger::setObject(p_obj);
if(!dash::xml::DOMParser::isDash(p_stream->p_source))
return VLC_EGENERIC;
......
......@@ -30,6 +30,7 @@
#include "mpd/SegmentInfoDefault.h"
#include "mpd/SegmentTemplate.h"
#include "mpd/SegmentTimeline.h"
#include "Logger.h"
#include <cstdlib>
#include <sstream>
......@@ -83,8 +84,8 @@ bool BasicCMParser::setMPD()
it = attr.find( "availabilityStartTime" );
if ( it == attr.end() && this->mpd->isLive() == true )
{
std::cerr << "An @availabilityStartTime attribute must be specified when"
" the stream @type is Live" << std::endl;
Logger::Error( "An @availabilityStartTime attribute must be specified when"
" the stream @type is Live" );
return false;
}
#ifdef HAVE_STRPTIME
......@@ -96,8 +97,8 @@ bool BasicCMParser::setMPD()
{
if ( this->mpd->isLive() == true )
{
std::cerr << "An @availabilityStartTime attribute must be specified when"
" the stream @type is Live" << std::endl;
Logger::Error("An @availabilityStartTime attribute must be specified when"
" the stream @type is Live");
return false;
}
}
......@@ -178,7 +179,7 @@ void BasicCMParser::parseSegmentTimeline(Node *node, SegmentInfoCommon *segmentI
sIt = sAttr.find( "t" );
if ( sIt == sAttr.end() )
{
std::cerr << "'t' attribute is mandatory for every SegmentTimeline/S element" << std::endl;
Logger::Error("'t' attribute is mandatory for every SegmentTimeline/S element");
delete s;
++it;
continue ;
......@@ -187,7 +188,7 @@ void BasicCMParser::parseSegmentTimeline(Node *node, SegmentInfoCommon *segmentI
sIt = sAttr.find( "d" );
if ( sIt == sAttr.end() )
{
std::cerr << "'d' attribute is mandatory for every SegmentTimeline/S element" << std::endl;
Logger::Error("'d' attribute is mandatory for every SegmentTimeline/S element");
delete s;
++it;
continue ;
......@@ -274,7 +275,7 @@ void BasicCMParser::parseTrickMode(Node *node, Representation *repr)
if ( trickModes.size() == 0 )
return ;
if ( trickModes.size() > 1 )
std::cerr << "More than 1 TrickMode element. Only the first one will be used." << std::endl;
Logger::Error("More than 1 TrickMode element. Only the first one will be used.");
Node* trickModeNode = trickModes[0];
TrickModeType *trickMode = new TrickModeType;
......@@ -306,14 +307,14 @@ void BasicCMParser::setRepresentations (Node *root, AdaptationSet *group)
it = attributes.find( "id" );
if ( it == attributes.end() )
std::cerr << "Missing mandatory attribute for Representation: @id" << std::endl;
Logger::Error("Missing mandatory attribute for Representation: @id");
else
rep->setId( it->second );
it = attributes.find( "bandwidth" );
if ( it == attributes.end() )
{
std::cerr << "Missing mandatory attribute for Representation: @bandwidth" << std::endl;
Logger::Error("Missing mandatory attribute for Representation: @bandwidth");
delete rep;
continue ;
}
......@@ -368,7 +369,7 @@ bool BasicCMParser::setSegmentInfo (Node *root, Representation *rep)
rep->setSegmentInfo( info );
return true;
}
std::cerr << "Missing mandatory element: Representation/SegmentInfo" << std::endl;
Logger::Error("Missing mandatory element: Representation/SegmentInfo");
return false;
}
......@@ -393,7 +394,7 @@ Segment* BasicCMParser::parseSegment( Node* node )
{
if ( this->resolveUrlTemplates( url, runtimeToken ) == false )
{
std::cerr << "Failed to substitute URLTemplate identifier." << std::endl;
Logger::Error("Failed to substitute URLTemplate identifier.");
return NULL;
}
seg = new SegmentTemplate( runtimeToken, this->currentRepresentation );
......@@ -435,8 +436,8 @@ void BasicCMParser::setInitSegment (Node *root, SegmentInfoCommon *info
const std::vector<Node *> initSeg = DOMHelper::getChildElementByTagName(root, "InitialisationSegmentURL");
if ( initSeg.size() > 1 )
std::cerr << "There could be at most one InitialisationSegmentURL per SegmentInfo"
" other InitialisationSegmentURL will be dropped." << std::endl;
Logger::Error("There could be at most one InitialisationSegmentURL per SegmentInfo"
" other InitialisationSegmentURL will be dropped.");
if ( initSeg.size() == 1 )
{
Segment *seg = parseSegment( initSeg.at(0) );
......@@ -474,7 +475,7 @@ bool BasicCMParser::resolveUrlTemplates( std::string &url, bool &containRunti
size_t closing = url.find( '$', it + 1 );
if ( closing == std::string::npos )
{
std::cerr << "Unmatched '$' in url template: " << url << std::endl;
Logger::Error(std::string("Unmatched '$' in url template: ").append(url));
return false;
}
std::string token = std::string( url, it, closing - it + 1 );
......@@ -487,8 +488,8 @@ bool BasicCMParser::resolveUrlTemplates( std::string &url, bool &containRunti
{
if ( this->currentRepresentation->getId().empty() == false )
{
std::cerr << "Representation doesn't have an ID. Can't substitute"
" identifier $RepresentationID$" << std::endl;
Logger::Error("Representation doesn't have an ID. Can't substitute"
" identifier $RepresentationID$");
return false;
}
url.replace( it, token.length(), this->currentRepresentation->getId() );
......@@ -510,7 +511,7 @@ bool BasicCMParser::resolveUrlTemplates( std::string &url, bool &containRunti
}
else
{
std::cerr << "Unhandled token " << token << std::endl;
Logger::Error(std::string("Unhandled token ").append(token));
return false;
}
}
......@@ -563,7 +564,7 @@ bool BasicCMParser::parseCommonAttributesElements( Node *node, CommonAttribut
common->setMimeType( parent->getMimeType() );
else if ( node->getName().find( "Representation" ) != std::string::npos )
{
std::cerr << "Missing mandatory attribute: @mimeType" << std::endl;
Logger::Error("Missing mandatory attribute: @mimeType");
return false;
}
}
......
......@@ -29,6 +29,7 @@
#include "Representation.h"
#include "AdaptationSet.h"
#include "SegmentInfoDefault.h"
#include "Logger.h"
#include <cassert>
#include <cstring>
......@@ -55,7 +56,7 @@ std::string SegmentTemplate::getSourceUrl() const
return Segment::getSourceUrl();
if ( this->beginIndex != std::string::npos )
std::cerr << "Unhandled identifier \"$Index$\"" << std::endl;
Logger::Error("Unhandled identifier \"$Index$\"");
if ( this->beginTime != std::string::npos )
{
//FIXME: This should use the current representation SegmentInfo
......
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