X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fvideo-live.ts;h=96c0bf7f770d1ce40f262b03d31de12387afdbbe;hb=4ec52d04dcc5d664612331f8e08d7d90da990415;hp=875ba9b31a61c73279128c3eba3187ecaeaacb8c;hpb=bb4ba6d94c5051fdd665ebe63fffcc105778b8be;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/video/video-live.ts b/server/models/video/video-live.ts index 875ba9b31..96c0bf7f7 100644 --- a/server/models/video/video-live.ts +++ b/server/models/video/video-live.ts @@ -1,7 +1,9 @@ import { AllowNull, BelongsTo, Column, CreatedAt, DataType, DefaultScope, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript' +import { CONFIG } from '@server/initializers/config' import { WEBSERVER } from '@server/initializers/constants' import { MVideoLive, MVideoLiveVideo } from '@server/types/models' -import { LiveVideo, VideoState } from '@shared/models' +import { LiveVideo, LiveVideoLatencyMode, VideoPrivacy, VideoState } from '@shared/models' +import { AttributesOnly } from '@shared/typescript-utils' import { VideoModel } from './video' import { VideoBlacklistModel } from './video-blacklist' @@ -28,7 +30,7 @@ import { VideoBlacklistModel } from './video-blacklist' } ] }) -export class VideoLiveModel extends Model { +export class VideoLiveModel extends Model>> { @AllowNull(true) @Column(DataType.STRING) @@ -42,6 +44,10 @@ export class VideoLiveModel extends Model { @Column permanentLive: boolean + @AllowNull(false) + @Column + latencyMode: LiveVideoLatencyMode + @CreatedAt createdAt: Date @@ -96,15 +102,23 @@ export class VideoLiveModel extends Model { } toFormattedJSON (): LiveVideo { + let rtmpUrl: string = null + let rtmpsUrl: string = null + + // If we don't have a stream key, it means this is a remote live so we don't specify the rtmp URL + if (this.streamKey) { + if (CONFIG.LIVE.RTMP.ENABLED) rtmpUrl = WEBSERVER.RTMP_URL + if (CONFIG.LIVE.RTMPS.ENABLED) rtmpsUrl = WEBSERVER.RTMPS_URL + } + return { - // If we don't have a stream key, it means this is a remote live so we don't specify the rtmp URL - rtmpUrl: this.streamKey - ? WEBSERVER.RTMP_URL - : null, + rtmpUrl, + rtmpsUrl, streamKey: this.streamKey, permanentLive: this.permanentLive, - saveReplay: this.saveReplay + saveReplay: this.saveReplay, + latencyMode: this.latencyMode } } }