Fix HLS federation

This commit is contained in:
Chocobozzz 2019-04-08 12:08:16 +02:00
parent 0e9c48c2ed
commit 594d0c6a7c
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
3 changed files with 13 additions and 3 deletions

View File

@ -17,7 +17,15 @@ import { isVideoFileInfoHashValid } from '../../helpers/custom-validators/videos
import { resetSequelizeInstance, retryTransactionWrapper } from '../../helpers/database-utils'
import { logger } from '../../helpers/logger'
import { doRequest, downloadImage } from '../../helpers/requests'
import { ACTIVITY_PUB, CONFIG, MIMETYPES, REMOTE_SCHEME, sequelizeTypescript, THUMBNAILS_SIZE } from '../../initializers'
import {
ACTIVITY_PUB,
CONFIG,
MIMETYPES,
P2P_MEDIA_LOADER_PEER_VERSION,
REMOTE_SCHEME,
sequelizeTypescript,
THUMBNAILS_SIZE
} from '../../initializers'
import { ActorModel } from '../../models/activitypub/actor'
import { TagModel } from '../../models/video/tag'
import { VideoModel } from '../../models/video/video'
@ -599,6 +607,7 @@ function streamingPlaylistActivityUrlToDBAttributes (video: VideoModel, videoObj
playlistUrl: playlistUrlObject.href,
segmentsSha256Url: segmentsSha256UrlObject.href,
p2pMediaLoaderInfohashes: VideoStreamingPlaylistModel.buildP2PMediaLoaderInfoHashes(playlistUrlObject.href, videoFiles),
p2pMediaLoaderPeerVersion: P2P_MEDIA_LOADER_PEER_VERSION,
videoId: video.id
}

View File

@ -19,7 +19,7 @@ async function updateStreamingPlaylistsInfohashesIfNeeded () {
await sequelizeTypescript.transaction(async t => {
const videoFiles = await VideoFileModel.listByStreamingPlaylist(playlist.id, t)
playlist.p2pMediaLoaderInfohashes = await VideoStreamingPlaylistModel.buildP2PMediaLoaderInfoHashes(playlist.playlistUrl, videoFiles)
playlist.p2pMediaLoaderInfohashes = VideoStreamingPlaylistModel.buildP2PMediaLoaderInfoHashes(playlist.playlistUrl, videoFiles)
playlist.p2pMediaLoaderPeerVersion = P2P_MEDIA_LOADER_PEER_VERSION
await playlist.save({ transaction: t })
})

View File

@ -1,4 +1,4 @@
import { CONFIG, HLS_STREAMING_PLAYLIST_DIRECTORY } from '../initializers'
import { CONFIG, HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION } from '../initializers'
import { join } from 'path'
import { getVideoFileFPS, transcode } from '../helpers/ffmpeg-utils'
import { ensureDir, move, remove, stat } from 'fs-extra'
@ -118,6 +118,7 @@ async function generateHlsPlaylist (video: VideoModel, resolution: VideoResoluti
playlistUrl,
segmentsSha256Url: CONFIG.WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsSha256SegmentsStaticPath(video.uuid),
p2pMediaLoaderInfohashes: VideoStreamingPlaylistModel.buildP2PMediaLoaderInfoHashes(playlistUrl, video.VideoFiles),
p2pMediaLoaderPeerVersion: P2P_MEDIA_LOADER_PEER_VERSION,
type: VideoStreamingPlaylistType.HLS
})