]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+admin/config/edit-custom-config/edit-live-configuration.component.ts
Migrate to bootstrap 5
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / config / edit-custom-config / edit-live-configuration.component.ts
CommitLineData
5f46d28c
C
1
2import { SelectOptionsItem } from 'src/types/select-options-item.model'
b06f1ead 3import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'
5f46d28c 4import { FormGroup } from '@angular/forms'
2989628b 5import { HTMLServerConfig } from '@shared/models'
5f46d28c
C
6import { ConfigService } from '../shared/config.service'
7import { 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 14export 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
C
53 return profiles.map(p => {
54 const description = p === 'default'
55 ? $localize`x264, targeting maximum device compatibility`
56 : ''
57
58 return { id: p, label: p, description }
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
70e33515
C
74 getDisabledLiveClass () {
75 return { 'disabled-checkbox-extra': !this.isLiveEnabled() }
76 }
77
78 getDisabledLiveTranscodingClass () {
79 return { 'disabled-checkbox-extra': !this.isLiveEnabled() || !this.isLiveTranscodingEnabled() }
80 }
81
5f46d28c
C
82 isLiveTranscodingEnabled () {
83 return this.editConfigurationService.isLiveTranscodingEnabled(this.form)
84 }
85
86 getTotalTranscodingThreads () {
87 return this.editConfigurationService.getTotalTranscodingThreads(this.form)
88 }
89}