]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+admin/config/edit-custom-config/edit-live-configuration.component.ts
Split admin conf page
[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 => ({ id: p, label: p }))
46 }
47
48 getResolutionKey (resolution: string) {
49 return 'live.transcoding.resolutions.' + resolution
50 }
51
52 getLiveRTMPPort () {
53 return this.serverConfig.live.rtmp.port
54 }
55
56 isLiveEnabled () {
57 return this.editConfigurationService.isLiveEnabled(this.form)
58 }
59
60 isLiveTranscodingEnabled () {
61 return this.editConfigurationService.isLiveTranscodingEnabled(this.form)
62 }
63
64 getTotalTranscodingThreads () {
65 return this.editConfigurationService.getTotalTranscodingThreads(this.form)
66 }
67 }