diff options
Diffstat (limited to 'server/models/video/video-streaming-playlist.ts')
-rw-r--r-- | server/models/video/video-streaming-playlist.ts | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/server/models/video/video-streaming-playlist.ts b/server/models/video/video-streaming-playlist.ts index d591a3134..3e9fd97c7 100644 --- a/server/models/video/video-streaming-playlist.ts +++ b/server/models/video/video-streaming-playlist.ts | |||
@@ -1,10 +1,25 @@ | |||
1 | import * as memoizee from 'memoizee' | 1 | import * as memoizee from 'memoizee' |
2 | import { join } from 'path' | 2 | import { join } from 'path' |
3 | import { Op } from 'sequelize' | 3 | import { Op } from 'sequelize' |
4 | import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, HasMany, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' | 4 | import { |
5 | AllowNull, | ||
6 | BelongsTo, | ||
7 | Column, | ||
8 | CreatedAt, | ||
9 | DataType, | ||
10 | Default, | ||
11 | ForeignKey, | ||
12 | HasMany, | ||
13 | Is, | ||
14 | Model, | ||
15 | Table, | ||
16 | UpdatedAt | ||
17 | } from 'sequelize-typescript' | ||
18 | import { getHLSPublicFileUrl } from '@server/lib/object-storage' | ||
5 | import { VideoFileModel } from '@server/models/video/video-file' | 19 | import { VideoFileModel } from '@server/models/video/video-file' |
6 | import { MStreamingPlaylist, MVideo } from '@server/types/models' | 20 | import { MStreamingPlaylist, MVideo } from '@server/types/models' |
7 | import { AttributesOnly } from '@shared/core-utils' | 21 | import { AttributesOnly } from '@shared/core-utils' |
22 | import { VideoStorage } from '@shared/models' | ||
8 | import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type' | 23 | import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type' |
9 | import { sha1 } from '../../helpers/core-utils' | 24 | import { sha1 } from '../../helpers/core-utils' |
10 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' | 25 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' |
@@ -81,6 +96,11 @@ export class VideoStreamingPlaylistModel extends Model<Partial<AttributesOnly<Vi | |||
81 | @Column | 96 | @Column |
82 | videoId: number | 97 | videoId: number |
83 | 98 | ||
99 | @AllowNull(false) | ||
100 | @Default(VideoStorage.FILE_SYSTEM) | ||
101 | @Column | ||
102 | storage: VideoStorage | ||
103 | |||
84 | @BelongsTo(() => VideoModel, { | 104 | @BelongsTo(() => VideoModel, { |
85 | foreignKey: { | 105 | foreignKey: { |
86 | allowNull: false | 106 | allowNull: false |
@@ -185,12 +205,20 @@ export class VideoStreamingPlaylistModel extends Model<Partial<AttributesOnly<Vi | |||
185 | } | 205 | } |
186 | 206 | ||
187 | getMasterPlaylistUrl (video: MVideo) { | 207 | getMasterPlaylistUrl (video: MVideo) { |
208 | if (this.storage === VideoStorage.OBJECT_STORAGE) { | ||
209 | return getHLSPublicFileUrl(this.playlistUrl) | ||
210 | } | ||
211 | |||
188 | if (video.isOwned()) return WEBSERVER.URL + this.getMasterPlaylistStaticPath(video.uuid) | 212 | if (video.isOwned()) return WEBSERVER.URL + this.getMasterPlaylistStaticPath(video.uuid) |
189 | 213 | ||
190 | return this.playlistUrl | 214 | return this.playlistUrl |
191 | } | 215 | } |
192 | 216 | ||
193 | getSha256SegmentsUrl (video: MVideo) { | 217 | getSha256SegmentsUrl (video: MVideo) { |
218 | if (this.storage === VideoStorage.OBJECT_STORAGE) { | ||
219 | return getHLSPublicFileUrl(this.segmentsSha256Url) | ||
220 | } | ||
221 | |||
194 | if (video.isOwned()) return WEBSERVER.URL + this.getSha256SegmentsStaticPath(video.uuid, video.isLive) | 222 | if (video.isOwned()) return WEBSERVER.URL + this.getSha256SegmentsStaticPath(video.uuid, video.isLive) |
195 | 223 | ||
196 | return this.segmentsSha256Url | 224 | return this.segmentsSha256Url |