@@ -328,6 +328,7 @@ Mss.dependencies.MssParser = function() {
328328 } else {
329329 prevSegment . d = segment . t - prevSegment . t ;
330330 }
331+ duration += prevSegment . d ;
331332 }
332333 // Set segment absolute timestamp if not set in manifest
333334 if ( ! segment . t ) {
@@ -340,7 +341,9 @@ Mss.dependencies.MssParser = function() {
340341 }
341342 }
342343
343- duration += segment . d ;
344+ if ( segment . d ) {
345+ duration += segment . d ;
346+ }
344347
345348 // Create new segment
346349 segments . push ( segment ) ;
@@ -567,7 +570,12 @@ Mss.dependencies.MssParser = function() {
567570 mpd . timescale = timescale ? parseFloat ( timescale ) : DEFAULT_TIME_SCALE ;
568571 var isLive = this . domParser . getAttributeValue ( smoothNode , 'IsLive' ) ;
569572 mpd . type = ( isLive !== null && isLive . toLowerCase ( ) === 'true' ) ? 'dynamic' : 'static' ;
570- mpd . timeShiftBufferDepth = parseFloat ( this . domParser . getAttributeValue ( smoothNode , 'DVRWindowLength' ) ) / mpd . timescale ;
573+ var canSeek = this . domParser . getAttributeValue ( smoothNode , 'CanSeek' ) ;
574+ var dvrWindowLength = parseFloat ( this . domParser . getAttributeValue ( smoothNode , 'DVRWindowLength' ) ) ;
575+ if ( dvrWindowLength === 0 && canSeek !== null && canSeek . toLowerCase ( ) === 'true' ) {
576+ dvrWindowLength = Infinity ;
577+ }
578+ mpd . timeShiftBufferDepth = dvrWindowLength / mpd . timescale ;
571579 var duration = parseFloat ( this . domParser . getAttributeValue ( smoothNode , 'Duration' ) ) ;
572580
573581 // If live manifest with Duration, we consider it as a start-over manifest
@@ -585,7 +593,7 @@ Mss.dependencies.MssParser = function() {
585593 mpd . minBufferTime = MediaPlayer . dependencies . BufferExtensions . DEFAULT_MIN_BUFFER_TIME ;
586594
587595 // In case of live streams, set availabilityStartTime property according to DVRWindowLength
588- if ( mpd . type === "dynamic" ) {
596+ if ( mpd . type === "dynamic" && mpd . timeShiftBufferDepth < Infinity ) {
589597 mpd . availabilityStartTime = new Date ( manifestLoadedTime . getTime ( ) - ( mpd . timeShiftBufferDepth * 1000 ) ) ;
590598 }
591599
@@ -647,8 +655,13 @@ Mss.dependencies.MssParser = function() {
647655 }
648656
649657 if ( mpd . type === "dynamic" ) {
658+ // set availabilityStartTime for infinite DVR Window from segment timeline duration
659+ if ( mpd . timeShiftBufferDepth === Infinity ) {
660+ mpd . availabilityStartTime = new Date ( manifestLoadedTime . getTime ( ) - ( adaptations [ 1 ] . SegmentTemplate . SegmentTimeline . duration * 1000 ) ) ;
661+ }
650662 // Match timeShiftBufferDepth to video segment timeline duration
651663 if ( mpd . timeShiftBufferDepth > 0 &&
664+ mpd . timeShiftBufferDepth !== Infinity &&
652665 adaptations [ i ] . contentType === 'video' &&
653666 mpd . timeShiftBufferDepth > adaptations [ i ] . SegmentTemplate . SegmentTimeline . duration ) {
654667 mpd . timeShiftBufferDepth = adaptations [ i ] . SegmentTemplate . SegmentTimeline . duration ;
@@ -765,4 +778,4 @@ Mss.dependencies.MssParser = function() {
765778
766779Mss . dependencies . MssParser . prototype = {
767780 constructor : Mss . dependencies . MssParser
768- } ;
781+ } ;
0 commit comments