[vlc-commits] demux: adaptive: add mime based demux proxy

Francois Cartegnie git at videolan.org
Mon Feb 26 12:14:36 CET 2018


vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Feb 20 22:42:28 2018 +0100| [bdc4d6e7d61b812f53365504f2228ba871fdaff4] | committer: Francois Cartegnie

demux: adaptive: add mime based demux proxy

(cherry picked from commit 4ea1c1b77bd3ca58c19c15055b3a2a5b625d9755)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=bdc4d6e7d61b812f53365504f2228ba871fdaff4
---

 modules/demux/adaptive/plumbing/Demuxer.cpp | 62 +++++++++++++++++++++++++++++
 modules/demux/adaptive/plumbing/Demuxer.hpp | 21 ++++++++++
 2 files changed, 83 insertions(+)

diff --git a/modules/demux/adaptive/plumbing/Demuxer.cpp b/modules/demux/adaptive/plumbing/Demuxer.cpp
index e05061aa37..caf78c5667 100644
--- a/modules/demux/adaptive/plumbing/Demuxer.cpp
+++ b/modules/demux/adaptive/plumbing/Demuxer.cpp
@@ -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()
 {
diff --git a/modules/demux/adaptive/plumbing/Demuxer.hpp b/modules/demux/adaptive/plumbing/Demuxer.hpp
index 15f79d6da9..1560c2af84 100644
--- a/modules/demux/adaptive/plumbing/Demuxer.hpp
+++ b/modules/demux/adaptive/plumbing/Demuxer.hpp
@@ -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:



More information about the vlc-commits mailing list