[vlc-commits] demux: dash: add Stream::Format

Francois Cartegnie git at videolan.org
Thu Dec 18 22:39:58 CET 2014


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Dec 17 16:50:03 2014 +0100| [945f6e087d0c45f067e6cc597149879eb561c4de] | committer: Francois Cartegnie

demux: dash: add Stream::Format

Not mandatory to be mp4

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

 modules/stream_filter/dash/DASHManager.cpp |    4 +--
 modules/stream_filter/dash/Streams.cpp     |   40 +++++++++++++++++++++-------
 modules/stream_filter/dash/Streams.hpp     |    8 +++---
 modules/stream_filter/dash/StreamsType.hpp |    7 +++++
 4 files changed, 45 insertions(+), 14 deletions(-)

diff --git a/modules/stream_filter/dash/DASHManager.cpp b/modules/stream_filter/dash/DASHManager.cpp
index 43b7b18..e6c5853 100644
--- a/modules/stream_filter/dash/DASHManager.cpp
+++ b/modules/stream_filter/dash/DASHManager.cpp
@@ -66,10 +66,10 @@ bool DASHManager::start(demux_t *demux)
         const AdaptationSet *set = period->getAdaptationSet(type);
         if(set)
         {
-            streams[type] = new Streams::Stream(type);
+            streams[type] = new Streams::Stream(set->getMimeType());
             try
             {
-                streams[type]->init(demux, AdaptationLogicFactory::create( logicType, mpd ) );
+                streams[type]->create(demux, AdaptationLogicFactory::create( logicType, mpd ) );
             } catch (int) {
                 delete streams[type];
                 streams[type] = NULL;
diff --git a/modules/stream_filter/dash/Streams.cpp b/modules/stream_filter/dash/Streams.cpp
index c2d61b8..b2340d8 100644
--- a/modules/stream_filter/dash/Streams.cpp
+++ b/modules/stream_filter/dash/Streams.cpp
@@ -30,17 +30,18 @@ using namespace dash::logic;
 
 Stream::Stream(const std::string &mime)
 {
-    init(mimeToType(mime));
+    init(mimeToType(mime), mimeToFormat(mime));
 }
 
-Stream::Stream(const Type type)
+Stream::Stream(const Type type, const Format format)
 {
-    init(type);
+    init(type, format);
 }
 
-void Stream::init(const Type type_)
+void Stream::init(const Type type_, const Format format_)
 {
     type = type_;
+    format = format_;
     output = NULL;
     currentChunk = NULL;
     eof = false;
@@ -56,21 +57,42 @@ Stream::~Stream()
 Type Stream::mimeToType(const std::string &mime)
 {
     Type mimetype;
-    if (mime == "video/mp4")
+    if (!mime.compare(0, 6, "video/"))
         mimetype = Streams::VIDEO;
-    else if (mime == "audio/mp4")
+    else if (!mime.compare(0, 6, "audio/"))
         mimetype = Streams::AUDIO;
-    else if (mime == "application/mp4")
+    else if (!mime.compare(0, 12, "application/"))
         mimetype = Streams::APPLICATION;
     else /* unknown of unsupported */
         mimetype = Streams::UNKNOWN;
     return mimetype;
 }
 
-void Stream::init(demux_t *demux, IAdaptationLogic *logic)
+Format Stream::mimeToFormat(const std::string &mime)
+{
+    Format format = Streams::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;
+    }
+    return format;
+}
+
+void Stream::create(demux_t *demux, IAdaptationLogic *logic)
 {
-    output = new Streams::MP4StreamOutput(demux);
     adaptationLogic = logic;
+    switch(format)
+    {
+        case Streams::MP4:
+            output = new MP4StreamOutput(demux);
+            break;
+        default:
+            throw VLC_EBADVAR;
+            break;
+    }
 }
 
 bool Stream::isEOF() const
diff --git a/modules/stream_filter/dash/Streams.hpp b/modules/stream_filter/dash/Streams.hpp
index 7affa67..8d125f0 100644
--- a/modules/stream_filter/dash/Streams.hpp
+++ b/modules/stream_filter/dash/Streams.hpp
@@ -41,11 +41,12 @@ namespace dash
         {
             public:
                 Stream(const std::string &mime);
-                Stream(const Type);
+                Stream(const Type, const Format);
                 ~Stream();
                 bool operator==(const Stream &) const;
                 static Type mimeToType(const std::string &mime);
-                void init(demux_t *, logic::IAdaptationLogic *);
+                static Format mimeToFormat(const std::string &mime);
+                void create(demux_t *, logic::IAdaptationLogic *);
                 bool isEOF() const;
                 mtime_t getPCR() const;
                 int getGroup() const;
@@ -54,8 +55,9 @@ namespace dash
 
             private:
                 http::Chunk *getChunk();
-                void init(const Type);
+                void init(const Type, const Format);
                 Type type;
+                Format format;
                 AbstractStreamOutput *output;
                 logic::IAdaptationLogic *adaptationLogic;
                 http::Chunk *currentChunk;
diff --git a/modules/stream_filter/dash/StreamsType.hpp b/modules/stream_filter/dash/StreamsType.hpp
index 994941f..d4ffd64 100644
--- a/modules/stream_filter/dash/StreamsType.hpp
+++ b/modules/stream_filter/dash/StreamsType.hpp
@@ -32,6 +32,13 @@ namespace dash
             APPLICATION
         };
 
+        enum Format
+        {
+            UNSUPPORTED = 0,
+            MP4,
+            MPEG2TS
+        };
+
         static const int count = APPLICATION + 1;
     }
 }



More information about the vlc-commits mailing list