Fix HLS federation
authorChocobozzz <me@florianbigard.com>
Mon, 8 Apr 2019 10:08:16 +0000 (12:08 +0200)
committerChocobozzz <me@florianbigard.com>
Mon, 8 Apr 2019 10:08:16 +0000 (12:08 +0200)
server/lib/activitypub/videos.ts
server/lib/hls.ts
server/lib/video-transcoding.ts

index 339f8e79701c1e1689a8e9502cc4e4c9c997cc60..caff0621ec65330b74b07926cc2e3cc8f004b19e 100644 (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
     }
 
index c0fc4961a021ed3983482ef76ada1d0a0697dba0..a9a96dd16fc80248a18826db1b4d49502b6af171 100644 (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 })
     })
index c29e34ab52517848c1434e8bd8da8e064ecd1a02..dbc22816cd4d7c08fb8bb316186db9b7fa8909e2 100644 (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
   })