1 import { Injectable } from '@angular/core'
2 import { FormGroup } from '@angular/forms'
4 export type ResolutionOption = {
11 export class EditConfigurationService {
13 getVODResolutions () {
17 label: $localize`Audio-only`,
18 description: $localize`A <code>.mp4</code> that keeps the original audio track, with no video`
22 label: $localize`144p`
26 label: $localize`240p`
30 label: $localize`360p`
34 label: $localize`480p`
38 label: $localize`720p`
42 label: $localize`1080p`
46 label: $localize`1440p`
50 label: $localize`2160p`
55 getLiveResolutions () {
56 return this.getVODResolutions().filter(r => r.id !== '0p')
59 isTranscodingEnabled (form: FormGroup) {
60 return form.value['transcoding']['enabled'] === true
63 isLiveEnabled (form: FormGroup) {
64 return form.value['live']['enabled'] === true
67 isLiveTranscodingEnabled (form: FormGroup) {
68 return form.value['live']['transcoding']['enabled'] === true
71 getTotalTranscodingThreads (form: FormGroup) {
72 const transcodingEnabled = form.value['transcoding']['enabled']
73 const transcodingThreads = form.value['transcoding']['threads']
74 const liveTranscodingEnabled = form.value['live']['transcoding']['enabled']
75 const liveTranscodingThreads = form.value['live']['transcoding']['threads']
77 // checks whether all enabled method are on fixed values and not on auto (= 0)
78 let noneOnAuto = !transcodingEnabled || +transcodingThreads > 0
79 noneOnAuto &&= !liveTranscodingEnabled || +liveTranscodingThreads > 0
81 // count total of fixed value, repalcing auto by a single thread (knowing it will display "at least")
83 if (transcodingEnabled) value += +transcodingThreads || 1
84 if (liveTranscodingEnabled) value += +liveTranscodingThreads || 1
88 atMost: noneOnAuto, // auto switches everything to a least estimation since ffmpeg will take as many threads as possible