blob: 069eeba12ff860243e1d99461f7871e2a24ce3ff (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
import { Component, Input, OnInit } from '@angular/core'
import { ServerService } from '@app/core'
import { HTMLServerConfig, VideoResolution } from '@shared/models/index'
@Component({
selector: 'my-user-real-quota-info',
templateUrl: './user-real-quota-info.component.html',
styleUrls: [ './user-real-quota-info.component.scss' ]
})
export class UserRealQuotaInfoComponent implements OnInit {
@Input() videoQuota: number | string
private serverConfig: HTMLServerConfig
constructor (private server: ServerService) { }
ngOnInit () {
this.serverConfig = this.server.getHTMLConfig()
}
isTranscodingInformationDisplayed () {
return this.serverConfig.transcoding.enabledResolutions.length !== 0 && this.getQuotaAsNumber() > 0
}
computeQuotaWithTranscoding () {
const transcodingConfig = this.serverConfig.transcoding
const resolutions = transcodingConfig.enabledResolutions
const higherResolution = VideoResolution.H_4K
let multiplier = 0
for (const resolution of resolutions) {
multiplier += resolution / higherResolution
}
if (transcodingConfig.hls.enabled) multiplier *= 2
return multiplier * this.getQuotaAsNumber()
}
private getQuotaAsNumber () {
return parseInt(this.videoQuota + '', 10)
}
}
|