import { forkJoin } from 'rxjs'
import { map } from 'rxjs/operators'
-import { SelectChannelItem } from 'src/types/select-options-item.model'
+import { SelectChannelItem, SelectOptionsItem } from 'src/types/select-options-item.model'
import { ChangeDetectorRef, Component, EventEmitter, Input, NgZone, OnDestroy, OnInit, Output, ViewChild } from '@angular/core'
import { AbstractControl, FormArray, FormControl, FormGroup, Validators } from '@angular/forms'
import { HooksService, PluginService, ServerService } from '@app/core'
} from '@app/shared/form-validators/video-validators'
import { FormReactiveValidationMessages, FormValidatorService } from '@app/shared/shared-forms'
import { InstanceService } from '@app/shared/shared-instance'
-import { VideoCaptionEdit, VideoEdit, VideoService } from '@app/shared/shared-main'
+import { VideoCaptionEdit, VideoCaptionWithPathEdit, VideoEdit, VideoService } from '@app/shared/shared-main'
import { PluginInfo } from '@root-helpers/plugins-manager'
import {
HTMLServerConfig,
LiveVideo,
+ LiveVideoLatencyMode,
RegisterClientFormFieldOptions,
RegisterClientVideoFieldOptions,
VideoConstant,
} from '@shared/models'
import { I18nPrimengCalendarService } from './i18n-primeng-calendar.service'
import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component'
+import { VideoCaptionEditModalComponent } from './video-caption-edit-modal/video-caption-edit-modal.component'
import { VideoEditType } from './video-edit.type'
type VideoLanguages = VideoConstant<string> & { group?: string }
@Input() videoToUpdate: VideoDetails
@Input() userVideoChannels: SelectChannelItem[] = []
- @Input() schedulePublicationPossible = true
+ @Input() forbidScheduledPublication = true
- @Input() videoCaptions: (VideoCaptionEdit & { captionPath?: string })[] = []
+ @Input() videoCaptions: VideoCaptionWithPathEdit[] = []
@Input() waitTranscodingEnabled = true
@Input() type: VideoEditType
@Input() liveVideo: LiveVideo
@ViewChild('videoCaptionAddModal', { static: true }) videoCaptionAddModal: VideoCaptionAddModalComponent
+ @ViewChild('videoCaptionEditModal', { static: true }) editCaptionModal: VideoCaptionEditModalComponent
@Output() formBuilt = new EventEmitter<void>()
@Output() pluginFieldsAdded = new EventEmitter<void>()
videoCategories: VideoConstant<number>[] = []
videoLicences: VideoConstant<number>[] = []
videoLanguages: VideoLanguages[] = []
+ latencyModes: SelectOptionsItem[] = [
+ {
+ id: LiveVideoLatencyMode.SMALL_LATENCY,
+ label: $localize`Small latency`,
+ description: $localize`Reduce latency to ~15s disabling P2P`
+ },
+ {
+ id: LiveVideoLatencyMode.DEFAULT,
+ label: $localize`Default`,
+ description: $localize`Average latency of 30s`
+ },
+ {
+ id: LiveVideoLatencyMode.HIGH_LATENCY,
+ label: $localize`High latency`,
+ description: $localize`Average latency of 60s increasing P2P ratio`
+ }
+ ]
pluginDataFormGroup: FormGroup
originallyPublishedAt: VIDEO_ORIGINALLY_PUBLISHED_AT_VALIDATOR,
liveStreamKey: null,
permanentLive: null,
+ latencyMode: null,
saveReplay: null
}
this.trackChannelChange()
this.trackPrivacyChange()
- this.trackLivePermanentFieldChange()
this.formBuilt.emit()
}
.subscribe(privacies => {
this.videoPrivacies = this.videoService.explainedPrivacyLabels(privacies).videoPrivacies
- if (this.schedulePublicationPossible) {
- this.videoPrivacies.push({
- id: this.SPECIAL_SCHEDULED_PRIVACY,
- label: $localize`Scheduled`,
- description: $localize`Hide the video until a specific date`
- })
- }
+ // Can't schedule publication if private privacy is not available (could be deleted by a plugin)
+ const hasPrivatePrivacy = this.videoPrivacies.some(p => p.id === VideoPrivacy.PRIVATE)
+ if (this.forbidScheduledPublication || !hasPrivatePrivacy) return
+
+ this.videoPrivacies.push({
+ id: this.SPECIAL_SCHEDULED_PRIVACY,
+ label: $localize`Scheduled`,
+ description: $localize`Hide the video until a specific date`
+ })
})
this.initialVideoCaptions = this.videoCaptions.map(c => c.language.id)
.map(c => c.language.id)
}
- onCaptionAdded (caption: VideoCaptionEdit) {
+ onCaptionEdited (caption: VideoCaptionEdit) {
const existingCaption = this.videoCaptions.find(c => c.language.id === caption.language.id)
// Replace existing caption?
if (existingCaption) {
- Object.assign(existingCaption, caption, { action: 'CREATE' as 'CREATE' })
+ Object.assign(existingCaption, caption)
} else {
this.videoCaptions.push(
Object.assign(caption, { action: 'CREATE' as 'CREATE' })
}
// This caption is not on the server, just remove it from our array
- if (caption.action === 'CREATE') {
+ if (caption.action === 'CREATE' || caption.action === 'UPDATE') {
removeElementFromArray(this.videoCaptions, caption)
return
}
return this.form.value['permanentLive'] === true
}
+ isLatencyModeEnabled () {
+ return this.serverConfig.live.latencySetting.enabled
+ }
+
isPluginFieldHidden (pluginField: PluginField) {
if (typeof pluginField.commonOptions.hidden !== 'function') return false
)
}
- private trackLivePermanentFieldChange () {
- // We will update the "support" field depending on the channel
- this.form.controls['permanentLive']
- .valueChanges
- .subscribe(
- permanentLive => {
- const saveReplayControl = this.form.controls['saveReplay']
-
- if (permanentLive === true) {
- saveReplayControl.setValue(false)
- saveReplayControl.disable()
- } else {
- saveReplayControl.enable()
- }
- }
- )
- }
-
private updateSupportField (support: string) {
return this.form.patchValue({ support: support || '' })
}