1 import { VideoFile } from '@shared/models'
3 function toTitleCase (str: string) {
4 return str.charAt(0).toUpperCase() + str.slice(1)
7 const dictionaryBytes = [
8 { max: 1024, type: 'B', decimals: 0 },
9 { max: 1048576, type: 'KB', decimals: 0 },
10 { max: 1073741824, type: 'MB', decimals: 0 },
11 { max: 1.0995116e12, type: 'GB', decimals: 1 }
13 function bytes (value: number) {
14 const format = dictionaryBytes.find(d => value < d.max) || dictionaryBytes[dictionaryBytes.length - 1]
15 const calc = (value / (format.max / 1024)).toFixed(format.decimals)
17 return [ calc, format.type ]
20 function videoFileMaxByResolution (files: VideoFile[]) {
23 for (let i = 1; i < files.length; i++) {
25 if (max.resolution.id < file.resolution.id) max = file
31 function videoFileMinByResolution (files: VideoFile[]) {
34 for (let i = 1; i < files.length; i++) {
36 if (min.resolution.id > file.resolution.id) min = file
42 function getRtcConfig () {
46 urls: 'stun:stun.stunprotocol.org'
49 urls: 'stun:stun.framasoft.org'
55 function isSameOrigin (current: string, target: string) {
56 return new URL(current).origin === new URL(target).origin
59 // ---------------------------------------------------------------------------
65 videoFileMaxByResolution,
66 videoFileMinByResolution,