From 594d0c6a7c64b045c11508bb4e4b19b75b3fc557 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 8 Apr 2019 12:08:16 +0200 Subject: [PATCH] Fix HLS federation --- server/lib/activitypub/videos.ts | 11 ++++++++++- server/lib/hls.ts | 2 +- server/lib/video-transcoding.ts | 3 ++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts index 339f8e797..caff0621e 100644 --- a/server/lib/activitypub/videos.ts +++ b/server/lib/activitypub/videos.ts @@ -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 } diff --git a/server/lib/hls.ts b/server/lib/hls.ts index c0fc4961a..a9a96dd16 100644 --- a/server/lib/hls.ts +++ b/server/lib/hls.ts @@ -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 }) }) diff --git a/server/lib/video-transcoding.ts b/server/lib/video-transcoding.ts index c29e34ab5..dbc22816c 100644 --- a/server/lib/video-transcoding.ts +++ b/server/lib/video-transcoding.ts @@ -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 }) -- 2.41.0