import { AllowNull, BelongsTo, Column, CreatedAt, DataType, DefaultScope, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript'
import { WEBSERVER } from '@server/initializers/constants'
import { MVideoLive, MVideoLiveVideo } from '@server/types/models'
+import { AttributesOnly } from '@shared/core-utils'
import { LiveVideo, VideoState } from '@shared/models'
import { VideoModel } from './video'
import { VideoBlacklistModel } from './video-blacklist'
+import { CONFIG } from '@server/initializers/config'
@DefaultScope(() => ({
include: [
}
]
})
-export class VideoLiveModel extends Model<VideoLiveModel> {
+export class VideoLiveModel extends Model<Partial<AttributesOnly<VideoLiveModel>>> {
@AllowNull(true)
@Column(DataType.STRING)
@Column
saveReplay: boolean
+ @AllowNull(false)
+ @Column
+ permanentLive: boolean
+
@CreatedAt
createdAt: Date
}
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 {
- rtmpUrl: WEBSERVER.RTMP_URL,
- streamKey: this.streamKey
+ rtmpUrl,
+ rtmpsUrl,
+
+ streamKey: this.streamKey,
+ permanentLive: this.permanentLive,
+ saveReplay: this.saveReplay
}
}
}