aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-03-04 13:40:02 +0100
committerChocobozzz <chocobozzz@cpy.re>2022-03-09 09:23:10 +0100
commitf443a74649174b2f9347c158e30f8ac7aa3e958a (patch)
treee423bc4e2307477bda4341037b7fa04ad10adae6 /server/models
parent01dd04cd5ab7b55d2a9af7d0ebf405bee9579b09 (diff)
downloadPeerTube-f443a74649174b2f9347c158e30f8ac7aa3e958a.tar.gz
PeerTube-f443a74649174b2f9347c158e30f8ac7aa3e958a.tar.zst
PeerTube-f443a74649174b2f9347c158e30f8ac7aa3e958a.zip
Add latency setting support
Diffstat (limited to 'server/models')
-rw-r--r--server/models/video/formatter/video-format-utils.ts39
-rw-r--r--server/models/video/sql/video/shared/video-table-attributes.ts1
-rw-r--r--server/models/video/video-live.ts11
3 files changed, 38 insertions, 13 deletions
diff --git a/server/models/video/formatter/video-format-utils.ts b/server/models/video/formatter/video-format-utils.ts
index 7456f37c5..611edf0b9 100644
--- a/server/models/video/formatter/video-format-utils.ts
+++ b/server/models/video/formatter/video-format-utils.ts
@@ -411,15 +411,6 @@ function videoModelToActivityPubObject (video: MVideoAP): VideoObject {
411 views: video.views, 411 views: video.views,
412 sensitive: video.nsfw, 412 sensitive: video.nsfw,
413 waitTranscoding: video.waitTranscoding, 413 waitTranscoding: video.waitTranscoding,
414 isLiveBroadcast: video.isLive,
415
416 liveSaveReplay: video.isLive
417 ? video.VideoLive.saveReplay
418 : null,
419
420 permanentLive: video.isLive
421 ? video.VideoLive.permanentLive
422 : null,
423 414
424 state: video.state, 415 state: video.state,
425 commentsEnabled: video.commentsEnabled, 416 commentsEnabled: video.commentsEnabled,
@@ -431,10 +422,13 @@ function videoModelToActivityPubObject (video: MVideoAP): VideoObject {
431 : null, 422 : null,
432 423
433 updated: video.updatedAt.toISOString(), 424 updated: video.updatedAt.toISOString(),
425
434 mediaType: 'text/markdown', 426 mediaType: 'text/markdown',
435 content: video.description, 427 content: video.description,
436 support: video.support, 428 support: video.support,
429
437 subtitleLanguage, 430 subtitleLanguage,
431
438 icon: icons.map(i => ({ 432 icon: icons.map(i => ({
439 type: 'Image', 433 type: 'Image',
440 url: i.getFileUrl(video), 434 url: i.getFileUrl(video),
@@ -442,11 +436,14 @@ function videoModelToActivityPubObject (video: MVideoAP): VideoObject {
442 width: i.width, 436 width: i.width,
443 height: i.height 437 height: i.height
444 })), 438 })),
439
445 url, 440 url,
441
446 likes: getLocalVideoLikesActivityPubUrl(video), 442 likes: getLocalVideoLikesActivityPubUrl(video),
447 dislikes: getLocalVideoDislikesActivityPubUrl(video), 443 dislikes: getLocalVideoDislikesActivityPubUrl(video),
448 shares: getLocalVideoSharesActivityPubUrl(video), 444 shares: getLocalVideoSharesActivityPubUrl(video),
449 comments: getLocalVideoCommentsActivityPubUrl(video), 445 comments: getLocalVideoCommentsActivityPubUrl(video),
446
450 attributedTo: [ 447 attributedTo: [
451 { 448 {
452 type: 'Person', 449 type: 'Person',
@@ -456,7 +453,9 @@ function videoModelToActivityPubObject (video: MVideoAP): VideoObject {
456 type: 'Group', 453 type: 'Group',
457 id: video.VideoChannel.Actor.url 454 id: video.VideoChannel.Actor.url
458 } 455 }
459 ] 456 ],
457
458 ...buildLiveAPAttributes(video)
460 } 459 }
461} 460}
462 461
@@ -500,3 +499,23 @@ export {
500 getPrivacyLabel, 499 getPrivacyLabel,
501 getStateLabel 500 getStateLabel
502} 501}
502
503// ---------------------------------------------------------------------------
504
505function buildLiveAPAttributes (video: MVideoAP) {
506 if (!video.isLive) {
507 return {
508 isLiveBroadcast: false,
509 liveSaveReplay: null,
510 permanentLive: null,
511 latencyMode: null
512 }
513 }
514
515 return {
516 isLiveBroadcast: true,
517 liveSaveReplay: video.VideoLive.saveReplay,
518 permanentLive: video.VideoLive.permanentLive,
519 latencyMode: video.VideoLive.latencyMode
520 }
521}
diff --git a/server/models/video/sql/video/shared/video-table-attributes.ts b/server/models/video/sql/video/shared/video-table-attributes.ts
index f4d9e99fd..e2c1c0f6d 100644
--- a/server/models/video/sql/video/shared/video-table-attributes.ts
+++ b/server/models/video/sql/video/shared/video-table-attributes.ts
@@ -158,6 +158,7 @@ export class VideoTableAttributes {
158 'streamKey', 158 'streamKey',
159 'saveReplay', 159 'saveReplay',
160 'permanentLive', 160 'permanentLive',
161 'latencyMode',
161 'videoId', 162 'videoId',
162 'createdAt', 163 'createdAt',
163 'updatedAt' 164 'updatedAt'
diff --git a/server/models/video/video-live.ts b/server/models/video/video-live.ts
index e3fdcc0ba..904f712b4 100644
--- a/server/models/video/video-live.ts
+++ b/server/models/video/video-live.ts
@@ -1,11 +1,11 @@
1import { AllowNull, BelongsTo, Column, CreatedAt, DataType, DefaultScope, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript' 1import { AllowNull, BelongsTo, Column, CreatedAt, DataType, DefaultScope, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript'
2import { CONFIG } from '@server/initializers/config'
2import { WEBSERVER } from '@server/initializers/constants' 3import { WEBSERVER } from '@server/initializers/constants'
3import { MVideoLive, MVideoLiveVideo } from '@server/types/models' 4import { MVideoLive, MVideoLiveVideo } from '@server/types/models'
5import { LiveVideo, LiveVideoLatencyMode, VideoState } from '@shared/models'
4import { AttributesOnly } from '@shared/typescript-utils' 6import { AttributesOnly } from '@shared/typescript-utils'
5import { LiveVideo, VideoState } from '@shared/models'
6import { VideoModel } from './video' 7import { VideoModel } from './video'
7import { VideoBlacklistModel } from './video-blacklist' 8import { VideoBlacklistModel } from './video-blacklist'
8import { CONFIG } from '@server/initializers/config'
9 9
10@DefaultScope(() => ({ 10@DefaultScope(() => ({
11 include: [ 11 include: [
@@ -44,6 +44,10 @@ export class VideoLiveModel extends Model<Partial<AttributesOnly<VideoLiveModel>
44 @Column 44 @Column
45 permanentLive: boolean 45 permanentLive: boolean
46 46
47 @AllowNull(false)
48 @Column
49 latencyMode: LiveVideoLatencyMode
50
47 @CreatedAt 51 @CreatedAt
48 createdAt: Date 52 createdAt: Date
49 53
@@ -113,7 +117,8 @@ export class VideoLiveModel extends Model<Partial<AttributesOnly<VideoLiveModel>
113 117
114 streamKey: this.streamKey, 118 streamKey: this.streamKey,
115 permanentLive: this.permanentLive, 119 permanentLive: this.permanentLive,
116 saveReplay: this.saveReplay 120 saveReplay: this.saveReplay,
121 latencyMode: this.latencyMode
117 } 122 }
118 } 123 }
119} 124}