Pass contexts when creating / starting MCUs.

This commit is contained in:
Joachim Bauch 2024-05-16 16:53:41 +02:00
commit c6cbe88d0e
No known key found for this signature in database
GPG key ID: 77C1D22D53E15F02
10 changed files with 65 additions and 61 deletions

View file

@ -22,6 +22,7 @@
package main
import (
"context"
"crypto/tls"
"errors"
"flag"
@ -240,9 +241,11 @@ func main() {
mcuRetryTimer := time.NewTimer(mcuRetry)
mcuTypeLoop:
for {
// Context should be cancelled on signals but need a way to differentiate later.
ctx := context.TODO()
switch mcuType {
case signaling.McuTypeJanus:
mcu, err = signaling.NewMcuJanus(mcuUrl, config)
mcu, err = signaling.NewMcuJanus(ctx, mcuUrl, config)
signaling.UnregisterProxyMcuStats()
signaling.RegisterJanusMcuStats()
case signaling.McuTypeProxy:
@ -253,7 +256,7 @@ func main() {
log.Fatal("Unsupported MCU type: ", mcuType)
}
if err == nil {
err = mcu.Start()
err = mcu.Start(ctx)
if err != nil {
log.Printf("Could not create %s MCU: %s", mcuType, err)
}