]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+admin/config/edit-custom-config/edit-live-configuration.component.ts
3328d28a9502f51372eed3ae1aeeb93fb2d4ff36
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / config / edit-custom-config / edit-live-configuration.component.ts
1
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'
8
9 @Component({
10 selector: 'my-edit-live-configuration',
11 templateUrl: './edit-live-configuration.component.html',
12 styleUrls: [ './edit-custom-config.component.scss' ]
13 })
14 export class EditLiveConfigurationComponent implements OnInit {
15 @Input() form: FormGroup
16 @Input() formErrors: any
17 @Input() serverConfig: ServerConfig
18
19 transcodingThreadOptions: SelectOptionsItem[] = []
20 liveMaxDurationOptions: SelectOptionsItem[] = []
21 liveResolutions: ResolutionOption[] = []
22
23 constructor (
24 private configService: ConfigService,
25 private editConfigurationService: EditConfigurationService
26 ) { }
27
28 ngOnInit () {
29 this.transcodingThreadOptions = this.configService.transcodingThreadOptions
30
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` }
37 ]
38
39 this.liveResolutions = this.editConfigurationService.getLiveResolutions()
40 }
41
42 getAvailableTranscodingProfile () {
43 const profiles = this.serverConfig.live.transcoding.availableProfiles
44
45 return profiles.map(p => {
46 const description = p === 'default'
47 ? $localize`x264, targeting maximum device compatibility`
48 : ''
49
50 return { id: p, label: p, description }
51 })
52 }
53
54 getResolutionKey (resolution: string) {
55 return 'live.transcoding.resolutions.' + resolution
56 }
57
58 getLiveRTMPPort () {
59 return this.serverConfig.live.rtmp.port
60 }
61
62 isLiveEnabled () {
63 return this.editConfigurationService.isLiveEnabled(this.form)
64 }
65
66 getDisabledLiveClass () {
67 return { 'disabled-checkbox-extra': !this.isLiveEnabled() }
68 }
69
70 getDisabledLiveTranscodingClass () {
71 return { 'disabled-checkbox-extra': !this.isLiveEnabled() || !this.isLiveTranscodingEnabled() }
72 }
73
74 isLiveTranscodingEnabled () {
75 return this.editConfigurationService.isLiveTranscodingEnabled(this.form)
76 }
77
78 getTotalTranscodingThreads () {
79 return this.editConfigurationService.getTotalTranscodingThreads(this.form)
80 }
81 }