From d3b2cc4e67f24c4df38d5b355bae2beeb2a0446a Mon Sep 17 00:00:00 2001 From: zarazaex69 Date: Mon, 20 Apr 2026 20:24:12 +0300 Subject: [PATCH] refactor: move builtin carrier registration behind carrier layer --- internal/app/session/session.go | 11 +++-------- internal/carrier/builtin/register.go | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 internal/carrier/builtin/register.go diff --git a/internal/app/session/session.go b/internal/app/session/session.go index c73cdd5..3f3e4dd 100644 --- a/internal/app/session/session.go +++ b/internal/app/session/session.go @@ -7,19 +7,17 @@ import ( "fmt" "github.com/openlibrecommunity/olcrtc/internal/carrier" + "github.com/openlibrecommunity/olcrtc/internal/carrier/builtin" "github.com/openlibrecommunity/olcrtc/internal/client" "github.com/openlibrecommunity/olcrtc/internal/link" "github.com/openlibrecommunity/olcrtc/internal/link/direct" - "github.com/openlibrecommunity/olcrtc/internal/provider/jazz" - "github.com/openlibrecommunity/olcrtc/internal/provider/telemost" - "github.com/openlibrecommunity/olcrtc/internal/provider/wbstream" "github.com/openlibrecommunity/olcrtc/internal/server" "github.com/openlibrecommunity/olcrtc/internal/transport" "github.com/openlibrecommunity/olcrtc/internal/transport/datachannel" ) var ( - // ErrRoomIDRequired indicates that a room id is required for the selected provider. + // ErrRoomIDRequired indicates that a room id is required for the selected carrier. ErrRoomIDRequired = errors.New("room ID required") // ErrModeRequired indicates that mode is not one of the supported values. ErrModeRequired = errors.New("specify -mode srv or -mode cnc") @@ -50,10 +48,7 @@ type Config struct { // RegisterDefaults registers built-in providers and transports. func RegisterDefaults() { - carrier.RegisterLegacy("jazz", jazz.New) - carrier.RegisterLegacy("telemost", telemost.New) - carrier.RegisterLegacy("wb_stream", wbstream.New) - + builtin.Register() link.Register("direct", direct.New) transport.Register("datachannel", datachannel.New) } diff --git a/internal/carrier/builtin/register.go b/internal/carrier/builtin/register.go new file mode 100644 index 0000000..dd57026 --- /dev/null +++ b/internal/carrier/builtin/register.go @@ -0,0 +1,16 @@ +// Package builtin registers the built-in carrier implementations. +package builtin + +import ( + "github.com/openlibrecommunity/olcrtc/internal/carrier" + "github.com/openlibrecommunity/olcrtc/internal/provider/jazz" + "github.com/openlibrecommunity/olcrtc/internal/provider/telemost" + "github.com/openlibrecommunity/olcrtc/internal/provider/wbstream" +) + +// Register wires the built-in legacy carriers into the carrier registry. +func Register() { + carrier.RegisterLegacy("jazz", jazz.New) + carrier.RegisterLegacy("telemost", telemost.New) + carrier.RegisterLegacy("wb_stream", wbstream.New) +}