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`240p`
26 label: $localize`360p`
30 label: $localize`480p`
34 label: $localize`720p`
38 label: $localize`1080p`
42 label: $localize`1440p`
46 label: $localize`2160p`
51 getLiveResolutions () {
52 return this.getVODResolutions().filter(r => r.id !== '0p')
55 isTranscodingEnabled (form: FormGroup) {
56 return form.value['transcoding']['enabled'] === true
59 isLiveEnabled (form: FormGroup) {
60 return form.value['live']['enabled'] === true
63 isLiveTranscodingEnabled (form: FormGroup) {
64 return form.value['live']['transcoding']['enabled'] === true
67 getTotalTranscodingThreads (form: FormGroup) {
68 const transcodingEnabled = form.value['transcoding']['enabled']
69 const transcodingThreads = form.value['transcoding']['threads']
70 const liveTranscodingEnabled = form.value['live']['transcoding']['enabled']
71 const liveTranscodingThreads = form.value['live']['transcoding']['threads']
73 // checks whether all enabled method are on fixed values and not on auto (= 0)
74 let noneOnAuto = !transcodingEnabled || +transcodingThreads > 0
75 noneOnAuto &&= !liveTranscodingEnabled || +liveTranscodingThreads > 0
77 // count total of fixed value, repalcing auto by a single thread (knowing it will display "at least")
79 if (transcodingEnabled) value += +transcodingThreads || 1
80 if (liveTranscodingEnabled) value += +liveTranscodingThreads || 1
84 atMost: noneOnAuto, // auto switches everything to a least estimation since ffmpeg will take as many threads as possible