[vlc-commits] demux: hls: workaround missing/invalid extinf duration

Francois Cartegnie git at videolan.org
Tue Nov 28 10:58:18 CET 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Nov 28 10:45:50 2017 +0100| [aad18acf8c22070eb007cb91b57886380cb08474] | committer: Francois Cartegnie

demux: hls: workaround missing/invalid extinf duration

as vimeo can't properly write extinf

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

 modules/demux/hls/playlist/Parser.cpp | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/modules/demux/hls/playlist/Parser.cpp b/modules/demux/hls/playlist/Parser.cpp
index 49bafc2107..928962e626 100644
--- a/modules/demux/hls/playlist/Parser.cpp
+++ b/modules/demux/hls/playlist/Parser.cpp
@@ -238,26 +238,25 @@ void M3U8Parser::parseSegments(vlc_object_t *, Representation *rep, const std::l
                 if((unsigned)rep->getStreamFormat() == StreamFormat::UNKNOWN)
                     setFormatFromExtension(rep, uritag->getValue().value);
 
+                /* Need to use EXTXTARGETDURATION as default as some can't properly set segment one */
+                double duration = rep->targetDuration;
                 if(ctx_extinf)
                 {
-                    const Attribute *attribute = ctx_extinf->getAttributeByName("DURATION");
-                    if(attribute)
-                    {
-                        const double duration = attribute->floatingPoint();
-                        const mtime_t nzDuration = CLOCK_FREQ * duration;
-                        segment->duration.Set(duration * (uint64_t) rep->getTimescale());
-                        segment->startTime.Set(rep->getTimescale().ToScaled(nzStartTime));
-                        nzStartTime += nzDuration;
-                        totalduration += nzDuration;
-
-                        if(absReferenceTime > VLC_TS_INVALID)
-                        {
-                            segment->utcTime = absReferenceTime;
-                            absReferenceTime += nzDuration;
-                        }
-                    }
+                    const Attribute *durAttribute = ctx_extinf->getAttributeByName("DURATION");
+                    if(durAttribute)
+                        duration = durAttribute->floatingPoint();
                     ctx_extinf = NULL;
                 }
+                const mtime_t nzDuration = CLOCK_FREQ * duration;
+                segment->duration.Set(duration * (uint64_t) rep->getTimescale());
+                segment->startTime.Set(rep->getTimescale().ToScaled(nzStartTime));
+                nzStartTime += nzDuration;
+                totalduration += nzDuration;
+                if(absReferenceTime > VLC_TS_INVALID)
+                {
+                    segment->utcTime = absReferenceTime;
+                    absReferenceTime += nzDuration;
+                }
 
                 segmentList->addSegment(segment);
 



More information about the vlc-commits mailing list