mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2024-06-07 08:22:36 +02:00
Move processing of deferred method to dedicated DeferredExecutor.
This fixes an issue where re-joining a room after error stopped the internal processing of deferred functions.
This commit is contained in:
parent
563658bf59
commit
4ef06867dd
|
@ -371,7 +371,7 @@ type mcuJanusClient struct {
|
||||||
handle *JanusHandle
|
handle *JanusHandle
|
||||||
handleId uint64
|
handleId uint64
|
||||||
closeChan chan bool
|
closeChan chan bool
|
||||||
deferred chan func()
|
deferred *DeferredExecutor
|
||||||
|
|
||||||
handleEvent func(event *janus.EventMsg)
|
handleEvent func(event *janus.EventMsg)
|
||||||
handleHangup func(event *janus.HangupMsg)
|
handleHangup func(event *janus.HangupMsg)
|
||||||
|
@ -389,6 +389,7 @@ func (c *mcuJanusClient) StreamType() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *mcuJanusClient) Close(ctx context.Context) {
|
func (c *mcuJanusClient) Close(ctx context.Context) {
|
||||||
|
c.deferred.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *mcuJanusClient) SendMessage(ctx context.Context, message *MessageClientMessage, data *MessageClientMessageData, callback func(error, map[string]interface{})) {
|
func (c *mcuJanusClient) SendMessage(ctx context.Context, message *MessageClientMessage, data *MessageClientMessageData, callback func(error, map[string]interface{})) {
|
||||||
|
@ -429,8 +430,6 @@ loop:
|
||||||
default:
|
default:
|
||||||
log.Println("Received unsupported event type", msg, reflect.TypeOf(msg))
|
log.Println("Received unsupported event type", msg, reflect.TypeOf(msg))
|
||||||
}
|
}
|
||||||
case f := <-c.deferred:
|
|
||||||
f()
|
|
||||||
case <-closeChan:
|
case <-closeChan:
|
||||||
break loop
|
break loop
|
||||||
}
|
}
|
||||||
|
@ -593,7 +592,7 @@ func (m *mcuJanus) NewPublisher(ctx context.Context, listener McuListener, id st
|
||||||
handle: handle,
|
handle: handle,
|
||||||
handleId: handle.Id,
|
handleId: handle.Id,
|
||||||
closeChan: make(chan bool, 1),
|
closeChan: make(chan bool, 1),
|
||||||
deferred: make(chan func(), 64),
|
deferred: NewDeferredExecutor(64),
|
||||||
},
|
},
|
||||||
id: id,
|
id: id,
|
||||||
}
|
}
|
||||||
|
@ -712,19 +711,19 @@ func (p *mcuJanusPublisher) SendMessage(ctx context.Context, message *MessageCli
|
||||||
jsep_msg := data.Payload
|
jsep_msg := data.Payload
|
||||||
switch data.Type {
|
switch data.Type {
|
||||||
case "offer":
|
case "offer":
|
||||||
p.deferred <- func() {
|
p.deferred.Execute(func() {
|
||||||
msgctx, cancel := context.WithTimeout(context.Background(), p.mcu.mcuTimeout)
|
msgctx, cancel := context.WithTimeout(context.Background(), p.mcu.mcuTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
p.sendOffer(msgctx, jsep_msg, callback)
|
p.sendOffer(msgctx, jsep_msg, callback)
|
||||||
}
|
})
|
||||||
case "candidate":
|
case "candidate":
|
||||||
p.deferred <- func() {
|
p.deferred.Execute(func() {
|
||||||
msgctx, cancel := context.WithTimeout(context.Background(), p.mcu.mcuTimeout)
|
msgctx, cancel := context.WithTimeout(context.Background(), p.mcu.mcuTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
p.sendCandidate(msgctx, jsep_msg["candidate"], callback)
|
p.sendCandidate(msgctx, jsep_msg["candidate"], callback)
|
||||||
}
|
})
|
||||||
case "endOfCandidates":
|
case "endOfCandidates":
|
||||||
// Ignore
|
// Ignore
|
||||||
default:
|
default:
|
||||||
|
@ -885,7 +884,7 @@ func (m *mcuJanus) NewSubscriber(ctx context.Context, listener McuListener, publ
|
||||||
handle: handle,
|
handle: handle,
|
||||||
handleId: handle.Id,
|
handleId: handle.Id,
|
||||||
closeChan: make(chan bool, 1),
|
closeChan: make(chan bool, 1),
|
||||||
deferred: make(chan func(), 64),
|
deferred: NewDeferredExecutor(64),
|
||||||
},
|
},
|
||||||
publisher: publisher,
|
publisher: publisher,
|
||||||
}
|
}
|
||||||
|
@ -1069,26 +1068,26 @@ func (p *mcuJanusSubscriber) SendMessage(ctx context.Context, message *MessageCl
|
||||||
case "requestoffer":
|
case "requestoffer":
|
||||||
fallthrough
|
fallthrough
|
||||||
case "sendoffer":
|
case "sendoffer":
|
||||||
p.deferred <- func() {
|
p.deferred.Execute(func() {
|
||||||
msgctx, cancel := context.WithTimeout(context.Background(), p.mcu.mcuTimeout)
|
msgctx, cancel := context.WithTimeout(context.Background(), p.mcu.mcuTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
p.joinRoom(msgctx, callback)
|
p.joinRoom(msgctx, callback)
|
||||||
}
|
})
|
||||||
case "answer":
|
case "answer":
|
||||||
p.deferred <- func() {
|
p.deferred.Execute(func() {
|
||||||
msgctx, cancel := context.WithTimeout(context.Background(), p.mcu.mcuTimeout)
|
msgctx, cancel := context.WithTimeout(context.Background(), p.mcu.mcuTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
p.sendAnswer(msgctx, jsep_msg, callback)
|
p.sendAnswer(msgctx, jsep_msg, callback)
|
||||||
}
|
})
|
||||||
case "candidate":
|
case "candidate":
|
||||||
p.deferred <- func() {
|
p.deferred.Execute(func() {
|
||||||
msgctx, cancel := context.WithTimeout(context.Background(), p.mcu.mcuTimeout)
|
msgctx, cancel := context.WithTimeout(context.Background(), p.mcu.mcuTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
p.sendCandidate(msgctx, jsep_msg["candidate"], callback)
|
p.sendCandidate(msgctx, jsep_msg["candidate"], callback)
|
||||||
}
|
})
|
||||||
case "endOfCandidates":
|
case "endOfCandidates":
|
||||||
// Ignore
|
// Ignore
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue