mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 02:39:33 +02:00
Add hls support on server
This commit is contained in:
parent
4348a27d25
commit
0920929696
81 changed files with 2000 additions and 407 deletions
|
@ -1,11 +1,28 @@
|
|||
import { CacheFileObject } from '../../../shared/index'
|
||||
import { ActivityPlaylistUrlObject, ActivityVideoUrlObject, CacheFileObject } from '../../../shared/index'
|
||||
import { VideoModel } from '../../models/video/video'
|
||||
import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy'
|
||||
import { Transaction } from 'sequelize'
|
||||
import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type'
|
||||
|
||||
function cacheFileActivityObjectToDBAttributes (cacheFileObject: CacheFileObject, video: VideoModel, byActor: { id?: number }) {
|
||||
const url = cacheFileObject.url
|
||||
|
||||
if (cacheFileObject.url.mediaType === 'application/x-mpegURL') {
|
||||
const url = cacheFileObject.url
|
||||
|
||||
const playlist = video.VideoStreamingPlaylists.find(t => t.type === VideoStreamingPlaylistType.HLS)
|
||||
if (!playlist) throw new Error('Cannot find HLS playlist of video ' + video.url)
|
||||
|
||||
return {
|
||||
expiresOn: new Date(cacheFileObject.expires),
|
||||
url: cacheFileObject.id,
|
||||
fileUrl: url.href,
|
||||
strategy: null,
|
||||
videoStreamingPlaylistId: playlist.id,
|
||||
actorId: byActor.id
|
||||
}
|
||||
}
|
||||
|
||||
const url = cacheFileObject.url
|
||||
const videoFile = video.VideoFiles.find(f => {
|
||||
return f.resolution === url.height && f.fps === url.fps
|
||||
})
|
||||
|
@ -15,7 +32,7 @@ function cacheFileActivityObjectToDBAttributes (cacheFileObject: CacheFileObject
|
|||
return {
|
||||
expiresOn: new Date(cacheFileObject.expires),
|
||||
url: cacheFileObject.id,
|
||||
fileUrl: cacheFileObject.url.href,
|
||||
fileUrl: url.href,
|
||||
strategy: null,
|
||||
videoFileId: videoFile.id,
|
||||
actorId: byActor.id
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue