Commit 08b864b7 authored by François Cartegnie's avatar François Cartegnie 🤞

demux: adaptative: remove confusing namespace

parent da6b5aac
......@@ -53,14 +53,14 @@ PlaylistManager::PlaylistManager( AbstractPlaylist *pl,
stream ( stream ),
nextPlaylistupdate ( 0 )
{
for(int i=0; i<Streams::count; i++)
for(int i=0; i<StreamTypeCount; i++)
streams[i] = NULL;
}
PlaylistManager::~PlaylistManager ()
{
delete conManager;
for(int i=0; i<Streams::count; i++)
for(int i=0; i<StreamTypeCount; i++)
delete streams[i];
}
......@@ -70,13 +70,13 @@ bool PlaylistManager::start(demux_t *demux)
if(!period)
return false;
for(int i=0; i<Streams::count; i++)
for(int i=0; i<StreamTypeCount; i++)
{
Streams::Type type = static_cast<Streams::Type>(i);
StreamType type = static_cast<StreamType>(i);
const BaseAdaptationSet *set = period->getAdaptationSet(type);
if(set)
{
streams[type] = new (std::nothrow) Streams::Stream(set->getMimeType());
streams[type] = new (std::nothrow) Stream(set->getMimeType());
if(!streams[type])
continue;
AbstractAdaptationLogic *logic = createLogic(logicType);
......@@ -112,22 +112,22 @@ bool PlaylistManager::start(demux_t *demux)
return true;
}
Streams::Stream::status PlaylistManager::demux(mtime_t nzdeadline)
Stream::status PlaylistManager::demux(mtime_t nzdeadline)
{
Streams::Stream::status i_return = Streams::Stream::status_demuxed;
Stream::status i_return = Stream::status_demuxed;
for(int type=0; type<Streams::count; type++)
for(int type=0; type<StreamTypeCount; type++)
{
if(!streams[type])
continue;
Streams::Stream::status i_ret =
Stream::status i_ret =
streams[type]->demux(conManager, nzdeadline);
if(i_ret < Streams::Stream::status_eof)
if(i_ret < Stream::status_eof)
return i_ret;
else if (i_ret == Streams::Stream::status_buffering)
i_return = Streams::Stream::status_buffering;
else if (i_ret == Stream::status_buffering)
i_return = Stream::status_buffering;
}
return i_return;
......@@ -136,7 +136,7 @@ Streams::Stream::status PlaylistManager::demux(mtime_t nzdeadline)
mtime_t PlaylistManager::getPCR() const
{
mtime_t pcr = VLC_TS_INVALID;
for(int type=0; type<Streams::count; type++)
for(int type=0; type<StreamTypeCount; type++)
{
if(!streams[type])
continue;
......@@ -148,7 +148,7 @@ mtime_t PlaylistManager::getPCR() const
int PlaylistManager::getGroup() const
{
for(int type=0; type<Streams::count; type++)
for(int type=0; type<StreamTypeCount; type++)
{
if(!streams[type])
continue;
......@@ -160,7 +160,7 @@ int PlaylistManager::getGroup() const
int PlaylistManager::esCount() const
{
int es = 0;
for(int type=0; type<Streams::count; type++)
for(int type=0; type<StreamTypeCount; type++)
{
if(!streams[type])
continue;
......@@ -183,7 +183,7 @@ bool PlaylistManager::setPosition(mtime_t time)
for(int real = 0; real < 2; real++)
{
/* Always probe if we can seek first */
for(int type=0; type<Streams::count; type++)
for(int type=0; type<StreamTypeCount; type++)
{
if(!streams[type])
continue;
......@@ -200,7 +200,7 @@ bool PlaylistManager::seekAble() const
if(playlist->isLive())
return false;
for(int type=0; type<Streams::count; type++)
for(int type=0; type<StreamTypeCount; type++)
{
if(!streams[type])
continue;
......
......@@ -50,7 +50,7 @@ namespace adaptative
bool start(demux_t *);
Streams::Stream::status demux(mtime_t);
Stream::status demux(mtime_t);
mtime_t getDuration() const;
mtime_t getPCR() const;
int getGroup() const;
......@@ -66,7 +66,7 @@ namespace adaptative
AbstractAdaptationLogic::LogicType logicType;
AbstractPlaylist *playlist;
stream_t *stream;
Streams::Stream *streams[Streams::count];
Stream *streams[StreamTypeCount];
mtime_t nextPlaylistupdate;
};
......
......@@ -53,7 +53,7 @@ void SegmentTracker::resetCounter()
prevRepresentation = NULL;
}
Chunk * SegmentTracker::getNextChunk(Streams::Type type)
Chunk * SegmentTracker::getNextChunk(StreamType type)
{
BaseRepresentation *rep;
ISegment *segment;
......
......@@ -58,7 +58,7 @@ namespace adaptative
void setAdaptationLogic(AbstractAdaptationLogic *);
void resetCounter();
Chunk* getNextChunk(Streams::Type);
Chunk* getNextChunk(StreamType);
bool setPosition(mtime_t, bool);
mtime_t getSegmentStart() const;
......
......@@ -28,23 +28,21 @@
#include <vlc_stream.h>
#include <vlc_demux.h>
using namespace adaptative::Streams;
using namespace adaptative;
using namespace adaptative::http;
using namespace adaptative::logic;
using namespace adaptative::Streams;
Stream::Stream(const std::string &mime)
{
init(mimeToType(mime), mimeToFormat(mime));
}
Stream::Stream(const Type type, const Format format)
Stream::Stream(const StreamType type, const StreamFormat format)
{
init(type, format);
}
void Stream::init(const Type type_, const Format format_)
void Stream::init(const StreamType type_, const StreamFormat format_)
{
type = type_;
format = format_;
......@@ -63,31 +61,31 @@ Stream::~Stream()
delete segmentTracker;
}
Type Stream::mimeToType(const std::string &mime)
StreamType Stream::mimeToType(const std::string &mime)
{
Type mimetype;
StreamType mimetype;
if (!mime.compare(0, 6, "video/"))
mimetype = Streams::VIDEO;
mimetype = StreamType::VIDEO;
else if (!mime.compare(0, 6, "audio/"))
mimetype = Streams::AUDIO;
mimetype = StreamType::AUDIO;
else if (!mime.compare(0, 12, "application/"))
mimetype = Streams::APPLICATION;
mimetype = StreamType::APPLICATION;
else /* unknown of unsupported */
mimetype = Streams::UNKNOWN;
mimetype = StreamType::UNKNOWN;
return mimetype;
}
Format Stream::mimeToFormat(const std::string &mime)
StreamFormat Stream::mimeToFormat(const std::string &mime)
{
Format format = Streams::UNSUPPORTED;
StreamFormat format = StreamFormat::UNSUPPORTED;
std::string::size_type pos = mime.find("/");
if(pos != std::string::npos)
{
std::string tail = mime.substr(pos + 1);
if(tail == "mp4")
format = Streams::MP4;
format = StreamFormat::MP4;
else if (tail == "mp2t")
format = Streams::MPEG2TS;
format = StreamFormat::MPEG2TS;
}
return format;
}
......@@ -96,10 +94,10 @@ void Stream::create(demux_t *demux, AbstractAdaptationLogic *logic, SegmentTrack
{
switch(format)
{
case adaptative::Streams::MP4:
case StreamFormat::MP4:
output = new MP4StreamOutput(demux);
break;
case adaptative::Streams::MPEG2TS:
case StreamFormat::MPEG2TS:
output = new MPEG2TSStreamOutput(demux);
break;
default:
......
......@@ -44,102 +44,101 @@ namespace adaptative
class AbstractAdaptationLogic;
}
namespace Streams
{
class AbstractStreamOutput;
using namespace http;
using namespace logic;
class AbstractStreamOutput;
class Stream
{
public:
Stream(const std::string &mime);
Stream(const Type, const Format);
~Stream();
bool operator==(const Stream &) const;
static Type mimeToType(const std::string &mime);
static Format mimeToFormat(const std::string &mime);
void create(demux_t *, AbstractAdaptationLogic *, SegmentTracker *);
bool isEOF() const;
mtime_t getPCR() const;
int getGroup() const;
int esCount() const;
bool seekAble() const;
typedef enum {status_eof, status_buffering, status_demuxed} status;
status demux(HTTPConnectionManager *, mtime_t);
bool setPosition(mtime_t, bool);
mtime_t getPosition() const;
private:
Chunk *getChunk();
void init(const Type, const Format);
size_t read(HTTPConnectionManager *);
Type type;
Format format;
AbstractStreamOutput *output;
AbstractAdaptationLogic *adaptationLogic;
SegmentTracker *segmentTracker;
http::Chunk *currentChunk;
bool eof;
};
using namespace http;
using namespace logic;
class AbstractStreamOutput
class Stream
{
public:
Stream(const std::string &mime);
Stream(const StreamType, const StreamFormat);
~Stream();
bool operator==(const Stream &) const;
static StreamType mimeToType(const std::string &mime);
static StreamFormat mimeToFormat(const std::string &mime);
void create(demux_t *, AbstractAdaptationLogic *, SegmentTracker *);
bool isEOF() const;
mtime_t getPCR() const;
int getGroup() const;
int esCount() const;
bool seekAble() const;
typedef enum {status_eof, status_buffering, status_demuxed} status;
status demux(HTTPConnectionManager *, mtime_t);
bool setPosition(mtime_t, bool);
mtime_t getPosition() const;
private:
Chunk *getChunk();
void init(const StreamType, const StreamFormat);
size_t read(HTTPConnectionManager *);
StreamType type;
StreamFormat format;
AbstractStreamOutput *output;
AbstractAdaptationLogic *adaptationLogic;
SegmentTracker *segmentTracker;
http::Chunk *currentChunk;
bool eof;
};
class AbstractStreamOutput
{
public:
AbstractStreamOutput(demux_t *);
virtual ~AbstractStreamOutput();
virtual void pushBlock(block_t *);
mtime_t getPCR() const;
int getGroup() const;
int esCount() const;
bool seekAble() const;
void setPosition(mtime_t);
void sendToDecoder(mtime_t);
protected:
mtime_t pcr;
int group;
es_out_t *fakeesout; /* to intercept/proxy what is sent from demuxstream */
stream_t *demuxstream;
bool seekable;
private:
demux_t *realdemux;
static es_out_id_t *esOutAdd(es_out_t *, const es_format_t *);
static int esOutSend(es_out_t *, es_out_id_t *, block_t *);
static void esOutDel(es_out_t *, es_out_id_t *);
static int esOutControl(es_out_t *, int, va_list);
static void esOutDestroy(es_out_t *);
class Demuxed
{
public:
AbstractStreamOutput(demux_t *);
virtual ~AbstractStreamOutput();
virtual void pushBlock(block_t *);
mtime_t getPCR() const;
int getGroup() const;
int esCount() const;
bool seekAble() const;
void setPosition(mtime_t);
void sendToDecoder(mtime_t);
protected:
mtime_t pcr;
int group;
es_out_t *fakeesout; /* to intercept/proxy what is sent from demuxstream */
stream_t *demuxstream;
bool seekable;
private:
demux_t *realdemux;
static es_out_id_t *esOutAdd(es_out_t *, const es_format_t *);
static int esOutSend(es_out_t *, es_out_id_t *, block_t *);
static void esOutDel(es_out_t *, es_out_id_t *);
static int esOutControl(es_out_t *, int, va_list);
static void esOutDestroy(es_out_t *);
class Demuxed
{
friend class AbstractStreamOutput;
Demuxed();
~Demuxed();
void drop();
es_out_id_t *es_id;
block_t *p_queue;
block_t **pp_queue_last;
};
std::list<Demuxed *> queues;
vlc_mutex_t lock;
friend class AbstractStreamOutput;
Demuxed();
~Demuxed();
void drop();
es_out_id_t *es_id;
block_t *p_queue;
block_t **pp_queue_last;
};
std::list<Demuxed *> queues;
vlc_mutex_t lock;
};
class MP4StreamOutput : public AbstractStreamOutput
{
public:
MP4StreamOutput(demux_t *);
virtual ~MP4StreamOutput(){}
};
class MP4StreamOutput : public AbstractStreamOutput
{
public:
MP4StreamOutput(demux_t *);
virtual ~MP4StreamOutput(){}
};
class MPEG2TSStreamOutput : public AbstractStreamOutput
{
public:
MPEG2TSStreamOutput(demux_t *);
virtual ~MPEG2TSStreamOutput(){}
};
class MPEG2TSStreamOutput : public AbstractStreamOutput
{
public:
MPEG2TSStreamOutput(demux_t *);
virtual ~MPEG2TSStreamOutput(){}
};
}
}
#endif // STREAMS_HPP
......@@ -22,25 +22,24 @@
namespace adaptative
{
namespace Streams
enum StreamType
{
UNKNOWN = 0,
VIDEO,
AUDIO,
APPLICATION
};
enum StreamFormat
{
enum Type
{
UNKNOWN = 0,
VIDEO,
AUDIO,
APPLICATION
};
UNSUPPORTED = 0,
MP4,
MPEG2TS
};
enum Format
{
UNSUPPORTED = 0,
MP4,
MPEG2TS
};
static const int StreamTypeCount = APPLICATION + 1;
static const int count = APPLICATION + 1;
}
}
#endif
......@@ -46,7 +46,7 @@ namespace adaptative
AbstractAdaptationLogic ();
virtual ~AbstractAdaptationLogic ();
virtual BaseRepresentation* getCurrentRepresentation(Streams::Type, BasePeriod *) const = 0;
virtual BaseRepresentation* getCurrentRepresentation(StreamType, BasePeriod *) const = 0;
virtual void updateDownloadRate (size_t, mtime_t);
enum LogicType
......
......@@ -36,7 +36,7 @@ AlwaysBestAdaptationLogic::AlwaysBestAdaptationLogic () :
{
}
BaseRepresentation *AlwaysBestAdaptationLogic::getCurrentRepresentation(Streams::Type type, BasePeriod *period) const
BaseRepresentation *AlwaysBestAdaptationLogic::getCurrentRepresentation(StreamType type, BasePeriod *period) const
{
RepresentationSelector selector;
return selector.select(period, type);
......
......@@ -36,7 +36,7 @@ namespace adaptative
public:
AlwaysBestAdaptationLogic ();
virtual BaseRepresentation *getCurrentRepresentation(Streams::Type, BasePeriod *) const;
virtual BaseRepresentation *getCurrentRepresentation(StreamType, BasePeriod *) const;
};
}
}
......
......@@ -28,7 +28,7 @@ AlwaysLowestAdaptationLogic::AlwaysLowestAdaptationLogic():
{
}
BaseRepresentation *AlwaysLowestAdaptationLogic::getCurrentRepresentation(Streams::Type type, BasePeriod *period) const
BaseRepresentation *AlwaysLowestAdaptationLogic::getCurrentRepresentation(StreamType type, BasePeriod *period) const
{
RepresentationSelector selector;
return selector.select(period, type, 0);
......
......@@ -31,7 +31,7 @@ namespace adaptative
public:
AlwaysLowestAdaptationLogic();
virtual BaseRepresentation* getCurrentRepresentation(Streams::Type, BasePeriod *) const;
virtual BaseRepresentation* getCurrentRepresentation(StreamType, BasePeriod *) const;
};
}
}
......
......@@ -42,7 +42,7 @@ RateBasedAdaptationLogic::RateBasedAdaptationLogic (int w, int h) :
height = h;
}
BaseRepresentation *RateBasedAdaptationLogic::getCurrentRepresentation(Streams::Type type, BasePeriod *period) const
BaseRepresentation *RateBasedAdaptationLogic::getCurrentRepresentation(StreamType type, BasePeriod *period) const
{
if(period == NULL)
return NULL;
......@@ -82,7 +82,7 @@ FixedRateAdaptationLogic::FixedRateAdaptationLogic(size_t bps) :
currentBps = bps;
}
BaseRepresentation *FixedRateAdaptationLogic::getCurrentRepresentation(Streams::Type type, BasePeriod *period) const
BaseRepresentation *FixedRateAdaptationLogic::getCurrentRepresentation(StreamType type, BasePeriod *period) const
{
if(period == NULL)
return NULL;
......
......@@ -39,7 +39,7 @@ namespace adaptative
public:
RateBasedAdaptationLogic (int, int);
BaseRepresentation *getCurrentRepresentation(Streams::Type, BasePeriod *) const;
BaseRepresentation *getCurrentRepresentation(StreamType, BasePeriod *) const;
virtual void updateDownloadRate(size_t, mtime_t);
private:
......@@ -55,7 +55,7 @@ namespace adaptative
public:
FixedRateAdaptationLogic(size_t);
BaseRepresentation *getCurrentRepresentation(Streams::Type, BasePeriod *) const;
BaseRepresentation *getCurrentRepresentation(StreamType, BasePeriod *) const;
private:
size_t currentBps;
......
......@@ -29,11 +29,11 @@ RepresentationSelector::RepresentationSelector()
{
}
BaseRepresentation * RepresentationSelector::select(BasePeriod *period, Streams::Type type) const
BaseRepresentation * RepresentationSelector::select(BasePeriod *period, StreamType type) const
{
return select(period, type, std::numeric_limits<uint64_t>::max());
}
BaseRepresentation * RepresentationSelector::select(BasePeriod *period, Streams::Type type, uint64_t bitrate) const
BaseRepresentation * RepresentationSelector::select(BasePeriod *period, StreamType type, uint64_t bitrate) const
{
if (period == NULL)
return NULL;
......@@ -56,7 +56,7 @@ BaseRepresentation * RepresentationSelector::select(BasePeriod *period, Streams:
return best;
}
BaseRepresentation * RepresentationSelector::select(BasePeriod *period, Streams::Type type, uint64_t bitrate,
BaseRepresentation * RepresentationSelector::select(BasePeriod *period, StreamType type, uint64_t bitrate,
int width, int height) const
{
if(period == NULL)
......
......@@ -40,9 +40,9 @@ namespace adaptative
public:
RepresentationSelector();
virtual ~RepresentationSelector() {}
virtual BaseRepresentation * select(BasePeriod *period, Streams::Type) const;
virtual BaseRepresentation * select(BasePeriod *period, Streams::Type, uint64_t bitrate) const;
virtual BaseRepresentation * select(BasePeriod *period, Streams::Type, uint64_t bitrate,
virtual BaseRepresentation * select(BasePeriod *period, StreamType) const;
virtual BaseRepresentation * select(BasePeriod *period, StreamType, uint64_t bitrate) const;
virtual BaseRepresentation * select(BasePeriod *period, StreamType, uint64_t bitrate,
int width, int height) const;
protected:
virtual BaseRepresentation * select(std::vector<BaseRepresentation *>&reps,
......
......@@ -55,13 +55,13 @@ const std::vector<BaseAdaptationSet*>& BasePeriod::getAdaptationSets() const
return adaptationSets;
}
const std::vector<BaseAdaptationSet*> BasePeriod::getAdaptationSets(Streams::Type type) const
const std::vector<BaseAdaptationSet*> BasePeriod::getAdaptationSets(StreamType type) const
{
std::vector<BaseAdaptationSet*> list;
std::vector<BaseAdaptationSet*>::const_iterator it;
for(it = adaptationSets.begin(); it!= adaptationSets.end(); ++it)
{
if( Streams::Stream::mimeToType((*it)->getMimeType()) == type )
if( Stream::mimeToType((*it)->getMimeType()) == type )
list.push_back(*it);
}
return list;
......@@ -76,12 +76,12 @@ void BasePeriod::addAdaptationSet(BaseAdaptationSet *adaptationSet)
}
}
BaseAdaptationSet * BasePeriod::getAdaptationSet(Streams::Type type) const
BaseAdaptationSet * BasePeriod::getAdaptationSet(StreamType type) const
{
std::vector<BaseAdaptationSet *>::const_iterator it;
for(it = adaptationSets.begin(); it != adaptationSets.end(); ++it)
{
if ( Streams::Stream::mimeToType((*it)->getMimeType()) == type )
if ( Stream::mimeToType((*it)->getMimeType()) == type )
return *it;
}
return NULL;
......
......@@ -43,8 +43,8 @@ namespace adaptative
virtual ~BasePeriod ();
const std::vector<BaseAdaptationSet *>& getAdaptationSets () const;
const std::vector<BaseAdaptationSet *> getAdaptationSets (Streams::Type) const;
BaseAdaptationSet * getAdaptationSet (Streams::Type) const;
const std::vector<BaseAdaptationSet *> getAdaptationSets (StreamType) const;
BaseAdaptationSet * getAdaptationSet (StreamType) const;
void addAdaptationSet (BaseAdaptationSet *AdaptationSet);
std::vector<std::string> toString (int = 0) const;
......
......@@ -84,7 +84,7 @@ bool DASHManager::updatePlaylist()
}
mtime_t minsegmentTime = 0;
for(int type=0; type<Streams::count; type++)
for(int type=0; type<StreamTypeCount; type++)
{
if(!streams[type])
continue;
......
......@@ -183,15 +183,15 @@ static int Demux(demux_t *p_demux)
{
demux_sys_t *p_sys = p_demux->p_sys;
Streams::Stream::status status =
Stream::status status =
p_sys->p_dashManager->demux(p_sys->i_nzpcr + DEMUX_INCREMENT);
switch(status)
{
case Streams::Stream::status_eof:
case Stream::status_eof:
return VLC_DEMUXER_EOF;
case Streams::Stream::status_buffering:
case Stream::status_buffering:
break;
case Streams::Stream::status_demuxed:
case Stream::status_demuxed:
p_sys->i_nzpcr += DEMUX_INCREMENT;
int group = p_sys->p_dashManager->getGroup();
es_out_Control(p_demux->out, ES_OUT_SET_GROUP_PCR, group, VLC_TS_0 + p_sys->i_nzpcr);
......
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