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

demux: adaptive: differentiate demux object and stream

parent 78c24aca
......@@ -135,7 +135,7 @@ static int Open(vlc_object_t *p_obj)
if(!dashmime && !smoothmime && HLSManager::isHTTPLiveStreaming(p_demux->s))
{
M3U8Parser parser;
M3U8 *p_playlist = parser.parse(p_demux->s, playlisturl);
M3U8 *p_playlist = parser.parse(VLC_OBJECT(p_demux),p_demux->s, playlisturl);
if(!p_playlist)
{
msg_Err( p_demux, "Could not parse playlist" );
......@@ -222,7 +222,8 @@ static PlaylistManager * HandleDash(demux_t *p_demux, DOMParser &xmlParser,
msg_Err(p_demux, "Cannot parse MPD");
return NULL;
}
IsoffMainParser mpdparser(xmlParser.getRootNode(), p_demux->s, playlisturl);
IsoffMainParser mpdparser(xmlParser.getRootNode(), VLC_OBJECT(p_demux),
p_demux->s, playlisturl);
MPD *p_playlist = mpdparser.parse();
if(p_playlist == NULL)
{
......@@ -244,7 +245,8 @@ static PlaylistManager * HandleSmooth(demux_t *p_demux, DOMParser &xmlParser,
msg_Err(p_demux, "Cannot parse Manifest");
return NULL;
}
ManifestParser mparser(xmlParser.getRootNode(), p_demux->s, playlisturl);
ManifestParser mparser(xmlParser.getRootNode(), VLC_OBJECT(p_demux),
p_demux->s, playlisturl);
Manifest *p_playlist = mparser.parse();
if(p_playlist == NULL)
{
......
......@@ -31,9 +31,9 @@
using namespace adaptive::playlist;
AbstractPlaylist::AbstractPlaylist (stream_t *stream_) :
AbstractPlaylist::AbstractPlaylist (vlc_object_t *p_object_) :
ICanonicalUrl(),
stream(stream_)
p_object(p_object_)
{
playbackStart.Set(0);
availabilityStartTime.Set( 0 );
......@@ -91,7 +91,7 @@ Url AbstractPlaylist::getUrlSegment() const
vlc_object_t * AbstractPlaylist::getVLCObject() const
{
return VLC_OBJECT(stream);
return p_object;
}
BasePeriod* AbstractPlaylist::getFirstPeriod()
......
......@@ -37,7 +37,7 @@ namespace adaptive
class AbstractPlaylist : public ICanonicalUrl
{
public:
AbstractPlaylist(stream_t *);
AbstractPlaylist(vlc_object_t *);
virtual ~AbstractPlaylist();
virtual bool isLive() const = 0;
......@@ -68,7 +68,7 @@ namespace adaptive
Property<mtime_t> timeShiftBufferDepth;
protected:
stream_t *stream;
vlc_object_t *p_object;
std::vector<BasePeriod *> periods;
std::vector<std::string> baseUrls;
std::string playlistUrl;
......
......@@ -102,11 +102,11 @@ bool DASHManager::updatePlaylist()
url.append("://");
url.append(p_demux->psz_location);
block_t *p_block = Retrieve::HTTP(VLC_OBJECT(p_demux->s), url);
block_t *p_block = Retrieve::HTTP(VLC_OBJECT(p_demux), url);
if(!p_block)
return false;
stream_t *mpdstream = stream_MemoryNew(p_demux->s, p_block->p_buffer, p_block->i_buffer, true);
stream_t *mpdstream = stream_MemoryNew(p_demux, p_block->p_buffer, p_block->i_buffer, true);
if(!mpdstream)
{
block_Release(p_block);
......@@ -130,8 +130,8 @@ bool DASHManager::updatePlaylist()
minsegmentTime = segmentTime;
}
IsoffMainParser mpdparser(parser.getRootNode(), mpdstream,
Helper::getDirectoryPath(url).append("/"));
IsoffMainParser mpdparser(parser.getRootNode(), VLC_OBJECT(p_demux),
mpdstream, Helper::getDirectoryPath(url).append("/"));
MPD *newmpd = mpdparser.parse();
if(newmpd)
{
......
......@@ -50,10 +50,12 @@ using namespace dash::mpd;
using namespace adaptive::xml;
using namespace adaptive::playlist;
IsoffMainParser::IsoffMainParser (Node *root_, stream_t *stream, const std::string & streambaseurl_)
IsoffMainParser::IsoffMainParser (Node *root_, vlc_object_t *p_object_,
stream_t *stream, const std::string & streambaseurl_)
{
root = root_;
p_stream = stream;
p_object = p_object_;
playlisturl = streambaseurl_;
}
......@@ -73,7 +75,7 @@ void IsoffMainParser::parseMPDBaseUrl(MPD *mpd, Node *root)
MPD * IsoffMainParser::parse()
{
MPD *mpd = new (std::nothrow) MPD(p_stream, getProfile());
MPD *mpd = new (std::nothrow) MPD(p_object, getProfile());
if(mpd)
{
parseMPDAttributes(mpd, root);
......
......@@ -63,7 +63,8 @@ namespace dash
class IsoffMainParser
{
public:
IsoffMainParser (xml::Node *root, stream_t *p_stream, const std::string &);
IsoffMainParser (xml::Node *root, vlc_object_t *p_object,
stream_t *p_stream, const std::string &);
virtual ~IsoffMainParser ();
MPD * parse();
......@@ -83,6 +84,7 @@ namespace dash
void parseProgramInformation(xml::Node *, MPD *);
xml::Node *root;
vlc_object_t *p_object;
stream_t *p_stream;
std::string playlisturl;
};
......
......@@ -34,8 +34,8 @@
using namespace dash::mpd;
MPD::MPD (stream_t *stream_, Profile profile_) :
AbstractPlaylist(stream_),
MPD::MPD (vlc_object_t *p_object, Profile profile_) :
AbstractPlaylist(p_object),
profile( profile_ )
{
programInfo.Set( NULL );
......@@ -82,14 +82,14 @@ StreamFormat MPD::mimeToFormat(const std::string &mime)
void MPD::debug()
{
msg_Dbg(stream, "MPD profile=%s mediaPresentationDuration=%" PRId64
msg_Dbg(p_object, "MPD profile=%s mediaPresentationDuration=%" PRId64
" minBufferTime=%" PRId64,
static_cast<std::string>(getProfile()).c_str(),
duration.Get() / CLOCK_FREQ,
minBufferTime.Get());
msg_Dbg(stream, "BaseUrl=%s", getUrlSegment().toString().c_str());
msg_Dbg(p_object, "BaseUrl=%s", getUrlSegment().toString().c_str());
std::vector<BasePeriod *>::const_iterator i;
for(i = periods.begin(); i != periods.end(); ++i)
(*i)->debug(VLC_OBJECT(stream));
(*i)->debug(VLC_OBJECT(p_object));
}
......@@ -41,7 +41,7 @@ namespace dash
class MPD : public AbstractPlaylist
{
public:
MPD(stream_t *, Profile);
MPD(vlc_object_t *, Profile);
virtual ~MPD();
Profile getProfile() const;
......
......@@ -31,8 +31,8 @@
using namespace hls::playlist;
M3U8::M3U8 (stream_t *stream_) :
AbstractPlaylist(stream_)
M3U8::M3U8 (vlc_object_t *p_object) :
AbstractPlaylist(p_object)
{
minUpdatePeriod.Set( 5 * CLOCK_FREQ );
}
......@@ -69,6 +69,6 @@ void M3U8::debug()
{
std::vector<BasePeriod *>::const_iterator i;
for(i = periods.begin(); i != periods.end(); ++i)
(*i)->debug(VLC_OBJECT(stream));
(*i)->debug(VLC_OBJECT(p_object));
}
......@@ -32,7 +32,7 @@ namespace hls
class M3U8 : public AbstractPlaylist
{
public:
M3U8(stream_t *);
M3U8(vlc_object_t *);
virtual ~M3U8();
virtual bool isLive() const;
......
......@@ -384,7 +384,7 @@ void M3U8Parser::parseSegments(vlc_object_t *p_obj, Representation *rep, const s
rep->setSegmentList(segmentList);
}
M3U8 * M3U8Parser::parse(stream_t *p_stream, const std::string &playlisturl)
M3U8 * M3U8Parser::parse(vlc_object_t *p_object, stream_t *p_stream, const std::string &playlisturl)
{
char *psz_line = stream_ReadLine(p_stream);
if(!psz_line || strcmp(psz_line, "#EXTM3U"))
......@@ -394,7 +394,7 @@ M3U8 * M3U8Parser::parse(stream_t *p_stream, const std::string &playlisturl)
}
free(psz_line);
M3U8 *playlist = new (std::nothrow) M3U8(p_stream);
M3U8 *playlist = new (std::nothrow) M3U8(p_object);
if(!playlist)
return NULL;
......@@ -502,7 +502,7 @@ M3U8 * M3U8Parser::parse(stream_t *p_stream, const std::string &playlisturl)
period->addAdaptationSet(adaptSet);
AttributesTag *tag = new AttributesTag(AttributesTag::EXTXSTREAMINF, "");
tag->addAttribute(new Attribute("URI", playlisturl));
createAndFillRepresentation(VLC_OBJECT(p_stream), adaptSet, tag, tagslist);
createAndFillRepresentation(p_object, adaptSet, tag, tagslist);
delete tag;
}
}
......
......@@ -59,7 +59,7 @@ namespace hls
M3U8Parser ();
virtual ~M3U8Parser ();
M3U8 * parse (stream_t *p_stream, const std::string &);
M3U8 * parse (vlc_object_t *p_obj, stream_t *p_stream, const std::string &);
bool appendSegmentsFromPlaylistURI(vlc_object_t *, Representation *);
private:
......
......@@ -74,7 +74,8 @@ Manifest * SmoothManager::fetchManifest()
Manifest *manifest = NULL;
ManifestParser *manifestParser = new (std::nothrow) ManifestParser(parser.getRootNode(), memorystream, playlisturl);
ManifestParser *manifestParser = new (std::nothrow) ManifestParser(parser.getRootNode(), VLC_OBJECT(p_demux),
memorystream, playlisturl);
if(manifestParser)
{
manifest = manifestParser->parse();
......
......@@ -25,12 +25,11 @@
#include "../adaptive/playlist/BasePeriod.h"
#include <vlc_common.h>
#include <vlc_stream.h>
using namespace smooth::playlist;
Manifest::Manifest (stream_t *stream_) :
AbstractPlaylist(stream_)
Manifest::Manifest (vlc_object_t *p_object) :
AbstractPlaylist(p_object)
{
minUpdatePeriod.Set( 5 * CLOCK_FREQ );
timescale.Set( 10000000 );
......@@ -51,5 +50,5 @@ void Manifest::debug()
{
std::vector<BasePeriod *>::const_iterator i;
for(i = periods.begin(); i != periods.end(); ++i)
(*i)->debug(VLC_OBJECT(stream));
(*i)->debug(VLC_OBJECT(p_object));
}
......@@ -33,7 +33,7 @@ namespace smooth
friend class ManifestParser;
public:
Manifest(stream_t *);
Manifest(vlc_object_t *);
virtual ~Manifest();
virtual bool isLive() const;
......
......@@ -35,9 +35,11 @@
using namespace smooth::playlist;
using namespace adaptive::xml;
ManifestParser::ManifestParser(Node *root_, stream_t *stream, const std::string & streambaseurl_)
ManifestParser::ManifestParser(Node *root_, vlc_object_t *p_object_,
stream_t *stream, const std::string & streambaseurl_)
{
root = root_;
p_object = p_object_;
p_stream = stream;
playlisturl = streambaseurl_;
}
......@@ -245,7 +247,7 @@ static void ParseStreamIndex(BasePeriod *period, Node *streamIndexNode, unsigned
Manifest * ManifestParser::parse()
{
Manifest *manifest = new (std::nothrow) Manifest(p_stream);
Manifest *manifest = new (std::nothrow) Manifest(p_object);
if(!manifest)
return NULL;
......
......@@ -58,13 +58,15 @@ namespace smooth
class ManifestParser
{
public:
ManifestParser (xml::Node *, stream_t *, const std::string &);
ManifestParser (xml::Node *, vlc_object_t *,
stream_t *, const std::string &);
virtual ~ManifestParser ();
Manifest * parse();
private:
xml::Node *root;
vlc_object_t *p_object;
stream_t *p_stream;
std::string playlisturl;
};
......
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