]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/models/video/video-file.ts
Handle higher FPS for high resolution (test)
[github/Chocobozzz/PeerTube.git] / server / models / video / video-file.ts
1 import { values } from 'lodash'
2 import { AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript'
3 import {
4 isVideoFileInfoHashValid,
5 isVideoFileResolutionValid,
6 isVideoFileSizeValid,
7 isVideoFPSResolutionValid
8 } from '../../helpers/custom-validators/videos'
9 import { CONSTRAINTS_FIELDS } from '../../initializers'
10 import { throwIfNotValid } from '../utils'
11 import { VideoModel } from './video'
12
13 @Table({
14 tableName: 'videoFile',
15 indexes: [
16 {
17 fields: [ 'videoId' ]
18 },
19 {
20 fields: [ 'infoHash' ]
21 }
22 ]
23 })
24 export class VideoFileModel extends Model<VideoFileModel> {
25 @CreatedAt
26 createdAt: Date
27
28 @UpdatedAt
29 updatedAt: Date
30
31 @AllowNull(false)
32 @Is('VideoFileResolution', value => throwIfNotValid(value, isVideoFileResolutionValid, 'resolution'))
33 @Column
34 resolution: number
35
36 @AllowNull(false)
37 @Is('VideoFileSize', value => throwIfNotValid(value, isVideoFileSizeValid, 'size'))
38 @Column(DataType.BIGINT)
39 size: number
40
41 @AllowNull(false)
42 @Column(DataType.ENUM(values(CONSTRAINTS_FIELDS.VIDEOS.EXTNAME)))
43 extname: string
44
45 @AllowNull(false)
46 @Is('VideoFileSize', value => throwIfNotValid(value, isVideoFileInfoHashValid, 'info hash'))
47 @Column
48 infoHash: string
49
50 @AllowNull(true)
51 @Default(null)
52 @Is('VideoFileFPS', value => throwIfNotValid(value, isVideoFPSResolutionValid, 'fps'))
53 @Column
54 fps: number
55
56 @ForeignKey(() => VideoModel)
57 @Column
58 videoId: number
59
60 @BelongsTo(() => VideoModel, {
61 foreignKey: {
62 allowNull: false
63 },
64 onDelete: 'CASCADE'
65 })
66 Video: VideoModel
67 }