aboutsummaryrefslogblamecommitdiffhomepage
path: root/client/src/assets/player/p2p-media-loader/segment-url-builder.ts
blob: 5ddc81ff6d55528987cc7ad7a086e2381dc5f5f4 (plain) (tree)
1
2
3
4
5
6
7
8
9
                                                         
                                                               
 
                                                                                                                  
                                                     


                                                                        
                                                     







                                                                              
import { Segment } from '@peertube/p2p-media-loader-core'
import { RedundancyUrlManager } from './redundancy-url-manager'

function segmentUrlBuilderFactory (redundancyUrlManager: RedundancyUrlManager, requiredSegmentsPriority: number) {
  return function segmentBuilder (segment: Segment) {
    // Don't use redundancy for high priority segments
    if (segment.priority <= requiredSegmentsPriority) return segment.url

    return redundancyUrlManager.buildUrl(segment.url)
  }
}

// ---------------------------------------------------------------------------

export {
  segmentUrlBuilderFactory
}