aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-01-29 08:37:25 +0100
committerChocobozzz <chocobozzz@cpy.re>2019-02-11 09:13:02 +0100
commit092092969633bbcf6d4891a083ea497a7d5c3154 (patch)
tree69e82fe4f60c444cca216830e96afe143a9dac71 /client/src/app
parent4348a27d252a3349bafa7ef4859c0e2cf060c255 (diff)
downloadPeerTube-092092969633bbcf6d4891a083ea497a7d5c3154.tar.gz
PeerTube-092092969633bbcf6d4891a083ea497a7d5c3154.tar.zst
PeerTube-092092969633bbcf6d4891a083ea497a7d5c3154.zip
Add hls support on server
Diffstat (limited to 'client/src/app')
-rw-r--r--client/src/app/+admin/users/user-edit/user-edit.ts6
-rw-r--r--client/src/app/core/server/server.service.ts5
-rw-r--r--client/src/app/shared/video/video-details.model.ts13
-rw-r--r--client/src/app/videos/+video-watch/video-watch.component.ts28
4 files changed, 45 insertions, 7 deletions
diff --git a/client/src/app/+admin/users/user-edit/user-edit.ts b/client/src/app/+admin/users/user-edit/user-edit.ts
index 0b3511e8e..021b1feb4 100644
--- a/client/src/app/+admin/users/user-edit/user-edit.ts
+++ b/client/src/app/+admin/users/user-edit/user-edit.ts
@@ -22,7 +22,9 @@ export abstract class UserEdit extends FormReactive {
22 } 22 }
23 23
24 computeQuotaWithTranscoding () { 24 computeQuotaWithTranscoding () {
25 const resolutions = this.serverService.getConfig().transcoding.enabledResolutions 25 const transcodingConfig = this.serverService.getConfig().transcoding
26
27 const resolutions = transcodingConfig.enabledResolutions
26 const higherResolution = VideoResolution.H_1080P 28 const higherResolution = VideoResolution.H_1080P
27 let multiplier = 0 29 let multiplier = 0
28 30
@@ -30,6 +32,8 @@ export abstract class UserEdit extends FormReactive {
30 multiplier += resolution / higherResolution 32 multiplier += resolution / higherResolution
31 } 33 }
32 34
35 if (transcodingConfig.hls.enabled) multiplier *= 2
36
33 return multiplier * parseInt(this.form.value['videoQuota'], 10) 37 return multiplier * parseInt(this.form.value['videoQuota'], 10)
34 } 38 }
35 39
diff --git a/client/src/app/core/server/server.service.ts b/client/src/app/core/server/server.service.ts
index 4ae72427b..c868ccdcc 100644
--- a/client/src/app/core/server/server.service.ts
+++ b/client/src/app/core/server/server.service.ts
@@ -51,7 +51,10 @@ export class ServerService {
51 requiresEmailVerification: false 51 requiresEmailVerification: false
52 }, 52 },
53 transcoding: { 53 transcoding: {
54 enabledResolutions: [] 54 enabledResolutions: [],
55 hls: {
56 enabled: false
57 }
55 }, 58 },
56 avatar: { 59 avatar: {
57 file: { 60 file: {
diff --git a/client/src/app/shared/video/video-details.model.ts b/client/src/app/shared/video/video-details.model.ts
index fa4ca7f93..f44b4138b 100644
--- a/client/src/app/shared/video/video-details.model.ts
+++ b/client/src/app/shared/video/video-details.model.ts
@@ -3,6 +3,8 @@ import { AuthUser } from '../../core'
3import { Video } from '../../shared/video/video.model' 3import { Video } from '../../shared/video/video.model'
4import { Account } from '@app/shared/account/account.model' 4import { Account } from '@app/shared/account/account.model'
5import { VideoChannel } from '@app/shared/video-channel/video-channel.model' 5import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
6import { VideoStreamingPlaylist } from '../../../../../shared/models/videos/video-streaming-playlist.model'
7import { VideoStreamingPlaylistType } from '../../../../../shared/models/videos/video-streaming-playlist.type'
6 8
7export class VideoDetails extends Video implements VideoDetailsServerModel { 9export class VideoDetails extends Video implements VideoDetailsServerModel {
8 descriptionPath: string 10 descriptionPath: string
@@ -19,6 +21,10 @@ export class VideoDetails extends Video implements VideoDetailsServerModel {
19 likesPercent: number 21 likesPercent: number
20 dislikesPercent: number 22 dislikesPercent: number
21 23
24 trackerUrls: string[]
25
26 streamingPlaylists: VideoStreamingPlaylist[]
27
22 constructor (hash: VideoDetailsServerModel, translations = {}) { 28 constructor (hash: VideoDetailsServerModel, translations = {}) {
23 super(hash, translations) 29 super(hash, translations)
24 30
@@ -30,6 +36,9 @@ export class VideoDetails extends Video implements VideoDetailsServerModel {
30 this.support = hash.support 36 this.support = hash.support
31 this.commentsEnabled = hash.commentsEnabled 37 this.commentsEnabled = hash.commentsEnabled
32 38
39 this.trackerUrls = hash.trackerUrls
40 this.streamingPlaylists = hash.streamingPlaylists
41
33 this.buildLikeAndDislikePercents() 42 this.buildLikeAndDislikePercents()
34 } 43 }
35 44
@@ -53,4 +62,8 @@ export class VideoDetails extends Video implements VideoDetailsServerModel {
53 this.likesPercent = (this.likes / (this.likes + this.dislikes)) * 100 62 this.likesPercent = (this.likes / (this.likes + this.dislikes)) * 100
54 this.dislikesPercent = (this.dislikes / (this.likes + this.dislikes)) * 100 63 this.dislikesPercent = (this.dislikes / (this.likes + this.dislikes)) * 100
55 } 64 }
65
66 getHlsPlaylist () {
67 return this.streamingPlaylists.find(p => p.type === VideoStreamingPlaylistType.HLS)
68 }
56} 69}
diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts
index 6e38af195..f77316712 100644
--- a/client/src/app/videos/+video-watch/video-watch.component.ts
+++ b/client/src/app/videos/+video-watch/video-watch.component.ts
@@ -23,7 +23,7 @@ import { I18n } from '@ngx-translate/i18n-polyfill'
23import { environment } from '../../../environments/environment' 23import { environment } from '../../../environments/environment'
24import { VideoCaptionService } from '@app/shared/video-caption' 24import { VideoCaptionService } from '@app/shared/video-caption'
25import { MarkdownService } from '@app/shared/renderer' 25import { MarkdownService } from '@app/shared/renderer'
26import { PeertubePlayerManager } from '../../../assets/player/peertube-player-manager' 26import { P2PMediaLoaderOptions, PeertubePlayerManager, PlayerMode, WebtorrentOptions } from '../../../assets/player/peertube-player-manager'
27 27
28@Component({ 28@Component({
29 selector: 'my-video-watch', 29 selector: 'my-video-watch',
@@ -424,15 +424,33 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
424 serverUrl: environment.apiUrl, 424 serverUrl: environment.apiUrl,
425 425
426 videoCaptions: playerCaptions 426 videoCaptions: playerCaptions
427 }, 427 }
428 }
428 429
429 webtorrent: { 430 let mode: PlayerMode
431 const hlsPlaylist = this.video.getHlsPlaylist()
432 if (hlsPlaylist) {
433 mode = 'p2p-media-loader'
434 const p2pMediaLoader = {
435 playlistUrl: hlsPlaylist.playlistUrl,
436 segmentsSha256Url: hlsPlaylist.segmentsSha256Url,
437 redundancyBaseUrls: hlsPlaylist.redundancies.map(r => r.baseUrl),
438 trackerAnnounce: this.video.trackerUrls,
430 videoFiles: this.video.files 439 videoFiles: this.video.files
431 } 440 } as P2PMediaLoaderOptions
441
442 Object.assign(options, { p2pMediaLoader })
443 } else {
444 mode = 'webtorrent'
445 const webtorrent = {
446 videoFiles: this.video.files
447 } as WebtorrentOptions
448
449 Object.assign(options, { webtorrent })
432 } 450 }
433 451
434 this.zone.runOutsideAngular(async () => { 452 this.zone.runOutsideAngular(async () => {
435 this.player = await PeertubePlayerManager.initialize('webtorrent', options) 453 this.player = await PeertubePlayerManager.initialize(mode, options)
436 this.player.on('customError', ({ err }: { err: any }) => this.handleError(err)) 454 this.player.on('customError', ({ err }: { err: any }) => this.handleError(err))
437 }) 455 })
438 456