2 import { SelectOptionsItem } from 'src/types/select-options-item.model'
3 import { Component, Input, OnInit } from '@angular/core'
4 import { FormGroup } from '@angular/forms'
5 import { ServerConfig } from '@shared/models'
6 import { ConfigService } from '../shared/config.service'
7 import { EditConfigurationService, ResolutionOption } from './edit-configuration.service'
10 selector: 'my-edit-live-configuration',
11 templateUrl: './edit-live-configuration.component.html',
12 styleUrls: [ './edit-custom-config.component.scss' ]
14 export class EditLiveConfigurationComponent implements OnInit {
15 @Input() form: FormGroup
16 @Input() formErrors: any
17 @Input() serverConfig: ServerConfig
19 transcodingThreadOptions: SelectOptionsItem[] = []
20 liveMaxDurationOptions: SelectOptionsItem[] = []
21 liveResolutions: ResolutionOption[] = []
24 private configService: ConfigService,
25 private editConfigurationService: EditConfigurationService
29 this.transcodingThreadOptions = this.configService.transcodingThreadOptions
31 this.liveMaxDurationOptions = [
32 { id: -1, label: $localize`No limit` },
33 { id: 1000 * 3600, label: $localize`1 hour` },
34 { id: 1000 * 3600 * 3, label: $localize`3 hours` },
35 { id: 1000 * 3600 * 5, label: $localize`5 hours` },
36 { id: 1000 * 3600 * 10, label: $localize`10 hours` }
39 this.liveResolutions = this.editConfigurationService.getLiveResolutions()
42 getAvailableTranscodingProfile () {
43 const profiles = this.serverConfig.live.transcoding.availableProfiles
45 return profiles.map(p => {
46 const description = p === 'default'
47 ? $localize`x264, targeting maximum device compatibility`
50 return { id: p, label: p, description }
54 getResolutionKey (resolution: string) {
55 return 'live.transcoding.resolutions.' + resolution
59 return this.serverConfig.live.rtmp.port
63 return this.editConfigurationService.isLiveEnabled(this.form)
66 getDisabledLiveClass () {
67 return { 'disabled-checkbox-extra': !this.isLiveEnabled() }
70 getDisabledLiveTranscodingClass () {
71 return { 'disabled-checkbox-extra': !this.isLiveEnabled() || !this.isLiveTranscodingEnabled() }
74 isLiveTranscodingEnabled () {
75 return this.editConfigurationService.isLiveTranscodingEnabled(this.form)
78 getTotalTranscodingThreads () {
79 return this.editConfigurationService.getTotalTranscodingThreads(this.form)