From bd445bd99b91c1104c7a8d93379ac283fda717fd Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Tue, 27 Feb 2024 11:38:15 +0100 Subject: [PATCH] Subscribe through "streams" list instead of "feed" for multistream Janus. --- mcu_janus.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/mcu_janus.go b/mcu_janus.go index 58d92e1..190360b 100644 --- a/mcu_janus.go +++ b/mcu_janus.go @@ -143,6 +143,7 @@ type mcuJanus struct { gw *JanusGateway session *JanusSession handle *JanusHandle + version int closeChan chan struct{} @@ -283,6 +284,10 @@ func (m *mcuJanus) ConnectionInterrupted() { m.notifyOnDisconnected() } +func (m *mcuJanus) isMultistream() bool { + return m.version >= 1000 +} + func (m *mcuJanus) Start() error { ctx := context.TODO() info, err := m.gw.Info(ctx) @@ -296,6 +301,8 @@ func (m *mcuJanus) Start() error { return fmt.Errorf("Plugin %s is not supported", pluginVideoRoom) } + m.version = info.Version + log.Printf("Found %s %s by %s", plugin.Name, plugin.VersionString, plugin.Author) if !info.DataChannels { return fmt.Errorf("Data channels are not supported") @@ -1175,7 +1182,15 @@ retry: "request": "join", "ptype": "subscriber", "room": p.roomId, - "feed": streamTypeUserIds[p.streamType], + } + if p.mcu.isMultistream() { + join_msg["streams"] = []map[string]interface{}{ + { + "feed": streamTypeUserIds[p.streamType], + }, + } + } else { + join_msg["feed"] = streamTypeUserIds[p.streamType] } if stream != nil { stream.AddToMessage(join_msg)