1 import { VideoFile } from '@shared/models'
3 function toTitleCase (str: string) {
4 return str.charAt(0).toUpperCase() + str.slice(1)
7 // https://github.com/danrevah/ngx-pipes/blob/master/src/pipes/math/bytes.ts
8 // Don't import all Angular stuff, just copy the code with shame
9 const dictionaryBytes: Array<{max: number, type: string}> = [
10 { max: 1024, type: 'B' },
11 { max: 1048576, type: 'KB' },
12 { max: 1073741824, type: 'MB' },
13 { max: 1.0995116e12, type: 'GB' }
15 function bytes (value: number) {
16 const format = dictionaryBytes.find(d => value < d.max) || dictionaryBytes[dictionaryBytes.length - 1]
17 const calc = Math.floor(value / (format.max / 1024)).toString()
19 return [ calc, format.type ]
22 function videoFileMaxByResolution (files: VideoFile[]) {
25 for (let i = 1; i < files.length; i++) {
27 if (max.resolution.id < file.resolution.id) max = file
33 function videoFileMinByResolution (files: VideoFile[]) {
36 for (let i = 1; i < files.length; i++) {
38 if (min.resolution.id > file.resolution.id) min = file
44 function getRtcConfig () {
48 urls: 'stun:stun.stunprotocol.org'
51 urls: 'stun:stun.framasoft.org'
57 // ---------------------------------------------------------------------------
63 videoFileMaxByResolution,
64 videoFileMinByResolution,