Commit 4ea1c1b7 authored by François Cartegnie's avatar François Cartegnie 🤞

demux: adaptive: add mime based demux proxy

parent 44751cd7
......@@ -76,6 +76,68 @@ bool AbstractDemuxer::needsRestartOnSeek() const
return b_reinitsonseek;
}
MimeDemuxer::MimeDemuxer(demux_t *p_realdemux_,
const DemuxerFactoryInterface *factory_,
es_out_t *out, AbstractSourceStream *source)
: AbstractDemuxer()
{
p_es_out = out;
factory = factory_;
p_realdemux = p_realdemux_;
demuxer = NULL;
sourcestream = source;
}
MimeDemuxer::~MimeDemuxer()
{
if( demuxer )
delete demuxer;
}
bool MimeDemuxer::create()
{
stream_t *p_newstream = sourcestream->makeStream();
if(!p_newstream)
return false;
char *type = stream_ContentType(p_newstream);
if(type)
{
demuxer = factory->newDemux( p_realdemux, StreamFormat(std::string(type)),
p_es_out, sourcestream );
free(type);
}
vlc_stream_Delete(p_newstream);
if(!demuxer || !demuxer->create())
return false;
return true;
}
void MimeDemuxer::destroy()
{
if(demuxer)
{
delete demuxer;
demuxer = NULL;
}
sourcestream->Reset();
}
void MimeDemuxer::drain()
{
if(demuxer)
demuxer->drain();
}
int MimeDemuxer::demux(mtime_t t)
{
if(!demuxer)
return VLC_DEMUXER_EOF;
return demuxer->demux(t);
}
Demuxer::Demuxer(demux_t *p_realdemux_, const std::string &name_, es_out_t *out, AbstractSourceStream *source)
: AbstractDemuxer()
{
......
......@@ -26,6 +26,8 @@
namespace adaptive
{
class AbstractSourceStream;
class DemuxerFactoryInterface;
class StreamFormat;
class AbstractDemuxer
{
......@@ -50,6 +52,25 @@ namespace adaptive
bool b_candetectswitches;
};
class MimeDemuxer : public AbstractDemuxer
{
public:
MimeDemuxer(demux_t *, const DemuxerFactoryInterface *,
es_out_t *, AbstractSourceStream *);
virtual ~MimeDemuxer();
virtual int demux(mtime_t); /* impl */
virtual void drain(); /* impl */
virtual bool create(); /* impl */
virtual void destroy(); /* impl */
protected:
AbstractSourceStream *sourcestream;
demux_t *p_realdemux;
AbstractDemuxer *demuxer;
const DemuxerFactoryInterface *factory;
es_out_t *p_es_out;
};
class Demuxer : public AbstractDemuxer
{
public:
......
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