Skip to content

Commit

Permalink
Subscribe through "streams" list instead of "feed" for multistream Ja…
Browse files Browse the repository at this point in the history
…nus.
  • Loading branch information
fancycode committed Feb 27, 2024
1 parent da00080 commit 1247f6d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion mcu_janus.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ type mcuJanus struct {
gw *JanusGateway
session *JanusSession
handle *JanusHandle
version int

closeChan chan struct{}

Expand Down Expand Up @@ -282,6 +283,10 @@ func (m *mcuJanus) ConnectionInterrupted() {
m.notifyOnDisconnected()
}

func (m *mcuJanus) withMultistream() bool {
return m.version >= 1000
}

func (m *mcuJanus) Start() error {
ctx := context.TODO()
info, err := m.gw.Info(ctx)
Expand All @@ -295,6 +300,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")
Expand Down Expand Up @@ -1167,7 +1174,15 @@ retry:
"request": "join",
"ptype": "subscriber",
"room": p.roomId,
"feed": streamTypeUserIds[p.streamType],
}
if p.mcu.withMultistream() {
join_msg["streams"] = []map[string]interface{}{
{
"feed": streamTypeUserIds[p.streamType],
},
}
} else {
join_msg["feed"] = streamTypeUserIds[p.streamType]
}
if stream != nil {
stream.AddToMessage(join_msg)
Expand Down

0 comments on commit 1247f6d

Please sign in to comment.