2021-02-10 10:06:32 +00:00
|
|
|
|
|
|
|
import { SelectOptionsItem } from 'src/types/select-options-item.model'
|
2021-04-08 12:41:15 +00:00
|
|
|
import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'
|
2021-02-10 10:06:32 +00:00
|
|
|
import { FormGroup } from '@angular/forms'
|
2021-06-04 11:31:41 +00:00
|
|
|
import { HTMLServerConfig } from '@shared/models'
|
2021-02-10 10:06:32 +00:00
|
|
|
import { ConfigService } from '../shared/config.service'
|
|
|
|
import { EditConfigurationService, ResolutionOption } from './edit-configuration.service'
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'my-edit-vod-transcoding',
|
|
|
|
templateUrl: './edit-vod-transcoding.component.html',
|
|
|
|
styleUrls: [ './edit-custom-config.component.scss' ]
|
|
|
|
})
|
2021-04-08 12:41:15 +00:00
|
|
|
export class EditVODTranscodingComponent implements OnInit, OnChanges {
|
2021-02-10 10:06:32 +00:00
|
|
|
@Input() form: FormGroup
|
|
|
|
@Input() formErrors: any
|
2021-06-04 11:31:41 +00:00
|
|
|
@Input() serverConfig: HTMLServerConfig
|
2021-02-10 10:06:32 +00:00
|
|
|
|
|
|
|
transcodingThreadOptions: SelectOptionsItem[] = []
|
2021-04-08 12:41:15 +00:00
|
|
|
transcodingProfiles: SelectOptionsItem[] = []
|
2021-02-10 10:06:32 +00:00
|
|
|
resolutions: ResolutionOption[] = []
|
|
|
|
|
2021-04-27 07:24:36 +00:00
|
|
|
additionalVideoExtensions = ''
|
|
|
|
|
2021-02-10 10:06:32 +00:00
|
|
|
constructor (
|
|
|
|
private configService: ConfigService,
|
|
|
|
private editConfigurationService: EditConfigurationService
|
|
|
|
) { }
|
|
|
|
|
|
|
|
ngOnInit () {
|
|
|
|
this.transcodingThreadOptions = this.configService.transcodingThreadOptions
|
|
|
|
this.resolutions = this.editConfigurationService.getVODResolutions()
|
|
|
|
|
|
|
|
this.checkTranscodingFields()
|
|
|
|
}
|
|
|
|
|
2021-04-08 12:41:15 +00:00
|
|
|
ngOnChanges (changes: SimpleChanges) {
|
|
|
|
if (changes['serverConfig']) {
|
|
|
|
this.transcodingProfiles = this.buildAvailableTranscodingProfile()
|
2021-04-27 07:24:36 +00:00
|
|
|
|
|
|
|
this.additionalVideoExtensions = this.serverConfig.video.file.extensions.join(' ')
|
2021-04-08 12:41:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
buildAvailableTranscodingProfile () {
|
2021-02-10 10:06:32 +00:00
|
|
|
const profiles = this.serverConfig.transcoding.availableProfiles
|
|
|
|
|
2021-02-10 10:27:36 +00:00
|
|
|
return profiles.map(p => {
|
|
|
|
const description = p === 'default'
|
|
|
|
? $localize`x264, targeting maximum device compatibility`
|
|
|
|
: ''
|
|
|
|
|
|
|
|
return { id: p, label: p, description }
|
|
|
|
})
|
2021-02-10 10:06:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
getResolutionKey (resolution: string) {
|
|
|
|
return 'transcoding.resolutions.' + resolution
|
|
|
|
}
|
|
|
|
|
|
|
|
isTranscodingEnabled () {
|
|
|
|
return this.editConfigurationService.isTranscodingEnabled(this.form)
|
|
|
|
}
|
|
|
|
|
2021-02-10 10:27:36 +00:00
|
|
|
getTranscodingDisabledClass () {
|
|
|
|
return { 'disabled-checkbox-extra': !this.isTranscodingEnabled() }
|
|
|
|
}
|
|
|
|
|
2021-02-10 10:06:32 +00:00
|
|
|
getTotalTranscodingThreads () {
|
|
|
|
return this.editConfigurationService.getTotalTranscodingThreads(this.form)
|
|
|
|
}
|
|
|
|
|
|
|
|
private checkTranscodingFields () {
|
|
|
|
const hlsControl = this.form.get('transcoding.hls.enabled')
|
|
|
|
const webtorrentControl = this.form.get('transcoding.webtorrent.enabled')
|
|
|
|
|
|
|
|
webtorrentControl.valueChanges
|
|
|
|
.subscribe(newValue => {
|
|
|
|
if (newValue === false && !hlsControl.disabled) {
|
|
|
|
hlsControl.disable()
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newValue === true && !hlsControl.enabled) {
|
|
|
|
hlsControl.enable()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
hlsControl.valueChanges
|
|
|
|
.subscribe(newValue => {
|
|
|
|
if (newValue === false && !webtorrentControl.disabled) {
|
|
|
|
webtorrentControl.disable()
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newValue === true && !webtorrentControl.enabled) {
|
|
|
|
webtorrentControl.enable()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|