1 import { Injectable } from '@angular/core'
2 import { FormGroup } from '@angular/forms'
3 import { prepareIcu } from '@app/helpers'
5 export type ResolutionOption = {
12 export class EditConfigurationService {
14 getVODResolutions () {
18 label: $localize`Audio-only`,
19 description: $localize`A <code>.mp4</code> that keeps the original audio track, with no video`
23 label: $localize`144p`
27 label: $localize`240p`
31 label: $localize`360p`
35 label: $localize`480p`
39 label: $localize`720p`
43 label: $localize`1080p`
47 label: $localize`1440p`
51 label: $localize`2160p`
56 getLiveResolutions () {
57 return this.getVODResolutions().filter(r => r.id !== '0p')
60 isTranscodingEnabled (form: FormGroup) {
61 return form.value['transcoding']['enabled'] === true
64 isStudioEnabled (form: FormGroup) {
65 return form.value['videoStudio']['enabled'] === true
68 isLiveEnabled (form: FormGroup) {
69 return form.value['live']['enabled'] === true
72 isLiveTranscodingEnabled (form: FormGroup) {
73 return form.value['live']['transcoding']['enabled'] === true
76 getTotalTranscodingThreads (form: FormGroup) {
77 const transcodingEnabled = form.value['transcoding']['enabled']
78 const transcodingThreads = form.value['transcoding']['threads']
79 const liveTranscodingEnabled = form.value['live']['transcoding']['enabled']
80 const liveTranscodingThreads = form.value['live']['transcoding']['threads']
82 // checks whether all enabled method are on fixed values and not on auto (= 0)
83 let noneOnAuto = !transcodingEnabled || +transcodingThreads > 0
84 noneOnAuto &&= !liveTranscodingEnabled || +liveTranscodingThreads > 0
86 // count total of fixed value, repalcing auto by a single thread (knowing it will display "at least")
88 if (transcodingEnabled) value += +transcodingThreads || 1
89 if (liveTranscodingEnabled) value += +liveTranscodingThreads || 1
93 atMost: noneOnAuto, // auto switches everything to a least estimation since ffmpeg will take as many threads as possible
94 unit: prepareIcu($localize`{value, plural, =1 {thread} other {threads}}`)(