Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix HLS federation

Chocobozzz594d0c6a7c64
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts
index 339f8e7970..caff0621ec 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 c0fc4961a0..a9a96dd16f 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 c29e34ab52..dbc22816cd 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
})