aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-main
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-09-17 09:20:52 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-11-09 15:33:04 +0100
commitc6c0fa6cd8fe8f752463d8982c3dbcd448739c4e (patch)
tree79304b0152b0a38d33b26e65d4acdad0da4032a7 /client/src/app/shared/shared-main
parent110d463fece85e87a26aca48a6048ae0017a27b3 (diff)
downloadPeerTube-c6c0fa6cd8fe8f752463d8982c3dbcd448739c4e.tar.gz
PeerTube-c6c0fa6cd8fe8f752463d8982c3dbcd448739c4e.tar.zst
PeerTube-c6c0fa6cd8fe8f752463d8982c3dbcd448739c4e.zip
Live streaming implementation first step
Diffstat (limited to 'client/src/app/shared/shared-main')
-rw-r--r--client/src/app/shared/shared-main/shared-main.module.ts3
-rw-r--r--client/src/app/shared/shared-main/video/index.ts1
-rw-r--r--client/src/app/shared/shared-main/video/video-details.model.ts7
-rw-r--r--client/src/app/shared/shared-main/video/video-live.service.ts28
-rw-r--r--client/src/app/shared/shared-main/video/video.model.ts12
-rw-r--r--client/src/app/shared/shared-main/video/video.service.ts3
6 files changed, 48 insertions, 6 deletions
diff --git a/client/src/app/shared/shared-main/shared-main.module.ts b/client/src/app/shared/shared-main/shared-main.module.ts
index 7f4676dd1..bca67b193 100644
--- a/client/src/app/shared/shared-main/shared-main.module.ts
+++ b/client/src/app/shared/shared-main/shared-main.module.ts
@@ -23,7 +23,7 @@ import { FeedComponent } from './feeds'
23import { LoaderComponent, SmallLoaderComponent } from './loaders' 23import { LoaderComponent, SmallLoaderComponent } from './loaders'
24import { HelpComponent, ListOverflowComponent, TopMenuDropdownComponent } from './misc' 24import { HelpComponent, ListOverflowComponent, TopMenuDropdownComponent } from './misc'
25import { UserHistoryService, UserNotificationsComponent, UserNotificationService, UserQuotaComponent } from './users' 25import { UserHistoryService, UserNotificationsComponent, UserNotificationService, UserQuotaComponent } from './users'
26import { RedundancyService, VideoImportService, VideoOwnershipService, VideoService } from './video' 26import { RedundancyService, VideoImportService, VideoOwnershipService, VideoService, VideoLiveService } from './video'
27import { VideoCaptionService } from './video-caption' 27import { VideoCaptionService } from './video-caption'
28import { VideoChannelService } from './video-channel' 28import { VideoChannelService } from './video-channel'
29 29
@@ -142,6 +142,7 @@ import { VideoChannelService } from './video-channel'
142 RedundancyService, 142 RedundancyService,
143 VideoImportService, 143 VideoImportService,
144 VideoOwnershipService, 144 VideoOwnershipService,
145 VideoLiveService,
145 VideoService, 146 VideoService,
146 147
147 VideoCaptionService, 148 VideoCaptionService,
diff --git a/client/src/app/shared/shared-main/video/index.ts b/client/src/app/shared/shared-main/video/index.ts
index 3053df4ef..121635a30 100644
--- a/client/src/app/shared/shared-main/video/index.ts
+++ b/client/src/app/shared/shared-main/video/index.ts
@@ -2,6 +2,7 @@ export * from './redundancy.service'
2export * from './video-details.model' 2export * from './video-details.model'
3export * from './video-edit.model' 3export * from './video-edit.model'
4export * from './video-import.service' 4export * from './video-import.service'
5export * from './video-live.service'
5export * from './video-ownership.service' 6export * from './video-ownership.service'
6export * from './video.model' 7export * from './video.model'
7export * from './video.service' 8export * from './video.service'
diff --git a/client/src/app/shared/shared-main/video/video-details.model.ts b/client/src/app/shared/shared-main/video/video-details.model.ts
index a1cb051e9..f060d1dc9 100644
--- a/client/src/app/shared/shared-main/video/video-details.model.ts
+++ b/client/src/app/shared/shared-main/video/video-details.model.ts
@@ -62,8 +62,11 @@ export class VideoDetails extends Video implements VideoDetailsServerModel {
62 } 62 }
63 63
64 getFiles () { 64 getFiles () {
65 if (this.files.length === 0) return this.getHlsPlaylist().files 65 if (this.files.length !== 0) return this.files
66 66
67 return this.files 67 const hls = this.getHlsPlaylist()
68 if (hls) return hls.files
69
70 return []
68 } 71 }
69} 72}
diff --git a/client/src/app/shared/shared-main/video/video-live.service.ts b/client/src/app/shared/shared-main/video/video-live.service.ts
new file mode 100644
index 000000000..12daff756
--- /dev/null
+++ b/client/src/app/shared/shared-main/video/video-live.service.ts
@@ -0,0 +1,28 @@
1import { catchError } from 'rxjs/operators'
2import { HttpClient } from '@angular/common/http'
3import { Injectable } from '@angular/core'
4import { RestExtractor } from '@app/core'
5import { VideoCreate, VideoLive } from '@shared/models'
6import { environment } from '../../../../environments/environment'
7
8@Injectable()
9export class VideoLiveService {
10 static BASE_VIDEO_LIVE_URL = environment.apiUrl + '/api/v1/videos/live/'
11
12 constructor (
13 private authHttp: HttpClient,
14 private restExtractor: RestExtractor
15 ) {}
16
17 goLive (video: VideoCreate) {
18 return this.authHttp
19 .post<{ video: { id: number, uuid: string } }>(VideoLiveService.BASE_VIDEO_LIVE_URL, video)
20 .pipe(catchError(err => this.restExtractor.handleError(err)))
21 }
22
23 getVideoLive (videoId: number | string) {
24 return this.authHttp
25 .get<VideoLive>(VideoLiveService.BASE_VIDEO_LIVE_URL + videoId)
26 .pipe(catchError(err => this.restExtractor.handleError(err)))
27 }
28}
diff --git a/client/src/app/shared/shared-main/video/video.model.ts b/client/src/app/shared/shared-main/video/video.model.ts
index 0dca3da0d..e3a52af3d 100644
--- a/client/src/app/shared/shared-main/video/video.model.ts
+++ b/client/src/app/shared/shared-main/video/video.model.ts
@@ -40,6 +40,8 @@ export class Video implements VideoServerModel {
40 thumbnailPath: string 40 thumbnailPath: string
41 thumbnailUrl: string 41 thumbnailUrl: string
42 42
43 isLive: boolean
44
43 previewPath: string 45 previewPath: string
44 previewUrl: string 46 previewUrl: string
45 47
@@ -103,6 +105,8 @@ export class Video implements VideoServerModel {
103 this.state = hash.state 105 this.state = hash.state
104 this.description = hash.description 106 this.description = hash.description
105 107
108 this.isLive = hash.isLive
109
106 this.duration = hash.duration 110 this.duration = hash.duration
107 this.durationLabel = durationToString(hash.duration) 111 this.durationLabel = durationToString(hash.duration)
108 112
@@ -113,10 +117,14 @@ export class Video implements VideoServerModel {
113 this.name = hash.name 117 this.name = hash.name
114 118
115 this.thumbnailPath = hash.thumbnailPath 119 this.thumbnailPath = hash.thumbnailPath
116 this.thumbnailUrl = hash.thumbnailUrl || (absoluteAPIUrl + hash.thumbnailPath) 120 this.thumbnailUrl = this.thumbnailPath
121 ? hash.thumbnailUrl || (absoluteAPIUrl + hash.thumbnailPath)
122 : null
117 123
118 this.previewPath = hash.previewPath 124 this.previewPath = hash.previewPath
119 this.previewUrl = hash.previewUrl || (absoluteAPIUrl + hash.previewPath) 125 this.previewUrl = this.previewPath
126 ? hash.previewUrl || (absoluteAPIUrl + hash.previewPath)
127 : null
120 128
121 this.embedPath = hash.embedPath 129 this.embedPath = hash.embedPath
122 this.embedUrl = hash.embedUrl || (getAbsoluteEmbedUrl() + hash.embedPath) 130 this.embedUrl = hash.embedUrl || (getAbsoluteEmbedUrl() + hash.embedPath)
diff --git a/client/src/app/shared/shared-main/video/video.service.ts b/client/src/app/shared/shared-main/video/video.service.ts
index 8a688c8ed..0e2d36081 100644
--- a/client/src/app/shared/shared-main/video/video.service.ts
+++ b/client/src/app/shared/shared-main/video/video.service.ts
@@ -18,7 +18,8 @@ import {
18 VideoFilter, 18 VideoFilter,
19 VideoPrivacy, 19 VideoPrivacy,
20 VideoSortField, 20 VideoSortField,
21 VideoUpdate 21 VideoUpdate,
22 VideoCreate
22} from '@shared/models' 23} from '@shared/models'
23import { environment } from '../../../../environments/environment' 24import { environment } from '../../../../environments/environment'
24import { Account } from '../account/account.model' 25import { Account } from '../account/account.model'