mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 02:09:37 +02:00
Fix client player error on fast restream
This commit is contained in:
parent
d47d95cb6f
commit
25684e837c
12 changed files with 141 additions and 41 deletions
|
@ -8,6 +8,7 @@ import { UserNotificationModelForApi } from '@server/types/models/user/index.js'
|
|||
import { LiveVideoEventPayload, LiveVideoEventType } from '@peertube/peertube-models'
|
||||
import { logger } from '../helpers/logger.js'
|
||||
import { authenticateRunnerSocket, authenticateSocket } from '../middlewares/index.js'
|
||||
import { isDevInstance } from '@peertube/peertube-node-utils'
|
||||
|
||||
class PeerTubeSocket {
|
||||
|
||||
|
@ -20,7 +21,11 @@ class PeerTubeSocket {
|
|||
private constructor () {}
|
||||
|
||||
init (server: HTTPServer) {
|
||||
const io = new SocketServer(server)
|
||||
const io = new SocketServer(server, {
|
||||
cors: isDevInstance()
|
||||
? { origin: 'http://localhost:5173', methods: [ 'GET', 'POST' ] }
|
||||
: undefined
|
||||
})
|
||||
|
||||
io.of('/user-notifications')
|
||||
.use(authenticateSocket)
|
||||
|
@ -88,6 +93,8 @@ class PeerTubeSocket {
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
sendVideoLiveNewState (video: MVideo) {
|
||||
const data: LiveVideoEventPayload = { state: video.state }
|
||||
const type: LiveVideoEventType = 'state-change'
|
||||
|
@ -110,6 +117,18 @@ class PeerTubeSocket {
|
|||
.emit(type, data)
|
||||
}
|
||||
|
||||
sendVideoForceEnd (video: MVideo) {
|
||||
const type: LiveVideoEventType = 'force-end'
|
||||
|
||||
logger.debug('Sending video live "force end" notification of %s.', video.url)
|
||||
|
||||
this.liveVideosNamespace
|
||||
.in(video.id + '')
|
||||
.emit(type)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@Debounce({ timeoutMS: 1000 })
|
||||
sendAvailableJobsPingToRunners () {
|
||||
logger.debug(`Sending available-jobs notification to ${this.runnerSockets.size} runner sockets`)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue