aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
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
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')
-rw-r--r--client/src/app/shared/shared-forms/input-readonly-copy.component.html2
-rw-r--r--client/src/app/shared/shared-forms/input-readonly-copy.component.ts2
-rw-r--r--client/src/app/shared/shared-instance/instance-features-table.component.html18
-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
9 files changed, 69 insertions, 7 deletions
diff --git a/client/src/app/shared/shared-forms/input-readonly-copy.component.html b/client/src/app/shared/shared-forms/input-readonly-copy.component.html
index 9566e9741..7a75bd70b 100644
--- a/client/src/app/shared/shared-forms/input-readonly-copy.component.html
+++ b/client/src/app/shared/shared-forms/input-readonly-copy.component.html
@@ -1,5 +1,5 @@
1<div class="input-group input-group-sm"> 1<div class="input-group input-group-sm">
2 <input #urlInput (click)="urlInput.select()" type="text" class="form-control readonly" readonly [value]="value" /> 2 <input [id]="id" #urlInput (click)="urlInput.select()" type="text" class="form-control readonly" readonly [value]="value" />
3 3
4 <div class="input-group-append"> 4 <div class="input-group-append">
5 <button [cdkCopyToClipboard]="urlInput.value" (click)="activateCopiedMessage()" type="button" class="btn btn-outline-secondary"> 5 <button [cdkCopyToClipboard]="urlInput.value" (click)="activateCopiedMessage()" type="button" class="btn btn-outline-secondary">
diff --git a/client/src/app/shared/shared-forms/input-readonly-copy.component.ts b/client/src/app/shared/shared-forms/input-readonly-copy.component.ts
index a67b0c691..520827a53 100644
--- a/client/src/app/shared/shared-forms/input-readonly-copy.component.ts
+++ b/client/src/app/shared/shared-forms/input-readonly-copy.component.ts
@@ -1,5 +1,6 @@
1import { Component, Input } from '@angular/core' 1import { Component, Input } from '@angular/core'
2import { Notifier } from '@app/core' 2import { Notifier } from '@app/core'
3import { FormGroup } from '@angular/forms'
3 4
4@Component({ 5@Component({
5 selector: 'my-input-readonly-copy', 6 selector: 'my-input-readonly-copy',
@@ -7,6 +8,7 @@ import { Notifier } from '@app/core'
7 styleUrls: [ './input-readonly-copy.component.scss' ] 8 styleUrls: [ './input-readonly-copy.component.scss' ]
8}) 9})
9export class InputReadonlyCopyComponent { 10export class InputReadonlyCopyComponent {
11 @Input() id: string
10 @Input() value = '' 12 @Input() value = ''
11 13
12 constructor (private notifier: Notifier) { } 14 constructor (private notifier: Notifier) { }
diff --git a/client/src/app/shared/shared-instance/instance-features-table.component.html b/client/src/app/shared/shared-instance/instance-features-table.component.html
index f6a3b7f0b..002695238 100644
--- a/client/src/app/shared/shared-instance/instance-features-table.component.html
+++ b/client/src/app/shared/shared-instance/instance-features-table.component.html
@@ -64,6 +64,24 @@
64 </tr> 64 </tr>
65 65
66 <tr> 66 <tr>
67 <th i18n class="label" colspan="2">Live streaming</th>
68 </tr>
69
70 <tr>
71 <th i18n class="sub-label" scope="row">Live streaming enabled</th>
72 <td>
73 <my-feature-boolean [value]="serverConfig.live.enabled"></my-feature-boolean>
74 </td>
75 </tr>
76
77 <tr>
78 <th i18n class="sub-label" scope="row">Transcode live video in multiple resolutions</th>
79 <td>
80 <my-feature-boolean [value]="serverConfig.live.transcoding.enabled && serverConfig.live.transcoding.enabledResolutions.length > 1"></my-feature-boolean>
81 </td>
82 </tr>
83
84 <tr>
67 <th i18n class="label" colspan="2">Import</th> 85 <th i18n class="label" colspan="2">Import</th>
68 </tr> 86 </tr>
69 87
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'