Fix mediaType not updated after publisher renegotiations

The "mediaTypes" attribute is checked to know if a publisher needs to be
closed when the permissions are updated. However, that attribute was set
only when the publisher was initially created; due to this if a
publisher then used a renegotiation to add media not included in the
original offer the publisher would not be closed if the publishing
permission for that media was later revoked.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2022-04-05 19:27:37 +02:00
parent b98a00ec10
commit b9d671ab2f
5 changed files with 16 additions and 0 deletions

View file

@ -895,6 +895,8 @@ func (s *ClientSession) GetOrCreatePublisher(ctx context.Context, mcu Mcu, strea
s.publishers[streamType] = publisher
}
log.Printf("Publishing %s as %s for session %s", streamType, publisher.Id(), s.PublicId())
} else {
publisher.SetMedia(mediaTypes)
}
return publisher, nil

View file

@ -90,6 +90,7 @@ type McuPublisher interface {
McuClient
HasMedia(MediaType) bool
SetMedia(MediaType)
}
type McuSubscriber interface {

View file

@ -883,6 +883,10 @@ func (p *mcuJanusPublisher) HasMedia(mt MediaType) bool {
return (p.mediaTypes & mt) == mt
}
func (p *mcuJanusPublisher) SetMedia(mt MediaType) {
p.mediaTypes = mt
}
func (p *mcuJanusPublisher) NotifyReconnected() {
ctx := context.TODO()
handle, session, roomId, err := p.mcu.getOrCreatePublisherHandle(ctx, p.id, p.streamType, p.bitrate)

View file

@ -144,6 +144,11 @@ func (p *mcuProxyPublisher) HasMedia(mt MediaType) bool {
return (p.mediaTypes & mt) == mt
}
func (p *mcuProxyPublisher) SetMedia(mt MediaType) {
// TODO: Also update mediaTypes on proxy.
p.mediaTypes = mt
}
func (p *mcuProxyPublisher) NotifyClosed() {
p.listener.PublisherClosed(p)
p.conn.removePublisher(p)

View file

@ -153,6 +153,10 @@ func (p *TestMCUPublisher) HasMedia(mt MediaType) bool {
return (p.mediaTypes & mt) == mt
}
func (p *TestMCUPublisher) SetMedia(mt MediaType) {
p.mediaTypes = mt
}
func (p *TestMCUPublisher) SendMessage(ctx context.Context, message *MessageClientMessage, data *MessageClientMessageData, callback func(error, map[string]interface{})) {
go func() {
if p.isClosed() {