]>
Commit | Line | Data |
---|---|---|
5f46d28c C |
1 | |
2 | import { SelectOptionsItem } from 'src/types/select-options-item.model' | |
b06f1ead | 3 | import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core' |
5f46d28c | 4 | import { FormGroup } from '@angular/forms' |
2989628b | 5 | import { HTMLServerConfig } from '@shared/models' |
5f46d28c C |
6 | import { ConfigService } from '../shared/config.service' |
7 | import { EditConfigurationService, ResolutionOption } from './edit-configuration.service' | |
8 | ||
9 | @Component({ | |
10 | selector: 'my-edit-live-configuration', | |
11 | templateUrl: './edit-live-configuration.component.html', | |
12 | styleUrls: [ './edit-custom-config.component.scss' ] | |
13 | }) | |
b06f1ead | 14 | export class EditLiveConfigurationComponent implements OnInit, OnChanges { |
5f46d28c C |
15 | @Input() form: FormGroup |
16 | @Input() formErrors: any | |
2989628b | 17 | @Input() serverConfig: HTMLServerConfig |
5f46d28c C |
18 | |
19 | transcodingThreadOptions: SelectOptionsItem[] = [] | |
b06f1ead C |
20 | transcodingProfiles: SelectOptionsItem[] = [] |
21 | ||
5f46d28c C |
22 | liveMaxDurationOptions: SelectOptionsItem[] = [] |
23 | liveResolutions: ResolutionOption[] = [] | |
24 | ||
25 | constructor ( | |
26 | private configService: ConfigService, | |
27 | private editConfigurationService: EditConfigurationService | |
28 | ) { } | |
29 | ||
30 | ngOnInit () { | |
31 | this.transcodingThreadOptions = this.configService.transcodingThreadOptions | |
32 | ||
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` } | |
39 | ] | |
40 | ||
41 | this.liveResolutions = this.editConfigurationService.getLiveResolutions() | |
42 | } | |
43 | ||
b06f1ead C |
44 | ngOnChanges (changes: SimpleChanges) { |
45 | if (changes['serverConfig']) { | |
46 | this.transcodingProfiles = this.buildAvailableTranscodingProfile() | |
47 | } | |
48 | } | |
49 | ||
50 | buildAvailableTranscodingProfile () { | |
5f46d28c C |
51 | const profiles = this.serverConfig.live.transcoding.availableProfiles |
52 | ||
70e33515 | 53 | return profiles.map(p => { |
b99ee1b1 C |
54 | if (p === 'default') { |
55 | return { id: p, label: $localize`Default`, description: $localize`x264, targeting maximum device compatibility` } | |
56 | } | |
70e33515 | 57 | |
b99ee1b1 | 58 | return { id: p, label: p } |
70e33515 | 59 | }) |
5f46d28c C |
60 | } |
61 | ||
62 | getResolutionKey (resolution: string) { | |
63 | return 'live.transcoding.resolutions.' + resolution | |
64 | } | |
65 | ||
66 | getLiveRTMPPort () { | |
67 | return this.serverConfig.live.rtmp.port | |
68 | } | |
69 | ||
70 | isLiveEnabled () { | |
71 | return this.editConfigurationService.isLiveEnabled(this.form) | |
72 | } | |
73 | ||
01283e20 C |
74 | isRemoteRunnerLiveEnabled () { |
75 | return this.editConfigurationService.isRemoteRunnerLiveEnabled(this.form) | |
76 | } | |
77 | ||
70e33515 C |
78 | getDisabledLiveClass () { |
79 | return { 'disabled-checkbox-extra': !this.isLiveEnabled() } | |
80 | } | |
81 | ||
82 | getDisabledLiveTranscodingClass () { | |
83 | return { 'disabled-checkbox-extra': !this.isLiveEnabled() || !this.isLiveTranscodingEnabled() } | |
84 | } | |
85 | ||
01283e20 C |
86 | getDisabledLiveLocalTranscodingClass () { |
87 | return { 'disabled-checkbox-extra': !this.isLiveEnabled() || !this.isLiveTranscodingEnabled() || this.isRemoteRunnerLiveEnabled() } | |
88 | } | |
89 | ||
5f46d28c C |
90 | isLiveTranscodingEnabled () { |
91 | return this.editConfigurationService.isLiveTranscodingEnabled(this.form) | |
92 | } | |
93 | ||
94 | getTotalTranscodingThreads () { | |
95 | return this.editConfigurationService.getTotalTranscodingThreads(this.form) | |
96 | } | |
97 | } |