File tree Expand file tree Collapse file tree 2 files changed +34
-8
lines changed Expand file tree Collapse file tree 2 files changed +34
-8
lines changed Original file line number Diff line number Diff line change 5
5
import { sumDurations , getPartsAndSegments } from './playlist' ;
6
6
import videojs from 'video.js' ;
7
7
import logger from './util/logger' ;
8
- import MediaSequenceSync from './util/media-sequence-sync' ;
8
+ import { MediaSequenceSync , DependantMediaSequenceSync } from './util/media-sequence-sync' ;
9
9
10
10
// The maximum gap allowed between two media sequence tags when trying to
11
11
// synchronize expired playlist segments.
@@ -233,11 +233,11 @@ export default class SyncController extends videojs.EventTarget {
233
233
// For some reason this map helps with syncing between quality switch for MPEG-DASH as well.
234
234
// Moreover if we disable this map for MPEG-DASH - quality switch will be broken.
235
235
// MPEG-DASH should have its own separate sync strategy
236
- this . mediaSequenceStorage_ = {
237
- main : new MediaSequenceSync ( ) ,
238
- audio : new MediaSequenceSync ( ) ,
239
- vtt : new MediaSequenceSync ( )
240
- } ;
236
+ const main = new MediaSequenceSync ( ) ;
237
+ const audio = new DependantMediaSequenceSync ( main ) ;
238
+ const vtt = new DependantMediaSequenceSync ( main ) ;
239
+
240
+ this . mediaSequenceStorage_ = { main , audio , vtt } ;
241
241
this . logger_ = logger ( 'SyncController' ) ;
242
242
}
243
243
Original file line number Diff line number Diff line change @@ -79,11 +79,11 @@ class SyncInfoData {
79
79
}
80
80
}
81
81
82
- export default class MediaSequenceSync {
82
+ export class MediaSequenceSync {
83
83
constructor ( ) {
84
84
/**
85
85
* @type {Map<number, SyncInfoData> }
86
- * @private
86
+ * @protected
87
87
*/
88
88
this . storage_ = new Map ( ) ;
89
89
this . diagnostics_ = '' ;
@@ -160,6 +160,10 @@ export default class MediaSequenceSync {
160
160
return null ;
161
161
}
162
162
163
+ getSyncInfoForMediaSequence ( mediaSequence ) {
164
+ return this . storage_ . get ( mediaSequence ) ;
165
+ }
166
+
163
167
updateStorage_ ( segments , startingMediaSequence , startingTime ) {
164
168
const newStorage = new Map ( ) ;
165
169
let newDiagnostics = '\n' ;
@@ -244,3 +248,25 @@ export default class MediaSequenceSync {
244
248
return mediaSequence !== undefined && mediaSequence !== null && Array . isArray ( segments ) && segments . length ;
245
249
}
246
250
}
251
+
252
+ export class DependantMediaSequenceSync extends MediaSequenceSync {
253
+ constructor ( parent ) {
254
+ super ( ) ;
255
+
256
+ this . parent_ = parent ;
257
+ }
258
+
259
+ calculateBaseTime_ ( mediaSequence , fallback ) {
260
+ if ( ! this . storage_ . size ) {
261
+ const info = this . parent_ . getSyncInfoForMediaSequence ( mediaSequence ) ;
262
+
263
+ if ( info ) {
264
+ return info . segmentSyncInfo . start ;
265
+ }
266
+
267
+ return 0 ;
268
+ }
269
+
270
+ return super . calculateBaseTime_ ( mediaSequence , fallback ) ;
271
+ }
272
+ }
You can’t perform that action at this time.
0 commit comments