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

adaptative: merge both modules

parent 58a0a847
......@@ -22,6 +22,7 @@ $Id$
* access_output_udp: UDP Network access_output module
* access_realrtsp: Real RTSP access
* access_wasapi: WASAPI audio input
* adaptative: Unified adaptative streaming module (DASH/HLS)
* addonsfsstorage: Local storage extensions repository
* addonsvorepository: Videolan extensions repository
* adjust: Contrast/Hue/saturation/Brightness adjust module
......@@ -85,7 +86,6 @@ $Id$
* d3d11_surface: Convert D3D11 GPU textures to YUV planes
* d3d11va: Direct3D11 hardware-accelerated decoding
* daala: a daala video decoder/packetizer using libdaala
* dash: MPEG DASH playback
* dbus: D-Bus control interface
* dbus_screensaver: preventing the computer from suspending
* dc1394: IIDC (DCAM) FireWire input module
......@@ -174,7 +174,6 @@ $Id$
* hevc: HEVC demuxer
* hotkeys: hotkeys control module
* hqdn3d: High Quality denoising filter
* hls: HTTP Live Streaming demuxer
* http: HTTP Network access module
* httplive: HTTP Live streaming for playback
* i420_rgb: planar YUV to packed RGB conversion functions
......
......@@ -244,7 +244,7 @@ if HAVE_DVBPSI
demux_LTLIBRARIES += libts_plugin.la
endif
adaptative_SOURCES = \
libadaptative_plugin_la_SOURCES = \
demux/adaptative/playlist/AbstractPlaylist.cpp \
demux/adaptative/playlist/AbstractPlaylist.hpp \
demux/adaptative/playlist/BaseAdaptationSet.cpp \
......@@ -311,7 +311,7 @@ adaptative_SOURCES = \
demux/adaptative/tools/Retrieve.cpp \
demux/adaptative/tools/Retrieve.hpp
libdash_plugin_la_SOURCES = \
libadaptative_dash_SOURCES = \
demux/dash/mpd/AdaptationSet.cpp \
demux/dash/mpd/AdaptationSet.h \
demux/dash/mpd/DASHCommonAttributesElements.cpp \
......@@ -344,22 +344,11 @@ libdash_plugin_la_SOURCES = \
demux/dash/xml/DOMParser.h \
demux/dash/xml/Node.cpp \
demux/dash/xml/Node.h \
demux/dash/dash.cpp \
demux/dash/DASHManager.cpp \
demux/dash/DASHManager.h \
demux/dash/DASHStreamFormat.hpp
libdash_plugin_la_SOURCES += $(adaptative_SOURCES)
libdash_plugin_la_SOURCES += demux/mp4/libmp4.c demux/mp4/libmp4.h
libdash_plugin_la_CXXFLAGS = $(AM_CFLAGS) -I$(srcdir)/demux/dash
libdash_plugin_la_LIBADD = $(SOCKET_LIBS) $(LIBM)
if HAVE_ZLIB
libdash_plugin_la_LIBADD += -lz
endif
demux_LTLIBRARIES += libdash_plugin.la
libhls_plugin_la_SOURCES = \
libadaptative_hls_SOURCES = \
demux/hls/playlist/M3U8.hpp \
demux/hls/playlist/M3U8.cpp \
demux/hls/playlist/Parser.hpp \
......@@ -374,21 +363,22 @@ libhls_plugin_la_SOURCES = \
demux/hls/HLSManager.cpp \
demux/hls/HLSStreamFormat.hpp \
demux/hls/HLSStreams.hpp \
demux/hls/HLSStreams.cpp \
demux/hls/hls.cpp
libhls_plugin_la_SOURCES += $(adaptative_SOURCES)
libhls_plugin_la_CXXFLAGS = $(AM_CFLAGS) -I$(srcdir)/demux/hls
libhls_plugin_la_LIBADD = $(SOCKET_LIBS) $(LIBM)
demux/hls/HLSStreams.cpp
libadaptative_plugin_la_SOURCES += $(libadaptative_hls_SOURCES)
libadaptative_plugin_la_SOURCES += $(libadaptative_dash_SOURCES)
libadaptative_plugin_la_SOURCES += demux/adaptative/adaptative.cpp
libadaptative_plugin_la_SOURCES += demux/mp4/libmp4.c demux/mp4/libmp4.h
libadaptative_plugin_la_CXXFLAGS = $(AM_CFLAGS) -I$(srcdir)/demux/adaptative
libadaptative_plugin_la_LIBADD = $(SOCKET_LIBS) $(LIBM)
if HAVE_ZLIB
libhls_plugin_la_LIBADD += -lz
libadaptative_plugin_la_LIBADD += -lz
endif
if HAVE_GCRYPT
libhls_plugin_la_CXXFLAGS += $(GCRYPT_CFLAGS)
libhls_plugin_la_LIBADD += $(GCRYPT_LIBS)
libadaptative_plugin_la_CXXFLAGS += $(GCRYPT_CFLAGS)
libadaptative_plugin_la_LIBADD += $(GCRYPT_LIBS)
endif
demux_LTLIBRARIES += libhls_plugin.la
demux_LTLIBRARIES += libadaptative_plugin.la
libttml_plugin_la_SOURCES = demux/ttml.c
demux_LTLIBRARIES += libttml_plugin.la
......
/*****************************************************************************
* hls.cpp: HTTP Live Streaming module
* adaptative.cpp: Adaptative streaming module
*****************************************************************************
* Copyright © 2015 - VideoLAN and VLC Authors
*
......@@ -32,16 +32,23 @@
#include <vlc_plugin.h>
#include <vlc_demux.h>
#include "../adaptative/logic/AbstractAdaptationLogic.h"
#include "HLSManager.hpp"
#include "HLSStreams.hpp"
#include "playlist/BasePeriod.h"
#include "../dash/xml/DOMParser.h"
#include "../dash/mpd/MPDFactory.h"
#include "../dash/DASHManager.h"
#include "../hls/HLSManager.hpp"
#include "../hls/HLSStreams.hpp"
#include "../hls/playlist/Parser.hpp"
#include "../hls/playlist/M3U8.hpp"
#include "playlist/Parser.hpp"
#include "playlist/M3U8.hpp"
using namespace adaptative;
using namespace adaptative::logic;
using namespace adaptative::playlist;
using namespace dash::mpd;
using namespace dash::xml;
using namespace dash;
using namespace hls;
using namespace hls::playlist;
......@@ -51,16 +58,14 @@ using namespace hls::playlist;
static int Open (vlc_object_t *);
static void Close (vlc_object_t *);
#define HLS_WIDTH_TEXT N_("Preferred Width")
#define HLS_WIDTH_LONGTEXT N_("Preferred Width")
#define ADAPT_WIDTH_TEXT N_("Preferred Width")
#define HLS_HEIGHT_TEXT N_("Preferred Height")
#define HLS_HEIGHT_LONGTEXT N_("Preferred Height")
#define ADAPT_HEIGHT_TEXT N_("Preferred Height")
#define HLS_BW_TEXT N_("Fixed Bandwidth in KiB/s")
#define HLS_BW_LONGTEXT N_("Preferred bandwidth for non adaptative streams")
#define ADAPT_BW_TEXT N_("Fixed Bandwidth in KiB/s")
#define ADAPT_BW_LONGTEXT N_("Preferred bandwidth for non adaptative streams")
#define HLS_LOGIC_TEXT N_("Adaptation Logic")
#define ADAPT_LOGIC_TEXT N_("Adaptation Logic")
static const int pi_logics[] = {AbstractAdaptationLogic::RateBased,
AbstractAdaptationLogic::FixedRate,
......@@ -73,17 +78,17 @@ static const char *const ppsz_logics[] = { N_("Bandwidth Adaptive"),
N_("Highest Bandwith/Quality")};
vlc_module_begin ()
set_shortname( N_("hls"))
set_description( N_("HTTP Live Streaming") )
set_shortname( N_("Adaptative"))
set_description( N_("Unified adaptative streaming for DASH/HLS") )
set_capability( "demux", 12 )
set_category( CAT_INPUT )
set_subcategory( SUBCAT_INPUT_DEMUX )
add_integer( "hls-logic", AbstractAdaptationLogic::Default,
HLS_LOGIC_TEXT, NULL, false )
add_integer( "adaptative-logic", AbstractAdaptationLogic::Default,
ADAPT_LOGIC_TEXT, NULL, false )
change_integer_list( pi_logics, ppsz_logics )
add_integer( "hls-prefwidth", 480, HLS_WIDTH_TEXT, HLS_WIDTH_LONGTEXT, true )
add_integer( "hls-prefheight", 360, HLS_HEIGHT_TEXT, HLS_HEIGHT_LONGTEXT, true )
add_integer( "hls-prefbw", 250, HLS_BW_TEXT, HLS_BW_LONGTEXT, false )
add_integer( "adaptative-width", 480, ADAPT_WIDTH_TEXT, ADAPT_WIDTH_TEXT, true )
add_integer( "adaptative-height", 360, ADAPT_HEIGHT_TEXT, ADAPT_HEIGHT_TEXT, true )
add_integer( "adaptative-bw", 250, ADAPT_BW_TEXT, ADAPT_BW_LONGTEXT, false )
set_callbacks( Open, Close )
vlc_module_end ()
......@@ -98,23 +103,56 @@ static int Open(vlc_object_t *p_obj)
{
demux_t *p_demux = (demux_t*) p_obj;
if(!HLSManager::isHTTPLiveStreaming(p_demux->s))
return VLC_EGENERIC;
Parser parser(p_demux->s);
M3U8 *p_playlist = parser.parse(std::string());
if(!p_playlist)
return VLC_EGENERIC;
bool b_mimematched = false;
char *psz_mime = stream_ContentType(p_demux->s);
if(psz_mime)
{
b_mimematched = !strcmp(psz_mime, "application/dash+xml");
free(psz_mime);
}
int logic = var_InheritInteger(p_obj, "hls-logic");
PlaylistManager *p_manager = NULL;
int logic = var_InheritInteger(p_obj, "adaptative-logic");
HLSManager *p_manager =
new (std::nothrow) HLSManager(p_demux, p_playlist,
new (std::nothrow) HLSStreamOutputFactory,
static_cast<AbstractAdaptationLogic::LogicType>(logic));
if(b_mimematched || DASHManager::isDASH(p_demux->s))
{
//Build a XML tree
DOMParser parser(p_demux->s);
if( !parser.parse() )
{
msg_Err( p_demux, "Could not parse MPD" );
return VLC_EGENERIC;
}
//Begin the actual MPD parsing:
MPD *p_playlist = MPDFactory::create(parser.getRootNode(), p_demux->s, parser.getProfile());
if(p_playlist == NULL)
{
msg_Err( p_demux, "Cannot create/unknown MPD for profile");
return VLC_EGENERIC;
}
p_manager = new DASHManager( p_demux, p_playlist,
new (std::nothrow) DASHStreamOutputFactory,
static_cast<AbstractAdaptationLogic::LogicType>(logic) );
}
else if(HLSManager::isHTTPLiveStreaming(p_demux->s))
{
Parser parser(p_demux->s);
M3U8 *p_playlist = parser.parse(std::string());
if(!p_playlist)
{
msg_Err( p_demux, "Could not parse MPD" );
return VLC_EGENERIC;
}
p_manager =
new (std::nothrow) HLSManager(p_demux, p_playlist,
new (std::nothrow) HLSStreamOutputFactory,
static_cast<AbstractAdaptationLogic::LogicType>(logic));
}
BasePeriod *period = p_playlist->getFirstPeriod();
if(period && !p_manager->start())
if(!p_manager->start())
{
delete p_manager;
return VLC_EGENERIC;
......@@ -124,7 +162,7 @@ static int Open(vlc_object_t *p_obj)
p_demux->pf_demux = p_manager->demux_callback;
p_demux->pf_control = p_manager->control_callback;
msg_Dbg(p_obj,"opening mpd file (%s)", p_demux->s->psz_path);
msg_Dbg(p_obj,"opening playlist file (%s)", p_demux->s->psz_path);
return VLC_SUCCESS;
}
......
......@@ -218,14 +218,14 @@ AbstractAdaptationLogic *DASHManager::createLogic(AbstractAdaptationLogic::Logic
{
case AbstractAdaptationLogic::FixedRate:
{
size_t bps = var_InheritInteger(p_demux, "dash-prefbw") * 8192;
size_t bps = var_InheritInteger(p_demux, "adaptative-bw") * 8192;
return new (std::nothrow) FixedRateAdaptationLogic(bps);
}
case AbstractAdaptationLogic::Default:
case AbstractAdaptationLogic::RateBased:
{
int width = var_InheritInteger(p_demux, "dash-prefwidth");
int height = var_InheritInteger(p_demux, "dash-prefheight");
int width = var_InheritInteger(p_demux, "adaptative-width");
int height = var_InheritInteger(p_demux, "adaptative-height");
return new (std::nothrow) RateBasedAdaptationLogic(width, height);
}
default:
......
/*****************************************************************************
* dash.cpp: DASH module
*****************************************************************************
* Copyright © 2010 - 2011 Klagenfurt University
*
* Created on: Aug 10, 2010
* Authors: Christopher Mueller <christopher.mueller@itec.uni-klu.ac.at>
* Christian Timmerer <christian.timmerer@itec.uni-klu.ac.at>
*
* 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.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdint.h>
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_demux.h>
#include "xml/DOMParser.h"
#include "mpd/MPDFactory.h"
#include "mpd/Period.h"
#include "DASHManager.h"
using namespace adaptative::logic;
using namespace adaptative::playlist;
using namespace dash::mpd;
using namespace dash::xml;
using namespace dash;
/*****************************************************************************
* Module descriptor
*****************************************************************************/
static int Open (vlc_object_t *);
static void Close (vlc_object_t *);
#define DASH_WIDTH_TEXT N_("Preferred Width")
#define DASH_WIDTH_LONGTEXT N_("Preferred Width")
#define DASH_HEIGHT_TEXT N_("Preferred Height")
#define DASH_HEIGHT_LONGTEXT N_("Preferred Height")
#define DASH_BW_TEXT N_("Fixed Bandwidth in KiB/s")
#define DASH_BW_LONGTEXT N_("Preferred bandwidth for non adaptative streams")
#define DASH_LOGIC_TEXT N_("Adaptation Logic")
static const int pi_logics[] = {AbstractAdaptationLogic::RateBased,
AbstractAdaptationLogic::FixedRate,
AbstractAdaptationLogic::AlwaysLowest,
AbstractAdaptationLogic::AlwaysBest};
static const char *const ppsz_logics[] = { N_("Bandwidth Adaptive"),
N_("Fixed Bandwidth"),
N_("Lowest Bandwidth/Quality"),
N_("Highest Bandwith/Quality")};
vlc_module_begin ()
set_shortname( N_("DASH"))
set_description( N_("Dynamic Adaptive Streaming over HTTP") )
set_capability( "demux", 10 )
set_category( CAT_INPUT )
set_subcategory( SUBCAT_INPUT_DEMUX )
add_integer( "dash-logic", dash::logic::AbstractAdaptationLogic::Default,
DASH_LOGIC_TEXT, NULL, false )
change_integer_list( pi_logics, ppsz_logics )
add_integer( "dash-prefwidth", 480, DASH_WIDTH_TEXT, DASH_WIDTH_LONGTEXT, true )
add_integer( "dash-prefheight", 360, DASH_HEIGHT_TEXT, DASH_HEIGHT_LONGTEXT, true )
add_integer( "dash-prefbw", 250, DASH_BW_TEXT, DASH_BW_LONGTEXT, false )
set_callbacks( Open, Close )
vlc_module_end ()
/*****************************************************************************
* Local prototypes
*****************************************************************************/
/*****************************************************************************
* Open:
*****************************************************************************/
static int Open(vlc_object_t *p_obj)
{
demux_t *p_demux = (demux_t*) p_obj;
bool b_mimematched = false;
char *psz_mime = stream_ContentType(p_demux->s);
if(psz_mime)
{
b_mimematched = !strcmp(psz_mime, "application/dash+xml");
free(psz_mime);
}
if(!b_mimematched && !DASHManager::isDASH(p_demux->s))
return VLC_EGENERIC;
//Build a XML tree
DOMParser parser(p_demux->s);
if( !parser.parse() )
{
msg_Err( p_demux, "Could not parse MPD" );
return VLC_EGENERIC;
}
//Begin the actual MPD parsing:
MPD *mpd = MPDFactory::create(parser.getRootNode(), p_demux->s, parser.getProfile());
if(mpd == NULL)
{
msg_Err( p_demux, "Cannot create/unknown MPD for profile");
return VLC_EGENERIC;
}
int logic = var_InheritInteger( p_obj, "dash-logic" );
DASHManager *p_dashManager = new (std::nothrow) DASHManager(p_demux, mpd,
new (std::nothrow) DASHStreamOutputFactory,
static_cast<AbstractAdaptationLogic::LogicType>(logic));
BasePeriod *period = mpd->getFirstPeriod();
if(period && !p_dashManager->start())
{
delete p_dashManager;
return VLC_EGENERIC;
}
p_demux->p_sys = reinterpret_cast<demux_sys_t *>(p_dashManager);
p_demux->pf_demux = p_dashManager->demux_callback;
p_demux->pf_control = p_dashManager->control_callback;
msg_Dbg(p_obj,"opening mpd file (%s)", p_demux->s->psz_path);
return VLC_SUCCESS;
}
/*****************************************************************************
* Close:
*****************************************************************************/
static void Close(vlc_object_t *p_obj)
{
demux_t *p_demux = (demux_t*) p_obj;
PlaylistManager *p_manager = reinterpret_cast<PlaylistManager *>(p_demux->p_sys);
delete p_manager;
}
......@@ -108,14 +108,14 @@ AbstractAdaptationLogic *HLSManager::createLogic(AbstractAdaptationLogic::LogicT
{
case AbstractAdaptationLogic::FixedRate:
{
size_t bps = var_InheritInteger(p_demux, "hls-prefbw") * 8192;
size_t bps = var_InheritInteger(p_demux, "adaptative-bw") * 8192;
return new (std::nothrow) FixedRateAdaptationLogic(bps);
}
case AbstractAdaptationLogic::Default:
case AbstractAdaptationLogic::RateBased:
{
int width = var_InheritInteger(p_demux, "hls-prefwidth");
int height = var_InheritInteger(p_demux, "hls-prefheight");
int width = var_InheritInteger(p_demux, "adaptative-width");
int height = var_InheritInteger(p_demux, "adaptative-height");
return new (std::nothrow) RateBasedAdaptationLogic(width, height);
}
default:
......
......@@ -22,8 +22,8 @@
#endif
#include "Parser.hpp"
#include "playlist/HLSSegment.hpp"
#include "playlist/Representation.hpp"
#include "HLSSegment.hpp"
#include "Representation.hpp"
#include "../adaptative/playlist/BasePeriod.h"
#include "../adaptative/playlist/BaseAdaptationSet.h"
#include "../adaptative/playlist/SegmentList.h"
......
......@@ -447,6 +447,7 @@ modules/control/ntservice.c
modules/control/oldrc.c
modules/control/unimotion.c
modules/control/unimotion.h
modules/demux/adaptative/adaptative.cpp
modules/demux/aiff.c
modules/demux/asf/asf.c
modules/demux/asf/libasf.c
......@@ -461,12 +462,10 @@ modules/demux/avi/libavi.c
modules/demux/avi/libavi.h
modules/demux/caf.c
modules/demux/cdg.c
modules/demux/dash/dash.cpp
modules/demux/demuxdump.c
modules/demux/dirac.c
modules/demux/flac.c
modules/demux/gme.c
modules/demux/hls/hls.cpp
modules/demux/image.c
modules/demux/mjpeg.c
modules/demux/mkv/chapter_command.cpp
......
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