aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-11-15 15:06:03 +0100
committerChocobozzz <me@florianbigard.com>2019-11-25 10:59:43 +0100
commitd7a25329f9e607894d29ab342b9cb66638b56dc0 (patch)
tree6cd6bc4f2689f78944238b313c93427423a932ac /shared
parent14981d7331da3f63fe6cfaf020ccb7c910006eaf (diff)
downloadPeerTube-d7a25329f9e607894d29ab342b9cb66638b56dc0.tar.gz
PeerTube-d7a25329f9e607894d29ab342b9cb66638b56dc0.tar.zst
PeerTube-d7a25329f9e607894d29ab342b9cb66638b56dc0.zip
Add ability to disable webtorrent
In favour of HLS
Diffstat (limited to 'shared')
-rw-r--r--shared/extra-utils/server/config.ts3
-rw-r--r--shared/extra-utils/videos/videos.ts3
-rw-r--r--shared/models/activitypub/objects/common-objects.ts51
-rw-r--r--shared/models/server/custom-config.model.ts7
-rw-r--r--shared/models/server/server-config.model.ts4
-rw-r--r--shared/models/videos/index.ts1
-rw-r--r--shared/models/videos/video-file.model.ts12
-rw-r--r--shared/models/videos/video-streaming-playlist.model.ts3
-rw-r--r--shared/models/videos/video.model.ts12
9 files changed, 65 insertions, 31 deletions
diff --git a/shared/extra-utils/server/config.ts b/shared/extra-utils/server/config.ts
index 578dd35cf..ada173313 100644
--- a/shared/extra-utils/server/config.ts
+++ b/shared/extra-utils/server/config.ts
@@ -118,6 +118,9 @@ function updateCustomSubConfig (url: string, token: string, newConfig: DeepParti
118 '1080p': false, 118 '1080p': false,
119 '2160p': false 119 '2160p': false
120 }, 120 },
121 webtorrent: {
122 enabled: true
123 },
121 hls: { 124 hls: {
122 enabled: false 125 enabled: false
123 } 126 }
diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts
index 75f7d58d7..1fcc949da 100644
--- a/shared/extra-utils/videos/videos.ts
+++ b/shared/extra-utils/videos/videos.ts
@@ -573,7 +573,6 @@ async function completeVideoCheck (
573 // Transcoding enabled: extension will always be .mp4 573 // Transcoding enabled: extension will always be .mp4
574 if (attributes.files.length > 1) extension = '.mp4' 574 if (attributes.files.length > 1) extension = '.mp4'
575 575
576 const magnetUri = file.magnetUri
577 expect(file.magnetUri).to.have.lengthOf.above(2) 576 expect(file.magnetUri).to.have.lengthOf.above(2)
578 expect(file.torrentUrl).to.equal(`http://${attributes.account.host}/static/torrents/${videoDetails.uuid}-${file.resolution.id}.torrent`) 577 expect(file.torrentUrl).to.equal(`http://${attributes.account.host}/static/torrents/${videoDetails.uuid}-${file.resolution.id}.torrent`)
579 expect(file.fileUrl).to.equal(`http://${attributes.account.host}/static/webseed/${videoDetails.uuid}-${file.resolution.id}${extension}`) 578 expect(file.fileUrl).to.equal(`http://${attributes.account.host}/static/webseed/${videoDetails.uuid}-${file.resolution.id}${extension}`)
@@ -594,7 +593,7 @@ async function completeVideoCheck (
594 await testImage(url, attributes.previewfile, videoDetails.previewPath) 593 await testImage(url, attributes.previewfile, videoDetails.previewPath)
595 } 594 }
596 595
597 const torrent = await webtorrentAdd(magnetUri, true) 596 const torrent = await webtorrentAdd(file.magnetUri, true)
598 expect(torrent.files).to.be.an('array') 597 expect(torrent.files).to.be.an('array')
599 expect(torrent.files.length).to.equal(1) 598 expect(torrent.files.length).to.equal(1)
600 expect(torrent.files[0].path).to.exist.and.to.not.equal('') 599 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
diff --git a/shared/models/activitypub/objects/common-objects.ts b/shared/models/activitypub/objects/common-objects.ts
index 8c89810d6..2a6529fed 100644
--- a/shared/models/activitypub/objects/common-objects.ts
+++ b/shared/models/activitypub/objects/common-objects.ts
@@ -3,12 +3,6 @@ export interface ActivityIdentifierObject {
3 name: string 3 name: string
4} 4}
5 5
6export interface ActivityTagObject {
7 type: 'Hashtag' | 'Mention'
8 href?: string
9 name: string
10}
11
12export interface ActivityIconObject { 6export interface ActivityIconObject {
13 type: 'Image' 7 type: 'Image'
14 url: string 8 url: string
@@ -19,8 +13,6 @@ export interface ActivityIconObject {
19 13
20export type ActivityVideoUrlObject = { 14export type ActivityVideoUrlObject = {
21 type: 'Link' 15 type: 'Link'
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' 16 mediaType: 'video/mp4' | 'video/webm' | 'video/ogg'
25 href: string 17 href: string
26 height: number 18 height: number
@@ -31,8 +23,6 @@ export type ActivityVideoUrlObject = {
31export type ActivityPlaylistSegmentHashesObject = { 23export type ActivityPlaylistSegmentHashesObject = {
32 type: 'Link' 24 type: 'Link'
33 name: 'sha256' 25 name: 'sha256'
34 // TODO: remove mimeType (backward compatibility, introduced in v1.1.0)
35 mimeType?: 'application/json'
36 mediaType: 'application/json' 26 mediaType: 'application/json'
37 href: string 27 href: string
38} 28}
@@ -44,31 +34,56 @@ export type ActivityPlaylistInfohashesObject = {
44 34
45export type ActivityPlaylistUrlObject = { 35export type ActivityPlaylistUrlObject = {
46 type: 'Link' 36 type: 'Link'
47 // TODO: remove mimeType (backward compatibility, introduced in v1.1.0)
48 mimeType?: 'application/x-mpegURL'
49 mediaType: 'application/x-mpegURL' 37 mediaType: 'application/x-mpegURL'
50 href: string 38 href: string
51 tag?: (ActivityPlaylistSegmentHashesObject | ActivityPlaylistInfohashesObject)[] 39 tag?: ActivityTagObject[]
52} 40}
53 41
54export type ActivityBitTorrentUrlObject = { 42export type ActivityBitTorrentUrlObject = {
55 type: 'Link' 43 type: 'Link'
56 // TODO: remove mimeType (backward compatibility, introduced in v1.1.0)
57 mimeType?: 'application/x-bittorrent' | 'application/x-bittorrent;x-scheme-handler/magnet'
58 mediaType: 'application/x-bittorrent' | 'application/x-bittorrent;x-scheme-handler/magnet' 44 mediaType: 'application/x-bittorrent' | 'application/x-bittorrent;x-scheme-handler/magnet'
59 href: string 45 href: string
60 height: number 46 height: number
61} 47}
62 48
49export type ActivityMagnetUrlObject = {
50 type: 'Link'
51 mediaType: 'application/x-bittorrent;x-scheme-handler/magnet'
52 href: string
53 height: number
54}
55
63export type ActivityHtmlUrlObject = { 56export type ActivityHtmlUrlObject = {
64 type: 'Link' 57 type: 'Link'
65 // TODO: remove mimeType (backward compatibility, introduced in v1.1.0)
66 mimeType?: 'text/html'
67 mediaType: 'text/html' 58 mediaType: 'text/html'
68 href: string 59 href: string
69} 60}
70 61
71export type ActivityUrlObject = ActivityVideoUrlObject | ActivityPlaylistUrlObject | ActivityBitTorrentUrlObject | ActivityHtmlUrlObject 62export interface ActivityHashTagObject {
63 type: 'Hashtag' | 'Mention'
64 href?: string
65 name: string
66}
67
68export interface ActivityMentionObject {
69 type: 'Hashtag' | 'Mention'
70 href?: string
71 name: string
72}
73
74export type ActivityTagObject = ActivityPlaylistSegmentHashesObject |
75 ActivityPlaylistInfohashesObject |
76 ActivityVideoUrlObject |
77 ActivityHashTagObject |
78 ActivityMentionObject |
79 ActivityBitTorrentUrlObject |
80 ActivityMagnetUrlObject
81
82export type ActivityUrlObject = ActivityVideoUrlObject |
83 ActivityPlaylistUrlObject |
84 ActivityBitTorrentUrlObject |
85 ActivityMagnetUrlObject |
86 ActivityHtmlUrlObject
72 87
73export interface ActivityPubAttributedTo { 88export interface ActivityPubAttributedTo {
74 type: 'Group' | 'Person' 89 type: 'Group' | 'Person'
diff --git a/shared/models/server/custom-config.model.ts b/shared/models/server/custom-config.model.ts
index c9957f825..97972b759 100644
--- a/shared/models/server/custom-config.model.ts
+++ b/shared/models/server/custom-config.model.ts
@@ -69,8 +69,10 @@ export interface CustomConfig {
69 69
70 transcoding: { 70 transcoding: {
71 enabled: boolean 71 enabled: boolean
72
72 allowAdditionalExtensions: boolean 73 allowAdditionalExtensions: boolean
73 allowAudioFiles: boolean 74 allowAudioFiles: boolean
75
74 threads: number 76 threads: number
75 resolutions: { 77 resolutions: {
76 '240p': boolean 78 '240p': boolean
@@ -80,6 +82,11 @@ export interface CustomConfig {
80 '1080p': boolean 82 '1080p': boolean
81 '2160p': boolean 83 '2160p': boolean
82 } 84 }
85
86 webtorrent: {
87 enabled: boolean
88 }
89
83 hls: { 90 hls: {
84 enabled: boolean 91 enabled: boolean
85 } 92 }
diff --git a/shared/models/server/server-config.model.ts b/shared/models/server/server-config.model.ts
index 3498f86d7..6d1072333 100644
--- a/shared/models/server/server-config.model.ts
+++ b/shared/models/server/server-config.model.ts
@@ -56,6 +56,10 @@ export interface ServerConfig {
56 enabled: boolean 56 enabled: boolean
57 } 57 }
58 58
59 webtorrent: {
60 enabled: boolean
61 }
62
59 enabledResolutions: number[] 63 enabledResolutions: number[]
60 } 64 }
61 65
diff --git a/shared/models/videos/index.ts b/shared/models/videos/index.ts
index 194ae1b96..51ccb9fbd 100644
--- a/shared/models/videos/index.ts
+++ b/shared/models/videos/index.ts
@@ -23,6 +23,7 @@ export * from './playlist/video-playlist-element.model'
23export * from './video-change-ownership.model' 23export * from './video-change-ownership.model'
24export * from './video-change-ownership-create.model' 24export * from './video-change-ownership-create.model'
25export * from './video-create.model' 25export * from './video-create.model'
26export * from './video-file.model'
26export * from './video-privacy.enum' 27export * from './video-privacy.enum'
27export * from './video-rate.type' 28export * from './video-rate.type'
28export * from './video-resolution.enum' 29export * from './video-resolution.enum'
diff --git a/shared/models/videos/video-file.model.ts b/shared/models/videos/video-file.model.ts
new file mode 100644
index 000000000..04da0627e
--- /dev/null
+++ b/shared/models/videos/video-file.model.ts
@@ -0,0 +1,12 @@
1import { VideoConstant, VideoResolution } from '@shared/models'
2
3export interface VideoFile {
4 magnetUri: string
5 resolution: VideoConstant<VideoResolution>
6 size: number // Bytes
7 torrentUrl: string
8 torrentDownloadUrl: string
9 fileUrl: string
10 fileDownloadUrl: string
11 fps: number
12}
diff --git a/shared/models/videos/video-streaming-playlist.model.ts b/shared/models/videos/video-streaming-playlist.model.ts
index 17f8fe865..42fce4bdc 100644
--- a/shared/models/videos/video-streaming-playlist.model.ts
+++ b/shared/models/videos/video-streaming-playlist.model.ts
@@ -1,4 +1,5 @@
1import { VideoStreamingPlaylistType } from './video-streaming-playlist.type' 1import { VideoStreamingPlaylistType } from './video-streaming-playlist.type'
2import { VideoFile } from '@shared/models/videos/video-file.model'
2 3
3export class VideoStreamingPlaylist { 4export class VideoStreamingPlaylist {
4 id: number 5 id: number
@@ -9,4 +10,6 @@ export class VideoStreamingPlaylist {
9 redundancies: { 10 redundancies: {
10 baseUrl: string 11 baseUrl: string
11 }[] 12 }[]
13
14 files: VideoFile[]
12} 15}
diff --git a/shared/models/videos/video.model.ts b/shared/models/videos/video.model.ts
index e057b3e06..7576439fe 100644
--- a/shared/models/videos/video.model.ts
+++ b/shared/models/videos/video.model.ts
@@ -5,17 +5,7 @@ import { VideoPrivacy } from './video-privacy.enum'
5import { VideoScheduleUpdate } from './video-schedule-update.model' 5import { VideoScheduleUpdate } from './video-schedule-update.model'
6import { VideoConstant } from './video-constant.model' 6import { VideoConstant } from './video-constant.model'
7import { VideoStreamingPlaylist } from './video-streaming-playlist.model' 7import { VideoStreamingPlaylist } from './video-streaming-playlist.model'
8 8import { VideoFile } from './video-file.model'
9export interface VideoFile {
10 magnetUri: string
11 resolution: VideoConstant<VideoResolution>
12 size: number // Bytes
13 torrentUrl: string
14 torrentDownloadUrl: string
15 fileUrl: string
16 fileDownloadUrl: string
17 fps: number
18}
19 9
20export interface Video { 10export interface Video {
21 id: number 11 id: number