2 import { SelectOptionsItem } from 'src/types/select-options-item.model'
3 import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'
4 import { FormGroup } from '@angular/forms'
5 import { HTMLServerConfig } 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, OnChanges {
15 @Input() form: FormGroup
16 @Input() formErrors: any
17 @Input() serverConfig: HTMLServerConfig
19 transcodingThreadOptions: SelectOptionsItem[] = []
20 transcodingProfiles: SelectOptionsItem[] = []
22 liveMaxDurationOptions: SelectOptionsItem[] = []
23 liveResolutions: ResolutionOption[] = []
26 private configService: ConfigService,
27 private editConfigurationService: EditConfigurationService
31 this.transcodingThreadOptions = this.configService.transcodingThreadOptions
33 this.liveMaxDurationOptions = [
34 { id: -1, label: $localize`No limit` },
35 { id: 1000 * 3600, label: $localize`1 hour` },
36 { id: 1000 * 3600 * 3, label: $localize`3 hours` },
37 { id: 1000 * 3600 * 5, label: $localize`5 hours` },
38 { id: 1000 * 3600 * 10, label: $localize`10 hours` }
41 this.liveResolutions = this.editConfigurationService.getLiveResolutions()
44 ngOnChanges (changes: SimpleChanges) {
45 if (changes['serverConfig']) {
46 this.transcodingProfiles = this.buildAvailableTranscodingProfile()
50 buildAvailableTranscodingProfile () {
51 const profiles = this.serverConfig.live.transcoding.availableProfiles
53 return profiles.map(p => {
54 const description = p === 'default'
55 ? $localize`x264, targeting maximum device compatibility`
58 return { id: p, label: p, description }
62 getResolutionKey (resolution: string) {
63 return 'live.transcoding.resolutions.' + resolution
67 return this.serverConfig.live.rtmp.port
71 return this.editConfigurationService.isLiveEnabled(this.form)
74 getDisabledLiveClass () {
75 return { 'disabled-checkbox-extra': !this.isLiveEnabled() }
78 getDisabledLiveTranscodingClass () {
79 return { 'disabled-checkbox-extra': !this.isLiveEnabled() || !this.isLiveTranscodingEnabled() }
82 isLiveTranscodingEnabled () {
83 return this.editConfigurationService.isLiveTranscodingEnabled(this.form)
86 getTotalTranscodingThreads () {
87 return this.editConfigurationService.getTotalTranscodingThreads(this.form)