mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-05-16 20:02:40 +00:00
3a4992633e
Sorry for the very big commit that may lead to git log issues and merge conflicts, but it's a major step forward: * Server can be faster at startup because imports() are async and we can easily lazy import big modules * Angular doesn't seem to support ES import (with .js extension), so we had to correctly organize peertube into a monorepo: * Use yarn workspace feature * Use typescript reference projects for dependencies * Shared projects have been moved into "packages", each one is now a node module (with a dedicated package.json/tsconfig.json) * server/tools have been moved into apps/ and is now a dedicated app bundled and published on NPM so users don't have to build peertube cli tools manually * server/tests have been moved into packages/ so we don't compile them every time we want to run the server * Use isolatedModule option: * Had to move from const enum to const (https://www.typescriptlang.org/docs/handbook/enums.html#objects-vs-enums) * Had to explictely specify "type" imports when used in decorators * Prefer tsx (that uses esbuild under the hood) instead of ts-node to load typescript files (tests with mocha or scripts): * To reduce test complexity as esbuild doesn't support decorator metadata, we only test server files that do not import server models * We still build tests files into js files for a faster CI * Remove unmaintained peertube CLI import script * Removed some barrels to speed up execution (less imports)
98 lines
3.1 KiB
TypeScript
98 lines
3.1 KiB
TypeScript
|
|
import { SelectOptionsItem } from 'src/types/select-options-item.model'
|
|
import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'
|
|
import { FormGroup } from '@angular/forms'
|
|
import { HTMLServerConfig } from '@peertube/peertube-models'
|
|
import { ConfigService } from '../shared/config.service'
|
|
import { EditConfigurationService, ResolutionOption } from './edit-configuration.service'
|
|
|
|
@Component({
|
|
selector: 'my-edit-live-configuration',
|
|
templateUrl: './edit-live-configuration.component.html',
|
|
styleUrls: [ './edit-custom-config.component.scss' ]
|
|
})
|
|
export class EditLiveConfigurationComponent implements OnInit, OnChanges {
|
|
@Input() form: FormGroup
|
|
@Input() formErrors: any
|
|
@Input() serverConfig: HTMLServerConfig
|
|
|
|
transcodingThreadOptions: SelectOptionsItem[] = []
|
|
transcodingProfiles: SelectOptionsItem[] = []
|
|
|
|
liveMaxDurationOptions: SelectOptionsItem[] = []
|
|
liveResolutions: ResolutionOption[] = []
|
|
|
|
constructor (
|
|
private configService: ConfigService,
|
|
private editConfigurationService: EditConfigurationService
|
|
) { }
|
|
|
|
ngOnInit () {
|
|
this.transcodingThreadOptions = this.configService.transcodingThreadOptions
|
|
|
|
this.liveMaxDurationOptions = [
|
|
{ id: -1, label: $localize`No limit` },
|
|
{ id: 1000 * 3600, label: $localize`1 hour` },
|
|
{ id: 1000 * 3600 * 3, label: $localize`3 hours` },
|
|
{ id: 1000 * 3600 * 5, label: $localize`5 hours` },
|
|
{ id: 1000 * 3600 * 10, label: $localize`10 hours` }
|
|
]
|
|
|
|
this.liveResolutions = this.editConfigurationService.getLiveResolutions()
|
|
}
|
|
|
|
ngOnChanges (changes: SimpleChanges) {
|
|
if (changes['serverConfig']) {
|
|
this.transcodingProfiles = this.buildAvailableTranscodingProfile()
|
|
}
|
|
}
|
|
|
|
buildAvailableTranscodingProfile () {
|
|
const profiles = this.serverConfig.live.transcoding.availableProfiles
|
|
|
|
return profiles.map(p => {
|
|
if (p === 'default') {
|
|
return { id: p, label: $localize`Default`, description: $localize`x264, targeting maximum device compatibility` }
|
|
}
|
|
|
|
return { id: p, label: p }
|
|
})
|
|
}
|
|
|
|
getResolutionKey (resolution: string) {
|
|
return 'live.transcoding.resolutions.' + resolution
|
|
}
|
|
|
|
getLiveRTMPPort () {
|
|
return this.serverConfig.live.rtmp.port
|
|
}
|
|
|
|
isLiveEnabled () {
|
|
return this.editConfigurationService.isLiveEnabled(this.form)
|
|
}
|
|
|
|
isRemoteRunnerLiveEnabled () {
|
|
return this.editConfigurationService.isRemoteRunnerLiveEnabled(this.form)
|
|
}
|
|
|
|
getDisabledLiveClass () {
|
|
return { 'disabled-checkbox-extra': !this.isLiveEnabled() }
|
|
}
|
|
|
|
getDisabledLiveTranscodingClass () {
|
|
return { 'disabled-checkbox-extra': !this.isLiveEnabled() || !this.isLiveTranscodingEnabled() }
|
|
}
|
|
|
|
getDisabledLiveLocalTranscodingClass () {
|
|
return { 'disabled-checkbox-extra': !this.isLiveEnabled() || !this.isLiveTranscodingEnabled() || this.isRemoteRunnerLiveEnabled() }
|
|
}
|
|
|
|
isLiveTranscodingEnabled () {
|
|
return this.editConfigurationService.isLiveTranscodingEnabled(this.form)
|
|
}
|
|
|
|
getTotalTranscodingThreads () {
|
|
return this.editConfigurationService.getTotalTranscodingThreads(this.form)
|
|
}
|
|
}
|