diff options
Diffstat (limited to 'shared/models')
-rw-r--r-- | shared/models/activitypub/objects/common-objects.ts | 12 | ||||
-rw-r--r-- | shared/models/actors/account.model.ts | 2 | ||||
-rw-r--r-- | shared/models/blocklist/account-block.model.ts | 7 | ||||
-rw-r--r-- | shared/models/blocklist/index.ts | 2 | ||||
-rw-r--r-- | shared/models/blocklist/server-block.model.ts | 9 | ||||
-rw-r--r-- | shared/models/index.ts | 1 | ||||
-rw-r--r-- | shared/models/search/videos-search-query.model.ts | 3 | ||||
-rw-r--r-- | shared/models/users/index.ts | 1 | ||||
-rw-r--r-- | shared/models/users/user-right.enum.ts | 4 | ||||
-rw-r--r-- | shared/models/users/user-role.ts | 5 | ||||
-rw-r--r-- | shared/models/users/user-update-me.model.ts | 3 | ||||
-rw-r--r-- | shared/models/users/user-watching-video.model.ts | 3 | ||||
-rw-r--r-- | shared/models/videos/index.ts | 1 | ||||
-rw-r--r-- | shared/models/videos/video-query.type.ts | 2 | ||||
-rw-r--r-- | shared/models/videos/video-resolution.enum.ts | 68 | ||||
-rw-r--r-- | shared/models/videos/video-transcoding-fps.model.ts | 6 | ||||
-rw-r--r-- | shared/models/videos/video.model.ts | 4 |
17 files changed, 127 insertions, 6 deletions
diff --git a/shared/models/activitypub/objects/common-objects.ts b/shared/models/activitypub/objects/common-objects.ts index 1de60da94..118a4f43d 100644 --- a/shared/models/activitypub/objects/common-objects.ts +++ b/shared/models/activitypub/objects/common-objects.ts | |||
@@ -19,7 +19,9 @@ export interface ActivityIconObject { | |||
19 | 19 | ||
20 | export type ActivityVideoUrlObject = { | 20 | export type ActivityVideoUrlObject = { |
21 | type: 'Link' | 21 | type: 'Link' |
22 | mimeType: 'video/mp4' | 'video/webm' | 'video/ogg' | 22 | // TODO: remove mimeType (backward compatibility, introduced in v1.1.0) |
23 | mimeType?: 'video/mp4' | 'video/webm' | 'video/ogg' | ||
24 | mediaType: 'video/mp4' | 'video/webm' | 'video/ogg' | ||
23 | href: string | 25 | href: string |
24 | height: number | 26 | height: number |
25 | size: number | 27 | size: number |
@@ -31,14 +33,18 @@ export type ActivityUrlObject = | |||
31 | | | 33 | | |
32 | { | 34 | { |
33 | type: 'Link' | 35 | type: 'Link' |
34 | mimeType: 'application/x-bittorrent' | 'application/x-bittorrent;x-scheme-handler/magnet' | 36 | // TODO: remove mimeType (backward compatibility, introduced in v1.1.0) |
37 | mimeType?: 'application/x-bittorrent' | 'application/x-bittorrent;x-scheme-handler/magnet' | ||
38 | mediaType: 'application/x-bittorrent' | 'application/x-bittorrent;x-scheme-handler/magnet' | ||
35 | href: string | 39 | href: string |
36 | height: number | 40 | height: number |
37 | } | 41 | } |
38 | | | 42 | | |
39 | { | 43 | { |
40 | type: 'Link' | 44 | type: 'Link' |
41 | mimeType: 'text/html' | 45 | // TODO: remove mimeType (backward compatibility, introduced in v1.1.0) |
46 | mimeType?: 'text/html' | ||
47 | mediaType: 'text/html' | ||
42 | href: string | 48 | href: string |
43 | } | 49 | } |
44 | 50 | ||
diff --git a/shared/models/actors/account.model.ts b/shared/models/actors/account.model.ts index e1117486d..7f1dbbc37 100644 --- a/shared/models/actors/account.model.ts +++ b/shared/models/actors/account.model.ts | |||
@@ -3,4 +3,6 @@ import { Actor } from './actor.model' | |||
3 | export interface Account extends Actor { | 3 | export interface Account extends Actor { |
4 | displayName: string | 4 | displayName: string |
5 | description: string | 5 | description: string |
6 | |||
7 | userId?: number | ||
6 | } | 8 | } |
diff --git a/shared/models/blocklist/account-block.model.ts b/shared/models/blocklist/account-block.model.ts new file mode 100644 index 000000000..a942ed614 --- /dev/null +++ b/shared/models/blocklist/account-block.model.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | import { Account } from '../actors' | ||
2 | |||
3 | export interface AccountBlock { | ||
4 | byAccount: Account | ||
5 | blockedAccount: Account | ||
6 | createdAt: Date | string | ||
7 | } | ||
diff --git a/shared/models/blocklist/index.ts b/shared/models/blocklist/index.ts new file mode 100644 index 000000000..fc7873270 --- /dev/null +++ b/shared/models/blocklist/index.ts | |||
@@ -0,0 +1,2 @@ | |||
1 | export * from './account-block.model' | ||
2 | export * from './server-block.model' | ||
diff --git a/shared/models/blocklist/server-block.model.ts b/shared/models/blocklist/server-block.model.ts new file mode 100644 index 000000000..a8b8af0b7 --- /dev/null +++ b/shared/models/blocklist/server-block.model.ts | |||
@@ -0,0 +1,9 @@ | |||
1 | import { Account } from '../actors' | ||
2 | |||
3 | export interface ServerBlock { | ||
4 | byAccount: Account | ||
5 | blockedServer: { | ||
6 | host: string | ||
7 | } | ||
8 | createdAt: Date | string | ||
9 | } | ||
diff --git a/shared/models/index.ts b/shared/models/index.ts index e61d6cbdc..062533834 100644 --- a/shared/models/index.ts +++ b/shared/models/index.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | export * from './activitypub' | 1 | export * from './activitypub' |
2 | export * from './actors' | 2 | export * from './actors' |
3 | export * from './avatars' | 3 | export * from './avatars' |
4 | export * from './blocklist' | ||
4 | export * from './redundancy' | 5 | export * from './redundancy' |
5 | export * from './users' | 6 | export * from './users' |
6 | export * from './videos' | 7 | export * from './videos' |
diff --git a/shared/models/search/videos-search-query.model.ts b/shared/models/search/videos-search-query.model.ts index 29aa5c100..0db220758 100644 --- a/shared/models/search/videos-search-query.model.ts +++ b/shared/models/search/videos-search-query.model.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | import { NSFWQuery } from './nsfw-query.model' | 1 | import { NSFWQuery } from './nsfw-query.model' |
2 | import { VideoFilter } from '../videos' | ||
2 | 3 | ||
3 | export interface VideosSearchQuery { | 4 | export interface VideosSearchQuery { |
4 | search?: string | 5 | search?: string |
@@ -23,4 +24,6 @@ export interface VideosSearchQuery { | |||
23 | 24 | ||
24 | durationMin?: number // seconds | 25 | durationMin?: number // seconds |
25 | durationMax?: number // seconds | 26 | durationMax?: number // seconds |
27 | |||
28 | filter?: VideoFilter | ||
26 | } | 29 | } |
diff --git a/shared/models/users/index.ts b/shared/models/users/index.ts index 15c2f99c2..7114741e0 100644 --- a/shared/models/users/index.ts +++ b/shared/models/users/index.ts | |||
@@ -7,3 +7,4 @@ export * from './user-update-me.model' | |||
7 | export * from './user-right.enum' | 7 | export * from './user-right.enum' |
8 | export * from './user-role' | 8 | export * from './user-role' |
9 | export * from './user-video-quota.model' | 9 | export * from './user-video-quota.model' |
10 | export * from './user-watching-video.model' | ||
diff --git a/shared/models/users/user-right.enum.ts b/shared/models/users/user-right.enum.ts index c4ccd632f..51c59d20a 100644 --- a/shared/models/users/user-right.enum.ts +++ b/shared/models/users/user-right.enum.ts | |||
@@ -8,11 +8,15 @@ export enum UserRight { | |||
8 | MANAGE_JOBS, | 8 | MANAGE_JOBS, |
9 | MANAGE_CONFIGURATION, | 9 | MANAGE_CONFIGURATION, |
10 | 10 | ||
11 | MANAGE_ACCOUNTS_BLOCKLIST, | ||
12 | MANAGE_SERVERS_BLOCKLIST, | ||
13 | |||
11 | MANAGE_VIDEO_BLACKLIST, | 14 | MANAGE_VIDEO_BLACKLIST, |
12 | 15 | ||
13 | REMOVE_ANY_VIDEO, | 16 | REMOVE_ANY_VIDEO, |
14 | REMOVE_ANY_VIDEO_CHANNEL, | 17 | REMOVE_ANY_VIDEO_CHANNEL, |
15 | REMOVE_ANY_VIDEO_COMMENT, | 18 | REMOVE_ANY_VIDEO_COMMENT, |
16 | UPDATE_ANY_VIDEO, | 19 | UPDATE_ANY_VIDEO, |
20 | SEE_ALL_VIDEOS, | ||
17 | CHANGE_VIDEO_OWNERSHIP | 21 | CHANGE_VIDEO_OWNERSHIP |
18 | } | 22 | } |
diff --git a/shared/models/users/user-role.ts b/shared/models/users/user-role.ts index 552aad999..adef8fd95 100644 --- a/shared/models/users/user-role.ts +++ b/shared/models/users/user-role.ts | |||
@@ -26,7 +26,10 @@ const userRoleRights: { [ id: number ]: UserRight[] } = { | |||
26 | UserRight.REMOVE_ANY_VIDEO, | 26 | UserRight.REMOVE_ANY_VIDEO, |
27 | UserRight.REMOVE_ANY_VIDEO_CHANNEL, | 27 | UserRight.REMOVE_ANY_VIDEO_CHANNEL, |
28 | UserRight.REMOVE_ANY_VIDEO_COMMENT, | 28 | UserRight.REMOVE_ANY_VIDEO_COMMENT, |
29 | UserRight.UPDATE_ANY_VIDEO | 29 | UserRight.UPDATE_ANY_VIDEO, |
30 | UserRight.SEE_ALL_VIDEOS, | ||
31 | UserRight.MANAGE_ACCOUNTS_BLOCKLIST, | ||
32 | UserRight.MANAGE_SERVERS_BLOCKLIST | ||
30 | ], | 33 | ], |
31 | 34 | ||
32 | [UserRole.USER]: [] | 35 | [UserRole.USER]: [] |
diff --git a/shared/models/users/user-update-me.model.ts b/shared/models/users/user-update-me.model.ts index bbffe1487..10edeee2e 100644 --- a/shared/models/users/user-update-me.model.ts +++ b/shared/models/users/user-update-me.model.ts | |||
@@ -3,7 +3,8 @@ import { NSFWPolicyType } from '../videos/nsfw-policy.type' | |||
3 | export interface UserUpdateMe { | 3 | export interface UserUpdateMe { |
4 | displayName?: string | 4 | displayName?: string |
5 | description?: string | 5 | description?: string |
6 | nsfwPolicy?: NSFWPolicyType | 6 | nsfwPolicy?: NSFWPolicyType, |
7 | webTorrentEnabled?: boolean, | ||
7 | autoPlayVideo?: boolean | 8 | autoPlayVideo?: boolean |
8 | email?: string | 9 | email?: string |
9 | currentPassword?: string | 10 | currentPassword?: string |
diff --git a/shared/models/users/user-watching-video.model.ts b/shared/models/users/user-watching-video.model.ts new file mode 100644 index 000000000..c22480595 --- /dev/null +++ b/shared/models/users/user-watching-video.model.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export interface UserWatchingVideo { | ||
2 | currentTime: number | ||
3 | } | ||
diff --git a/shared/models/videos/index.ts b/shared/models/videos/index.ts index 90a0e3053..056ae06da 100644 --- a/shared/models/videos/index.ts +++ b/shared/models/videos/index.ts | |||
@@ -21,6 +21,7 @@ export * from './video-update.model' | |||
21 | export * from './video.model' | 21 | export * from './video.model' |
22 | export * from './video-query.type' | 22 | export * from './video-query.type' |
23 | export * from './video-state.enum' | 23 | export * from './video-state.enum' |
24 | export * from './video-transcoding-fps.model' | ||
24 | export * from './caption/video-caption.model' | 25 | export * from './caption/video-caption.model' |
25 | export * from './caption/video-caption-update.model' | 26 | export * from './caption/video-caption-update.model' |
26 | export * from './import/video-import-create.model' | 27 | export * from './import/video-import-create.model' |
diff --git a/shared/models/videos/video-query.type.ts b/shared/models/videos/video-query.type.ts index ff0f527f3..f76a91aad 100644 --- a/shared/models/videos/video-query.type.ts +++ b/shared/models/videos/video-query.type.ts | |||
@@ -1 +1 @@ | |||
export type VideoFilter = 'local' | export type VideoFilter = 'local' | 'all-local' | ||
diff --git a/shared/models/videos/video-resolution.enum.ts b/shared/models/videos/video-resolution.enum.ts index 100fc0e6e..7da5e7100 100644 --- a/shared/models/videos/video-resolution.enum.ts +++ b/shared/models/videos/video-resolution.enum.ts | |||
@@ -1,3 +1,5 @@ | |||
1 | import { VideoTranscodingFPS } from './video-transcoding-fps.model' | ||
2 | |||
1 | export enum VideoResolution { | 3 | export enum VideoResolution { |
2 | H_240P = 240, | 4 | H_240P = 240, |
3 | H_360P = 360, | 5 | H_360P = 360, |
@@ -5,3 +7,69 @@ export enum VideoResolution { | |||
5 | H_720P = 720, | 7 | H_720P = 720, |
6 | H_1080P = 1080 | 8 | H_1080P = 1080 |
7 | } | 9 | } |
10 | |||
11 | /** | ||
12 | * Bitrate targets for different resolutions, at VideoTranscodingFPS.AVERAGE. | ||
13 | * | ||
14 | * Sources for individual quality levels: | ||
15 | * Google Live Encoder: https://support.google.com/youtube/answer/2853702?hl=en | ||
16 | * YouTube Video Info (tested with random music video): https://www.h3xed.com/blogmedia/youtube-info.php | ||
17 | */ | ||
18 | function getBaseBitrate (resolution: VideoResolution) { | ||
19 | switch (resolution) { | ||
20 | case VideoResolution.H_240P: | ||
21 | // quality according to Google Live Encoder: 300 - 700 Kbps | ||
22 | // Quality according to YouTube Video Info: 186 Kbps | ||
23 | return 250 * 1000 | ||
24 | case VideoResolution.H_360P: | ||
25 | // quality according to Google Live Encoder: 400 - 1,000 Kbps | ||
26 | // Quality according to YouTube Video Info: 480 Kbps | ||
27 | return 500 * 1000 | ||
28 | case VideoResolution.H_480P: | ||
29 | // quality according to Google Live Encoder: 500 - 2,000 Kbps | ||
30 | // Quality according to YouTube Video Info: 879 Kbps | ||
31 | return 900 * 1000 | ||
32 | case VideoResolution.H_720P: | ||
33 | // quality according to Google Live Encoder: 1,500 - 4,000 Kbps | ||
34 | // Quality according to YouTube Video Info: 1752 Kbps | ||
35 | return 1750 * 1000 | ||
36 | case VideoResolution.H_1080P: // fallthrough | ||
37 | default: | ||
38 | // quality according to Google Live Encoder: 3000 - 6000 Kbps | ||
39 | // Quality according to YouTube Video Info: 3277 Kbps | ||
40 | return 3300 * 1000 | ||
41 | } | ||
42 | } | ||
43 | |||
44 | /** | ||
45 | * Calculate the target bitrate based on video resolution and FPS. | ||
46 | * | ||
47 | * The calculation is based on two values: | ||
48 | * Bitrate at VideoTranscodingFPS.AVERAGE is always the same as | ||
49 | * getBaseBitrate(). Bitrate at VideoTranscodingFPS.MAX is always | ||
50 | * getBaseBitrate() * 1.4. All other values are calculated linearly | ||
51 | * between these two points. | ||
52 | */ | ||
53 | export function getTargetBitrate (resolution: VideoResolution, fps: number, fpsTranscodingConstants: VideoTranscodingFPS) { | ||
54 | const baseBitrate = getBaseBitrate(resolution) | ||
55 | // The maximum bitrate, used when fps === VideoTranscodingFPS.MAX | ||
56 | // Based on numbers from Youtube, 60 fps bitrate divided by 30 fps bitrate: | ||
57 | // 720p: 2600 / 1750 = 1.49 | ||
58 | // 1080p: 4400 / 3300 = 1.33 | ||
59 | const maxBitrate = baseBitrate * 1.4 | ||
60 | const maxBitrateDifference = maxBitrate - baseBitrate | ||
61 | const maxFpsDifference = fpsTranscodingConstants.MAX - fpsTranscodingConstants.AVERAGE | ||
62 | // For 1080p video with default settings, this results in the following formula: | ||
63 | // 3300 + (x - 30) * (1320/30) | ||
64 | // Example outputs: | ||
65 | // 1080p10: 2420 kbps, 1080p30: 3300 kbps, 1080p60: 4620 kbps | ||
66 | // 720p10: 1283 kbps, 720p30: 1750 kbps, 720p60: 2450 kbps | ||
67 | return baseBitrate + (fps - fpsTranscodingConstants.AVERAGE) * (maxBitrateDifference / maxFpsDifference) | ||
68 | } | ||
69 | |||
70 | /** | ||
71 | * The maximum bitrate we expect to see on a transcoded video in bytes per second. | ||
72 | */ | ||
73 | export function getMaxBitrate (resolution: VideoResolution, fps: number, fpsTranscodingConstants: VideoTranscodingFPS) { | ||
74 | return getTargetBitrate(resolution, fps, fpsTranscodingConstants) * 2 | ||
75 | } | ||
diff --git a/shared/models/videos/video-transcoding-fps.model.ts b/shared/models/videos/video-transcoding-fps.model.ts new file mode 100644 index 000000000..82022d2f1 --- /dev/null +++ b/shared/models/videos/video-transcoding-fps.model.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | export type VideoTranscodingFPS = { | ||
2 | MIN: number, | ||
3 | AVERAGE: number, | ||
4 | MAX: number, | ||
5 | KEEP_ORIGIN_FPS_RESOLUTION_MIN: number | ||
6 | } | ||
diff --git a/shared/models/videos/video.model.ts b/shared/models/videos/video.model.ts index b47ab1ab8..4a9fa58b1 100644 --- a/shared/models/videos/video.model.ts +++ b/shared/models/videos/video.model.ts | |||
@@ -68,6 +68,10 @@ export interface Video { | |||
68 | 68 | ||
69 | account: AccountAttribute | 69 | account: AccountAttribute |
70 | channel: VideoChannelAttribute | 70 | channel: VideoChannelAttribute |
71 | |||
72 | userHistory?: { | ||
73 | currentTime: number | ||
74 | } | ||
71 | } | 75 | } |
72 | 76 | ||
73 | export interface VideoDetails extends Video { | 77 | export interface VideoDetails extends Video { |