mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2024-06-08 00:42:25 +02:00
Add API to select a simulcast substream / temporal layer.
This commit is contained in:
parent
6886bb9b53
commit
0a8ce3bda3
10
hub.go
10
hub.go
|
@ -1211,6 +1211,8 @@ func (h *Hub) processMessageMsg(client *Client, message *ClientMessage) {
|
||||||
fallthrough
|
fallthrough
|
||||||
case "endOfCandidates":
|
case "endOfCandidates":
|
||||||
fallthrough
|
fallthrough
|
||||||
|
case "selectStream":
|
||||||
|
fallthrough
|
||||||
case "candidate":
|
case "candidate":
|
||||||
h.processMcuMessage(session, session, message, msg, &data)
|
h.processMcuMessage(session, session, message, msg, &data)
|
||||||
return
|
return
|
||||||
|
@ -1640,6 +1642,14 @@ func (h *Hub) processMcuMessage(senderSession *ClientSession, session *ClientSes
|
||||||
|
|
||||||
clientType = "publisher"
|
clientType = "publisher"
|
||||||
mc, err = session.GetOrCreatePublisher(ctx, h.mcu, data.RoomType)
|
mc, err = session.GetOrCreatePublisher(ctx, h.mcu, data.RoomType)
|
||||||
|
case "selectStream":
|
||||||
|
if session.PublicId() == message.Recipient.SessionId {
|
||||||
|
log.Printf("Not selecting substream for own %s stream in session %s", data.RoomType, session.PublicId())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
clientType = "subscriber"
|
||||||
|
mc = session.GetSubscriber(message.Recipient.SessionId, data.RoomType)
|
||||||
default:
|
default:
|
||||||
if session.PublicId() == message.Recipient.SessionId {
|
if session.PublicId() == message.Recipient.SessionId {
|
||||||
if !isAllowedToSend(session, data) {
|
if !isAllowedToSend(session, data) {
|
||||||
|
|
71
mcu_janus.go
71
mcu_janus.go
|
@ -572,6 +572,36 @@ func (c *mcuJanusClient) handleTrickle(event *TrickleMsg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *mcuJanusClient) selectStream(ctx context.Context, substream int, temporal int, callback func(error, map[string]interface{})) {
|
||||||
|
handle := c.handle
|
||||||
|
if handle == nil {
|
||||||
|
callback(ErrNotConnected, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if substream < 0 && temporal < 0 {
|
||||||
|
callback(nil, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
configure_msg := map[string]interface{}{
|
||||||
|
"request": "configure",
|
||||||
|
}
|
||||||
|
if substream >= 0 {
|
||||||
|
configure_msg["substream"] = substream
|
||||||
|
}
|
||||||
|
if temporal >= 0 {
|
||||||
|
configure_msg["temporal"] = temporal
|
||||||
|
}
|
||||||
|
_, err := handle.Message(ctx, configure_msg, nil)
|
||||||
|
if err != nil {
|
||||||
|
callback(err, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(nil, nil)
|
||||||
|
}
|
||||||
|
|
||||||
type mcuJanusPublisher struct {
|
type mcuJanusPublisher struct {
|
||||||
mcuJanusClient
|
mcuJanusClient
|
||||||
|
|
||||||
|
@ -1079,6 +1109,47 @@ func (p *mcuJanusSubscriber) SendMessage(ctx context.Context, message *MessageCl
|
||||||
}
|
}
|
||||||
case "endOfCandidates":
|
case "endOfCandidates":
|
||||||
// Ignore
|
// Ignore
|
||||||
|
case "selectStream":
|
||||||
|
substream := -1
|
||||||
|
if s, found := jsep_msg["substream"]; found {
|
||||||
|
switch s := s.(type) {
|
||||||
|
case int:
|
||||||
|
substream = s
|
||||||
|
case float32:
|
||||||
|
substream = int(s)
|
||||||
|
case float64:
|
||||||
|
substream = int(s)
|
||||||
|
default:
|
||||||
|
go callback(fmt.Errorf("Unsupported substream value: %v", s), nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
temporal := -1
|
||||||
|
if s, found := jsep_msg["temporal"]; found {
|
||||||
|
switch s := s.(type) {
|
||||||
|
case int:
|
||||||
|
temporal = s
|
||||||
|
case float32:
|
||||||
|
temporal = int(s)
|
||||||
|
case float64:
|
||||||
|
temporal = int(s)
|
||||||
|
default:
|
||||||
|
go callback(fmt.Errorf("Unsupported temporal value: %v", s), nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if substream == -1 && temporal == -1 {
|
||||||
|
// Nothing to do
|
||||||
|
go callback(nil, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
p.deferred <- func() {
|
||||||
|
msgctx, cancel := context.WithTimeout(context.Background(), p.mcu.mcuTimeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
p.selectStream(msgctx, substream, temporal, callback)
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
// Return error asynchronously
|
// Return error asynchronously
|
||||||
go callback(fmt.Errorf("Unsupported message type: %s", data.Type), nil)
|
go callback(fmt.Errorf("Unsupported message type: %s", data.Type), nil)
|
||||||
|
|
|
@ -756,6 +756,8 @@ func (s *ProxyServer) processPayload(ctx context.Context, client *ProxyClient, s
|
||||||
fallthrough
|
fallthrough
|
||||||
case "answer":
|
case "answer":
|
||||||
fallthrough
|
fallthrough
|
||||||
|
case "selectStream":
|
||||||
|
fallthrough
|
||||||
case "candidate":
|
case "candidate":
|
||||||
mcuData = &signaling.MessageClientMessageData{
|
mcuData = &signaling.MessageClientMessageData{
|
||||||
Type: payload.Type,
|
Type: payload.Type,
|
||||||
|
|
Loading…
Reference in a new issue