]> git.sesse.net Git - vlc/commitdiff
demux: dash: handle bitswitchable property
authorFrancois Cartegnie <fcvlcdev@free.fr>
Mon, 22 Dec 2014 15:16:39 +0000 (16:16 +0100)
committerFrancois Cartegnie <fcvlcdev@free.fr>
Mon, 22 Dec 2014 18:03:36 +0000 (19:03 +0100)
modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.cpp
modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.h
modules/stream_filter/dash/mpd/IsoffMainParser.cpp
modules/stream_filter/dash/mpd/SegmentInformation.cpp
modules/stream_filter/dash/mpd/SegmentInformation.hpp

index 43ac0f6ff5798cb9b00ed5edf1a67879f0bbe271..3fcabf137a591bec2093af11eba173696aa4ffb6 100644 (file)
@@ -50,7 +50,13 @@ Chunk*  AbstractAdaptationLogic::getNextChunk(Streams::Type type)
     if(!currentPeriod)
         return NULL;
 
-    Representation *rep = getCurrentRepresentation(type);
+    Representation *rep;
+
+    if(prevRepresentation && !prevRepresentation->canBitswitch())
+        rep = prevRepresentation;
+    else
+        rep = getCurrentRepresentation(type);
+
     if ( rep == NULL )
             return NULL;
 
@@ -68,6 +74,7 @@ Chunk*  AbstractAdaptationLogic::getNextChunk(Streams::Type type)
     if (count == segments.size() && !b_templated)
     {
         currentPeriod = mpd->getNextPeriod(currentPeriod);
+        prevRepresentation = NULL;
         count = 0;
         return getNextChunk(type);
     }
index abb153f5a0f4b085e71b6523a7261ae6622d7e9e..8bb311dac8f22aebac8fc14fd36bff0d2eeaf1ba 100644 (file)
@@ -54,7 +54,7 @@ namespace dash
                 dash::mpd::MPD         *mpd;
                 dash::mpd::Period      *currentPeriod;
                 size_t                  count;
-                const mpd::Representation *prevRepresentation;
+                mpd::Representation    *prevRepresentation;
 
             private:
                 mtime_t                 bufferedMicroSec;
index fdaff37895dc3dbb1342aed81f6e8f7c5f9fe2ec..ee07cd9244293bc0938df6187cfc8701f702ec59 100644 (file)
@@ -143,6 +143,8 @@ size_t IsoffMainParser::parseSegmentInformation(Node *node, SegmentInformation *
     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");
     return total;
 }
 
index 315600c88f708d1dd9a6d5dfa1b18592027135dc..6cb163061f246b020621f522968e757ac2681c8d 100644 (file)
@@ -35,6 +35,7 @@ SegmentInformation::SegmentInformation(SegmentInformation *parent_) :
     segmentList = NULL;
     for(int i=0; i<InfoTypeCount; i++)
         segmentTemplate[i] = NULL;
+    bitswitch_policy = BITSWITCH_INHERIT;
 }
 
 SegmentInformation::SegmentInformation(ICanonicalUrl * parent_) :
@@ -45,6 +46,7 @@ SegmentInformation::SegmentInformation(ICanonicalUrl * parent_) :
     segmentList = NULL;
     for(int i=0; i<InfoTypeCount; i++)
         segmentTemplate[i] = NULL;
+    bitswitch_policy = BITSWITCH_INHERIT;
 }
 
 SegmentInformation::~SegmentInformation()
@@ -94,6 +96,14 @@ vector<ISegment *> SegmentInformation::getSegments() const
     return retSegments;
 }
 
+bool SegmentInformation::canBitswitch() const
+{
+    if(bitswitch_policy == BITSWITCH_INHERIT)
+        return (parent) ? parent->canBitswitch() : false;
+    else
+        return (bitswitch_policy == BITSWITCH_YES);
+}
+
 void SegmentInformation::setSegmentList(SegmentList *list)
 {
     segmentList = list;
@@ -156,6 +166,11 @@ void SegmentInformation::SplitUsingIndex(std::vector<SplitPoint> &splitlist)
     }
 }
 
+void SegmentInformation::setBitstreamSwitching(bool bitswitch)
+{
+    bitswitch_policy = (bitswitch) ? BITSWITCH_YES : BITSWITCH_NO;
+}
+
 SegmentBase * SegmentInformation::inheritSegmentBase() const
 {
     if(segmentBase)
index 50db1c390051639bc113cfbedd281b159e9fa835..3968111853c8643b54743b28349ae77faa4cde84 100644 (file)
@@ -48,6 +48,7 @@ namespace dash
                 explicit SegmentInformation( ICanonicalUrl * );
                 virtual ~SegmentInformation();
                 std::vector<ISegment *> getSegments() const;
+                bool canBitswitch() const;
 
                 class SplitPoint
                 {
@@ -69,6 +70,7 @@ namespace dash
                 void setSegmentList(SegmentList *);
                 void setSegmentBase(SegmentBase *);
                 void setSegmentTemplate(SegmentTemplate *, SegmentInfoType);
+                void setBitstreamSwitching(bool);
 
                 SegmentBase *     inheritSegmentBase() const;
                 SegmentList *     inheritSegmentList() const;
@@ -78,6 +80,13 @@ namespace dash
                 SegmentBase     *segmentBase;
                 SegmentList     *segmentList;
                 SegmentTemplate *segmentTemplate[InfoTypeCount];
+
+                enum BitswitchPolicy
+                {
+                    BITSWITCH_INHERIT,
+                    BITSWITCH_YES,
+                    BITSWITCH_NO
+                } bitswitch_policy;
         };
     }
 }