@@ -22,7 +22,7 @@ if (!Number.MAX_SAFE_INTEGER) {
2222Mss . dependencies . MssParser = function ( ) {
2323 "use strict" ;
2424
25- var TIME_SCALE_100_NANOSECOND_UNIT = 10000000.0 ,
25+ var DEFAULT_TIME_SCALE = 10000000.0 ,
2626 SUPPORTED_CODECS = [ "AAC" , "AACL" , "AVC1" , "H264" , "TTML" , "DFXP" ] ,
2727 samplingFrequencyIndex = {
2828 96000 : 0x0 ,
@@ -47,7 +47,7 @@ Mss.dependencies.MssParser = function() {
4747 xmlDoc = null ,
4848 baseURL = null ,
4949
50- mapPeriod = function ( ) {
50+ mapPeriod = function ( timescale ) {
5151 var period = { } ,
5252 adaptations = [ ] ,
5353 adaptation ,
@@ -59,7 +59,7 @@ Mss.dependencies.MssParser = function() {
5959 // For each StreamIndex node, create an AdaptationSet element
6060 for ( i = 0 ; i < smoothNode . childNodes . length ; i ++ ) {
6161 if ( smoothNode . childNodes [ i ] . nodeName === "StreamIndex" ) {
62- adaptation = mapAdaptationSet . call ( this , smoothNode . childNodes [ i ] ) ;
62+ adaptation = mapAdaptationSet . call ( this , smoothNode . childNodes [ i ] , timescale ) ;
6363 if ( adaptation !== null ) {
6464 adaptations . push ( adaptation ) ;
6565 }
@@ -74,7 +74,7 @@ Mss.dependencies.MssParser = function() {
7474 return period ;
7575 } ,
7676
77- mapAdaptationSet = function ( streamIndex ) {
77+ mapAdaptationSet = function ( streamIndex , timescale ) {
7878
7979 var adaptationSet = { } ,
8080 representations = [ ] ,
@@ -98,7 +98,7 @@ Mss.dependencies.MssParser = function() {
9898 }
9999
100100 // Create a SegmentTemplate with a SegmentTimeline
101- segmentTemplate = mapSegmentTemplate . call ( this , streamIndex ) ;
101+ segmentTemplate = mapSegmentTemplate . call ( this , streamIndex , timescale ) ;
102102
103103 qualityLevels = this . domParser . getChildNodes ( streamIndex , "QualityLevel" ) ;
104104 // For each QualityLevel node, create a Representation element
@@ -265,7 +265,7 @@ Mss.dependencies.MssParser = function() {
265265 return "mp4a.40." + objectType ;
266266 } ,
267267
268- mapSegmentTemplate = function ( streamIndex ) {
268+ mapSegmentTemplate = function ( streamIndex , timescale ) {
269269
270270 var segmentTemplate = { } ,
271271 mediaUrl ;
@@ -274,14 +274,14 @@ Mss.dependencies.MssParser = function() {
274274 mediaUrl = mediaUrl . replace ( '{start time}' , '$Time$' ) ;
275275
276276 segmentTemplate . media = mediaUrl ;
277- segmentTemplate . timescale = TIME_SCALE_100_NANOSECOND_UNIT ;
277+ segmentTemplate . timescale = timescale ;
278278
279- segmentTemplate . SegmentTimeline = mapSegmentTimeline . call ( this , streamIndex ) ;
279+ segmentTemplate . SegmentTimeline = mapSegmentTimeline . call ( this , streamIndex , timescale ) ;
280280
281281 return segmentTemplate ;
282282 } ,
283283
284- mapSegmentTimeline = function ( streamIndex ) {
284+ mapSegmentTimeline = function ( streamIndex , timescale ) {
285285
286286 var segmentTimeline = { } ,
287287 chunks = this . domParser . getChildNodes ( streamIndex , "c" ) ,
@@ -361,7 +361,7 @@ Mss.dependencies.MssParser = function() {
361361
362362 segmentTimeline . S = segments ;
363363 segmentTimeline . S_asArray = segments ;
364- segmentTimeline . duration = duration / TIME_SCALE_100_NANOSECOND_UNIT ;
364+ segmentTimeline . duration = duration / timescale ;
365365
366366 return segmentTimeline ;
367367 } ,
@@ -559,22 +559,24 @@ Mss.dependencies.MssParser = function() {
559559 // Set mpd node properties
560560 mpd . name = 'MSS' ;
561561 mpd . profiles = "urn:mpeg:dash:profile:isoff-live:2011" ;
562+ var timescale = this . domParser . getAttributeValue ( smoothNode , 'TimeScale' ) ;
563+ mpd . timescale = timescale ? parseFloat ( timescale ) : DEFAULT_TIME_SCALE ;
562564 var isLive = this . domParser . getAttributeValue ( smoothNode , 'IsLive' ) ;
563565 mpd . type = ( isLive !== null && isLive . toLowerCase ( ) === 'true' ) ? 'dynamic' : 'static' ;
564- mpd . timeShiftBufferDepth = parseFloat ( this . domParser . getAttributeValue ( smoothNode , 'DVRWindowLength' ) ) / TIME_SCALE_100_NANOSECOND_UNIT ;
566+ mpd . timeShiftBufferDepth = parseFloat ( this . domParser . getAttributeValue ( smoothNode , 'DVRWindowLength' ) ) / mpd . timescale ;
565567 var duration = parseFloat ( this . domParser . getAttributeValue ( smoothNode , 'Duration' ) ) ;
566568
567569 // If live manifest with Duration, we consider it as a start-over manifest
568570 if ( mpd . type === "dynamic" && duration > 0 ) {
569571 mpd . type = "static" ;
570572 mpd . startOver = true ;
571573 // We set timeShiftBufferDepth to initial duration, to be used by MssFragmentController to update segment timeline
572- mpd . timeShiftBufferDepth = duration / TIME_SCALE_100_NANOSECOND_UNIT ;
574+ mpd . timeShiftBufferDepth = duration / mpd . timescale ;
573575 // Duration will be set according to current segment timeline duration (see below)
574576 }
575577
576578 // Complete manifest/mpd initialization
577- mpd . mediaPresentationDuration = ( duration === 0 ) ? Infinity : ( duration / TIME_SCALE_100_NANOSECOND_UNIT ) ;
579+ mpd . mediaPresentationDuration = ( duration === 0 ) ? Infinity : ( duration / mpd . timescale ) ;
578580 mpd . BaseURL = baseURL ;
579581 mpd . minBufferTime = MediaPlayer . dependencies . BufferExtensions . DEFAULT_MIN_BUFFER_TIME ;
580582
@@ -584,7 +586,7 @@ Mss.dependencies.MssParser = function() {
584586 }
585587
586588 // Map period node to manifest root node
587- mpd . Period = mapPeriod . call ( this ) ;
589+ mpd . Period = mapPeriod . call ( this , mpd . timescale ) ;
588590 mpd . Period_asArray = [ mpd . Period ] ;
589591
590592 period = mpd . Period ;
@@ -701,7 +703,7 @@ Mss.dependencies.MssParser = function() {
701703 period . start = Math . max ( segments [ 0 ] . t , period . start ) ;
702704 }
703705 }
704- period . start /= TIME_SCALE_100_NANOSECOND_UNIT ;
706+ period . start /= mpd . timescale ;
705707 }
706708 }
707709
0 commit comments