[vlc-commits] demux: adaptative: fix quality switch policies

Francois Cartegnie git at videolan.org
Wed Jun 10 18:58:05 CEST 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sun Jun  7 21:28:45 2015 +0200| [bfe02ea6a660589642ff585d9864f433823fa04c] | committer: Francois Cartegnie

demux: adaptative: fix quality switch policies

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

 modules/demux/adaptative/SegmentTracker.cpp         |    2 +-
 .../demux/adaptative/playlist/BaseAdaptationSet.cpp |    2 +-
 .../demux/adaptative/playlist/BaseAdaptationSet.h   |    2 +-
 .../adaptative/playlist/SegmentInformation.cpp      |   14 +++++++-------
 .../adaptative/playlist/SegmentInformation.hpp      |   19 ++++++++++---------
 modules/demux/dash/mpd/IsoffMainParser.cpp          |   13 +++++++++++--
 6 files changed, 31 insertions(+), 21 deletions(-)

diff --git a/modules/demux/adaptative/SegmentTracker.cpp b/modules/demux/adaptative/SegmentTracker.cpp
index f5e49a3..a9fc992 100644
--- a/modules/demux/adaptative/SegmentTracker.cpp
+++ b/modules/demux/adaptative/SegmentTracker.cpp
@@ -62,7 +62,7 @@ Chunk * SegmentTracker::getNextChunk(StreamType type)
     if(!currentPeriod)
         return NULL;
 
-    if(prevRepresentation && !prevRepresentation->canBitswitch())
+    if(prevRepresentation && prevRepresentation->getSwitchPolicy() == SegmentInformation::SWITCH_UNAVAILABLE)
         rep = prevRepresentation;
     else
         rep = logic->getCurrentRepresentation(type, currentPeriod);
diff --git a/modules/demux/adaptative/playlist/BaseAdaptationSet.cpp b/modules/demux/adaptative/playlist/BaseAdaptationSet.cpp
index 0ac16fd..c1ecffc 100644
--- a/modules/demux/adaptative/playlist/BaseAdaptationSet.cpp
+++ b/modules/demux/adaptative/playlist/BaseAdaptationSet.cpp
@@ -69,7 +69,7 @@ void BaseAdaptationSet::addRepresentation(BaseRepresentation *rep)
     childs.push_back(rep);
 }
 
-void BaseAdaptationSet::setBitstreamSwitching  (bool value)
+void BaseAdaptationSet::setSwitchPolicy  (bool value)
 {
     this->isBitstreamSwitching = value;
 }
diff --git a/modules/demux/adaptative/playlist/BaseAdaptationSet.h b/modules/demux/adaptative/playlist/BaseAdaptationSet.h
index 70d1c8e..653bbbf 100644
--- a/modules/demux/adaptative/playlist/BaseAdaptationSet.h
+++ b/modules/demux/adaptative/playlist/BaseAdaptationSet.h
@@ -47,7 +47,7 @@ namespace adaptative
 
                 virtual const std::string&      getMimeType() const; /*reimpl*/
                 std::vector<BaseRepresentation *>&  getRepresentations      ();
-                void                            setBitstreamSwitching(bool value);
+                void                            setSwitchPolicy(bool value);
                 bool                            getBitstreamSwitching() const;
                 void                            addRepresentation( BaseRepresentation *rep );
                 void                            debug(vlc_object_t *,int = 0) const;
diff --git a/modules/demux/adaptative/playlist/SegmentInformation.cpp b/modules/demux/adaptative/playlist/SegmentInformation.cpp
index 963d96f..73913cd 100644
--- a/modules/demux/adaptative/playlist/SegmentInformation.cpp
+++ b/modules/demux/adaptative/playlist/SegmentInformation.cpp
@@ -51,7 +51,7 @@ void SegmentInformation::init()
     segmentBase = NULL;
     segmentList = NULL;
     mediaSegmentTemplate = NULL;
-    bitswitch_policy = BITSWITCH_INHERIT;
+    switchpolicy = SWITCH_UNKNOWN;
 }
 
 SegmentInformation::~SegmentInformation()
@@ -306,12 +306,12 @@ void SegmentInformation::pruneBySegmentNumber(uint64_t num)
         childs.at(i)->pruneBySegmentNumber(num);
 }
 
-bool SegmentInformation::canBitswitch() const
+SegmentInformation::SwitchPolicy SegmentInformation::getSwitchPolicy() const
 {
-    if(bitswitch_policy == BITSWITCH_INHERIT)
-        return (parent) ? parent->canBitswitch() : false;
+    if(switchpolicy == SWITCH_UNKNOWN)
+        return (parent) ? parent->getSwitchPolicy() : SWITCH_UNAVAILABLE;
     else
-        return (bitswitch_policy == BITSWITCH_YES);
+        return switchpolicy;
 }
 
 mtime_t SegmentInformation::getPeriodStart() const
@@ -385,9 +385,9 @@ void SegmentInformation::SplitUsingIndex(std::vector<SplitPoint> &splitlist)
     }
 }
 
-void SegmentInformation::setBitstreamSwitching(bool bitswitch)
+void SegmentInformation::setSwitchPolicy(SegmentInformation::SwitchPolicy policy)
 {
-    bitswitch_policy = (bitswitch) ? BITSWITCH_YES : BITSWITCH_NO;
+    switchpolicy = policy;
 }
 
 Url SegmentInformation::getUrlSegment() const
diff --git a/modules/demux/adaptative/playlist/SegmentInformation.hpp b/modules/demux/adaptative/playlist/SegmentInformation.hpp
index 895458d..0652b76 100644
--- a/modules/demux/adaptative/playlist/SegmentInformation.hpp
+++ b/modules/demux/adaptative/playlist/SegmentInformation.hpp
@@ -54,7 +54,14 @@ namespace adaptative
                 SegmentInformation( SegmentInformation * = 0 );
                 explicit SegmentInformation( AbstractPlaylist * );
                 virtual ~SegmentInformation();
-                bool canBitswitch() const;
+                typedef enum SwitchPolicy
+                {
+                    SWITCH_UNKNOWN,
+                    SWITCH_UNAVAILABLE,
+                    SWITCH_SEGMENT_ALIGNED,
+                    SWITCH_BITSWITCHEABLE
+                } SwitchPolicy;
+                SwitchPolicy getSwitchPolicy() const;
                 virtual mtime_t getPeriodStart() const;
                 virtual AbstractPlaylist *getPlaylist() const;
 
@@ -87,12 +94,13 @@ namespace adaptative
                 std::size_t getSegments(SegmentInfoType, std::vector<ISegment *>&, std::size_t * = NULL) const;
                 std::vector<SegmentInformation *> childs;
                 SegmentInformation *parent;
+                SwitchPolicy switchpolicy;
 
             public:
                 void setSegmentList(SegmentList *);
                 void setSegmentBase(SegmentBase *);
                 void setSegmentTemplate(MediaSegmentTemplate *);
-                void setBitstreamSwitching(bool);
+                void setSwitchPolicy(SwitchPolicy);
                 virtual Url getUrlSegment() const; /* impl */
                 Property<Url *> baseUrl;
 
@@ -105,13 +113,6 @@ namespace adaptative
                 SegmentBase     *segmentBase;
                 SegmentList     *segmentList;
                 MediaSegmentTemplate *mediaSegmentTemplate;
-
-                enum BitswitchPolicy
-                {
-                    BITSWITCH_INHERIT,
-                    BITSWITCH_YES,
-                    BITSWITCH_NO
-                } bitswitch_policy;
         };
     }
 }
diff --git a/modules/demux/dash/mpd/IsoffMainParser.cpp b/modules/demux/dash/mpd/IsoffMainParser.cpp
index 6e6ee11..b2e3a9c 100644
--- a/modules/demux/dash/mpd/IsoffMainParser.cpp
+++ b/modules/demux/dash/mpd/IsoffMainParser.cpp
@@ -196,8 +196,17 @@ size_t IsoffMainParser::parseSegmentInformation(Node *node, SegmentInformation *
     total += parseSegmentBase(DOMHelper::getFirstChildElementByName(node, "SegmentBase"), info);
     total += parseSegmentList(DOMHelper::getFirstChildElementByName(node, "SegmentList"), info);
     total += parseSegmentTemplate(DOMHelper::getFirstChildElementByName(node, "SegmentTemplate" ), info);
-    if(node->hasAttribute("bitstreamSwitching"))
-        info->setBitstreamSwitching(node->getAttributeValue("bitstreamSwitching") == "true");
+    if(node->hasAttribute("bitstreamSwitching") && node->getAttributeValue("bitstreamSwitching") == "true")
+    {
+        info->setSwitchPolicy(SegmentInformation::SWITCH_BITSWITCHEABLE);
+    }
+    else if(node->hasAttribute("segmentAlignment"))
+    {
+        if( node->getAttributeValue("segmentAlignment") == "true" )
+            info->setSwitchPolicy(SegmentInformation::SWITCH_SEGMENT_ALIGNED);
+        else
+            info->setSwitchPolicy(SegmentInformation::SWITCH_UNAVAILABLE);
+    }
     if(node->hasAttribute("timescale"))
         info->timescale.Set(Integer<uint64_t>(node->getAttributeValue("timescale")));
     return total;



More information about the vlc-commits mailing list